Files
haos_config/www/community/advanced-camera-card/card-b98d578d.js
2026-01-30 23:31:00 -06:00

656 lines
688 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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:u,defineProperty:d,getOwnPropertyDescriptor:h,getOwnPropertyNames:p,getOwnPropertySymbols:m,getPrototypeOf:f}=Object,g=globalThis,_=g.trustedTypes,v=_?_.emptyScript:"",y=g.reactiveElementPolyfillSupport,b=(e,t)=>e,w={toAttribute(e,t){switch(t){case Boolean:e=e?v: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)=>!u(e,t),M={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),g.litPropertyMetadata??=new WeakMap;class k 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=M){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&&d(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)??M}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const e=f(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),...m(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.isUpdatePending&&(this._$ES=this._$ET())}P(e,t,n){this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$Em!==e&&(this._$Ej??=new Set).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,n]of e)!0!==n.wrapped||this._$AL.has(t)||void 0===this[t]||this.P(t,this[t],n)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&=this._$Ej.forEach((e=>this._$EC(e,this[e]))),this._$EU()}updated(e){}firstUpdated(e){}}k.elementStyles=[],k.shadowRootOptions={mode:"open"},k[b("elementProperties")]=new Map,k[b("finalized")]=new Map,y?.({ReactiveElement:k}),(g.reactiveElementVersions??=[]).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const C=globalThis,S=C.trustedTypes,E=S?S.createPolicy("lit-html",{createHTML:e=>e}):void 0,A="$lit$",T=`lit$${(Math.random()+"").slice(9)}$`,$="?"+T,I=`<${$}>`,O=document,L=()=>O.createComment(""),D=e=>null===e||"object"!=typeof e&&"function"!=typeof e,j=Array.isArray,z=e=>j(e)||"function"==typeof e?.[Symbol.iterator],P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,N=/-->/g,F=/>/g,B=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,H=/"/g,U=/^(?:script|style|textarea|title)$/i,q=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),W=Symbol.for("lit-noChange"),Z=Symbol.for("lit-nothing"),K=new WeakMap,Q=O.createTreeWalker(O,129);function Y(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(t):t}const G=(e,t)=>{const n=e.length-1,i=[];let a,r=2===t?"<svg>":"",s=R;for(let t=0;t<n;t++){const n=e[t];let o,c,l=-1,u=0;for(;u<n.length&&(s.lastIndex=u,c=s.exec(n),null!==c);)u=s.lastIndex,s===R?"!--"===c[1]?s=N:void 0!==c[1]?s=F:void 0!==c[2]?(U.test(c[2])&&(a=RegExp("</"+c[2],"g")),s=B):void 0!==c[3]&&(s=B):s===B?">"===c[0]?(s=a??R,l=-1):void 0===c[1]?l=-2:(l=s.lastIndex-c[2].length,o=c[1],s=void 0===c[3]?B:'"'===c[3]?H:V):s===H||s===V?s=B:s===N||s===F?s=R:(s=B,a=void 0);const d=s===B&&e[t+1].startsWith("/>")?" ":"";r+=s===R?n+I:l>=0?(i.push(o),n.slice(0,l)+A+n.slice(l)+T+d):n+T+(-2===l?t:d)}return[Y(e,r+(e[n]||"<?>")+(2===t?"</svg>":"")),i]};class X{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]=G(e,t);if(this.el=X.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(A)){const t=l[r++],n=i.getAttribute(e).split(T),s=/([.?@])?(.*)/.exec(t);o.push({type:1,index:a,name:s[2],strings:n,ctor:"."===s[1]?ie:"?"===s[1]?ae:"@"===s[1]?re:ne}),i.removeAttribute(e)}else e.startsWith(T)&&(o.push({type:6,index:a}),i.removeAttribute(e));if(U.test(i.tagName)){const e=i.textContent.split(T),t=e.length-1;if(t>0){i.textContent=S?S.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],L()),Q.nextNode(),o.push({type:2,index:++a});i.append(e[t],L())}}}else if(8===i.nodeType)if(i.data===$)o.push({type:2,index:a});else{let e=-1;for(;-1!==(e=i.data.indexOf(T,e+1));)o.push({type:7,index:a}),e+=T.length-1}a++}}static createElement(e,t){const n=O.createElement("template");return n.innerHTML=e,n}}function J(e,t,n=e,i){if(t===W)return t;let a=void 0!==i?n._$Co?.[i]:n._$Cl;const r=D(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=J(e,a._$AS(e,t.values),a,i)),t}let ee=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??O).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 te(a,a.nextSibling,this,e):1===o.type?t=new o.ctor(a,o.name,o.strings,this,e):6===o.type&&(t=new se(a,this,e)),this._$AV.push(t),o=n[++s]}r!==o?.index&&(a=Q.nextNode(),r++)}return Q.currentNode=O,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 te{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=Z,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=J(this,e,t),D(e)?e===Z||null==e||""===e?(this._$AH!==Z&&this._$AR(),this._$AH=Z):e!==this._$AH&&e!==W&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):z(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==Z&&D(this._$AH)?this._$AA.nextSibling.data=e:this.T(O.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:n}=e,i="number"==typeof n?this._$AC(e):(void 0===n.el&&(n.el=X.createElement(Y(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(t);else{const e=new ee(i,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=K.get(e.strings);return void 0===t&&K.set(e.strings,t=new X(e)),t}k(e){j(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const a of e)i===t.length?t.push(n=new te(this.S(L()),this.S(L()),this,this.options)):n=t[i],n._$AI(a),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ne{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,a){this.type=1,this._$AH=Z,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=a,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Z}_$AI(e,t=this,n,i){const a=this.strings;let r=!1;if(void 0===a)e=J(this,e,t,0),r=!D(e)||e!==this._$AH&&e!==W,r&&(this._$AH=e);else{const i=e;let s,o;for(e=a[0],s=0;s<a.length-1;s++)o=J(this,i[n+s],t,s),o===W&&(o=this._$AH[s]),r||=!D(o)||o!==this._$AH[s],o===Z?e=Z:e!==Z&&(e+=(o??"")+a[s+1]),this._$AH[s]=o}r&&!i&&this.j(e)}j(e){e===Z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ie extends ne{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Z?void 0:e}}class ae extends ne{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Z)}}class re extends ne{constructor(e,t,n,i,a){super(e,t,n,i,a),this.type=5}_$AI(e,t=this){if((e=J(this,e,t,0)??Z)===W)return;const n=this._$AH,i=e===Z&&n!==Z||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,a=e!==Z&&(n===Z||i);i&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class se{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){J(this,e)}}const oe={P:A,A:T,C:$,M:1,L:G,R:ee,D:z,V:J,I:te,H:ne,N:ae,U:re,B:ie,F:se},ce=C.litHtmlPolyfillSupport;ce?.(X,te),(C.litHtmlVersions??=[]).push("3.1.2");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let le=class extends k{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 te(t.insertBefore(L(),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 W}};le._$litElement$=!0,le.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:le});const ue=globalThis.litElementPolyfillSupport;ue?.({LitElement:le}),(globalThis.litElementVersions??=[]).push("4.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const de=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
*/,he={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},pe=(e=he,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 me(e){return(t,n)=>"object"==typeof n?pe(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 fe(e){return me({...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},_e=e=>(...t)=>({_$litDirective$:e,values:t});let ve=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 ye=_e(class extends ve{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 W}}),be=e=>e??Z
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{I:we}=oe,xe=e=>void 0===e.strings,Me=()=>document.createComment(""),ke=(e,t,n)=>{const i=e._$AA.parentNode,a=void 0===t?e._$AB:t._$AA;if(void 0===n){const t=i.insertBefore(Me(),a),r=i.insertBefore(Me(),a);n=new we(t,r,e,e.options)}else{const t=n._$AB.nextSibling,r=n._$AM,s=r!==e;if(s){let t;n._$AQ?.(e),n._$AM=e,void 0!==n._$AP&&(t=e._$AU)!==r._$AU&&n._$AP(t)}if(t!==a||s){let e=n._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,a),e=t}}}return n},Ce=(e,t,n=e)=>(e._$AI(t,n),e),Se={},Ee=(e,t=Se)=>e._$AH=t,Ae=e=>e._$AH,Te=e=>{e._$AP?.(!1,!0);let t=e._$AA;const n=e._$AB.nextSibling;for(;t!==n;){const e=t.nextSibling;t.remove(),t=e}},$e=(e,t)=>{const n=e._$AN;if(void 0===n)return!1;for(const e of n)e._$AO?.(t,!1),$e(e,t);return!0},Ie=e=>{let t,n;do{if(void 0===(t=e._$AM))break;n=t._$AN,n.delete(e),e=t}while(0===n?.size)},Oe=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),je(t)}};
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function Le(e){void 0!==this._$AN?(Ie(this),this._$AM=e,Oe(this)):this._$AM=e}function De(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++)$e(i[e],!1),Ie(i[e]);else null!=i&&($e(i,!1),Ie(i));else $e(this,e)}const je=e=>{e.type==ge.CHILD&&(e._$AP??=De,e._$AQ??=Le)};class ze extends ve{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),Oe(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&($e(this,e),Ie(this))}setValue(e){if(xe(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 Pe=()=>new Re;let Re=class{};const Ne=new WeakMap,Fe=_e(class extends ze{render(e){return Z}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)),Z}rt(e){if("function"==typeof this.Y){const t=this.ht??globalThis;let n=Ne.get(t);void 0===n&&(n=new WeakMap,Ne.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?Ne.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Be="important",Ve=" !"+Be,He=_e(class extends ve{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(Ve);e.includes("-")||t?n.setProperty(e,t?i.slice(0,-11):i,t?Be:""):n[e]=i}}return W}});
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function Ue(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?Ue(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(...Ue(e.shadowRoot,t,n,i,a+1)):"SLOT"===e.tagName?r.push(...s(e)):r.push(...Ue(e,t,n,i,a+1)));return r}function qe(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 We(e){return"-1"!==e.getAttribute("tabindex")&&!qe(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 Ze=new Map;const Ke=document.createElement("template");Ke.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 Qe extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const e=this.attachShadow({mode:"open"});e.appendChild(Ke.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 Ue(this,qe,We)}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=Ze.get(n);null!=i&&window.clearTimeout(i),Ze.set(n,window.setTimeout((()=>{e(),Ze.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 Ye(e){return Number(e.getAttribute("data-dialog-count"))||0}function Ge(e,t){e.setAttribute("data-dialog-count",t.toString())}function Xe(e=document.activeElement){return null!=e&&null!=e.shadowRoot&&null!=e.shadowRoot.activeElement?Xe(e.shadowRoot.activeElement):e}window.customElements.define("focus-trap",Qe);const Je=document.createElement("template");Je.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-behavior:contain;-webkit-overflow-scrolling:touch}:host([center]){display:flex;align-items:center;justify-content:center;overflow:hidden}:host([center]) #dialog{max-height:var(--dialog-max-height,100%)}:host(:not(:defined)),:host(:not([open])){display:none}#backdrop{background:var(--dialog-backdrop-bg,rgba(0,0,0,.6));animation:fadeIn var(--dialog-animation-duration,.1s) var(--dialog-animation-easing,ease-out);z-index:-1}#dialog{animation:scaleIn var(--dialog-animation-duration,.1s) var(--dialog-animation-easing,ease-out);border-radius:var(--dialog-border-radius,12px);box-shadow:var(--dialog-box-shadow,0 2px 10px -5px rgba(0,0,0,.6));max-width:var(--dialog-max-width,700px);width:var(--dialog-width,100%);padding:var(--dialog-padding,24px);max-height:var(--dialog-max-height,unset);height:var(--dialog-height,auto);color:var(--dialog-color,currentColor);background:var(--dialog-bg,#fff);z-index:1;position:relative;display:flex;flex-direction:column;margin:0 auto;border:none}::slotted(article),article{flex-grow:1;overflow-y:auto;-webkit-overflow-scrolling:touch}::slotted(footer),::slotted(header),footer,header{flex-shrink:0}@keyframes scaleIn{0%{transform:scale(.9) translateY(30px);opacity:0}to{transform:scale(1) translateY(0);opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}</style>\n <div id="backdrop" part="backdrop"></div>\n <focus-trap id="dialog" part="dialog">\n <slot></slot>\n </focus-trap>\n';class et extends HTMLElement{constructor(){super(),this.$scrollContainer=document.documentElement,this.$previousActiveElement=null;const e=this.attachShadow({mode:"open"});e.appendChild(Je.content.cloneNode(!0)),this.$dialog=e.querySelector("#dialog"),this.$backdrop=e.querySelector("#backdrop"),this.onBackdropClick=this.onBackdropClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.setAttribute("aria-modal","true"),this.$dialog.setAttribute("role","alertdialog")}static get observedAttributes(){return["open","center"]}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}get center(){return this.hasAttribute("center")}set center(e){e?this.setAttribute("center",""):this.removeAttribute("center")}connectedCallback(){this.$backdrop.addEventListener("click",this.onBackdropClick)}disconnectedCallback(){this.$backdrop.removeEventListener("click",this.onBackdropClick),this.open&&this.didClose()}show(){this.open=!0}close(e){this.result=e,this.open=!1}onBackdropClick(){this.assertClosing()&&this.close()}onKeyDown(e){if("Escape"===e.code)this.assertClosing()&&(this.close(),e.stopImmediatePropagation())}assertClosing(){return this.dispatchEvent(new CustomEvent("closing",{cancelable:!0}))}didOpen(){this.$previousActiveElement=Xe(document.activeElement),requestAnimationFrame((()=>{this.$dialog.focusFirstElement()})),this.tabIndex=0,this.$scrollContainer.style.overflow="hidden",this.addEventListener("keydown",this.onKeyDown,{capture:!0,passive:!0}),Ge(this.$scrollContainer,Ye(this.$scrollContainer)+1),this.dispatchEvent(new CustomEvent("open"))}didClose(){this.removeEventListener("keydown",this.onKeyDown,{capture:!0}),Ge(this.$scrollContainer,Math.max(0,Ye(this.$scrollContainer)-1)),Ye(this.$scrollContainer)<=0&&(this.$scrollContainer.style.overflow=""),this.tabIndex=-1,null!=this.$previousActiveElement&&(this.$previousActiveElement.focus(),this.$previousActiveElement=null),this.dispatchEvent(new CustomEvent("close",{detail:this.result}))}attributeChangedCallback(e,t,n){if("open"===e)this.open?this.didOpen():this.didClose()}}customElements.define("web-dialog",et);const tt=(e,t,n,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:i?.bubbles??!0,composed:i?.composed??!0,cancelable:i?.cancelable??!1,detail:n}))};var nt,it;!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),i={};for(const e of n)i[e]=t[e];return e.objectValues(i)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(nt||(nt={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(it||(it={}));const at=nt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),rt=e=>{switch(typeof e){case"undefined":return at.undefined;case"string":return at.string;case"number":return isNaN(e)?at.nan:at.number;case"boolean":return at.boolean;case"function":return at.function;case"bigint":return at.bigint;case"symbol":return at.symbol;case"object":return Array.isArray(e)?at.array:null===e?at.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?at.promise:"undefined"!=typeof Map&&e instanceof Map?at.map:"undefined"!=typeof Set&&e instanceof Set?at.set:"undefined"!=typeof Date&&e instanceof Date?at.date:at.object;default:return at.unknown}},st=nt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ot extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},i=e=>{for(const a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(i);else if("invalid_return_type"===a.code)i(a.returnTypeError);else if("invalid_arguments"===a.code)i(a.argumentsError);else if(0===a.path.length)n._errors.push(t(a));else{let e=n,i=0;for(;i<a.path.length;){const n=a.path[i];i===a.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(a))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(this),n}static assert(e){if(!(e instanceof ot))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,nt.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ot.create=e=>new ot(e);const ct=(e,t)=>{let n;switch(e.code){case st.invalid_type:n=e.received===at.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case st.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,nt.jsonStringifyReplacer)}`;break;case st.unrecognized_keys:n=`Unrecognized key(s) in object: ${nt.joinValues(e.keys,", ")}`;break;case st.invalid_union:n="Invalid input";break;case st.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${nt.joinValues(e.options)}`;break;case st.invalid_enum_value:n=`Invalid enum value. Expected ${nt.joinValues(e.options)}, received '${e.received}'`;break;case st.invalid_arguments:n="Invalid function arguments";break;case st.invalid_return_type:n="Invalid function return type";break;case st.invalid_date:n="Invalid date";break;case st.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:nt.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case st.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case st.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case st.custom:n="Invalid input";break;case st.invalid_intersection_types:n="Intersection results could not be merged";break;case st.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case st.not_finite:n="Number must be finite";break;default:n=t.defaultError,nt.assertNever(e)}return{message:n}};let lt=ct;function ut(){return lt}const dt=e=>{const{data:t,path:n,errorMaps:i,issueData:a}=e,r=[...n,...a.path||[]],s={...a,path:r};if(void 0!==a.message)return{...a,path:r,message:a.message};let o="";const c=i.filter((e=>!!e)).slice().reverse();for(const e of c)o=e(s,{data:t,defaultError:o}).message;return{...a,path:r,message:o}};function ht(e,t){const n=ut(),i=dt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ct?void 0:ct].filter((e=>!!e))});e.common.issues.push(i)}class pt{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if("aborted"===i.status)return mt;"dirty"===i.status&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,i=await e.value;n.push({key:t,value:i})}return pt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:t,value:a}=i;if("aborted"===t.status)return mt;if("aborted"===a.status)return mt;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"===t.value||void 0===a.value&&!i.alwaysSet||(n[t.value]=a.value)}return{status:e.value,value:n}}}const mt=Object.freeze({status:"aborted"}),ft=e=>({status:"dirty",value:e}),gt=e=>({status:"valid",value:e}),_t=e=>"aborted"===e.status,vt=e=>"dirty"===e.status,yt=e=>"valid"===e.status,bt=e=>"undefined"!=typeof Promise&&e instanceof Promise;function wt(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function xt(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n}var Mt,kt,Ct;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(Mt||(Mt={}));class St{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Et=(e,t)=>{if(yt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ot(e.common.issues);return this._error=t,this._error}}};function At(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:i,description:a}=e;if(t&&(n||i))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:(t,a)=>{var r,s;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:a.defaultError}:void 0===a.data?{message:null!==(r=null!=o?o:i)&&void 0!==r?r:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(s=null!=o?o:n)&&void 0!==s?s:a.defaultError}},description:a}}class Tt{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return rt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:rt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pt,ctx:{common:e.parent.common,data:e.data,parsedType:rt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(bt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:rt(e)},a=this._parseSync({data:e,path:i.path,parent:i});return Et(i,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:rt(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(bt(i)?i:Promise.resolve(i));return Et(n,a)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,i)=>{const a=e(t),r=()=>i.addIssue({code:st.custom,...n(t)});return"undefined"!=typeof Promise&&a instanceof Promise?a.then((e=>!!e||(r(),!1))):!!a||(r(),!1)}))}refinement(e,t){return this._refinement(((n,i)=>!!e(n)||(i.addIssue("function"==typeof t?t(n,i):t),!1)))}_refinement(e){return new Cn({schema:this,typeName:Pn.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sn.create(this,this._def)}nullable(){return En.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sn.create(this,this._def)}promise(){return kn.create(this,this._def)}or(e){return ln.create([this,e],this._def)}and(e){return pn.create(this,e,this._def)}transform(e){return new Cn({...At(this._def),schema:this,typeName:Pn.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new An({...At(this._def),innerType:this,defaultValue:t,typeName:Pn.ZodDefault})}brand(){return new On({typeName:Pn.ZodBranded,type:this,...At(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Tn({...At(this._def),innerType:this,catchValue:t,typeName:Pn.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ln.create(this,e)}readonly(){return Dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $t=/^c[^\s-]{8,}$/i,It=/^[0-9a-z]+$/,Ot=/^[0-9A-HJKMNP-TV-Z]{26}$/,Lt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Dt=/^[a-z0-9_-]{21}$/i,jt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Pt;const Rt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Nt=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ft=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vt=new RegExp(`^${Bt}$`);function Ht(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function Ut(e){let t=`${Bt}T${Ht(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function qt(e,t){return!("v4"!==t&&t||!Rt.test(e))||!("v6"!==t&&t||!Nt.test(e))}class Wt extends Tt{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==at.string){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.string,received:t.parsedType}),mt}const t=new pt;let n;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),ht(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),ht(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const a=e.data.length>i.value,r=e.data.length<i.value;(a||r)&&(n=this._getOrReturnCtx(e,n),a?ht(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):r&&ht(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)zt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"email",code:st.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)Pt||(Pt=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"emoji",code:st.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"uuid",code:st.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"nanoid",code:st.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)$t.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"cuid",code:st.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)It.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"cuid2",code:st.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"ulid",code:st.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(a){n=this._getOrReturnCtx(e,n),ht(n,{validation:"url",code:st.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"regex",code:st.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){Ut(i).test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else if("date"===i.kind){Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:"date",message:i.message}),t.dirty())}else if("time"===i.kind){new RegExp(`^${Ht(i)}$`).test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{code:st.invalid_string,validation:"time",message:i.message}),t.dirty())}else"duration"===i.kind?jt.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"duration",code:st.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?qt(e.data,i.version)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"ip",code:st.invalid_string,message:i.message}),t.dirty()):"base64"===i.kind?Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),ht(n,{validation:"base64",code:st.invalid_string,message:i.message}),t.dirty()):nt.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement((t=>e.test(t)),{validation:t,code:st.invalid_string,...Mt.errToObj(n)})}_addCheck(e){return new Wt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Mt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Mt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Mt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Mt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Mt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Mt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Mt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Mt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Mt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Mt.errToObj(e)})}datetime(e){var t,n;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(n=null==e?void 0:e.local)&&void 0!==n&&n,...Mt.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...Mt.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Mt.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Mt.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...Mt.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Mt.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Mt.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Mt.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Mt.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Mt.errToObj(t)})}nonempty(e){return this.min(1,Mt.errToObj(e))}trim(){return new Wt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Wt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Wt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Zt(e,t){const n=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,a=n>i?n:i;return parseInt(e.toFixed(a).replace(".",""))%parseInt(t.toFixed(a).replace(".",""))/Math.pow(10,a)}Wt.create=e=>{var t;return new Wt({checks:[],typeName:Pn.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...At(e)})};class Kt extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==at.number){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.number,received:t.parsedType}),mt}let t;const n=new pt;for(const i of this._def.checks)if("int"===i.kind)nt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),ht(t,{code:st.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else"multipleOf"===i.kind?0!==Zt(e.data,i.value)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),ht(t,{code:st.not_finite,message:i.message}),n.dirty()):nt.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Mt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Mt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Mt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Mt.toString(t))}setLimit(e,t,n,i){return new Kt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Kt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Mt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Mt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Mt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Mt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Mt.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&nt.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Kt.create=e=>new Kt({checks:[],typeName:Pn.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...At(e)});class Qt extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==at.bigint){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.bigint,received:t.parsedType}),mt}let t;const n=new pt;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),ht(t,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):nt.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Mt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Mt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Mt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Mt.toString(t))}setLimit(e,t,n,i){return new Qt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Qt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Qt.create=e=>{var t;return new Qt({checks:[],typeName:Pn.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...At(e)})};class Yt extends Tt{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==at.boolean){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.boolean,received:t.parsedType}),mt}return gt(e.data)}}Yt.create=e=>new Yt({typeName:Pn.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...At(e)});class Gt extends Tt{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==at.date){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.date,received:t.parsedType}),mt}if(isNaN(e.data.getTime())){return ht(this._getOrReturnCtx(e),{code:st.invalid_date}),mt}const t=new pt;let n;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),ht(n,{code:st.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),ht(n,{code:st.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):nt.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Mt.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Mt.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Gt.create=e=>new Gt({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Pn.ZodDate,...At(e)});class Xt extends Tt{_parse(e){if(this._getType(e)!==at.symbol){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.symbol,received:t.parsedType}),mt}return gt(e.data)}}Xt.create=e=>new Xt({typeName:Pn.ZodSymbol,...At(e)});class Jt extends Tt{_parse(e){if(this._getType(e)!==at.undefined){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.undefined,received:t.parsedType}),mt}return gt(e.data)}}Jt.create=e=>new Jt({typeName:Pn.ZodUndefined,...At(e)});class en extends Tt{_parse(e){if(this._getType(e)!==at.null){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.null,received:t.parsedType}),mt}return gt(e.data)}}en.create=e=>new en({typeName:Pn.ZodNull,...At(e)});class tn extends Tt{constructor(){super(...arguments),this._any=!0}_parse(e){return gt(e.data)}}tn.create=e=>new tn({typeName:Pn.ZodAny,...At(e)});class nn extends Tt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return gt(e.data)}}nn.create=e=>new nn({typeName:Pn.ZodUnknown,...At(e)});class an extends Tt{_parse(e){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.never,received:t.parsedType}),mt}}an.create=e=>new an({typeName:Pn.ZodNever,...At(e)});class rn extends Tt{_parse(e){if(this._getType(e)!==at.undefined){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.void,received:t.parsedType}),mt}return gt(e.data)}}rn.create=e=>new rn({typeName:Pn.ZodVoid,...At(e)});class sn extends Tt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==at.array)return ht(t,{code:st.invalid_type,expected:at.array,received:t.parsedType}),mt;if(null!==i.exactLength){const e=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(e||a)&&(ht(t,{code:e?st.too_big:st.too_small,minimum:a?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(ht(t,{code:st.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(ht(t,{code:st.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>i.type._parseAsync(new St(t,e,t.path,n))))).then((e=>pt.mergeArray(n,e)));const a=[...t.data].map(((e,n)=>i.type._parseSync(new St(t,e,t.path,n))));return pt.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new sn({...this._def,minLength:{value:e,message:Mt.toString(t)}})}max(e,t){return new sn({...this._def,maxLength:{value:e,message:Mt.toString(t)}})}length(e,t){return new sn({...this._def,exactLength:{value:e,message:Mt.toString(t)}})}nonempty(e){return this.min(1,e)}}function on(e){if(e instanceof cn){const t={};for(const n in e.shape){const i=e.shape[n];t[n]=Sn.create(on(i))}return new cn({...e._def,shape:()=>t})}return e instanceof sn?new sn({...e._def,type:on(e.element)}):e instanceof Sn?Sn.create(on(e.unwrap())):e instanceof En?En.create(on(e.unwrap())):e instanceof mn?mn.create(e.items.map((e=>on(e)))):e}sn.create=(e,t)=>new sn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Pn.ZodArray,...At(t)});class cn extends Tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=nt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==at.object){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.object,received:t.parsedType}),mt}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof an&&"strip"===this._def.unknownKeys))for(const e in n.data)a.includes(e)||r.push(e);const s=[];for(const e of a){const t=i[e],a=n.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new St(n,a,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof an){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)s.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)r.length>0&&(ht(n,{code:st.unrecognized_keys,keys:r}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of r){const i=n.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new St(n,i,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of s){const n=await t.key,i=await t.value;e.push({key:n,value:i,alwaysSet:t.alwaysSet})}return e})).then((e=>pt.mergeObjectSync(t,e))):pt.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return Mt.errToObj,new cn({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var i,a,r,s;const o=null!==(r=null===(a=(i=this._def).errorMap)||void 0===a?void 0:a.call(i,t,n).message)&&void 0!==r?r:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(s=Mt.errToObj(e).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new cn({...this._def,unknownKeys:"strip"})}passthrough(){return new cn({...this._def,unknownKeys:"passthrough"})}extend(e){return new cn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new cn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Pn.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new cn({...this._def,catchall:e})}pick(e){const t={};return nt.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new cn({...this._def,shape:()=>t})}omit(e){const t={};return nt.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new cn({...this._def,shape:()=>t})}deepPartial(){return on(this)}partial(e){const t={};return nt.objectKeys(this.shape).forEach((n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()})),new cn({...this._def,shape:()=>t})}required(e){const t={};return nt.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof Sn;)e=e._def.innerType;t[n]=e}})),new cn({...this._def,shape:()=>t})}keyof(){return wn(nt.objectKeys(this.shape))}}cn.create=(e,t)=>new cn({shape:()=>e,unknownKeys:"strip",catchall:an.create(),typeName:Pn.ZodObject,...At(t)}),cn.strictCreate=(e,t)=>new cn({shape:()=>e,unknownKeys:"strict",catchall:an.create(),typeName:Pn.ZodObject,...At(t)}),cn.lazycreate=(e,t)=>new cn({shape:e,unknownKeys:"strip",catchall:an.create(),typeName:Pn.ZodObject,...At(t)});class ln extends Tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map((e=>new ot(e.ctx.common.issues)));return ht(t,{code:st.invalid_union,unionErrors:n}),mt}));{let e;const i=[];for(const a of n){const n={...t,common:{...t.common,issues:[]},parent:null},r=a._parseSync({data:t.data,path:t.path,parent:n});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:n}),n.common.issues.length&&i.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const a=i.map((e=>new ot(e)));return ht(t,{code:st.invalid_union,unionErrors:a}),mt}}get options(){return this._def.options}}ln.create=(e,t)=>new ln({options:e,typeName:Pn.ZodUnion,...At(t)});const un=e=>e instanceof yn?un(e.schema):e instanceof Cn?un(e.innerType()):e instanceof bn?[e.value]:e instanceof xn?e.options:e instanceof Mn?nt.objectValues(e.enum):e instanceof An?un(e._def.innerType):e instanceof Jt?[void 0]:e instanceof en?[null]:e instanceof Sn?[void 0,...un(e.unwrap())]:e instanceof En?[null,...un(e.unwrap())]:e instanceof On||e instanceof Dn?un(e.unwrap()):e instanceof Tn?un(e._def.innerType):[];class dn extends Tt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==at.object)return ht(t,{code:st.invalid_type,expected:at.object,received:t.parsedType}),mt;const n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(ht(t,{code:st.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),mt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const n of t){const t=un(n.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of t){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,n)}}return new dn({typeName:Pn.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...At(n)})}}function hn(e,t){const n=rt(e),i=rt(t);if(e===t)return{valid:!0,data:e};if(n===at.object&&i===at.object){const n=nt.objectKeys(t),i=nt.objectKeys(e).filter((e=>-1!==n.indexOf(e))),a={...e,...t};for(const n of i){const i=hn(e[n],t[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===at.array&&i===at.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const a=hn(e[i],t[i]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}return n===at.date&&i===at.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class pn extends Tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(e,i)=>{if(_t(e)||_t(i))return mt;const a=hn(e.value,i.value);return a.valid?((vt(e)||vt(i))&&t.dirty(),{status:t.value,value:a.data}):(ht(n,{code:st.invalid_intersection_types}),mt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>i(e,t))):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}pn.create=(e,t,n)=>new pn({left:e,right:t,typeName:Pn.ZodIntersection,...At(n)});class mn extends Tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==at.array)return ht(n,{code:st.invalid_type,expected:at.array,received:n.parsedType}),mt;if(n.data.length<this._def.items.length)return ht(n,{code:st.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&n.data.length>this._def.items.length&&(ht(n,{code:st.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map(((e,t)=>{const i=this._def.items[t]||this._def.rest;return i?i._parse(new St(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(i).then((e=>pt.mergeArray(t,e))):pt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new mn({...this._def,rest:e})}}mn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mn({items:e,typeName:Pn.ZodTuple,rest:null,...At(t)})};class fn extends Tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==at.object)return ht(n,{code:st.invalid_type,expected:at.object,received:n.parsedType}),mt;const i=[],a=this._def.keyType,r=this._def.valueType;for(const e in n.data)i.push({key:a._parse(new St(n,e,n.path,e)),value:r._parse(new St(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?pt.mergeObjectAsync(t,i):pt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return new fn(t instanceof Tt?{keyType:e,valueType:t,typeName:Pn.ZodRecord,...At(n)}:{keyType:Wt.create(),valueType:e,typeName:Pn.ZodRecord,...At(t)})}}class gn extends Tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==at.map)return ht(n,{code:st.invalid_type,expected:at.map,received:n.parsedType}),mt;const i=this._def.keyType,a=this._def.valueType,r=[...n.data.entries()].map((([e,t],r)=>({key:i._parse(new St(n,e,n.path,[r,"key"])),value:a._parse(new St(n,t,n.path,[r,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of r){const i=await n.key,a=await n.value;if("aborted"===i.status||"aborted"===a.status)return mt;"dirty"!==i.status&&"dirty"!==a.status||t.dirty(),e.set(i.value,a.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of r){const i=n.key,a=n.value;if("aborted"===i.status||"aborted"===a.status)return mt;"dirty"!==i.status&&"dirty"!==a.status||t.dirty(),e.set(i.value,a.value)}return{status:t.value,value:e}}}}gn.create=(e,t,n)=>new gn({valueType:t,keyType:e,typeName:Pn.ZodMap,...At(n)});class _n extends Tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==at.set)return ht(n,{code:st.invalid_type,expected:at.set,received:n.parsedType}),mt;const i=this._def;null!==i.minSize&&n.data.size<i.minSize.value&&(ht(n,{code:st.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&n.data.size>i.maxSize.value&&(ht(n,{code:st.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const a=this._def.valueType;function r(e){const n=new Set;for(const i of e){if("aborted"===i.status)return mt;"dirty"===i.status&&t.dirty(),n.add(i.value)}return{status:t.value,value:n}}const s=[...n.data.values()].map(((e,t)=>a._parse(new St(n,e,n.path,t))));return n.common.async?Promise.all(s).then((e=>r(e))):r(s)}min(e,t){return new _n({...this._def,minSize:{value:e,message:Mt.toString(t)}})}max(e,t){return new _n({...this._def,maxSize:{value:e,message:Mt.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_n.create=(e,t)=>new _n({valueType:e,minSize:null,maxSize:null,typeName:Pn.ZodSet,...At(t)});class vn extends Tt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==at.function)return ht(t,{code:st.invalid_type,expected:at.function,received:t.parsedType}),mt;function n(e,n){return dt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ut(),ct].filter((e=>!!e)),issueData:{code:st.invalid_arguments,argumentsError:n}})}function i(e,n){return dt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ut(),ct].filter((e=>!!e)),issueData:{code:st.invalid_return_type,returnTypeError:n}})}const a={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof kn){const e=this;return gt((async function(...t){const s=new ot([]),o=await e._def.args.parseAsync(t,a).catch((e=>{throw s.addIssue(n(t,e)),s})),c=await Reflect.apply(r,this,o),l=await e._def.returns._def.type.parseAsync(c,a).catch((e=>{throw s.addIssue(i(c,e)),s}));return l}))}{const e=this;return gt((function(...t){const s=e._def.args.safeParse(t,a);if(!s.success)throw new ot([n(t,s.error)]);const o=Reflect.apply(r,this,s.data),c=e._def.returns.safeParse(o,a);if(!c.success)throw new ot([i(o,c.error)]);return c.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vn({...this._def,args:mn.create(e).rest(nn.create())})}returns(e){return new vn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new vn({args:e||mn.create([]).rest(nn.create()),returns:t||nn.create(),typeName:Pn.ZodFunction,...At(n)})}}class yn extends Tt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}yn.create=(e,t)=>new yn({getter:e,typeName:Pn.ZodLazy,...At(t)});class bn extends Tt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ht(t,{received:t.data,code:st.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:e.data}}get value(){return this._def.value}}function wn(e,t){return new xn({values:e,typeName:Pn.ZodEnum,...At(t)})}bn.create=(e,t)=>new bn({value:e,typeName:Pn.ZodLiteral,...At(t)});class xn extends Tt{constructor(){super(...arguments),kt.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return ht(t,{expected:nt.joinValues(n),received:t.parsedType,code:st.invalid_type}),mt}if(wt(this,kt,"f")||xt(this,kt,new Set(this._def.values),"f"),!wt(this,kt,"f").has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ht(t,{received:t.data,code:st.invalid_enum_value,options:n}),mt}return gt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return xn.create(e,{...this._def,...t})}exclude(e,t=this._def){return xn.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}kt=new WeakMap,xn.create=wn;class Mn extends Tt{constructor(){super(...arguments),Ct.set(this,void 0)}_parse(e){const t=nt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==at.string&&n.parsedType!==at.number){const e=nt.objectValues(t);return ht(n,{expected:nt.joinValues(e),received:n.parsedType,code:st.invalid_type}),mt}if(wt(this,Ct,"f")||xt(this,Ct,new Set(nt.getValidEnumValues(this._def.values)),"f"),!wt(this,Ct,"f").has(e.data)){const e=nt.objectValues(t);return ht(n,{received:n.data,code:st.invalid_enum_value,options:e}),mt}return gt(e.data)}get enum(){return this._def.values}}Ct=new WeakMap,Mn.create=(e,t)=>new Mn({values:e,typeName:Pn.ZodNativeEnum,...At(t)});class kn extends Tt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==at.promise&&!1===t.common.async)return ht(t,{code:st.invalid_type,expected:at.promise,received:t.parsedType}),mt;const n=t.parsedType===at.promise?t.data:Promise.resolve(t.data);return gt(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}kn.create=(e,t)=>new kn({type:e,typeName:Pn.ZodPromise,...At(t)});class Cn extends Tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Pn.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{ht(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===i.type){const e=i.transform(n.data,a);if(n.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return mt;const i=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===i.status?mt:"dirty"===i.status||"dirty"===t.value?ft(i.value):i}));{if("aborted"===t.value)return mt;const i=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===i.status?mt:"dirty"===i.status||"dirty"===t.value?ft(i.value):i}}if("refinement"===i.type){const e=e=>{const t=i.refinement(e,a);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===i.status?mt:("dirty"===i.status&&t.dirty(),e(i.value),{status:t.value,value:i.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?mt:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===i.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!yt(e))return e;const r=i.transform(e.value,a);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>yt(e)?Promise.resolve(i.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}nt.assertNever(i)}}Cn.create=(e,t,n)=>new Cn({schema:e,typeName:Pn.ZodEffects,effect:t,...At(n)}),Cn.createWithPreprocess=(e,t,n)=>new Cn({schema:t,effect:{type:"preprocess",transform:e},typeName:Pn.ZodEffects,...At(n)});class Sn extends Tt{_parse(e){return this._getType(e)===at.undefined?gt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sn.create=(e,t)=>new Sn({innerType:e,typeName:Pn.ZodOptional,...At(t)});class En extends Tt{_parse(e){return this._getType(e)===at.null?gt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}En.create=(e,t)=>new En({innerType:e,typeName:Pn.ZodNullable,...At(t)});class An extends Tt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===at.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}An.create=(e,t)=>new An({innerType:e,typeName:Pn.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...At(t)});class Tn extends Tt{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return bt(i)?i.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Tn.create=(e,t)=>new Tn({innerType:e,typeName:Pn.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...At(t)});class $n extends Tt{_parse(e){if(this._getType(e)!==at.nan){const t=this._getOrReturnCtx(e);return ht(t,{code:st.invalid_type,expected:at.nan,received:t.parsedType}),mt}return{status:"valid",value:e.data}}}$n.create=e=>new $n({typeName:Pn.ZodNaN,...At(e)});const In=Symbol("zod_brand");class On extends Tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ln extends Tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?mt:"dirty"===e.status?(t.dirty(),ft(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?mt:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new Ln({in:e,out:t,typeName:Pn.ZodPipeline})}}class Dn extends Tt{_parse(e){const t=this._def.innerType._parse(e),n=e=>(yt(e)&&(e.value=Object.freeze(e.value)),e);return bt(t)?t.then((e=>n(e))):n(t)}unwrap(){return this._def.innerType}}function jn(e,t={},n){return e?tn.create().superRefine(((i,a)=>{var r,s;if(!e(i)){const e="function"==typeof t?t(i):"string"==typeof t?{message:t}:t,o=null===(s=null!==(r=e.fatal)&&void 0!==r?r:n)||void 0===s||s,c="string"==typeof e?{message:e}:e;a.addIssue({code:"custom",...c,fatal:o})}})):tn.create()}Dn.create=(e,t)=>new Dn({innerType:e,typeName:Pn.ZodReadonly,...At(t)});const zn={object:cn.lazycreate};var Pn;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Pn||(Pn={}));const Rn=Wt.create,Nn=Kt.create,Fn=$n.create,Bn=Qt.create,Vn=Yt.create,Hn=Gt.create,Un=Xt.create,qn=Jt.create,Wn=en.create,Zn=tn.create,Kn=nn.create,Qn=an.create,Yn=rn.create,Gn=sn.create,Xn=cn.create,Jn=cn.strictCreate,ei=ln.create,ti=dn.create,ni=pn.create,ii=mn.create,ai=fn.create,ri=gn.create,si=_n.create,oi=vn.create,ci=yn.create,li=bn.create,ui=xn.create,di=Mn.create,hi=kn.create,pi=Cn.create,mi=Sn.create,fi=En.create,gi=Cn.createWithPreprocess,_i=Ln.create,vi={string:e=>Wt.create({...e,coerce:!0}),number:e=>Kt.create({...e,coerce:!0}),boolean:e=>Yt.create({...e,coerce:!0}),bigint:e=>Qt.create({...e,coerce:!0}),date:e=>Gt.create({...e,coerce:!0})},yi=mt;var bi=Object.freeze({__proto__:null,defaultErrorMap:ct,setErrorMap:function(e){lt=e},getErrorMap:ut,makeIssue:dt,EMPTY_PATH:[],addIssueToContext:ht,ParseStatus:pt,INVALID:mt,DIRTY:ft,OK:gt,isAborted:_t,isDirty:vt,isValid:yt,isAsync:bt,get util(){return nt},get objectUtil(){return it},ZodParsedType:at,getParsedType:rt,ZodType:Tt,datetimeRegex:Ut,ZodString:Wt,ZodNumber:Kt,ZodBigInt:Qt,ZodBoolean:Yt,ZodDate:Gt,ZodSymbol:Xt,ZodUndefined:Jt,ZodNull:en,ZodAny:tn,ZodUnknown:nn,ZodNever:an,ZodVoid:rn,ZodArray:sn,ZodObject:cn,ZodUnion:ln,ZodDiscriminatedUnion:dn,ZodIntersection:pn,ZodTuple:mn,ZodRecord:fn,ZodMap:gn,ZodSet:_n,ZodFunction:vn,ZodLazy:yn,ZodLiteral:bn,ZodEnum:xn,ZodNativeEnum:Mn,ZodPromise:kn,ZodEffects:Cn,ZodTransformer:Cn,ZodOptional:Sn,ZodNullable:En,ZodDefault:An,ZodCatch:Tn,ZodNaN:$n,BRAND:In,ZodBranded:On,ZodPipeline:Ln,ZodReadonly:Dn,custom:jn,Schema:Tt,ZodSchema:Tt,late:zn,get ZodFirstPartyTypeKind(){return Pn},coerce:vi,any:Zn,array:Gn,bigint:Bn,boolean:Vn,date:Hn,discriminatedUnion:ti,effect:pi,enum:ui,function:oi,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>jn((t=>t instanceof e),t),intersection:ni,lazy:ci,literal:li,map:ri,nan:Fn,nativeEnum:di,never:Qn,null:Wn,nullable:fi,number:Nn,object:Xn,oboolean:()=>Vn().optional(),onumber:()=>Nn().optional(),optional:mi,ostring:()=>Rn().optional(),pipeline:_i,preprocess:gi,promise:hi,record:ai,set:si,strictObject:Jn,string:Rn,symbol:Un,transformer:pi,tuple:ii,undefined:qn,union:ei,unknown:Kn,void:Yn,NEVER:yi,ZodIssueCode:st,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:ot});const wi=/^[-\w]+$/,xi=100,Mi=100,ki=20,Ci="live",Si=["diagnostics","live","clip","clips","folder","folders","snapshot","snapshots","recording","recordings","image","timeline"],Ei=bi.object({confirmation:bi.boolean().or(bi.object({text:bi.string().optional(),exemptions:bi.object({user:bi.string()}).array().optional()})).optional(),card_id:bi.string().regex(wi,"card_id parameter can only contain [a-z][A-Z][0-9_]-").optional()}),Ai=Ei.extend({action:bi.literal("fire-dom-event").or(bi.literal("custom:advanced-camera-card-action").transform((()=>"fire-dom-event")))}),Ti="__INTERNAL_CALLBACK_ACTION__",$i=Ai.extend({advanced_camera_card_action:bi.literal(Ti),callback:bi.function().args(bi.any()).returns(bi.promise(bi.void()))});function Ii(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function Oi(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Li(e,t){const n=Ii(e);return isNaN(t)?Oi(e,NaN):t?(n.setDate(n.getDate()+t),n):n}function Di(e,t){const n=Ii(e);if(isNaN(t))return Oi(e,NaN);if(!t)return n;const i=n.getDate(),a=Oi(e,n.getTime());a.setMonth(n.getMonth()+t+1,0);return i>=a.getDate()?a:(n.setFullYear(a.getFullYear(),a.getMonth(),i),n)}function ji(e,t){const{years:n=0,months:i=0,weeks:a=0,days:r=0,hours:s=0,minutes:o=0,seconds:c=0}=t,l=Ii(e),u=i||n?Di(l,i+12*n):l,d=1e3*(c+60*(o+60*s));return Oi(e,(r||a?Li(u,r+7*a):u).getTime()+d)}const zi=6048e5,Pi=864e5,Ri=6e4,Ni=36e5;let Fi={};function Bi(){return Fi}function Vi(e,t){const n=Bi(),i=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=Ii(e),r=a.getDay(),s=(r<i?7:0)+r-i;return a.setDate(a.getDate()-s),a.setHours(0,0,0,0),a}function Hi(e){return Vi(e,{weekStartsOn:1})}function Ui(e){const t=Ii(e),n=t.getFullYear(),i=Oi(e,0);i.setFullYear(n+1,0,4),i.setHours(0,0,0,0);const a=Hi(i),r=Oi(e,0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);const s=Hi(r);return t.getTime()>=a.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function qi(e){const t=Ii(e);return t.setHours(0,0,0,0),t}function Wi(e){const t=Ii(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Zi(e){if(!(t=e,t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const n=Ii(e);return!isNaN(Number(n))}function Ki(e){return t=>{const n=(e?Math[e]:Math.trunc)(t);return 0===n?0:n}}function Qi(e,t){return+Ii(e)-+Ii(t)}function Yi(e,t,n){const i=Qi(e,t)/1e3;return Ki(n?.roundingMethod)(i)}const Gi={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Xi(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ji={date:Xi({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Xi({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Xi({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ea={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function ta(e){return(t,n)=>{let i;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):t;i=e.formattingValues[a]||e.formattingValues[t]}else{const t=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;i=e.values[a]||e.values[t]}return i[e.argumentCallback?e.argumentCallback(t):t]}}function na(e){return(t,n={})=>{const i=n.width,a=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],r=t.match(a);if(!r)return null;const s=r[0],o=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(o,(e=>e.test(s))):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(o,(e=>e.test(s)));let l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;return{value:l,rest:t.slice(s.length)}}}var ia;const aa={code:"en-US",formatDistance:(e,t,n)=>{let i;const a=Gi[e];return i="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},formatLong:Ji,formatRelative:(e,t,n,i)=>ea[e],localize:{ordinalNumber:(e,t)=>{const n=Number(e),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:ta({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:ta({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:ta({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:ta({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:ta({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(ia={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(ia.matchPattern);if(!n)return null;const i=n[0],a=e.match(ia.parsePattern);if(!a)return null;let r=ia.valueCallback?ia.valueCallback(a[0]):a[0];return r=t.valueCallback?t.valueCallback(r):r,{value:r,rest:e.slice(i.length)}}),era:na({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:na({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:na({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:na({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:na({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function ra(e){const t=Ii(e),n=function(e,t){const n=qi(e),i=qi(t),a=+n-Wi(n),r=+i-Wi(i);return Math.round((a-r)/Pi)}(t,function(e){const t=Ii(e),n=Oi(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}(t));return n+1}function sa(e){const t=Ii(e),n=+Hi(t)-+function(e){const t=Ui(e),n=Oi(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Hi(n)}(t);return Math.round(n/zi)+1}function oa(e,t){const n=Ii(e),i=n.getFullYear(),a=Bi(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=Oi(e,0);s.setFullYear(i+1,0,r),s.setHours(0,0,0,0);const o=Vi(s,t),c=Oi(e,0);c.setFullYear(i,0,r),c.setHours(0,0,0,0);const l=Vi(c,t);return n.getTime()>=o.getTime()?i+1:n.getTime()>=l.getTime()?i:i-1}function ca(e,t){const n=Ii(e),i=+Vi(n,t)-+function(e,t){const n=Bi(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=oa(e,t),r=Oi(e,0);return r.setFullYear(a,0,i),r.setHours(0,0,0,0),Vi(r,t)}(n,t);return Math.round(i/zi)+1}function la(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const ua={y(e,t){const n=e.getFullYear(),i=n>0?n:1-n;return la("yy"===t?i%100:i,t.length)},M(e,t){const n=e.getMonth();return"M"===t?String(n+1):la(n+1,2)},d:(e,t)=>la(e.getDate(),t.length),a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:(e,t)=>la(e.getHours()%12||12,t.length),H:(e,t)=>la(e.getHours(),t.length),m:(e,t)=>la(e.getMinutes(),t.length),s:(e,t)=>la(e.getSeconds(),t.length),S(e,t){const n=t.length,i=e.getMilliseconds();return la(Math.trunc(i*Math.pow(10,n-3)),t.length)}},da="midnight",ha="noon",pa="morning",ma="afternoon",fa="evening",ga="night",_a={G:function(e,t,n){const i=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});default:return n.era(i,{width:"wide"})}},y:function(e,t,n){if("yo"===t){const t=e.getFullYear(),i=t>0?t:1-t;return n.ordinalNumber(i,{unit:"year"})}return ua.y(e,t)},Y:function(e,t,n,i){const a=oa(e,i),r=a>0?a:1-a;if("YY"===t){return la(r%100,2)}return"Yo"===t?n.ordinalNumber(r,{unit:"year"}):la(r,t.length)},R:function(e,t){return la(Ui(e),t.length)},u:function(e,t){return la(e.getFullYear(),t.length)},Q:function(e,t,n){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return la(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});default:return n.quarter(i,{width:"wide",context:"formatting"})}},q:function(e,t,n){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return la(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});default:return n.quarter(i,{width:"wide",context:"standalone"})}},M:function(e,t,n){const i=e.getMonth();switch(t){case"M":case"MM":return ua.M(e,t);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});default:return n.month(i,{width:"wide",context:"formatting"})}},L:function(e,t,n){const i=e.getMonth();switch(t){case"L":return String(i+1);case"LL":return la(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});default:return n.month(i,{width:"wide",context:"standalone"})}},w:function(e,t,n,i){const a=ca(e,i);return"wo"===t?n.ordinalNumber(a,{unit:"week"}):la(a,t.length)},I:function(e,t,n){const i=sa(e);return"Io"===t?n.ordinalNumber(i,{unit:"week"}):la(i,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getDate(),{unit:"date"}):ua.d(e,t)},D:function(e,t,n){const i=ra(e);return"Do"===t?n.ordinalNumber(i,{unit:"dayOfYear"}):la(i,t.length)},E:function(e,t,n){const i=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},e:function(e,t,n,i){const a=e.getDay(),r=(a-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return la(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,i){const a=e.getDay(),r=(a-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return la(r,t.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const i=e.getDay(),a=0===i?7:i;switch(t){case"i":return String(a);case"ii":return la(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const i=e.getHours();let a;switch(a=12===i?ha:0===i?da:i/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const i=e.getHours();let a;switch(a=i>=17?fa:i>=12?ma:i>=4?pa:ga,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return ua.h(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getHours(),{unit:"hour"}):ua.H(e,t)},K:function(e,t,n){const i=e.getHours()%12;return"Ko"===t?n.ordinalNumber(i,{unit:"hour"}):la(i,t.length)},k:function(e,t,n){let i=e.getHours();return 0===i&&(i=24),"ko"===t?n.ordinalNumber(i,{unit:"hour"}):la(i,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):ua.m(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getSeconds(),{unit:"second"}):ua.s(e,t)},S:function(e,t){return ua.S(e,t)},X:function(e,t,n){const i=e.getTimezoneOffset();if(0===i)return"Z";switch(t){case"X":return ya(i);case"XXXX":case"XX":return ba(i);default:return ba(i,":")}},x:function(e,t,n){const i=e.getTimezoneOffset();switch(t){case"x":return ya(i);case"xxxx":case"xx":return ba(i);default:return ba(i,":")}},O:function(e,t,n){const i=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+va(i,":");default:return"GMT"+ba(i,":")}},z:function(e,t,n){const i=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+va(i,":");default:return"GMT"+ba(i,":")}},t:function(e,t,n){return la(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,n){return la(e.getTime(),t.length)}};function va(e,t=""){const n=e>0?"-":"+",i=Math.abs(e),a=Math.trunc(i/60),r=i%60;return 0===r?n+String(a):n+String(a)+t+la(r,2)}function ya(e,t){if(e%60==0){return(e>0?"-":"+")+la(Math.abs(e)/60,2)}return ba(e,t)}function ba(e,t=""){const n=e>0?"-":"+",i=Math.abs(e);return n+la(Math.trunc(i/60),2)+t+la(i%60,2)}const wa=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},xa=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Ma={p:xa,P:(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],i=n[1],a=n[2];if(!a)return wa(e,t);let r;switch(i){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;default:r=t.dateTime({width:"full"})}return r.replace("{{date}}",wa(i,t)).replace("{{time}}",xa(a,t))}},ka=/^D+$/,Ca=/^Y+$/,Sa=["D","DD","YY","YYYY"];function Ea(e){return ka.test(e)}function Aa(e){return Ca.test(e)}function Ta(e,t,n){const i=function(e,t,n){const i="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${i} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,n);if(console.warn(i),Sa.includes(e))throw new RangeError(i)}const $a=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ia=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Oa=/^'([^]*?)'?$/,La=/''/g,Da=/[a-zA-Z]/;function ja(e,t,n){const i=Bi(),a=n?.locale??i.locale??aa,r=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,o=Ii(e);if(!Zi(o))throw new RangeError("Invalid time value");let c=t.match(Ia).map((e=>{const t=e[0];if("p"===t||"P"===t){return(0,Ma[t])(e,a.formatLong)}return e})).join("").match($a).map((e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:za(e)};if(_a[t])return{isToken:!0,value:e};if(t.match(Da))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}}));a.localize.preprocessor&&(c=a.localize.preprocessor(o,c));const l={firstWeekContainsDate:r,weekStartsOn:s,locale:a};return c.map((i=>{if(!i.isToken)return i.value;const r=i.value;(!n?.useAdditionalWeekYearTokens&&Aa(r)||!n?.useAdditionalDayOfYearTokens&&Ea(r))&&Ta(r,t,String(e));return(0,_a[r[0]])(o,r,a.localize,l)})).join("")}function za(e){const t=e.match(Oa);return t?t[1].replace(La,"'"):e}class Pa{subPriority=0;validate(e,t){return!0}}class Ra extends Pa{constructor(e,t,n,i,a){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=i,a&&(this.subPriority=a)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}}class Na extends Pa{priority=10;subPriority=-1;set(e,t){return t.timestampIsSet?e:Oi(e,function(e,t){const n=t instanceof Date?Oi(t,0):new t(0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}(e,Date))}}class Fa{run(e,t,n,i){const a=this.parse(e,t,n,i);return a?{setter:new Ra(a.value,this.validate,this.set,this.priority,this.subPriority),rest:a.rest}:null}validate(e,t,n){return!0}}const Ba=/^(1[0-2]|0?\d)/,Va=/^(3[0-1]|[0-2]?\d)/,Ha=/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,Ua=/^(5[0-3]|[0-4]?\d)/,qa=/^(2[0-3]|[0-1]?\d)/,Wa=/^(2[0-4]|[0-1]?\d)/,Za=/^(1[0-1]|0?\d)/,Ka=/^(1[0-2]|0?\d)/,Qa=/^[0-5]?\d/,Ya=/^[0-5]?\d/,Ga=/^\d/,Xa=/^\d{1,2}/,Ja=/^\d{1,3}/,er=/^\d{1,4}/,tr=/^-?\d+/,nr=/^-?\d/,ir=/^-?\d{1,2}/,ar=/^-?\d{1,3}/,rr=/^-?\d{1,4}/,sr=/^([+-])(\d{2})(\d{2})?|Z/,or=/^([+-])(\d{2})(\d{2})|Z/,cr=/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,lr=/^([+-])(\d{2}):(\d{2})|Z/,ur=/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/;function dr(e,t){return e?{value:t(e.value),rest:e.rest}:e}function hr(e,t){const n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function pr(e,t){const n=t.match(e);if(!n)return null;if("Z"===n[0])return{value:0,rest:t.slice(1)};const i="+"===n[1]?1:-1,a=n[2]?parseInt(n[2],10):0,r=n[3]?parseInt(n[3],10):0,s=n[5]?parseInt(n[5],10):0;return{value:i*(a*Ni+r*Ri+1e3*s),rest:t.slice(n[0].length)}}function mr(e){return hr(tr,e)}function fr(e,t){switch(e){case 1:return hr(Ga,t);case 2:return hr(Xa,t);case 3:return hr(Ja,t);case 4:return hr(er,t);default:return hr(new RegExp("^\\d{1,"+e+"}"),t)}}function gr(e,t){switch(e){case 1:return hr(nr,t);case 2:return hr(ir,t);case 3:return hr(ar,t);case 4:return hr(rr,t);default:return hr(new RegExp("^-?\\d{1,"+e+"}"),t)}}function _r(e){switch(e){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function vr(e,t){const n=t>0,i=n?t:1-t;let a;if(i<=50)a=e||100;else{const t=i+50;a=e+100*Math.trunc(t/100)-(e>=t%100?100:0)}return n?a:1-a}function yr(e){return e%400==0||e%4==0&&e%100!=0}const br=[31,28,31,30,31,30,31,31,30,31,30,31],wr=[31,29,31,30,31,30,31,31,30,31,30,31];function xr(e,t,n){const i=Bi(),a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,r=Ii(e),s=r.getDay(),o=7-a;return Li(r,t<0||t>6?t-(s+o)%7:((t%7+7)%7+o)%7-(s+o)%7)}function Mr(e,t){const n=Ii(e),i=function(e){let t=Ii(e).getDay();return 0===t&&(t=7),t}(n);return Li(n,t-i)}const kr={G:new class extends Fa{priority=140;parse(e,t,n){switch(t){case"G":case"GG":case"GGG":return n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"});case"GGGGG":return n.era(e,{width:"narrow"});default:return n.era(e,{width:"wide"})||n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"})}}set(e,t,n){return t.era=n,e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]},y:new class extends Fa{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,n){const i=e=>({year:e,isTwoDigitYear:"yy"===t});switch(t){case"y":return dr(fr(4,e),i);case"yo":return dr(n.ordinalNumber(e,{unit:"year"}),i);default:return dr(fr(t.length,e),i)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n){const i=e.getFullYear();if(n.isTwoDigitYear){const t=vr(n.year,i);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}const a="era"in t&&1!==t.era?1-n.year:n.year;return e.setFullYear(a,0,1),e.setHours(0,0,0,0),e}},Y:new class extends Fa{priority=130;parse(e,t,n){const i=e=>({year:e,isTwoDigitYear:"YY"===t});switch(t){case"Y":return dr(fr(4,e),i);case"Yo":return dr(n.ordinalNumber(e,{unit:"year"}),i);default:return dr(fr(t.length,e),i)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n,i){const a=oa(e,i);if(n.isTwoDigitYear){const t=vr(n.year,a);return e.setFullYear(t,0,i.firstWeekContainsDate),e.setHours(0,0,0,0),Vi(e,i)}const r="era"in t&&1!==t.era?1-n.year:n.year;return e.setFullYear(r,0,i.firstWeekContainsDate),e.setHours(0,0,0,0),Vi(e,i)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:new class extends Fa{priority=130;parse(e,t){return gr("R"===t?4:t.length,e)}set(e,t,n){const i=Oi(e,0);return i.setFullYear(n,0,4),i.setHours(0,0,0,0),Hi(i)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:new class extends Fa{priority=130;parse(e,t){return gr("u"===t?4:t.length,e)}set(e,t,n){return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},Q:new class extends Fa{priority=120;parse(e,t,n){switch(t){case"Q":case"QQ":return fr(t.length,e);case"Qo":return n.ordinalNumber(e,{unit:"quarter"});case"QQQ":return n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return n.quarter(e,{width:"narrow",context:"formatting"});default:return n.quarter(e,{width:"wide",context:"formatting"})||n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth(3*(n-1),1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:new class extends Fa{priority=120;parse(e,t,n){switch(t){case"q":case"qq":return fr(t.length,e);case"qo":return n.ordinalNumber(e,{unit:"quarter"});case"qqq":return n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return n.quarter(e,{width:"narrow",context:"standalone"});default:return n.quarter(e,{width:"wide",context:"standalone"})||n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth(3*(n-1),1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:new class extends Fa{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,n){const i=e=>e-1;switch(t){case"M":return dr(hr(Ba,e),i);case"MM":return dr(fr(2,e),i);case"Mo":return dr(n.ordinalNumber(e,{unit:"month"}),i);case"MMM":return n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(e,{width:"narrow",context:"formatting"});default:return n.month(e,{width:"wide",context:"formatting"})||n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}},L:new class extends Fa{priority=110;parse(e,t,n){const i=e=>e-1;switch(t){case"L":return dr(hr(Ba,e),i);case"LL":return dr(fr(2,e),i);case"Lo":return dr(n.ordinalNumber(e,{unit:"month"}),i);case"LLL":return n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return n.month(e,{width:"narrow",context:"standalone"});default:return n.month(e,{width:"wide",context:"standalone"})||n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:new class extends Fa{priority=100;parse(e,t,n){switch(t){case"w":return hr(Ua,e);case"wo":return n.ordinalNumber(e,{unit:"week"});default:return fr(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n,i){return Vi(function(e,t,n){const i=Ii(e),a=ca(i,n)-t;return i.setDate(i.getDate()-7*a),i}(e,n,i),i)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:new class extends Fa{priority=100;parse(e,t,n){switch(t){case"I":return hr(Ua,e);case"Io":return n.ordinalNumber(e,{unit:"week"});default:return fr(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n){return Hi(function(e,t){const n=Ii(e),i=sa(n)-t;return n.setDate(n.getDate()-7*i),n}(e,n))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:new class extends Fa{priority=90;subPriority=1;parse(e,t,n){switch(t){case"d":return hr(Va,e);case"do":return n.ordinalNumber(e,{unit:"date"});default:return fr(t.length,e)}}validate(e,t){const n=yr(e.getFullYear()),i=e.getMonth();return n?t>=1&&t<=wr[i]:t>=1&&t<=br[i]}set(e,t,n){return e.setDate(n),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:new class extends Fa{priority=90;subpriority=1;parse(e,t,n){switch(t){case"D":case"DD":return hr(Ha,e);case"Do":return n.ordinalNumber(e,{unit:"date"});default:return fr(t.length,e)}}validate(e,t){return yr(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,n){return e.setMonth(0,n),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:new class extends Fa{priority=90;parse(e,t,n){switch(t){case"E":case"EE":case"EEE":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return n.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,i){return(e=xr(e,n,i)).setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},e:new class extends Fa{priority=90;parse(e,t,n,i){const a=e=>{const t=7*Math.floor((e-1)/7);return(e+i.weekStartsOn+6)%7+t};switch(t){case"e":case"ee":return dr(fr(t.length,e),a);case"eo":return dr(n.ordinalNumber(e,{unit:"day"}),a);case"eee":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"eeeee":return n.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,i){return(e=xr(e,n,i)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:new class extends Fa{priority=90;parse(e,t,n,i){const a=e=>{const t=7*Math.floor((e-1)/7);return(e+i.weekStartsOn+6)%7+t};switch(t){case"c":case"cc":return dr(fr(t.length,e),a);case"co":return dr(n.ordinalNumber(e,{unit:"day"}),a);case"ccc":return n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});case"ccccc":return n.day(e,{width:"narrow",context:"standalone"});case"cccccc":return n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});default:return n.day(e,{width:"wide",context:"standalone"})||n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,i){return(e=xr(e,n,i)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:new class extends Fa{priority=90;parse(e,t,n){const i=e=>0===e?7:e;switch(t){case"i":case"ii":return fr(t.length,e);case"io":return n.ordinalNumber(e,{unit:"day"});case"iii":return dr(n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),i);case"iiiii":return dr(n.day(e,{width:"narrow",context:"formatting"}),i);case"iiiiii":return dr(n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),i);default:return dr(n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),i)}}validate(e,t){return t>=1&&t<=7}set(e,t,n){return(e=Mr(e,n)).setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},a:new class extends Fa{priority=80;parse(e,t,n){switch(t){case"a":case"aa":case"aaa":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours(_r(n),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},b:new class extends Fa{priority=80;parse(e,t,n){switch(t){case"b":case"bb":case"bbb":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours(_r(n),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},B:new class extends Fa{priority=80;parse(e,t,n){switch(t){case"B":case"BB":case"BBB":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours(_r(n),0,0,0),e}incompatibleTokens=["a","b","t","T"]},h:new class extends Fa{priority=70;parse(e,t,n){switch(t){case"h":return hr(Ka,e);case"ho":return n.ordinalNumber(e,{unit:"hour"});default:return fr(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,n){const i=e.getHours()>=12;return i&&n<12?e.setHours(n+12,0,0,0):i||12!==n?e.setHours(n,0,0,0):e.setHours(0,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},H:new class extends Fa{priority=70;parse(e,t,n){switch(t){case"H":return hr(qa,e);case"Ho":return n.ordinalNumber(e,{unit:"hour"});default:return fr(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,n){return e.setHours(n,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]},K:new class extends Fa{priority=70;parse(e,t,n){switch(t){case"K":return hr(Za,e);case"Ko":return n.ordinalNumber(e,{unit:"hour"});default:return fr(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.getHours()>=12&&n<12?e.setHours(n+12,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]},k:new class extends Fa{priority=70;parse(e,t,n){switch(t){case"k":return hr(Wa,e);case"ko":return n.ordinalNumber(e,{unit:"hour"});default:return fr(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,n){const i=n<=24?n%24:n;return e.setHours(i,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},m:new class extends Fa{priority=60;parse(e,t,n){switch(t){case"m":return hr(Qa,e);case"mo":return n.ordinalNumber(e,{unit:"minute"});default:return fr(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setMinutes(n,0,0),e}incompatibleTokens=["t","T"]},s:new class extends Fa{priority=50;parse(e,t,n){switch(t){case"s":return hr(Ya,e);case"so":return n.ordinalNumber(e,{unit:"second"});default:return fr(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setSeconds(n,0),e}incompatibleTokens=["t","T"]},S:new class extends Fa{priority=30;parse(e,t){return dr(fr(t.length,e),(e=>Math.trunc(e*Math.pow(10,3-t.length))))}set(e,t,n){return e.setMilliseconds(n),e}incompatibleTokens=["t","T"]},X:new class extends Fa{priority=10;parse(e,t){switch(t){case"X":return pr(sr,e);case"XX":return pr(or,e);case"XXXX":return pr(cr,e);case"XXXXX":return pr(ur,e);default:return pr(lr,e)}}set(e,t,n){return t.timestampIsSet?e:Oi(e,e.getTime()-Wi(e)-n)}incompatibleTokens=["t","T","x"]},x:new class extends Fa{priority=10;parse(e,t){switch(t){case"x":return pr(sr,e);case"xx":return pr(or,e);case"xxxx":return pr(cr,e);case"xxxxx":return pr(ur,e);default:return pr(lr,e)}}set(e,t,n){return t.timestampIsSet?e:Oi(e,e.getTime()-Wi(e)-n)}incompatibleTokens=["t","T","X"]},t:new class extends Fa{priority=40;parse(e){return mr(e)}set(e,t,n){return[Oi(e,1e3*n),{timestampIsSet:!0}]}incompatibleTokens="*"},T:new class extends Fa{priority=20;parse(e){return mr(e)}set(e,t,n){return[Oi(e,n),{timestampIsSet:!0}]}incompatibleTokens="*"}},Cr=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Sr=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Er=/^'([^]*?)'?$/,Ar=/''/g,Tr=/\S/,$r=/[a-zA-Z]/;function Ir(e,t,n,i){const a=Object.assign({},Bi()),r=i?.locale??a.locale??aa,s=i?.firstWeekContainsDate??i?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,o=i?.weekStartsOn??i?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0;if(""===t)return""===e?Ii(n):Oi(n,NaN);const c={firstWeekContainsDate:s,weekStartsOn:o,locale:r},l=[new Na],u=t.match(Sr).map((e=>{const t=e[0];if(t in Ma){return(0,Ma[t])(e,r.formatLong)}return e})).join("").match(Cr),d=[];for(let a of u){!i?.useAdditionalWeekYearTokens&&Aa(a)&&Ta(a,t,e),!i?.useAdditionalDayOfYearTokens&&Ea(a)&&Ta(a,t,e);const s=a[0],o=kr[s];if(o){const{incompatibleTokens:t}=o;if(Array.isArray(t)){const e=d.find((e=>t.includes(e.token)||e.token===s));if(e)throw new RangeError(`The format string mustn't contain \`${e.fullToken}\` and \`${a}\` at the same time`)}else if("*"===o.incompatibleTokens&&d.length>0)throw new RangeError(`The format string mustn't contain \`${a}\` and any other token at the same time`);d.push({token:s,fullToken:a});const i=o.run(e,a,r.match,c);if(!i)return Oi(n,NaN);l.push(i.setter),e=i.rest}else{if(s.match($r))throw new RangeError("Format string contains an unescaped latin alphabet character `"+s+"`");if("''"===a?a="'":"'"===s&&(a=a.match(Er)[1].replace(Ar,"'")),0!==e.indexOf(a))return Oi(n,NaN);e=e.slice(a.length)}}if(e.length>0&&Tr.test(e))return Oi(n,NaN);const h=l.map((e=>e.priority)).sort(((e,t)=>t-e)).filter(((e,t,n)=>n.indexOf(e)===t)).map((e=>l.filter((t=>t.priority===e)).sort(((e,t)=>t.subPriority-e.subPriority)))).map((e=>e[0]));let p=Ii(n);if(isNaN(p.getTime()))return Oi(n,NaN);const m={};for(const e of h){if(!e.validate(p,c))return Oi(n,NaN);const t=e.set(p,m,c);Array.isArray(t)?(p=t[0],Object.assign(m,t[1])):p=t}return Oi(n,p)}function Or(e,t){const{years:n=0,months:i=0,weeks:a=0,days:r=0,hours:s=0,minutes:o=0,seconds:c=0}=t,l=function(e,t){return Di(e,-t)}(e,i+12*n),u=function(e,t){return Li(e,-t)}(l,r+7*a),d=1e3*(c+60*(o+60*s));return Oi(e,u.getTime()-d)}var Lr="object"==typeof global&&global&&global.Object===Object&&global,Dr="object"==typeof self&&self&&self.Object===Object&&self,jr=Lr||Dr||Function("return this")(),zr=jr.Symbol,Pr=Object.prototype,Rr=Pr.hasOwnProperty,Nr=Pr.toString,Fr=zr?zr.toStringTag:void 0;var Br=Object.prototype.toString;var Vr="[object Null]",Hr="[object Undefined]",Ur=zr?zr.toStringTag:void 0;function qr(e){return null==e?void 0===e?Hr:Vr:Ur&&Ur in Object(e)?function(e){var t=Rr.call(e,Fr),n=e[Fr];try{e[Fr]=void 0;var i=!0}catch(e){}var a=Nr.call(e);return i&&(t?e[Fr]=n:delete e[Fr]),a}(e):function(e){return Br.call(e)}(e)}function Wr(e){return null!=e&&"object"==typeof e}var Zr="[object Symbol]";function Kr(e){return"symbol"==typeof e||Wr(e)&&qr(e)==Zr}function Qr(e,t){for(var n=-1,i=null==e?0:e.length,a=Array(i);++n<i;)a[n]=t(e[n],n,e);return a}var Yr=Array.isArray,Gr=1/0,Xr=zr?zr.prototype:void 0,Jr=Xr?Xr.toString:void 0;function es(e){if("string"==typeof e)return e;if(Yr(e))return Qr(e,es)+"";if(Kr(e))return Jr?Jr.call(e):"";var t=e+"";return"0"==t&&1/e==-Gr?"-0":t}var ts=/\s/;var ns=/^\s+/;function is(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&ts.test(e.charAt(t)););return t}(e)+1).replace(ns,""):e}function as(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var rs=NaN,ss=/^[-+]0x[0-9a-f]+$/i,os=/^0b[01]+$/i,cs=/^0o[0-7]+$/i,ls=parseInt;function us(e){if("number"==typeof e)return e;if(Kr(e))return rs;if(as(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=as(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=is(e);var n=os.test(e);return n||cs.test(e)?ls(e.slice(2),n?2:8):ss.test(e)?rs:+e}var ds=1/0,hs=17976931348623157e292;function ps(e){var t=function(e){return e?(e=us(e))===ds||e===-ds?(e<0?-1:1)*hs:e==e?e:0:0===e?e:0}(e),n=t%1;return t==t?n?t-n:t:0}function ms(e){return e}var fs="[object AsyncFunction]",gs="[object Function]",_s="[object GeneratorFunction]",vs="[object Proxy]";function ys(e){if(!as(e))return!1;var t=qr(e);return t==gs||t==_s||t==fs||t==vs}var bs,ws=jr["__core-js_shared__"],xs=(bs=/[^.]+$/.exec(ws&&ws.keys&&ws.keys.IE_PROTO||""))?"Symbol(src)_1."+bs:"";var Ms=Function.prototype.toString;function ks(e){if(null!=e){try{return Ms.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Cs=/^\[object .+?Constructor\]$/,Ss=Function.prototype,Es=Object.prototype,As=Ss.toString,Ts=Es.hasOwnProperty,$s=RegExp("^"+As.call(Ts).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Is(e){return!(!as(e)||(t=e,xs&&xs in t))&&(ys(e)?$s:Cs).test(ks(e));var t}function Os(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Is(n)?n:void 0}var Ls=Os(jr,"WeakMap"),Ds=Object.create,js=function(){function e(){}return function(t){if(!as(t))return{};if(Ds)return Ds(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function zs(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n<i;)t[n]=e[n];return t}var Ps=Date.now;var Rs,Ns,Fs,Bs=function(){try{var e=Os(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Vs=Bs,Hs=Vs?function(e,t){return Vs(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:ms,Us=(Rs=Hs,Ns=0,Fs=0,function(){var e=Ps(),t=16-(e-Fs);if(Fs=e,t>0){if(++Ns>=800)return arguments[0]}else Ns=0;return Rs.apply(void 0,arguments)});function qs(e){return e!=e}function Ws(e,t){return!!(null==e?0:e.length)&&function(e,t,n){return t==t?function(e,t,n){for(var i=n-1,a=e.length;++i<a;)if(e[i]===t)return i;return-1}(e,t,n):function(e,t,n,i){for(var a=e.length,r=n+(i?1:-1);i?r--:++r<a;)if(t(e[r],r,e))return r;return-1}(e,qs,n)}(e,t,0)>-1}var Zs=9007199254740991,Ks=/^(?:0|[1-9]\d*)$/;function Qs(e,t){var n=typeof e;return!!(t=null==t?Zs:t)&&("number"==n||"symbol"!=n&&Ks.test(e))&&e>-1&&e%1==0&&e<t}function Ys(e,t,n){"__proto__"==t&&Vs?Vs(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Gs(e,t){return e===t||e!=e&&t!=t}var Xs=Object.prototype.hasOwnProperty;function Js(e,t,n){var i=e[t];Xs.call(e,t)&&Gs(i,n)&&(void 0!==n||t in e)||Ys(e,t,n)}function eo(e,t,n,i){var a=!n;n||(n={});for(var r=-1,s=t.length;++r<s;){var o=t[r],c=i?i(n[o],e[o],o,n,e):void 0;void 0===c&&(c=e[o]),a?Ys(n,o,c):Js(n,o,c)}return n}var to=Math.max;function no(e,t){return Us(function(e,t,n){return t=to(void 0===t?e.length-1:t,0),function(){for(var i=arguments,a=-1,r=to(i.length-t,0),s=Array(r);++a<r;)s[a]=i[t+a];a=-1;for(var o=Array(t+1);++a<t;)o[a]=i[a];return o[t]=n(s),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,o)}}(e,t,ms),e+"")}var io=9007199254740991;function ao(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=io}function ro(e){return null!=e&&ao(e.length)&&!ys(e)}function so(e,t,n){if(!as(n))return!1;var i=typeof t;return!!("number"==i?ro(n)&&Qs(t,n.length):"string"==i&&t in n)&&Gs(n[t],e)}function oo(e){return no((function(t,n){var i=-1,a=n.length,r=a>1?n[a-1]:void 0,s=a>2?n[2]:void 0;for(r=e.length>3&&"function"==typeof r?(a--,r):void 0,s&&so(n[0],n[1],s)&&(r=a<3?void 0:r,a=1),t=Object(t);++i<a;){var o=n[i];o&&e(t,o,i,r)}return t}))}var co=Object.prototype;function lo(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||co)}function uo(e){return Wr(e)&&"[object Arguments]"==qr(e)}var ho=Object.prototype,po=ho.hasOwnProperty,mo=ho.propertyIsEnumerable,fo=uo(function(){return arguments}())?uo:function(e){return Wr(e)&&po.call(e,"callee")&&!mo.call(e,"callee")};var go="object"==typeof exports&&exports&&!exports.nodeType&&exports,_o=go&&"object"==typeof module&&module&&!module.nodeType&&module,vo=_o&&_o.exports===go?jr.Buffer:void 0,yo=(vo?vo.isBuffer:void 0)||function(){return!1},bo={};function wo(e){return function(t){return e(t)}}bo["[object Float32Array]"]=bo["[object Float64Array]"]=bo["[object Int8Array]"]=bo["[object Int16Array]"]=bo["[object Int32Array]"]=bo["[object Uint8Array]"]=bo["[object Uint8ClampedArray]"]=bo["[object Uint16Array]"]=bo["[object Uint32Array]"]=!0,bo["[object Arguments]"]=bo["[object Array]"]=bo["[object ArrayBuffer]"]=bo["[object Boolean]"]=bo["[object DataView]"]=bo["[object Date]"]=bo["[object Error]"]=bo["[object Function]"]=bo["[object Map]"]=bo["[object Number]"]=bo["[object Object]"]=bo["[object RegExp]"]=bo["[object Set]"]=bo["[object String]"]=bo["[object WeakMap]"]=!1;var xo="object"==typeof exports&&exports&&!exports.nodeType&&exports,Mo=xo&&"object"==typeof module&&module&&!module.nodeType&&module,ko=Mo&&Mo.exports===xo&&Lr.process,Co=function(){try{var e=Mo&&Mo.require&&Mo.require("util").types;return e||ko&&ko.binding&&ko.binding("util")}catch(e){}}(),So=Co,Eo=So&&So.isTypedArray,Ao=Eo?wo(Eo):function(e){return Wr(e)&&ao(e.length)&&!!bo[qr(e)]},To=Object.prototype.hasOwnProperty;function $o(e,t){var n=Yr(e),i=!n&&fo(e),a=!n&&!i&&yo(e),r=!n&&!i&&!a&&Ao(e),s=n||i||a||r,o=s?function(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}(e.length,String):[],c=o.length;for(var l in e)!t&&!To.call(e,l)||s&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Qs(l,c))||o.push(l);return o}function Io(e,t){return function(n){return e(t(n))}}var Oo=Io(Object.keys,Object),Lo=Object.prototype.hasOwnProperty;function Do(e){return ro(e)?$o(e):function(e){if(!lo(e))return Oo(e);var t=[];for(var n in Object(e))Lo.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}var jo=Object.prototype.hasOwnProperty;function zo(e){if(!as(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=lo(e),n=[];for(var i in e)("constructor"!=i||!t&&jo.call(e,i))&&n.push(i);return n}function Po(e){return ro(e)?$o(e,!0):zo(e)}var Ro=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,No=/^\w*$/;function Fo(e,t){if(Yr(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!Kr(e))||(No.test(e)||!Ro.test(e)||null!=t&&e in Object(t))}var Bo=Os(Object,"create");var Vo=Object.prototype.hasOwnProperty;var Ho=Object.prototype.hasOwnProperty;function Uo(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function qo(e,t){for(var n=e.length;n--;)if(Gs(e[n][0],t))return n;return-1}Uo.prototype.clear=function(){this.__data__=Bo?Bo(null):{},this.size=0},Uo.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Uo.prototype.get=function(e){var t=this.__data__;if(Bo){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return Vo.call(t,e)?t[e]:void 0},Uo.prototype.has=function(e){var t=this.__data__;return Bo?void 0!==t[e]:Ho.call(t,e)},Uo.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Bo&&void 0===t?"__lodash_hash_undefined__":t,this};var Wo=Array.prototype.splice;function Zo(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}Zo.prototype.clear=function(){this.__data__=[],this.size=0},Zo.prototype.delete=function(e){var t=this.__data__,n=qo(t,e);return!(n<0)&&(n==t.length-1?t.pop():Wo.call(t,n,1),--this.size,!0)},Zo.prototype.get=function(e){var t=this.__data__,n=qo(t,e);return n<0?void 0:t[n][1]},Zo.prototype.has=function(e){return qo(this.__data__,e)>-1},Zo.prototype.set=function(e,t){var n=this.__data__,i=qo(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};var Ko=Os(jr,"Map");function Qo(e,t){var n=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function Yo(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}Yo.prototype.clear=function(){this.size=0,this.__data__={hash:new Uo,map:new(Ko||Zo),string:new Uo}},Yo.prototype.delete=function(e){var t=Qo(this,e).delete(e);return this.size-=t?1:0,t},Yo.prototype.get=function(e){return Qo(this,e).get(e)},Yo.prototype.has=function(e){return Qo(this,e).has(e)},Yo.prototype.set=function(e,t){var n=Qo(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this};var Go="Expected a function";function Xo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(Go);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],r=n.cache;if(r.has(a))return r.get(a);var s=e.apply(this,i);return n.cache=r.set(a,s)||r,s};return n.cache=new(Xo.Cache||Yo),n}Xo.Cache=Yo;var Jo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ec=/\\(\\)?/g,tc=function(e){var t=Xo(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Jo,(function(e,n,i,a){t.push(i?a.replace(ec,"$1"):n||e)})),t})),nc=tc;function ic(e){return null==e?"":es(e)}function ac(e,t){return Yr(e)?e:Fo(e,t)?[e]:nc(ic(e))}var rc=1/0;function sc(e){if("string"==typeof e||Kr(e))return e;var t=e+"";return"0"==t&&1/e==-rc?"-0":t}function oc(e,t){for(var n=0,i=(t=ac(t,e)).length;null!=e&&n<i;)e=e[sc(t[n++])];return n&&n==i?e:void 0}function cc(e,t,n){var i=null==e?void 0:oc(e,t);return void 0===i?n:i}function lc(e,t){for(var n=-1,i=t.length,a=e.length;++n<i;)e[a+n]=t[n];return e}var uc=Io(Object.getPrototypeOf,Object),dc="[object Object]",hc=Function.prototype,pc=Object.prototype,mc=hc.toString,fc=pc.hasOwnProperty,gc=mc.call(Object);function _c(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(a);++i<a;)r[i]=e[i+t];return r}var vc=jr.isFinite,yc=Math.min;var bc=Math.ceil,wc=Math.max;function xc(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=us(n))==n?n:0),void 0!==t&&(t=(t=us(t))==t?t:0),function(e,t,n){return e==e&&(void 0!==n&&(e=e<=n?e:n),void 0!==t&&(e=e>=t?e:t)),e}(us(e),t,n)}function Mc(e){var t=this.__data__=new Zo(e);this.size=t.size}Mc.prototype.clear=function(){this.__data__=new Zo,this.size=0},Mc.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Mc.prototype.get=function(e){return this.__data__.get(e)},Mc.prototype.has=function(e){return this.__data__.has(e)},Mc.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Zo){var i=n.__data__;if(!Ko||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Yo(i)}return n.set(e,t),this.size=n.size,this};var kc="object"==typeof exports&&exports&&!exports.nodeType&&exports,Cc=kc&&"object"==typeof module&&module&&!module.nodeType&&module,Sc=Cc&&Cc.exports===kc?jr.Buffer:void 0,Ec=Sc?Sc.allocUnsafe:void 0;function Ac(e,t){if(t)return e.slice();var n=e.length,i=Ec?Ec(n):new e.constructor(n);return e.copy(i),i}function Tc(){return[]}var $c=Object.prototype.propertyIsEnumerable,Ic=Object.getOwnPropertySymbols,Oc=Ic?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,i=null==e?0:e.length,a=0,r=[];++n<i;){var s=e[n];t(s,n,e)&&(r[a++]=s)}return r}(Ic(e),(function(t){return $c.call(e,t)})))}:Tc;var Lc=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)lc(t,Oc(e)),e=uc(e);return t}:Tc;function Dc(e,t,n){var i=t(e);return Yr(e)?i:lc(i,n(e))}function jc(e){return Dc(e,Do,Oc)}function zc(e){return Dc(e,Po,Lc)}var Pc=Os(jr,"DataView"),Rc=Os(jr,"Promise"),Nc=Os(jr,"Set"),Fc="[object Map]",Bc="[object Promise]",Vc="[object Set]",Hc="[object WeakMap]",Uc="[object DataView]",qc=ks(Pc),Wc=ks(Ko),Zc=ks(Rc),Kc=ks(Nc),Qc=ks(Ls),Yc=qr;(Pc&&Yc(new Pc(new ArrayBuffer(1)))!=Uc||Ko&&Yc(new Ko)!=Fc||Rc&&Yc(Rc.resolve())!=Bc||Nc&&Yc(new Nc)!=Vc||Ls&&Yc(new Ls)!=Hc)&&(Yc=function(e){var t=qr(e),n="[object Object]"==t?e.constructor:void 0,i=n?ks(n):"";if(i)switch(i){case qc:return Uc;case Wc:return Fc;case Zc:return Bc;case Kc:return Vc;case Qc:return Hc}return t});var Gc=Yc,Xc=Object.prototype.hasOwnProperty;var Jc=jr.Uint8Array;function el(e){var t=new e.constructor(e.byteLength);return new Jc(t).set(new Jc(e)),t}var tl=/\w*$/;var nl=zr?zr.prototype:void 0,il=nl?nl.valueOf:void 0;function al(e,t){var n=t?el(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var rl="[object Boolean]",sl="[object Date]",ol="[object Map]",cl="[object Number]",ll="[object RegExp]",ul="[object Set]",dl="[object String]",hl="[object Symbol]",pl="[object ArrayBuffer]",ml="[object DataView]",fl="[object Float32Array]",gl="[object Float64Array]",_l="[object Int8Array]",vl="[object Int16Array]",yl="[object Int32Array]",bl="[object Uint8Array]",wl="[object Uint8ClampedArray]",xl="[object Uint16Array]",Ml="[object Uint32Array]";function kl(e,t,n){var i,a,r,s=e.constructor;switch(t){case pl:return el(e);case rl:case sl:return new s(+e);case ml:return function(e,t){var n=t?el(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case fl:case gl:case _l:case vl:case yl:case bl:case wl:case xl:case Ml:return al(e,n);case ol:return new s;case cl:case dl:return new s(e);case ll:return(r=new(a=e).constructor(a.source,tl.exec(a))).lastIndex=a.lastIndex,r;case ul:return new s;case hl:return i=e,il?Object(il.call(i)):{}}}function Cl(e){return"function"!=typeof e.constructor||lo(e)?{}:js(uc(e))}var Sl=So&&So.isMap,El=Sl?wo(Sl):function(e){return Wr(e)&&"[object Map]"==Gc(e)};var Al=So&&So.isSet,Tl=Al?wo(Al):function(e){return Wr(e)&&"[object Set]"==Gc(e)},$l=1,Il=2,Ol=4,Ll="[object Arguments]",Dl="[object Function]",jl="[object GeneratorFunction]",zl="[object Object]",Pl={};function Rl(e,t,n,i,a,r){var s,o=t&$l,c=t&Il,l=t&Ol;if(n&&(s=a?n(e,i,a,r):n(e)),void 0!==s)return s;if(!as(e))return e;var u=Yr(e);if(u){if(s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Xc.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!o)return zs(e,s)}else{var d=Gc(e),h=d==Dl||d==jl;if(yo(e))return Ac(e,o);if(d==zl||d==Ll||h&&!a){if(s=c||h?{}:Cl(e),!o)return c?function(e,t){return eo(e,Lc(e),t)}(e,function(e,t){return e&&eo(t,Po(t),e)}(s,e)):function(e,t){return eo(e,Oc(e),t)}(e,function(e,t){return e&&eo(t,Do(t),e)}(s,e))}else{if(!Pl[d])return a?e:{};s=kl(e,d,o)}}r||(r=new Mc);var p=r.get(e);if(p)return p;r.set(e,s),Tl(e)?e.forEach((function(i){s.add(Rl(i,t,n,i,e,r))})):El(e)&&e.forEach((function(i,a){s.set(a,Rl(i,t,n,a,e,r))}));var m=u?void 0:(l?c?zc:jc:c?Po:Do)(e);return function(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););}(m||e,(function(i,a){m&&(i=e[a=i]),Js(s,a,Rl(i,t,n,a,e,r))})),s}Pl[Ll]=Pl["[object Array]"]=Pl["[object ArrayBuffer]"]=Pl["[object DataView]"]=Pl["[object Boolean]"]=Pl["[object Date]"]=Pl["[object Float32Array]"]=Pl["[object Float64Array]"]=Pl["[object Int8Array]"]=Pl["[object Int16Array]"]=Pl["[object Int32Array]"]=Pl["[object Map]"]=Pl["[object Number]"]=Pl[zl]=Pl["[object RegExp]"]=Pl["[object Set]"]=Pl["[object String]"]=Pl["[object Symbol]"]=Pl["[object Uint8Array]"]=Pl["[object Uint8ClampedArray]"]=Pl["[object Uint16Array]"]=Pl["[object Uint32Array]"]=!0,Pl["[object Error]"]=Pl[Dl]=Pl["[object WeakMap]"]=!1;function Nl(e){return Rl(e,5)}function Fl(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Yo;++t<n;)this.add(e[t])}function Bl(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}function Vl(e,t){return e.has(t)}Fl.prototype.add=Fl.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Fl.prototype.has=function(e){return this.__data__.has(e)};var Hl=1,Ul=2;function ql(e,t,n,i,a,r){var s=n&Hl,o=e.length,c=t.length;if(o!=c&&!(s&&c>o))return!1;var l=r.get(e),u=r.get(t);if(l&&u)return l==t&&u==e;var d=-1,h=!0,p=n&Ul?new Fl:void 0;for(r.set(e,t),r.set(t,e);++d<o;){var m=e[d],f=t[d];if(i)var g=s?i(f,m,d,t,e,r):i(m,f,d,e,t,r);if(void 0!==g){if(g)continue;h=!1;break}if(p){if(!Bl(t,(function(e,t){if(!Vl(p,t)&&(m===e||a(m,e,n,i,r)))return p.push(t)}))){h=!1;break}}else if(m!==f&&!a(m,f,n,i,r)){h=!1;break}}return r.delete(e),r.delete(t),h}function Wl(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function Zl(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var Kl=1,Ql=2,Yl="[object Boolean]",Gl="[object Date]",Xl="[object Error]",Jl="[object Map]",eu="[object Number]",tu="[object RegExp]",nu="[object Set]",iu="[object String]",au="[object Symbol]",ru="[object ArrayBuffer]",su="[object DataView]",ou=zr?zr.prototype:void 0,cu=ou?ou.valueOf:void 0;var lu=1,uu=Object.prototype.hasOwnProperty;var du=1,hu="[object Arguments]",pu="[object Array]",mu="[object Object]",fu=Object.prototype.hasOwnProperty;function gu(e,t,n,i,a,r){var s=Yr(e),o=Yr(t),c=s?pu:Gc(e),l=o?pu:Gc(t),u=(c=c==hu?mu:c)==mu,d=(l=l==hu?mu:l)==mu,h=c==l;if(h&&yo(e)){if(!yo(t))return!1;s=!0,u=!1}if(h&&!u)return r||(r=new Mc),s||Ao(e)?ql(e,t,n,i,a,r):function(e,t,n,i,a,r,s){switch(n){case su:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ru:return!(e.byteLength!=t.byteLength||!r(new Jc(e),new Jc(t)));case Yl:case Gl:case eu:return Gs(+e,+t);case Xl:return e.name==t.name&&e.message==t.message;case tu:case iu:return e==t+"";case Jl:var o=Wl;case nu:var c=i&Kl;if(o||(o=Zl),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;i|=Ql,s.set(e,t);var u=ql(o(e),o(t),i,a,r,s);return s.delete(e),u;case au:if(cu)return cu.call(e)==cu.call(t)}return!1}(e,t,c,n,i,a,r);if(!(n&du)){var p=u&&fu.call(e,"__wrapped__"),m=d&&fu.call(t,"__wrapped__");if(p||m){var f=p?e.value():e,g=m?t.value():t;return r||(r=new Mc),a(f,g,n,i,r)}}return!!h&&(r||(r=new Mc),function(e,t,n,i,a,r){var s=n&lu,o=jc(e),c=o.length;if(c!=jc(t).length&&!s)return!1;for(var l=c;l--;){var u=o[l];if(!(s?u in t:uu.call(t,u)))return!1}var d=r.get(e),h=r.get(t);if(d&&h)return d==t&&h==e;var p=!0;r.set(e,t),r.set(t,e);for(var m=s;++l<c;){var f=e[u=o[l]],g=t[u];if(i)var _=s?i(g,f,u,t,e,r):i(f,g,u,e,t,r);if(!(void 0===_?f===g||a(f,g,n,i,r):_)){p=!1;break}m||(m="constructor"==u)}if(p&&!m){var v=e.constructor,y=t.constructor;v==y||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof y&&y instanceof y||(p=!1)}return r.delete(e),r.delete(t),p}(e,t,n,i,a,r))}function _u(e,t,n,i,a){return e===t||(null==e||null==t||!Wr(e)&&!Wr(t)?e!=e&&t!=t:gu(e,t,n,i,_u,a))}var vu=1,yu=2;function bu(e){return e==e&&!as(e)}function wu(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function xu(e){var t=function(e){for(var t=Do(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,bu(a)]}return t}(e);return 1==t.length&&t[0][2]?wu(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,i){var a=n.length,r=a,s=!i;if(null==e)return!r;for(e=Object(e);a--;){var o=n[a];if(s&&o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++a<r;){var c=(o=n[a])[0],l=e[c],u=o[1];if(s&&o[2]){if(void 0===l&&!(c in e))return!1}else{var d=new Mc;if(i)var h=i(l,u,c,e,t,d);if(!(void 0===h?_u(u,l,vu|yu,i,d):h))return!1}}return!0}(n,e,t)}}function Mu(e,t){return null!=e&&t in Object(e)}function ku(e,t){return null!=e&&function(e,t,n){for(var i=-1,a=(t=ac(t,e)).length,r=!1;++i<a;){var s=sc(t[i]);if(!(r=null!=e&&n(e,s)))break;e=e[s]}return r||++i!=a?r:!!(a=null==e?0:e.length)&&ao(a)&&Qs(s,a)&&(Yr(e)||fo(e))}(e,t,Mu)}var Cu=1,Su=2;function Eu(e){return Fo(e)?(t=sc(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return oc(t,e)}}(e);var t}function Au(e){return"function"==typeof e?e:null==e?ms:"object"==typeof e?Yr(e)?(t=e[0],n=e[1],Fo(t)&&bu(n)?wu(sc(t),n):function(e){var i=cc(e,t);return void 0===i&&i===n?ku(e,t):_u(n,i,Cu|Su)}):xu(e):Eu(e);var t,n}var Tu,$u=function(e,t,n){for(var i=-1,a=Object(e),r=n(e),s=r.length;s--;){var o=r[Tu?s:++i];if(!1===t(a[o],o,a))break}return e};var Iu=function(e,t){return function(n,i){if(null==n)return n;if(!ro(n))return e(n,i);for(var a=n.length,r=t?a:-1,s=Object(n);(t?r--:++r<a)&&!1!==i(s[r],r,s););return n}}((function(e,t){return e&&$u(e,t,Do)})),Ou=Iu,Lu=function(){return jr.Date.now()},Du="Expected a function",ju=Math.max,zu=Math.min;function Pu(e,t,n){var i,a,r,s,o,c,l=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError(Du);function p(t){var n=i,r=a;return i=a=void 0,l=t,s=e.apply(r,n)}function m(e){var n=e-c;return void 0===c||n>=t||n<0||d&&e-l>=r}function f(){var e=Lu();if(m(e))return g(e);o=setTimeout(f,function(e){var n=t-(e-c);return d?zu(n,r-(e-l)):n}(e))}function g(e){return o=void 0,h&&i?p(e):(i=a=void 0,s)}function _(){var e=Lu(),n=m(e);if(i=arguments,a=this,c=e,n){if(void 0===o)return function(e){return l=e,o=setTimeout(f,t),u?p(e):s}(c);if(d)return clearTimeout(o),o=setTimeout(f,t),p(c)}return void 0===o&&(o=setTimeout(f,t)),s}return t=us(t)||0,as(n)&&(u=!!n.leading,r=(d="maxWait"in n)?ju(us(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h),_.cancel=function(){void 0!==o&&clearTimeout(o),l=0,i=c=a=o=void 0},_.flush=function(){return void 0===o?s:g(Lu())},_}function Ru(e,t,n){(void 0!==n&&!Gs(e[t],n)||void 0===n&&!(t in e))&&Ys(e,t,n)}function Nu(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Fu(e,t,n,i,a,r,s){var o=Nu(e,n),c=Nu(t,n),l=s.get(c);if(l)Ru(e,n,l);else{var u,d=r?r(o,c,n+"",e,t,s):void 0,h=void 0===d;if(h){var p=Yr(c),m=!p&&yo(c),f=!p&&!m&&Ao(c);d=c,p||m||f?Yr(o)?d=o:Wr(u=o)&&ro(u)?d=zs(o):m?(h=!1,d=Ac(c,!0)):f?(h=!1,d=al(c,!0)):d=[]:function(e){if(!Wr(e)||qr(e)!=dc)return!1;var t=uc(e);if(null===t)return!0;var n=fc.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&mc.call(n)==gc}(c)||fo(c)?(d=o,fo(o)?d=function(e){return eo(e,Po(e))}(o):as(o)&&!ys(o)||(d=Cl(c))):h=!1}h&&(s.set(c,d),a(d,c,i,r,s),s.delete(c)),Ru(e,n,d)}}function Bu(e,t,n,i,a){e!==t&&$u(t,(function(r,s){if(a||(a=new Mc),as(r))Fu(e,t,s,n,Bu,i,a);else{var o=i?i(Nu(e,s),r,s+"",e,t,a):void 0;void 0===o&&(o=r),Ru(e,s,o)}}),Po)}var Vu=oo((function(e,t,n,i){Bu(e,t,n,i)}));function Hu(e,t,n){for(var i=-1,a=null==e?0:e.length;++i<a;)if(n(t,e[i]))return!0;return!1}function Uu(e,t){return _u(e,t)}var qu=oo((function(e,t,n){Bu(e,t,n)}));function Wu(e,t){return null==(e=function(e,t){return t.length<2?e:oc(e,_c(t,0,-1))}(e,t=ac(t,e)))||delete e[sc((n=t,i=null==n?0:n.length,i?n[i-1]:void 0))];var n,i}function Zu(e,t){if(e!==t){var n=void 0!==e,i=null===e,a=e==e,r=Kr(e),s=void 0!==t,o=null===t,c=t==t,l=Kr(t);if(!o&&!l&&!r&&e>t||r&&s&&c&&!o&&!l||i&&s&&c||!n&&c||!a)return 1;if(!i&&!r&&!l&&e<t||l&&n&&a&&!i&&!r||o&&n&&a||!s&&a||!c)return-1}return 0}function Ku(e,t,n){t=t.length?Qr(t,(function(e){return Yr(e)?function(t){return oc(t,1===e.length?e[0]:e)}:e})):[ms];var i=-1;t=Qr(t,wo(Au));var a=function(e,t){var n=-1,i=ro(e)?Array(e.length):[];return Ou(e,(function(e,a,r){i[++n]=t(e,a,r)})),i}(e,(function(e,n,a){return{criteria:Qr(t,(function(t){return t(e)})),index:++i,value:e}}));return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(a,(function(e,t){return function(e,t,n){for(var i=-1,a=e.criteria,r=t.criteria,s=a.length,o=n.length;++i<s;){var c=Zu(a[i],r[i]);if(c)return i>=o?c:c*("desc"==n[i]?-1:1)}return e.index-t.index}(e,t,n)}))}function Qu(e,t,n,i){return null==e?[]:(Yr(t)||(t=null==t?[]:[t]),Yr(n=i?void 0:n)||(n=null==n?[]:[n]),Ku(e,t,n))}var Yu=function(e){var t=Math[e];return function(e,n){if(e=us(e),(n=null==n?0:yc(ps(n),292))&&vc(e)){var i=(ic(e)+"e").split("e");return+((i=(ic(t(i[0]+"e"+(+i[1]+n)))+"e").split("e"))[0]+"e"+(+i[1]-n))}return t(e)}}("round"),Gu=Yu;function Xu(e,t,n){return null==e?e:function(e,t,n,i){if(!as(e))return e;for(var a=-1,r=(t=ac(t,e)).length,s=r-1,o=e;null!=o&&++a<r;){var c=sc(t[a]),l=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(a!=s){var u=o[c];void 0===(l=i?i(u,c,o):void 0)&&(l=as(u)?u:Qs(t[a+1])?[]:{})}Js(o,c,l),o=o[c]}return e}(e,t,n)}function Ju(e,t){return e&&e.length?function(e,t){for(var n=-1,i=e.length,a=0,r=[];++n<i;){var s=e[n],o=t?t(s):s;if(!n||!Gs(o,c)){var c=o;r[a++]=0===s?0:s}}return r}(e,Au(t)):[]}function ed(e,t,n){var i=!0,a=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return as(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),Pu(e,t,{leading:i,maxWait:t,trailing:a})}var td,nd=Nc&&1/Zl(new Nc([,-0]))[1]==1/0?function(e){return new Nc(e)}:function(){},id=200;function ad(e,t,n){var i=-1,a=Ws,r=e.length,s=!0,o=[],c=o;if(n)s=!1,a=Hu;else if(r>=id){var l=t?null:nd(e);if(l)return Zl(l);s=!1,a=Vl,c=new Fl}else c=t?[]:o;e:for(;++i<r;){var u=e[i],d=t?t(u):u;if(u=n||0!==u?u:0,s&&d==d){for(var h=c.length;h--;)if(c[h]===d)continue e;t&&c.push(d),o.push(u)}else a(c,d,n)||(c!==o&&c.push(d),o.push(u))}return o}function rd(e,t){return t="function"==typeof t?t:void 0,e&&e.length?ad(e,void 0,t):[]}class sd extends Error{constructor(e,t){super(e),this.context=t}}!function(e){e.Relative="relative",e.Continuous="continuous"}(td||(td={}));const od=["clips","remote-control-entity","favorite-events","favorite-recordings","live","menu","ptz","recordings","seek","snapshots","substream","2-way-audio","trigger"],cd=bi.object({path:bi.string()});function ld(e){if(!e)return;return e.trim().split(/[_\s]+/).map((e=>e[0].toUpperCase()+e.substring(1))).join(" ")}function ud(e,t,n){const i=e[t];return e.splice(t,1),e.splice(n,0,i),e}const dd=e=>e?Array.isArray(e)?e:[e]:[],hd=e=>e instanceof Set?e:new Set(dd(e));function pd(e,t,n){return!function(e,t,n){var i=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===i?_u(e,t,void 0,n):!!i}(e,t,n)}function md(e,t=console.warn){e instanceof sd&&e.context?t(e,e.context):t("object"==typeof e&&"message"in e?e.message:e)}const fd=()=>window.matchMedia("(hover: hover) and (pointer: fine)").matches,gd=(e,t)=>ja(e,"yyyy-MM-dd HH:mm"+(t?":ss":"")),_d=e=>ja(e,"yyyy-MM-dd"),vd=(e,t)=>{window.requestIdleCallback?window.requestIdleCallback(e,{...t&&{timeout:t}}):e()};function yd(e,t){const n=function(e,t,n){const i=Qi(e,t)/Ni;return Ki(n?.roundingMethod)(i)}(t,e),i=function(e,t,n){const i=Qi(e,t)/Ri;return Ki(n?.roundingMethod)(i)}(t,e)-60*n;let a="";return n&&(a+=`${n}h `),i&&(a+=`${i}m `),a+=`${Yi(t,e)-60*n*60-60*i}s`,a}const bd=async(e,t)=>await Promise.all(Array.from(e).map((e=>t(e)))),wd=e=>new Date(`${e}T00:00:00`),xd=e=>!isNaN(e.getTime()),Md=(e,t,n,i)=>{t?e.setAttribute(n,i??""):e.removeAttribute(n)},kd=(e,t,n,i)=>{t?e.style.setProperty(n,i??""):e.style.removeProperty(n)},Cd=e=>!!e,Sd=e=>e instanceof HTMLElement,Ed=e=>(e instanceof HTMLSlotElement?e.assignedElements({flatten:!0}):[...e.children]).filter(Sd),Ad=e=>e?.ratio&&2===e.ratio.length?`${e.ratio[0]} / ${e.ratio[1]}`:e?.defaultStatic?"16 / 9":"auto",Td=e=>({"aspect-ratio":Ad(e)}),$d=e=>{if(Array.isArray(e))return e.filter((e=>void 0!==e)).map((e=>$d(e)));if("object"==typeof e&&null!==e){const t={};for(const n in e)t[n]=$d(e[n]);return t}return e},Id=(e,t,n)=>Gu(e,n)===Gu(t,n),Od=e=>e.replace(/^http/i,"ws"),Ld=e=>{e.offsetHeight};function Dd(e,t){return{action:"fire-dom-event",advanced_camera_card_action:e,...t?.cardID&&{card_id:t.cardID}}}function jd(e,t){return{action:"fire-dom-event",advanced_camera_card_action:e,...t?.cardID&&{card_id:t.cardID},...t?.folderID&&{folder:t.folderID}}}function zd(e,t,n){return{action:"fire-dom-event",advanced_camera_card_action:e,camera:t,...n?.cardID&&{card_id:n.cardID}}}function Pd(e,t,n){return{action:"fire-dom-event",advanced_camera_card_action:"media_player",media_player:e,media_player_action:t,...n?.cardID&&{card_id:n.cardID}}}function Rd(e){return{action:"fire-dom-event",advanced_camera_card_action:"ptz_multi",...e?.cardID&&{card_id:e.cardID},...e?.ptzAction&&{ptz_action:e.ptzAction},...e?.ptzPhase&&{ptz_phase:e.ptzPhase},...e?.ptzPreset&&{ptz_preset:e.ptzPreset},...e?.targetID&&{target_id:e.targetID}}}function Nd(e,t){return{action:"fire-dom-event",advanced_camera_card_action:Ti,callback:e,...t?.cardID&&{card_id:t.cardID}}}function Fd(e,t,n,i){return function(e,t){return{action:"perform-action",perform_action:e,...t?.target&&{target:t.target},...t?.data&&{data:t.data},...t?.cardID&&{card_id:t.cardID}}}(`${e}.select_option`,{...i,target:{entity_id:t},data:{option:n}})}function Bd(e,t){return e&&t?"tap"===e&&t.tap_action?t.tap_action:"tap"===e&&t.entity?{action:"more-info"}:"hold"===e&&t.hold_action?t.hold_action:"double_tap"===e&&t.double_tap_action?t.double_tap_action:"end_tap"===e&&t.end_tap_action?t.end_tap_action:"start_tap"===e&&t.start_tap_action?t.start_tap_action:null:null}const Vd=e=>dd(e).some((e=>"none"!==e.action)),Hd=e=>"fire-dom-event"===e.action&&"advanced_camera_card_action"in e&&"string"==typeof e.advanced_camera_card_action,Ud=e=>{e.stopPropagation()};class qd{constructor(){this._timer=null,this._repeated=!1}stop(){this._timer&&(this._repeated?window.clearInterval(this._timer):window.clearTimeout(this._timer),this._timer=null)}isRunning(){return null!==this._timer}start(e,t){this.stop(),this._timer=window.setTimeout((()=>{this._timer=null,t()}),1e3*e),this._repeated=!1}startRepeated(e,t){this.stop(),this._timer=window.setInterval((()=>{t()}),1e3*e),this._repeated=!0}}class Wd extends HTMLElement{constructor(){super(...arguments),this.holdTime=.4,this.holdTimer=new qd,this.doubleClickTimer=new qd,this.held=!1,this.started=!1}connectedCallback(){["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach((e=>{document.addEventListener(e,(()=>{this.holdTimer.stop()}),{passive:!0})}))}bind(e,t){if(e.actionHandlerOptions)return void(e.actionHandlerOptions=t);e.actionHandlerOptions=t,e.addEventListener("contextmenu",(e=>{const t=e||window.event;return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0,t.returnValue=!1,!1}));const n=()=>{this.held=!1,this.holdTimer.start(this.holdTime,(()=>{this.held=!0})),this.started||(this.started=!0,tt(e,"action",{action:"start_tap"}))},i=t=>{this.holdTimer.stop(),this.started&&(this.started=!1,tt(e,"action",{action:"end_tap"}))},a=t=>{const n=e.actionHandlerOptions;n?.allowPropagation||Ud(t),["touchend","touchcancel"].includes(t.type)&&!this.held||(i(),n?.hasHold&&this.held?tt(e,"action",{action:"hold"}):n?.hasDoubleClick?"click"===t.type&&t.detail<2||!this.doubleClickTimer.isRunning()?this.doubleClickTimer.start(.25,(()=>tt(e,"action",{action:"tap"}))):(this.doubleClickTimer.stop(),tt(e,"action",{action:"double_tap"})):tt(e,"action",{action:"tap"}))};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",a),e.addEventListener("touchcancel",a),e.addEventListener("mousedown",n,{passive:!0}),e.addEventListener("click",a),e.addEventListener("keyup",(e=>{"Enter"===e.key&&a(e)})),e.addEventListener("mouseleave",i)}}customElements.define("action-handler-advanced-camera-card",Wd);const Zd=(e,t)=>{const n=(()=>{const e=document.body;if(e.querySelector("action-handler-advanced-camera-card"))return e.querySelector("action-handler-advanced-camera-card");const t=document.createElement("action-handler-advanced-camera-card");return e.appendChild(t),t})();n&&n.bind(e,t)},Kd=_e(class extends ve{update(e,[t]){return Zd(e.element,t),W}render(e){}});var Qd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gd={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(e,t,i,r,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,r||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],o]:e._events[c].push(o):(e._events[c]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),o.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=n?n+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,r=i.length,s=new Array(r);a<r;a++)s[a]=i[a].fn;return s},o.prototype.listenerCount=function(e){var t=n?n+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,a,r,s){var o=n?n+e:e;if(!this._events[o])return!1;var c,l,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,i),!0;case 4:return u.fn.call(u.context,t,i,a),!0;case 5:return u.fn.call(u.context,t,i,a,r),!0;case 6:return u.fn.call(u.context,t,i,a,r,s),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,i);break;case 4:u[l].fn.call(u[l].context,t,i,a);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},o.prototype.on=function(e,t,n){return r(this,e,t,n,!1)},o.prototype.once=function(e,t,n){return r(this,e,t,n,!0)},o.prototype.removeListener=function(e,t,i,a){var r=n?n+e:e;if(!this._events[r])return this;if(!t)return s(this,r),this;var o=this._events[r];if(o.fn)o.fn!==t||a&&!o.once||i&&o.context!==i||s(this,r);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||a&&!o[c].once||i&&o[c].context!==i)&&l.push(o[c]);l.length?this._events[r]=1===l.length?l[0]:l:s(this,r)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,e.exports=o}(Gd);var Xd=Yd(Gd.exports);class Jd extends Error{constructor(e){super(e),this.name="TimeoutError"}}class eh extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const th=e=>void 0===globalThis.DOMException?new eh(e):new DOMException(e),nh=e=>{const t=void 0===e.reason?th("This operation was aborted."):e.reason;return t instanceof Error?t:th(t)};class ih{#e=[];enqueue(e,t){const n={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority)return void this.#e.push(n);const i=function(e,t,n){let i=0,a=e.length;for(;a>0;){const r=Math.trunc(a/2);let s=i+r;n(e[s],t)<=0?(i=++s,a-=r+1):a=r}return i}(this.#e,n,((e,t)=>t.priority-e.priority));this.#e.splice(i,0,n)}dequeue(){const e=this.#e.shift();return e?.run}filter(e){return this.#e.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this.#e.length}}class ah extends Xd{#t;#n;#i=0;#a;#r;#s=0;#o;#c;#e;#l;#u=0;#d;#h;#p;timeout;constructor(e){if(super(),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:ih,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#t=e.carryoverConcurrencyCount,this.#n=e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,this.#a=e.intervalCap,this.#r=e.interval,this.#e=new e.queueClass,this.#l=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#p=!0===e.throwOnTimeout,this.#h=!1===e.autoStart}get#m(){return this.#n||this.#i<this.#a}get#f(){return this.#u<this.#d}#g(){this.#u--,this.#_(),this.emit("next")}#v(){this.#y(),this.#b(),this.#c=void 0}get#w(){const e=Date.now();if(void 0===this.#o){const t=this.#s-e;if(!(t<0))return void 0===this.#c&&(this.#c=setTimeout((()=>{this.#v()}),t)),!0;this.#i=this.#t?this.#u:0}return!1}#_(){if(0===this.#e.size)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),0===this.#u&&this.emit("idle"),!1;if(!this.#h){const e=!this.#w;if(this.#m&&this.#f){const t=this.#e.dequeue();return!!t&&(this.emit("active"),t(),e&&this.#b(),!0)}}return!1}#b(){this.#n||void 0!==this.#o||(this.#o=setInterval((()=>{this.#y()}),this.#r),this.#s=Date.now()+this.#r)}#y(){0===this.#i&&0===this.#u&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#i=this.#t?this.#u:0,this.#x()}#x(){for(;this.#_(););}get concurrency(){return this.#d}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#d=e,this.#x()}async#M(e){return new Promise(((t,n)=>{e.addEventListener("abort",(()=>{n(e.reason)}),{once:!0})}))}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#p,...t},new Promise(((n,i)=>{this.#e.enqueue((async()=>{this.#u++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=function(e,t){const{milliseconds:n,fallback:i,message:a,customTimers:r={setTimeout:setTimeout,clearTimeout:clearTimeout}}=t;let s;const o=new Promise(((o,c)=>{if("number"!=typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(t.signal){const{signal:e}=t;e.aborted&&c(nh(e)),e.addEventListener("abort",(()=>{c(nh(e))}))}if(n===Number.POSITIVE_INFINITY)return void e.then(o,c);const l=new Jd;s=r.setTimeout.call(void 0,(()=>{if(i)try{o(i())}catch(e){c(e)}else"function"==typeof e.cancel&&e.cancel(),!1===a?o():a instanceof Error?c(a):(l.message=a??`Promise timed out after ${n} milliseconds`,c(l))}),n),(async()=>{try{o(await e)}catch(e){c(e)}})()})),c=o.finally((()=>{c.clear()}));return c.clear=()=>{r.clearTimeout.call(void 0,s),s=void 0},c}(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#M(t.signal)]));const a=await i;n(a),this.emit("completed",a)}catch(e){if(e instanceof Jd&&!t.throwOnTimeout)return void n();i(e),this.emit("error",e)}finally{this.#g()}}),t),this.emit("add"),this.#_()}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this.#h?(this.#h=!1,this.#x(),this):this}pause(){this.#h=!0}clear(){this.#e=new this.#l}async onEmpty(){0!==this.#e.size&&await this.#k("empty")}async onSizeLessThan(e){this.#e.size<e||await this.#k("next",(()=>this.#e.size<e))}async onIdle(){0===this.#u&&0===this.#e.size||await this.#k("idle")}async#k(e,t){return new Promise((n=>{const i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)}))}get size(){return this.#e.size}sizeBy(e){return this.#e.filter(e).length}get pending(){return this.#u}get isPaused(){return this.#h}}var rh,sh;!function(e){e.Clip="clip",e.Snapshot="snapshot",e.Recording="recording"}(rh||(rh={})),function(e){e.MP4="mp4",e.HLS="hls"}(sh||(sh={}));class oh{constructor(e,t){this._mediaType=e,this._cameraID=t?.cameraID??null,this._folder=t?.folder??null}getCameraID(){return this._cameraID}getFolder(){return this._folder}getMediaType(){return this._mediaType}getVideoContentType(){return null}getID(){return null}getStartTime(){return null}getEndTime(){return null}getUsableEndTime(){return this.getEndTime()??(this.inProgress()?new Date:this.getStartTime())}inProgress(){return null}getContentID(){return null}getTitle(){return null}getThumbnail(){return null}getIcon(){return null}isFavorite(){return null}includesTime(e){const t=this.getStartTime(),n=this.getUsableEndTime();return!!t&&!!n&&e>=t&&e<=n}setFavorite(e){}getWhere(){return null}}class ch{constructor(e,t){this._folder=e,this._icon=t?.icon??null,this._id=t?.id??null,this._title=t?.title??null,this._thumbnail=t?.thumbnail??null}getFolder(){return this._folder}getID(){return this._id}getTitle(){return this._title}getThumbnail(){return this._thumbnail}getIcon(){return this._icon}isFavorite(){return null}}class lh{static isMedia(e){return e instanceof oh}static isFolder(e){return e instanceof ch}static isEvent(e){return this.isMedia(e)&&(this.isClip(e)||this.isSnapshot(e))}static isRecording(e){return this.isMedia(e)&&"recording"===e.getMediaType()}static isClip(e){return this.isMedia(e)&&"clip"===e.getMediaType()}static isSnapshot(e){return this.isMedia(e)&&"snapshot"===e.getMediaType()}static isVideo(e){return this.isMedia(e)&&(this.isClip(e)||this.isRecording(e))}}const uh=e=>{return Qu((n=e=>e.getID()??e,(t=e)&&t.length?ad(t,Au(n)):[]),[e=>!lh.isFolder(e),e=>lh.isMedia(e)?e.getStartTime()??e.getID():e.getID()],["asc","asc"]);var t,n},dh=["up","right","down","left"],hh=[...dh,"zoom_in","zoom_out"],ph=[...hh,"preset"],mh=["start","stop"],fh=Ai.extend({advanced_camera_card_action:bi.literal("ptz"),camera:bi.string().optional(),ptz_action:bi.enum(ph).optional(),ptz_phase:bi.enum(mh).optional(),ptz_preset:bi.string().optional()}),gh="https://card.camera",_h=`${gh}/#/troubleshooting`,vh=`${_h}?id=stream-does-not-load`,yh=`${gh}/#/configuration`,bh=`${yh}/folders`,wh="cameras",xh=`${wh}.#.always_error_if_entity_unavailable`,Mh=`${wh}.#.camera_entity`,kh=`${wh}.#.frigate.camera_name`,Ch=`${wh}.#.capabilities.disable`,Sh=`${wh}.#.capabilities.disable_except`,Eh=`${wh}.#.cast.method`,Ah=`${wh}.#.cast.dashboard.dashboard_path`,Th=`${wh}.#.cast.dashboard.view_path`,$h=`${wh}.#.dimensions.aspect_ratio`,Ih=`${wh}.#.dimensions.rotation`,Oh=`${wh}.#.frigate.client_id`,Lh=`${wh}.#.frigate.labels`,Dh=`${wh}.#.frigate.url`,jh=`${wh}.#.frigate.zones`,zh=`${wh}.#.go2rtc.modes`,Ph=`${wh}.#.go2rtc.stream`,Rh=`${wh}.#.go2rtc.url`,Nh=`${wh}.#.icon`,Fh=`${wh}.#.id`,Bh=`${wh}.#.image.entity`,Vh=`${wh}.#.image.entity_parameters`,Hh=`${wh}.#.image.mode`,Uh=`${wh}.#.image.refresh_seconds`,qh=`${wh}.#.image.url`,Wh=`${wh}.#.motioneye.images.directory_pattern`,Zh=`${wh}.#.motioneye.images.file_pattern`,Kh=`${wh}.#.motioneye.movies.directory_pattern`,Qh=`${wh}.#.motioneye.movies.file_pattern`,Yh=`${wh}.#.motioneye.url`,Gh=`${wh}.#.title`,Xh=`${wh}.#.webrtc_card.entity`,Jh=`${wh}.#.webrtc_card.url`,ep=`${wh}.#.live_provider`,tp=`${wh}.#.dependencies.cameras`,np=`${wh}.#.dependencies.all_cameras`,ip=`${wh}.#.dimensions.layout.fit`,ap=`${wh}.#.dimensions.layout.pan.x`,rp=`${wh}.#.dimensions.layout.pan.y`,sp=`${wh}.#.dimensions.layout.position.x`,op=`${wh}.#.dimensions.layout.position.y`,cp=`${wh}.#.dimensions.layout.view_box.top`,lp=`${wh}.#.dimensions.layout.view_box.bottom`,up=`${wh}.#.dimensions.layout.view_box.left`,dp=`${wh}.#.dimensions.layout.view_box.right`,hp=`${wh}.#.dimensions.layout.zoom`,pp=`${wh}.#.proxy.dynamic`,mp=`${wh}.#.proxy.live`,fp=`${wh}.#.proxy.media`,gp=`${wh}.#.proxy.ssl_ciphers`,_p=`${wh}.#.proxy.ssl_verification`,vp=`${wh}.#.reolink.media_resolution`,yp=`${wh}.#.reolink.url`,bp=`${wh}.#.triggers.motion`,wp=`${wh}.#.triggers.occupancy`,xp=`${wh}.#.triggers.entities`,Mp=`${wh}.#.triggers.events`,kp="cameras_global",Cp=`${kp}.live_provider`,Sp=`${kp}.triggers.occupancy`,Ep=`${kp}.image.refresh_seconds`,Ap=`${kp}.dimensions.layout`,Tp=`${kp}.ptz`,$p="elements",Ip="folders",Op=`${Ip}.#.ha.url`,Lp=`${Ip}.#.icon`,Dp=`${Ip}.#.id`,jp=`${Ip}.#.title`,zp=`${Ip}.#.type`,Pp="view",Rp=`${Pp}.camera_select`,Np=`${Pp}.default`,Fp=`${Pp}.dim`,Bp=`${Pp}.interaction_seconds`,Vp=`${Pp}.keyboard_shortcuts`,Hp=`${Pp}.keyboard_shortcuts.enabled`,Up=`${Vp}.ptz_left`,qp=`${Vp}.ptz_right`,Wp=`${Vp}.ptz_up`,Zp=`${Vp}.ptz_down`,Kp=`${Vp}.ptz_zoom_in`,Qp=`${Vp}.ptz_zoom_out`,Yp=`${Vp}.ptz_home`,Gp=`${Pp}.default_cycle_camera`,Xp=`${Pp}.default_reset`,Jp=`${Xp}.interaction_mode`,em=`${Xp}.every_seconds`,tm=`${Xp}.entities`,nm=`${Xp}.after_interaction`,im=`${Pp}.theme.themes`,am=`${Pp}.triggers`,rm=`${am}.show_trigger_status`,sm=`${am}.filter_selected_camera`,om=`${am}.untrigger_seconds`,cm=`${am}.actions`,lm=`${cm}.trigger`,um=`${cm}.untrigger`,dm=`${cm}.interaction_mode`,hm="media_gallery",pm=`${hm}.controls.filter.mode`,mm=`${hm}.controls.thumbnails.show_details`,fm=`${hm}.controls.thumbnails.show_download_control`,gm=`${hm}.controls.thumbnails.show_favorite_control`,_m=`${hm}.controls.thumbnails.show_timeline_control`,vm=`${hm}.controls.thumbnails.size`,ym="media_viewer",bm=`${ym}.auto_play`,wm=`${ym}.auto_pause`,xm=`${ym}.auto_mute`,Mm=`${ym}.auto_unmute`,km=`${ym}.display.mode`,Cm=`${ym}.display.grid_columns`,Sm=`${ym}.display.grid_max_columns`,Em=`${ym}.display.grid_selected_position`,Am=`${ym}.display.grid_selected_width_factor`,Tm=`${ym}.draggable`,$m=`${ym}.lazy_load`,Im=`${ym}.snapshot_click_plays_clip`,Om=`${ym}.transition_effect`,Lm=`${ym}.controls.builtin`,Dm=`${ym}.controls.next_previous.style`,jm=`${ym}.controls.next_previous.size`,zm=`${ym}.controls.thumbnails.mode`,Pm=`${ym}.controls.thumbnails.show_details`,Rm=`${ym}.controls.thumbnails.show_download_control`,Nm=`${ym}.controls.thumbnails.show_favorite_control`,Fm=`${ym}.controls.thumbnails.show_timeline_control`,Bm=`${ym}.controls.thumbnails.size`,Vm=`${ym}.controls.timeline.clustering_threshold`,Hm=`${ym}.controls.timeline.events_media_type`,Um=`${ym}.controls.timeline.format.24h`,qm=`${ym}.controls.timeline.mode`,Wm=`${ym}.controls.timeline.pan_mode`,Zm=`${ym}.controls.timeline.show_recordings`,Km=`${ym}.controls.timeline.style`,Qm=`${ym}.controls.timeline.window_seconds`,Ym=`${ym}.controls.wheel`,Gm=`${ym}.zoomable`,Xm="live",Jm=`${Xm}.auto_play`,ef=`${Xm}.auto_pause`,tf=`${Xm}.auto_mute`,nf=`${Xm}.auto_unmute`,af=`${Xm}.controls.builtin`,rf=`${Xm}.controls.next_previous.style`,sf=`${Xm}.controls.next_previous.size`,of=`${Xm}.controls.ptz.hide_home`,cf=`${Xm}.controls.ptz.hide_pan_tilt`,lf=`${Xm}.controls.ptz.hide_zoom`,uf=`${Xm}.controls.ptz.mode`,df=`${Xm}.controls.ptz.orientation`,hf=`${Xm}.controls.ptz.position`,pf=`${Xm}.controls.wheel`,mf=`${Xm}.controls.thumbnails.media_type`,ff=`${Xm}.controls.thumbnails.events_media_type`,gf=`${Xm}.controls.thumbnails.mode`,_f=`${Xm}.controls.thumbnails.size`,vf=`${Xm}.controls.thumbnails.show_details`,yf=`${Xm}.controls.thumbnails.show_download_control`,bf=`${Xm}.controls.thumbnails.show_favorite_control`,wf=`${Xm}.controls.thumbnails.show_timeline_control`,xf=`${Xm}.controls.timeline.clustering_threshold`,Mf=`${Xm}.controls.timeline.events_media_type`,kf=`${Xm}.controls.timeline.format.24h`,Cf=`${Xm}.controls.timeline.mode`,Sf=`${Xm}.controls.timeline.pan_mode`,Ef=`${Xm}.controls.timeline.show_recordings`,Af=`${Xm}.controls.timeline.style`,Tf=`${Xm}.controls.timeline.window_seconds`,$f=`${Xm}.display.mode`,If=`${Xm}.display.grid_columns`,Of=`${Xm}.display.grid_max_columns`,Lf=`${Xm}.display.grid_selected_position`,Df=`${Xm}.display.grid_selected_width_factor`,jf=`${Xm}.draggable`,zf=`${Xm}.lazy_load`,Pf=`${Xm}.lazy_unload`,Rf=`${Xm}.preload`,Nf=`${Xm}.transition_effect`,Ff=`${Xm}.show_image_during_load`,Bf=`${Xm}.microphone.disconnect_seconds`,Vf=`${Xm}.microphone.mute_after_microphone_mute_seconds`,Hf=`${Xm}.microphone.always_connected`,Uf=`${Xm}.zoomable`,qf="image",Wf=`${qf}.entity`,Zf=`${qf}.entity_parameters`,Kf=`${qf}.mode`,Qf=`${qf}.refresh_seconds`,Yf=`${qf}.url`,Gf="timeline",Xf=`${Gf}.window_seconds`,Jf=`${Gf}.clustering_threshold`,eg=`${Gf}.events_media_type`,tg=`${Gf}.format.24h`,ng=`${Gf}.show_recordings`,ig=`${Gf}.style`,ag=`${Gf}.controls.thumbnails.mode`,rg=`${Gf}.controls.thumbnails.size`,sg=`${Gf}.controls.thumbnails.show_details`,og=`${Gf}.controls.thumbnails.show_download_control`,cg=`${Gf}.controls.thumbnails.show_favorite_control`,lg=`${Gf}.controls.thumbnails.show_timeline_control`,ug="menu",dg=`${ug}.alignment`,hg=`${ug}.position`,pg=`${ug}.style`,mg=`${ug}.button_size`,fg=`${ug}.buttons`,gg=`${fg}.fullscreen`,_g=`${fg}.iris`,vg=`${fg}.play`,yg=`${fg}.mute`,bg=`${fg}.media_player`,wg=`${fg}.timeline`,xg="status_bar",Mg=`${xg}.position`,kg=`${xg}.style`,Cg=`${xg}.popup_seconds`,Sg=`${xg}.height`,Eg=`${xg}.items`,Ag="dimensions",Tg=`${Ag}.aspect_ratio`,$g=`${Ag}.aspect_ratio_mode`,Ig=`${Ag}.height`,Og="overrides",Lg="performance",Dg=`${Lg}.features.animated_progress_indicator`,jg=`${Lg}.features.card_loading_effects`,zg=`${Lg}.features.card_loading_indicator`,Pg=`${Lg}.features.media_chunk_size`,Rg=`${Lg}.features.max_simultaneous_engine_requests`,Ng=`${Lg}.profile`,Fg=`${Lg}.style.box_shadow`,Bg=`${Lg}.style.border_radius`,Vg="profiles",Hg="remote_control.entities.camera",Ug=1e3,qg="__IMAGE_VIEW_ZOOM__";var Wg={abort:"Aborted action",confirmation:"Are you sure you want to perform this action"},Zg={advanced_camera_card:"Advanced Camera Card",advanced_camera_card_description:"An Advanced Camera Card",folder:"Folder",live:"Live",no_folder:"No folder to display",no_media:"No media to display",recordings:"Recordings",version:"Version"},Kg={cameras:{always_error_if_entity_unavailable:"Always treat entity unavailability as error",camera_entity:"Camera Entity",capabilities:{capabilities:{clips:"Clips","favorite-events":"Favorite Events","favorite-recordings":"Favorite Recordings",live:"Live",menu:"Menu",ptz:"PTZ",recordings:"Recordings",seek:"Seeking",snapshots:"Snapshots",substream:"Substream"},disable:"Disable",disable_except:"Disable except",editor_label:"Camera capabilities"},cast:{dashboard:{dashboard_path:"Dashboard path",view_path:"View path"},editor_label:"Cast options",method:"Cast method",methods:{dashboard:"Dashboard",standard:"Standard"}},dependencies:{all_cameras:"Show events for all cameras with this camera",cameras:"Show events for specific cameras with this camera",editor_label:"Dependency options"},dimensions:{aspect_ratio:"Static aspect ratio",editor_label:"Camera dimensions",layout:{editor_label:"Camera Layout",fit:"Layout fit",fits:{contain:"Media is contained/letterboxed",cover:"Media expands proportionally to cover the card",fill:"Media is stretched to fill the card"},pan:{x:"Pan horizontal percentage",y:"Pan vertical percentage"},position:{editor_label:"Layout Cover Position",x:"Horizontal placement percentage",y:"Vertical placement percentage"},view_box:{bottom:"Bottom inset percentage",editor_label:"Layout View Box",left:"Left inset percentage",right:"Right inset percentage",top:"Top inset percentage"},zoom:"Zoom factor"},rotation:"Rotation",rotations:{0:"No rotation",90:"90 degrees clockwise",180:"180 degrees clockwise",270:"270 degrees clockwise"}},engines:{editor_label:"Camera engine options"},frigate:{camera_name:"Frigate camera name (Autodetected from entity)",client_id:"Frigate client id (For >1 Frigate server)",editor_label:"Frigate options",labels:"Frigate labels/object filters",url:"Frigate server URL",zones:"Frigate zones"},go2rtc:{editor_label:"go2rtc Options",modes:{editor_label:"go2rtc Modes",mjpeg:"Motion JPEG (MJPEG)",mp4:"MPEG-4 (MP4)",mse:"Media Source Extensions (MSE)",webrtc:"Web Real-Time Communication (WebRTC)"},stream:"go2rtc stream name",url:"go2rtc URL"},icon:"Icon for this camera (Autodetected from entity)",id:"Unique ID for this camera in this card",image:{editor_label:"Image Options",refresh_seconds:"Number of seconds after which to refresh live image (0=never)",url:"Image URL to use instead of camera entity snapshot"},live_provider:"Live view provider for this camera",live_provider_options:{editor_label:"Live provider options"},live_providers:{auto:"Automatic",go2rtc:"go2rtc",ha:"Home Assistant video stream (i.e. HLS, LL-HLS, WebRTC via HA)",image:"Image",jsmpeg:"JSMpeg","webrtc-card":"WebRTC Card (i.e. AlexxIT's WebRTC Card)"},motioneye:{editor_label:"MotionEye options",images:{directory_pattern:"Images directory pattern",file_pattern:"Images file pattern"},movies:{directory_pattern:"Movies directory pattern",file_pattern:"Movies file pattern"},url:"MotionEye UI URL"},proxy:{dynamic:"Dynamic proxying",editor_label:"Camera proxying",live:"Live proxying",media:"Media proxying",modes:{auto:"Proxying automatically configured",false:"Proxying disabled",true:"Proxying enabled"},ssl_ciphers:{auto:"SSL ciphers automatically configured",default:"Default SSL ciphers",editor_label:"SSL ciphers",insecure:"Insecure SSL ciphers",intermediate:"Intermediate SSL ciphers",modern:"Modern SSL ciphers"},ssl_verification:{auto:"SSL verification automatically configured",editor_label:"SSL verification",false:"SSL verification disabled",true:"SSL verification enabled"}},reolink:{editor_label:"Reolink options",media_resolution:{editor_label:"Media Resolution",high:"High Resolution",low:"Low Resolution"},url:"Reolink UI URL"},title:"Title for this camera (Autodetected from entity)",triggers:{editor_label:"Trigger options",entities:"Trigger from other entities",events:{clips:"Events with new clips",editor_label:"Trigger Events",events:"All events",snapshots:"Events with new snapshots"},motion:"Trigger by auto-detecting the motion sensor",occupancy:"Trigger by auto-detecting the occupancy sensor"},webrtc_card:{editor_label:"WebRTC Card Options",entity:"WebRTC Card Camera Entity",url:"WebRTC Card Camera URL"}},common:{controls:{builtin:"Built-in video controls",filter:{editor_label:"Media Filter",mode:"Filter mode",modes:{left:"Media filter in a drawer to the left",none:"No media filter",right:"Media filter in a drawer to the right"}},next_previous:{editor_label:"Next & Previous",size:"Next & previous control size in pixels",style:"Next & previous control style",styles:{chevrons:"Chevrons",icons:"Icons",none:"None",thumbnails:"Thumbnails"}},thumbnails:{editor_label:"Thumbnails",events_media_type:"Whether to show event thumbnails of clips or snapshots",events_media_types:{clips:"Clip thumbnails",snapshots:"Snapshot thumbnails"},media_type:"Whether to show thumnails of events or recordings",media_types:{events:"Events",recordings:"Recordings"},mode:"Thumbnails mode",modes:{above:"Thumbnails above",below:"Thumbnails below",left:"Thumbnails in a drawer to the left",none:"No thumbnails",right:"Thumbnails in a drawer to the right"},show_details:"Show details with thumbnails",show_download_control:"Show download control on thumbnails",show_favorite_control:"Show favorite control on thumbnails",show_timeline_control:"Show timeline control on thumbnails",size:"Thumbnails size in pixels"},timeline:{editor_label:"Mini Timeline",format:{"24h":"Use 24-hour clock",editor_label:"Time & date format"},mode:"Mode",modes:{above:"Above",below:"Below",none:"None"},pan_mode:"Default pan mode",pan_modes:{pan:"Pan",seek:"Pan seeks across all media","seek-in-camera":"Pan seeks within selected camera only","seek-in-media":"Pan seeks within selected media item only"}},wheel:"Scroll wheel scrolls media carousel"},display:{editor_label:"Display",grid_columns:"Exact number of grid columns",grid_max_columns:"Maximum number of grid columns",grid_selected_position:"Position of selected media in grid",grid_selected_positions:{default:"Selected item in default position",first:"Selected item is first in grid",last:"Selected item is last in grid"},grid_selected_width_factor:"Increase selected media width by this factor",mode:"Mode"},image:{entity:"Entity for use with entity mode",entity_parameters:"Query parameters added to the entity-based picture URLs (e.g. width=1920&height=1080)",mode:"Image mode",modes:{camera:"Home Assistant camera snapshot of camera entity",entity:"Entity with entity_picture attribute",screensaver:"Embedded screensaver image",url:"Arbitrary image specified by URL"},refresh_seconds:"Number of seconds after which to refresh (0=never)",url:"Static image URL"},media_action_conditions:{all:"All opportunities",hidden:"On browser/tab hiding",microphone_mute:"On microphone mute",microphone_unmute:"On microphone unmute",never:"Never",selected:"On selection",unselected:"On unselection",visible:"On browser/tab visibility"},timeline:{clustering_threshold:"The count of events at which they are clustered (0=no clustering)",events_media_type:"The events media the timeline displays",events_media_types:{all:"All event media types",clips:"Clips",snapshots:"Snapshots"},show_recordings:"Show recordings",style:"Timeline style",styles:{ribbon:"Events on a single ribbon",stack:"Stacked & clustered events"},window_seconds:"The default length of the timeline view in seconds"}},dimensions:{aspect_ratio:"Default aspect ratio (e.g. '16:9')",aspect_ratio_mode:"Aspect ratio mode",aspect_ratio_modes:{dynamic:"Aspect ratio adjusts to media",static:"Static aspect ratio",unconstrained:"Unconstrained aspect ratio"},height:"Card height in CSS units (e.g. '500px')"},folders:{ha:{editor_label:"Home Assistant Media Folder Options",path_info:"Additional path matching functionality is available in the text editor",url:"URL of media folder"},icon:"Icon for this folder",id:"Unique ID for this folder in this card",title:"Title for this folder",type:"Folder type",types:{ha:"Home Assistant Media Folder"}},live:{auto_mute:"Automatically mute live cameras",auto_pause:"Automatically pause live cameras",auto_play:"Automatically play live cameras",auto_unmute:"Automatically unmute live cameras",controls:{editor_label:"Live Controls",ptz:{editor_label:"PTZ",hide_home:"Hide home & preset controls",hide_pan_tilt:"Hide pan & tilt control",hide_zoom:"Hide zoom control",mode:"Mode",modes:{off:"Off",on:"On"},orientation:"Orientation",orientations:{horizontal:"Horizontal",vertical:"Vertical"},position:"Position",positions:{"bottom-left":"Bottom left","bottom-right":"Bottom right","top-left":"Top left","top-right":"Top right"}}},draggable:"Live cameras view can be dragged/swiped",lazy_load:"Live cameras are lazily loaded",lazy_unload:"Live cameras are lazily unloaded",microphone:{always_connected:"Always keep the microphone connected",disconnect_seconds:"Seconds after which to disconnect microphone (0=never)",editor_label:"Microphone",enabled:"Microphone enabled",mute_after_microphone_mute_seconds:"Seconds after microphone mute to mute inbound audio"},preload:"Preload live view in the background",show_image_during_load:"Show still image while the live stream is loading",transition_effect:"Live camera transition effect",zoomable:"Live cameras can be zoomed/panned"},media_viewer:{auto_mute:"Automatically mute media",auto_pause:"Automatically pause media",auto_play:"Automatically play media",auto_unmute:"Automatically unmute media",controls:{editor_label:"Media Viewer Controls"},draggable:"Media Viewer can be dragged/swiped",lazy_load:"Media Viewer media is lazily loaded in carousel",snapshot_click_plays_clip:"Clicking on a snapshot plays a related clip",transition_effect:"Media Viewer transition effect",transition_effects:{none:"No transition",slide:"Slide transition"},zoomable:"Media Viewer can be zoomed/panned"},menu:{alignment:"Menu alignment",alignments:{bottom:"Aligned to the bottom",left:"Aligned to the left",right:"Aligned to the right",top:"Aligned to the top"},button_size:"Menu button size in pixels",buttons:{alignment:"Button alignment",alignments:{matching:"Matching the menu alignment",opposing:"Opposing the menu alignment"},camera_ui:"Camera user interface",cameras:"Cameras",clips:"Clips",display_mode:"Display mode",download:"Download",enabled:"Button enabled",expand:"Expand",folders:"Folders",fullscreen:"Fullscreen",icon:"Icon",image:"Image",iris:"Iris / Default View / Unhide menu",live:"Live",media_player:"Send to media player",microphone:"Microphone",mute:"Mute / Unmute",permanent:"Show when the menu is hidden",play:"Play / Pause",priority:"Priority",ptz_controls:"Show PTZ controls",ptz_home:"PTZ Home",recordings:"Recordings",screenshot:"Screenshot",snapshots:"Snapshots",substreams:"Substream(s)",timeline:"Timeline",type:"Button type",types:{momentary:"Momentary",toggle:"Toggle"}},position:"Menu position",positions:{bottom:"Positioned on the bottom",left:"Positioned on the left",right:"Positioned on the right",top:"Positioned on the top"},style:"Menu style",styles:{hidden:"Hidden menu",hover:"Hover menu","hover-card":"Hover menu (card-wide)",none:"No menu",outside:"Outside menu",overlay:"Overlay menu"}},overrides:{info:"This card configuration has manually specified overrides configured which may override values shown in the visual editor, please consult the code editor to view/modify these overrides"},performance:{features:{animated_progress_indicator:"Animated Progress Indicator",card_loading_effects:"Card Loading Effects",card_loading_indicator:"Card Loading Indicator",editor_label:"Feature Options",max_simultaneous_engine_requests:"Max simultaneous camera engine requests",media_chunk_size:"Media chunk size"},style:{border_radius:"Curves",box_shadow:"Shadows",editor_label:"Style Options"},warning:"This card is in low profile mode so defaults have changed to optimize performance"},profiles:{casting:"Casting",editor_label:"Configuration profiles","low-performance":"Low performance",scrubbing:"Video scrubbing"},remote_control:{entities:{camera:"Input Select entity to control camera",editor_label:"Remote Control Entities"}},status_bar:{height:"Status bar height in pixels",items:{enabled:"Item enabled",engine:"Camera engine",live_provider:"Live provider",priority:"Item priority",resolution:"Resolution",technology:"Technology",title:"Title"},popup_seconds:"Status bar popup seconds",position:"Status bar position",positions:{bottom:"Positioned on the bottom",top:"Positioned on the top"},style:"Status bar style",styles:{hover:"Hover status bar","hover-card":"Hover status bar (card-wide)",none:"No status bar",outside:"Outside status bar",overlay:"Overlay status bar",popup:"Popup status bar"}},view:{camera_select:"View for newly selected cameras",default:"Default view",default_cycle_camera:"Cycle through cameras when default view updates",default_reset:{after_interaction:"Reset to the default view after user interaction ends",editor_label:"Default view reset behavior",entities:"Reset to the default view on entity state change",every_seconds:"Reset to default view every X seconds (0=never)",interaction_mode:"How default reset behaves when the card has human interaction",interaction_modes:{active:"Only allow reset when card has active human interaction",all:"Reset regardless of human interaction",inactive:"Only reset when card has no human interaction"}},dim:"Dim when no interaction",interaction_seconds:"Seconds after user action to remain interacted with (0=never)",keyboard_shortcuts:{editor_label:"Keyboard shortcuts",enabled:"Keyboard shortcuts enabled",ptz_down:"PTZ Down",ptz_home:"PTZ Home",ptz_left:"PTZ Left",ptz_right:"PTZ Right",ptz_up:"PTZ Up",ptz_zoom_in:"PTZ Zoom In",ptz_zoom_out:"PTZ Zoom Out"},theme:{themes:{dark:"Dark",editor_label:"Themes",ha:"Home Assistant",light:"Light",traditional:"Traditional"}},triggers:{actions:{editor_label:"Trigger actions",interaction_mode:"How to handle actions when the card has human interaction",interaction_modes:{active:"Only trigger actions when card has human interaction",all:"Trigger actions regardless of human interaction",inactive:"Only trigger actions when card has no human interaction"},trigger:"Trigger action",triggers:{default:"Change to or update default view",live:"Change to or update live view",media:"Change to the relevant media view for new media",none:"No action"},untrigger:"Untrigger action",untriggers:{default:"Change to default view/camera",none:"No action"}},editor_label:"Trigger behavior",filter_selected_camera:"Only trigger on selected camera",show_trigger_status:"Show pulsing border when triggered",untrigger_seconds:"Seconds after inactive state change to untrigger"},views:{clip:"Most recent clip",clips:"Clips gallery",current:"Current view",folder:"Folder media",folders:"Folders gallery",image:"Static image",live:"Live view",recording:"Most recent recording",recordings:"Recordings gallery",snapshot:"Most recent snapshot",snapshots:"Snapshots gallery",timeline:"Timeline view"}}},Qg={grid:"Show media viewer for each camera in a grid",single:"Show single media viewer"},Yg={add_new_camera:"Add new camera",add_new_folder:"Add new folder",button:"Button",camera:"Camera",cameras:"Cameras",cameras_secondary:"What cameras to render on this card",delete:"Delete",dimensions:"Card dimensions",dimensions_secondary:"Card dimensions & shape options",folders:"Folders",folders_secondary:"What folders to render on this card",image:"Image",image_secondary:"Static image view options",live:"Live",live_secondary:"Live camera view options",media_gallery:"Media gallery",media_gallery_secondary:"Media gallery options",media_viewer:"Media viewer",media_viewer_secondary:"Viewer for static media (clips, snapshots or recordings)",menu:"Menu",menu_secondary:"Menu look & feel options",move_down:"Move down",move_up:"Move up",overrides:"Overrides are active",overrides_secondary:"Dynamic configuration overrides detected",performance:"Performance",performance_secondary:"Card performance options",profiles:"Configuration profiles",profiles_secondary:"Choose pre-configured sets of defaults",remote_control:"Remote Control",remote_control_secondary:"Options for remote controlling the card",status_bar:"Status bar",status_bar_secondary:"Status bar look & feel options",timeline:"Timeline",timeline_secondary:"Event timeline options",upgrade:"Upgrade",upgrade_available:"An automatic card configuration upgrade is available",view:"View",view_secondary:"What the card should show and how to show it"},Gg={ptz:{down:"Down",home:"Home",left:"Left",presets:"Presets",right:"Right",up:"Up",zoom_in:"Zoom In",zoom_out:"Zoom Out"}},Xg={awaiting_folder:"Waiting for folder to load",awaiting_live:"Waiting for live stream to load ...",awaiting_media:"Waiting for media to load",camera_initialization:"Camera initialization failed",camera_initialization_reolink:"Could not initialize Reolink camera",configuration:"Check configuration",could_not_render_elements:"Could not render picture elements",could_not_resolve:"Could not resolve media URL",diagnostics:"Card diagnostics. Please review for confidential information prior to sharing",download_no_media:"No media to download",download_sign_failed:"Could not sign media URL for download",duplicate_camera_id:"Duplicate camera id for the following camera, use the 'id' parameter to uniquely identify cameras",duplicate_folder_id:"Duplicate folder id for the following folder, use the 'id' parameter to uniquely identify folders",empty_response:"Received empty response from Home Assistant for request",failed_fetch:"Could not fetch URL",failed_proxy:"Could not proxy via Home Assistant",failed_response:"Failed to receive response from Home Assistant for request",failed_retain:"Could not retain event",failed_sign:"Could not sign Home Assistant URL",fetching_diagnostics:"Fetching diagnostics",image_load_error:"The image could not be loaded",invalid_configuration:"Invalid configuration",invalid_configuration_no_hint:"No location hint available (bad or missing type?)",invalid_configuration_override:"Invalid override configuration",invalid_elements_config:"Invalid picture elements configuration",invalid_response:"Received invalid response from Home Assistant for request",jsmpeg_no_player:"Could not start JSMPEG player",live_camera_no_endpoint:"Could not get camera endpoint for this live provider (incomplete configuration?)",live_camera_not_found:"The configured camera_entity was not found",live_camera_unavailable:"Camera unavailable",no_camera_engine:"Could not determine suitable engine for camera",no_camera_entity:"Could not find camera entity",no_camera_entity_for_triggers:"A camera entity is required in order to autodetect triggers",no_camera_id:"Could not determine camera id for the following camera, may need to set 'id' parameter manually",no_camera_or_media_for_timeline:"No camera or media available for timeline",no_dashboard_or_view:"Both 'dashboard_path' and 'view_path' parameters are required for the 'dashboard' cast method",no_live_camera:"The camera_entity parameter must be set and valid for this live provider",no_supported_camera:"The selected camera or media does not support this view",no_supported_cameras:"No cameras support this view",reconnecting:"Reconnecting",stream_not_loading:"The video stream has not yet loaded. This is could for any number of reasons. If configured (and by default), there will be an image refreshing every second until the stream loads correctly",too_many_automations:"Too many nested automation calls, please check your configuration for loops",troubleshooting:"Check troubleshooting",unknown:"Unknown error",upgrade_available:"An automated card configuration upgrade is available, please visit the visual card editor",webrtc_card_reported_error:"WebRTC Card reported an error",webrtc_card_waiting:"Waiting for WebRTC Card to load ..."},Jg={assign:"Assign",modifiers:{alt:"Alt",ctrl:"Ctrl",meta:"Meta",shift:"Shift"},unassign:"Unassign"},e_={all:"All",camera:"Camera",favorite:"Favorite",media_type:"Media Type",media_types:{clips:"Clips",recordings:"Recordings",snapshots:"Snapshots"},not_favorite:"Not Favorite",select_camera:"Select camera...",select_favorite:"Select favorite...",select_media_type:"Select media type...",select_tag:"Select tag...",select_what:"Select what...",select_when:"Select when...",select_where:"Select where...",tag:"Tag",what:"What",when:"When",whens:{custom:"Custom",past_month:"Past Month",past_week:"Past Week",today:"Today",yesterday:"Yesterday"},where:"Where"},t_={unseekable:"Seek time not found in media"},n_={camera:"Camera",download:"Download media",duration:"Duration",events:"Events",in_progress:"In Progress",no_thumbnail:"No thumbnail available",retain_indefinitely:"Media will be indefinitely retained",score:"Score",seek:"Seek",start:"Start",tag:"Tag",timeline:"See media in timeline",title:"Title",what:"What",where:"Where"},i_={select_date:"Choose date"},a_={actions:Wg,common:Zg,config:Kg,display_modes:Qg,editor:Yg,elements:Gg,error:Xg,key_assigner:Jg,media_filter:e_,media_viewer:t_,thumbnail:n_,timeline:i_},r_=Object.freeze({__proto__:null,actions:Wg,common:Zg,config:Kg,default:a_,display_modes:Qg,editor:Yg,elements:Gg,error:Xg,key_assigner:Jg,media_filter:e_,media_viewer:t_,thumbnail:n_,timeline:i_});const s_="en",o_={[s_]:r_};let c_;function l_(e){const t=e=>e.replace("-","_"),n=e?.language??e?.selectedLanguage;if(n)return t(n);const i=localStorage.getItem("selectedLanguage");if(i){const e=JSON.parse(i);if(e)return t(e)}for(const e of navigator.languages){const n=t(e);if(n&&n in o_)return n}return s_}function u_(e,t="",n=""){let i="";try{i=e.split(".").reduce(((e,t)=>e[t]),o_[c_??s_])}catch(e){}return i||(i=e.split(".").reduce(((e,t)=>e[t]),o_[s_])),""!==t&&""!==n&&(i=i.replace(t,n)),i}function d_(e){return"string"==typeof e?.id&&e.id||"string"==typeof e?.camera_entity&&e.camera_entity||"object"==typeof e?.webrtc_card&&e.webrtc_card&&("string"==typeof e.webrtc_card.entity&&e.webrtc_card.entity||"string"==typeof e.webrtc_card.url&&e.webrtc_card.url)||"object"==typeof e?.go2rtc&&e.go2rtc&&"string"==typeof e.go2rtc.url&&"string"==typeof e.go2rtc.stream&&`${e.go2rtc.url}#${e.go2rtc.stream}`||"object"==typeof e?.frigate&&e.frigate&&"string"==typeof e?.frigate.camera_name&&e.frigate.camera_name||""}const h_=(e,...t)=>{e?.debug?.logging&&console.debug(...t)};class p_{constructor(e,t){this._capabilities=e;for(const e of t?.disable??[])this._disable(e);for(const e of od)t?.disableExcept?.length&&!t.disableExcept.includes(e)&&this._disable(e)}_disable(e){delete this._capabilities[e]}matches(e){let t=!0;return"string"==typeof e&&(t&&=this.has(e)),"object"==typeof e&&e.allCapabilities&&(t&&=e.allCapabilities.every((e=>this.has(e)))),"object"==typeof e&&e.anyCapabilities&&(t&&=e.anyCapabilities.some((e=>this.has(e)))),t}has(e){return!!this._capabilities[e]}getPTZCapabilities(){return this._capabilities.ptz??null}hasPTZCapability(){return!!(this._capabilities.ptz?.down?.length||this._capabilities.ptz?.up?.length||this._capabilities.ptz?.left?.length||this._capabilities.ptz?.right?.length||this._capabilities.ptz?.zoomIn?.length||this._capabilities.ptz?.zoomOut?.length||this._capabilities.ptz?.presets?.length)}getRawCapabilities(){return this._capabilities}}async function m_(e,t,n,i=!1){let a;try{a=await e.callWS(n)}catch(e){throw new sd(u_("error.failed_response"),{request:n,response:e})}if(!a)throw new sd(u_("error.empty_response"),{request:n});try{return t.parse(i?JSON.parse(a):a)}catch(e){throw new sd(u_("error.invalid_response"),{request:n,response:a,error:e})}}class f_{constructor(e){this._cache=e}has(e){return this._cache.has(e)}entries(){return this._cache.entries()}delete(e){return this._cache.delete(e)}clear(){this._cache.clear()}get(e){return this._cache.get(e)??null}getMatches(e){return[...this._cache.values()].filter(e)}set(e,t){this._cache.set(e,t)}}class g_{constructor(){this._data=[]}get[Symbol.toStringTag](){return"EqualityMap"}has(e){return!!this.get(e)}get(e){for(const t of this._data)if(Uu(t.key,e))return t.value}set(e,t){return this.delete(e),this._data.push({key:e,value:t}),this}delete(e){for(let t=0;t<this._data.length;t++)if(Uu(this._data[t].key,e))return this._data.splice(t,1),!0;return!1}clear(){this._data=[]}*entries(){for(const e of this._data)yield[e.key,e.value]}forEach(e,t){for(const n of this._data)e.call(t,n.value,n.key,this)}get size(){return this._data.length}[Symbol.iterator](){return this.entries()}keys(){return this._data.map((e=>e.key)).values()}values(){return this._data.map((e=>e.value)).values()}}class __ extends f_{constructor(){super(new g_)}}class v_{constructor(){this._data=new __}get(e){const t=this._data.get(e),n=new Date;return t&&(!t.expires||n<=t.expires)?t.value:null}has(e){return!!this.get(e)}set(e,t,n){this._data.set(e,{value:t,expires:n}),this._expireOldValues()}delete(e){return this._data.delete(e)}clear(){this._data.clear()}*entries(){const e=new Date;for(const[t,n]of this._data.entries())(!n.expires||e<=n.expires)&&(yield[t,n.value])}getMatches(e){const t=[];for(const[n,i]of this.entries())e(i)&&t.push(i);return t}_expireOldValues(){const e=new Date;for(const[t,n]of this._data.entries())n.expires&&e>n.expires&&this._data.delete(t)}}const y_=bi.lazy((()=>bi.object({title:bi.string(),media_class:bi.string(),media_content_type:bi.string(),media_content_id:bi.string(),can_play:bi.boolean(),can_expand:bi.boolean(),children_media_class:bi.string().nullable().optional(),thumbnail:bi.string().nullable(),children:bi.array(y_).nullable().optional()})));class b_ extends v_{}const w_="video",x_="image",M_=60;class k_{async walk(e,t,n){return t&&t.length?(await bd(t,(async t=>await this._walkBrowseMedia(e,t,n)))).flat():[]}async _walkBrowseMedia(e,t,n){let i=[];for(const a of function(e,t,n){t=(n?so(e,t,n):void 0===t)?1:wc(ps(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var a=0,r=0,s=Array(bc(i/t));a<i;)s[r++]=_c(e,a,a+=t);return s}(t.targets,t.concurrency??1/0)){const r=await bd(a,(async i=>await this._browseMedia(e,i,{cache:n?.cache,metadataGenerator:t.metadataGenerator})));for(const e of r)for(const n of e.children??[])t.matcher&&!t.matcher(n)||i.push(n);if(t.sorter&&(i=t.sorter(i)),t.earlyExit&&t.earlyExit(i))break}const a=t.advance?t.advance(i):null;return a?.length?await this.walk(e,a,n):i}async _browseMedia(e,t,n){const i="object"==typeof t?t.media_content_id:t,a=n?.cache?n.cache.get(i):null;if(a)return a;const r={type:"media_source/browse_media",media_content_id:i},s=await m_(e,y_,r);if(n?.metadataGenerator)for(const e of s.children??[])e._metadata=n.metadataGenerator(e,"object"==typeof t?t:void 0)??void 0;return n?.cache&&n.cache.set(i,s,ji(new Date,{seconds:60})),s}}class C_{constructor(e){this._ranges=e??[]}hasCoverage(e){return this._ranges.some((t=>E_(t,e)))}add(e){this._ranges.push(e),this._ranges=T_(this._ranges)}clear(){this._ranges=[]}}class S_{constructor(e){this._ranges=e??[]}hasCoverage(e){const t=new Date;return this._ranges.some((n=>t<n.expires&&E_(n,e)))}add(e){this._ranges.push(e),this._expireOldRanges()}_expireOldRanges(){const e=new Date;this._ranges=this._ranges.filter((t=>e<t.expires))}clear(){this._ranges=[]}}const E_=(e,t)=>t.start>=e.start&&t.end<=e.end,A_=(e,t)=>e.start>=t.start&&e.start<=t.end||e.end>=t.start&&e.end<=t.end||e.start<=t.start&&e.end>=t.end,T_=(e,t=0)=>{const n=[];e=Qu(e,(e=>e.start),"asc");let i=null;for(const a of e){const e=a.start instanceof Date?a.start.getTime():a.start;if(!i){i={...a};continue}(i.end instanceof Date?i.end.getTime():i.end)+1e3*t>=e?a.end>i.end&&(i.end=a.end):(n.push(i),i={...a})}return i&&n.push(i),n};class $_{constructor(e,t){this._ranges=new C_,this._data=[],this._timeFunc=e,this._idFunc=t}add(e,t){this._ranges.add(e),this._data=Ju(Qu(this._data.concat(t),this._timeFunc,"asc"),this._idFunc)}hasCoverage(e){return this._ranges.hasCoverage(e)}get(e){if(!this.hasCoverage(e))return null;const t=[];for(const n of this._data){const i=this._timeFunc(n);if(i>=e.start.getTime()){if(i>e.end.getTime())break;t.push(n)}}return t}getSize(){return this._data.length}expireMatches(e){this._data=this._data.filter((t=>!e(t)))}}class I_{constructor(){this._segments=new Map}add(e,t,n){let i=this._segments.get(e);i||(i=new $_((e=>1e3*e.start_time),(e=>e.id)),this._segments.set(e,i)),i.add(t,n)}clear(){this._segments.clear()}hasCoverage(e,t){return!!this._segments.get(e)?.hasCoverage(t)}get(e,t){return this._segments.get(e)?.get(t)??null}getSize(e){return this._segments.get(e)?.getSize()??null}getCameraIDs(){return[...this._segments.keys()]}expireMatches(e,t){this._segments.get(e)?.expireMatches(t)}}class O_ extends sd{}class L_ extends sd{}var D_,j_,z_;!function(e){e.Event="event-query",e.Recording="recording-query",e.RecordingSegments="recording-segments-query",e.MediaMetadata="media-metadata"}(D_||(D_={})),function(e){e.Event="event-results",e.Recording="recording-results",e.RecordingSegments="recording-segments-results",e.MediaMetadata="media-metadata-results"}(j_||(j_={})),function(e){e.Frigate="frigate",e.Generic="generic",e.MotionEye="motioneye",e.Reolink="reolink",e.TPLink="tplink"}(z_||(z_={}));class P_ extends v_{}const R_=e=>e?.camera_entity??e?.webrtc_card?.entity??null;class N_{constructor(e,t){this._entityRegistryManager=e,this._deviceRegistryManager=t}async createEngine(e,t){let n;switch(e){case z_.Generic:const{GenericCameraManagerEngine:e}=await import("./engine-generic-75ad9390.js").then((function(e){return e.e}));n=new e(t.stateWatcher,t.eventCallback);break;case z_.Frigate:const{FrigateCameraManagerEngine:i}=await import("./engine-frigate-c3dcf0c3.js");n=new i(this._entityRegistryManager,t.stateWatcher,new I_,new P_,t.eventCallback);break;case z_.MotionEye:const{MotionEyeCameraManagerEngine:a}=await import("./engine-motioneye-b430ad70.js");n=new a(this._entityRegistryManager,t.stateWatcher,new k_,t.resolvedMediaCache,new P_,t.eventCallback);break;case z_.Reolink:const{ReolinkCameraManagerEngine:r}=await import("./engine-reolink-1424605a.js");n=new r(this._entityRegistryManager,this._deviceRegistryManager,t.stateWatcher,new k_,t.resolvedMediaCache,new P_,t.eventCallback);break;case z_.TPLink:const{TPLinkCameraManagerEngine:s}=await import("./engine-tplink-574781a5.js");n=new s(this._entityRegistryManager,t.stateWatcher,t.eventCallback)}return n}async getEngineForCamera(e,t){let n=null;if("frigate"===t.engine)n=z_.Frigate;else if("motioneye"===t.engine)n=z_.MotionEye;else if("generic"===t.engine)n=z_.Generic;else if("reolink"===t.engine)n=z_.Reolink;else if("tplink"===t.engine)n=z_.TPLink;else{const i=R_(t);if(i){const a=await this._entityRegistryManager.getEntity(e,i);if(!a){if(e.states[i])return z_.Generic;throw new O_(u_("error.no_camera_entity"),t)}switch(a?.platform){case"frigate":n=z_.Frigate;break;case"motioneye":n=z_.MotionEye;break;case"reolink":n=z_.Reolink;break;case"tplink":n=z_.TPLink;break;default:n=z_.Generic}}else t.frigate.camera_name?n=z_.Frigate:(t.webrtc_card?.url||t.go2rtc?.url&&t.go2rtc?.stream)&&(n=z_.Generic)}return n}}class F_{constructor(){this._cameras=new Map,this._enginesByType=new Map}addCamera(e){this._cameras.set(e.getID(),e),this._enginesByType.set(e.getEngine().getEngineType(),e.getEngine())}async setCameras(e){for(const t of e){const e=this._cameras.get(t.getID());e!==t&&(this.addCamera(t),await(e?.destroy()))}for(const t of this._cameras.values())e.includes(t)||(await t.destroy(),this._cameras.delete(t.getID()))}async reset(){await bd(this._cameras.values(),(e=>e.destroy())),this._cameras.clear(),this._enginesByType.clear()}getCamera(e){return this._cameras.get(e)??null}getCameras(){return this._cameras}getCameraConfig(e){return this._cameras.get(e)?.getConfig()??null}hasCameraID(e){return this._cameras.has(e)}getCameraCount(){return this._cameras.size}getDefaultCameraID(){return this._cameras.keys().next().value??null}*getCameraConfigs(e){for(const[t,n]of this.getCameraConfigEntries(e))yield n}*getCameraConfigEntries(e){for(const t of e??this._cameras.keys()){const e=this.getCameraConfig(t);e&&(yield[t,e])}}getCameraIDs(){return new Set(this._cameras.keys())}getCameraIDsWithCapability(e,t){const n=new Set;for(const i of this._cameras.values())this.getAllDependentCameras(i.getID(),e,t).forEach((e=>{n.add(e)}));return n}getCameraConfigForMedia(e){const t=e.getCameraID();return t?this.getCameraConfig(t):null}getEngineOfType(e){return this._enginesByType.get(e)??null}getEngineForCameraID(e){return this._cameras.get(e)?.getEngine()??null}getEnginesForCameraIDs(e){const t=new Map;for(const n of e){const e=this.getEngineForCameraID(n);e&&(t.has(e)||t.set(e,new Set),t.get(e)?.add(n))}return t.size?t:null}getEngineForMedia(e){const t=e.getCameraID();return t?this.getEngineForCameraID(t):null}getAllDependentCameras(e,t,n){const i=new Set,a=e=>{i.add(e);const r=new Set,s=this.getCamera(e),o=s?.getConfig();if(!s||!o)return r;const c=new Set;o.dependencies.cameras.forEach((e=>c.add(e))),o.dependencies.all_cameras&&this.getCameraIDs().forEach((e=>c.add(e)));const l=new Set;for(const e of c)i.has(e)||a(e).forEach((e=>l.add(e)));return new Set([...!t||s.getCapabilities()?.matches(t)||n?.inclusive&&l.size?[e]:[],...l])};return a(e)}}class B_{static isEventQuery(e){return e.type===D_.Event}static isRecordingQuery(e){return e.type===D_.Recording}static isRecordingSegmentsQuery(e){return e.type===D_.RecordingSegments}static isMediaMetadataQuery(e){return e.type===D_.MediaMetadata}}class V_{static isEventQueryResult(e){return e?.type===j_.Event}static isRecordingQueryResult(e){return e?.type===j_.Recording}static isRecordingSegmentsQueryResult(e){return e?.type===j_.RecordingSegments}static isMediaMetadataQueryResult(e){return e?.type===j_.MediaMetadata}}class H_{constructor(e,t){this._requestLimit=new ah,this._api=e,this._engineFactory=t?.factory??new N_(this._api.getEntityRegistryManager(),this._api.getDeviceRegistryManager()),this._store=t?.store??new F_}async initializeCamerasFromConfig(){const e=this._api.getConfigManager().getConfig(),t=this._api.getHASSManager().getHASS();if(!e||!t)return!1;this._requestLimit.concurrency=e.performance.features.max_simultaneous_engine_requests??1/0;const n=e.cameras.map((t=>{return n={},i=Nl(e?.cameras_global),Vu(n,i,t,((e,t)=>Array.isArray(t)?t:void 0));var n,i}));try{await this._initializeCameras(n)}catch(e){return this._api.getMessageManager().setErrorIfHigherPriority(e,u_("error.camera_initialization")),!1}return!0}async destroy(){await this._store.reset()}async _getEnginesForCameras(e){const t=new Map,n=new Map,i=this._api.getHASSManager().getHASS();
/* istanbul ignore if: the if path cannot be reached -- @preserve */
if(!i)return t;const a=await(async e=>await bd(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 O_(u_("error.no_camera_engine"),Nl(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 bd(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=d_(e.getConfig());if(!t)throw await r(),new O_(u_("error.no_camera_id"),e.getConfig());if(s.has(t))throw await r(),new O_(u_("error.duplicate_camera_id"),e.getConfig());e.setID(t),s.add(t)}await this._store.setCameras(a),h_(this._api.getConfigManager().getCardWideConfig(),"Advanced Camera 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:D_.Event,...t})}generateDefaultRecordingQueries(e,t){return this._generateDefaultQueries(e,{type:D_.Recording,...t})}generateDefaultRecordingSegmentsQueries(e,t){return this._generateDefaultQueries(e,{type:D_.RecordingSegments,...t})}_generateDefaultQueries(e,t){const n=[],i=hd(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 */B_.isEventQuery(t)?a=e.generateDefaultEventQuery(this._store,i,t):B_.isRecordingQuery(t)?a=e.generateDefaultRecordingQuery(this._store,i,t):B_.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:D_.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){if(!lh.isMedia(i))continue;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=uh(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))),h_(this._api.getConfigManager().getCardWideConfig(),"Advanced Camera Card CameraManager favorite request (",`Duration: ${((new Date).getTime()-r.getTime())/1e3}s,`,"Media:",e.getID(),", Favorite:",t,")")}areMediaQueriesResultsFresh(e,t){if(!t)return!1;const n=new Date;for(const i of t){const t=this._store.getEnginesForCameraIDs(i.cameraIDs);for(const[a,r]of t??[]){const t=a.getQueryResultMaxAge({...i,cameraIDs:r});if(null!==t&&ji(e,{seconds:t})<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=dd(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 */B_.isEventQuery(n)?a=await e.getEvents(r,this._store,n,t):B_.isRecordingQuery(n)?a=await e.getRecordings(r,this._store,n,t):B_.isRecordingSegmentsQuery(n)?a=await e.getRecordingSegments(r,this._store,n,t):B_.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,ms):0;var l;return h_(this._api.getConfigManager().getCardWideConfig(),"Advanced Camera 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 */B_.isEventQuery(i)&&V_.isEventQueryResult(a)?r=e.generateMediaFromEvents(n,this._store,i,a):B_.isRecordingQuery(i)&&V_.isRecordingQueryResult(a)&&(r=e.generateMediaFromRecordings(n,this._store,i,a)),r&&t.push(...r)}}return uh(t)}getCameraEndpoints(e,t){return this._store.getCamera(e)?.getEndpoints(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(Cd);return new p_({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")))})}_rotatePTZAction(e,t){if(!t)return e;const n=dh.indexOf(e);if(-1===n)return e;return dh[(n+(4-t/90)%4)%4]}async executePTZAction(e,t,n){const i=this._store.getCamera(e);if(!i)return;const a=this._rotatePTZAction(t,i.getConfig().dimensions?.rotation);await this._requestLimit.add((()=>i.executePTZAction(this._api.getActionsManager(),a,n)))}}class U_{constructor(){this._listeners=[],this._state={},this._callListeners=e=>{this._listeners.forEach((t=>t(e)))}}addListener(e){this._listeners.push(e)}removeListener(e){this._listeners=this._listeners.filter((t=>t!==e))}getState(){return this._state}setState(e){this._processStateChange(this._calculateTrueChange(e))}_processStateChange(e){if(!Object.keys(e).length)return;const t=this._state;this._state={...t,...e},this._callListeners({old:t,change:e,new:this._state})}_calculateTrueChange(e){const t={};for(const n of Object.keys(e))Uu(e[n],this._state[n])||(t[n]=e[n]);return t}}class q_ extends f_{constructor(){super(new Map)}}const W_=bi.object({id:bi.string(),model:bi.string().nullable(),config_entries:bi.string().array(),manufacturer:bi.string().nullable(),configuration_url:bi.string().nullable().optional()}).array();class Z_ extends q_{}class K_{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 m_(e,W_,{type:"config/device_registry/list"})}catch(e){return void md(e)}t.forEach((e=>{this._cache.set(e.id,e)})),this._fetchedDeviceList=!0}}const Q_=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()}),Y_=Q_.array();class G_ extends q_{}class X_{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 m_(e,Q_,{type:"config/entity_registry/get",entity_id:t})}catch(e){return md(e),null}return this._cache.set(i.entity_id,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 m_(e,Y_,{type:"config/entity_registry/list"})}catch(e){return void md(e)}t.forEach((e=>{this._cache.set(e.entity_id,e)})),this._fetchedEntityList=!0}}class J_ 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)}_deleteIfExpired(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield e)}}for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){const i="number"==typeof n&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:i}):this._set(e,{value:t,expiry:i}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const n=e[t],[i,a]=n;!1===this._deleteIfExpired(i,a)&&(yield[i,a.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const n=e[t],[i,a]=n;if(!this.cache.has(i)){!1===this._deleteIfExpired(i,a)&&(yield[i,a.value])}}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[n,i]of this.entriesAscending())e.call(t,i,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}class ev extends f_{constructor(e){super(new J_({maxSize:e}))}}const tv=bi.object({url:bi.string(),mime_type:bi.string()});class nv extends ev{constructor(){super(1e3)}}const iv=async(e,t,n)=>{const i=n?.get(t)??null;if(i)return i;const a={type:"media_source/resolve_media",media_content_id:t};let r=null;try{r=await m_(e,tv,a)}catch(e){md(e)}return n&&r&&n.set(t,r),r},av=e=>{tt(window,"haptic",e)};class rv extends sd{}class sv{constructor(e,t,n){this._context=e,this._action=t,this._config=n}_shouldSeekConfirmation(e){const t=e.getHASSManager().getHASS();return"boolean"==typeof this._action.confirmation&&this._action.confirmation||"object"==typeof this._action.confirmation&&(!this._action.confirmation.exemptions||!this._action.confirmation.exemptions.some((e=>e.user===t?.user.id)))}async execute(e){if(this._shouldSeekConfirmation(e)){const e=Hd(this._action)?this._action.advanced_camera_card_action:this._action.action,t=("object"==typeof this._action.confirmation?this._action.confirmation.text:null)??`${u_("actions.confirmation")}: ${e}`;if(!confirm(t))throw new rv(u_("actions.abort"))}}async stop(){}}class ov extends sv{}class cv extends ov{async execute(e){await super.execute(e);const t=e.getHASSManager().getHASS();if(!t)return;const[n,i]=this._action.service.split(".",2);await t.callService(n,i,this._action.data,this._action.target)}}class lv extends ov{async execute(e){await super.execute(e);const t=this._action.camera??(this._action.triggered?e.getTriggersManager().getMostRecentlyTriggeredCameraID():null),n=e.getViewManager().getView(),i=e.getConfigManager().getConfig();if(t&&n&&t!==n.camera){const a=i?.view.camera_select??"current",r="current"===a?n.view:a;await e.getViewManager().setViewByParametersWithNewQuery({params:{view:r,camera:t},failSafe:!0})}}}class uv extends ov{async execute(e){await super.execute(e),e.getCameraURLManager().openURL()}}class dv extends ov{async execute(e){await super.execute(e),tt(e.getCardElementManager().getElement(),"ll-custom",this._action)}}class hv extends ov{async execute(e){await super.execute(e),await e.getViewManager().setViewDefaultWithNewQuery()}}class pv extends ov{async execute(e){await super.execute(e),await e.getViewManager().setViewByParametersWithNewQuery({params:{displayMode:this._action.display_mode}})}}class mv extends ov{async execute(e){await super.execute(e);const t=e.getViewManager().getView()?.queryResults?.getSelectedResult();t&&await e.getViewItemManager().download(t)}}class fv extends ov{async execute(e){await super.execute(e),e.getExpandManager().toggleExpanded()}}class gv extends ov{async execute(e){switch(await super.execute(e),this._action.effect_action){case"start":e.getEffectsControllerAPI()?.startEffect(this._action.effect);break;case"stop":e.getEffectsControllerAPI()?.stopEffect(this._action.effect);break;case"toggle":e.getEffectsControllerAPI()?.toggleEffect(this._action.effect)}}}class _v extends ov{async execute(e){await super.execute(e),e.getFullscreenManager().toggleFullscreen()}}class vv extends ov{async execute(e){await super.execute(e),await this._action.callback(e)}}class yv extends ov{async execute(e){await super.execute(e),console[this._action.level](this._action.message)}}const bv=(e,t)=>e.context?.live?.overrides?.get(t??e.camera)??t??e.camera,wv=e=>bv(e)!==e.camera,xv=(e,t)=>{const n=e.context?.live?.overrides??new Map;n.set(e.camera,t),e.mergeInContext({live:{overrides:n}})};class Mv extends ov{async execute(e){await super.execute(e);const t=this._action.media_player,n=e.getMediaPlayerManager();if("stop"===this._action.media_player_action)return void await n.stop(t);const i=e.getViewManager().getView(),a=i?.queryResults?.getSelectedResult()??null;i?.is("live")?await n.playLive(t,bv(i)):i?.isViewerView()&&a&&lh.isMedia(a)&&await n.playMedia(t,a)}}class kv extends ov{async execute(e){await super.execute(e),e.getCardElementManager().toggleMenu()}}class Cv extends ov{async execute(e){await super.execute(e),await e.getMicrophoneManager().connect()}}class Sv extends ov{async execute(e){await super.execute(e),e.getMicrophoneManager().disconnect()}}class Ev extends ov{async execute(e){await super.execute(e),e.getMicrophoneManager().mute()}}class Av extends ov{async execute(e){await super.execute(e),await e.getMicrophoneManager().unmute()}}class Tv extends ov{async execute(e){await super.execute(e);const t=this._action.entity??this._config?.entity??null;t&&tt(e.getCardElementManager().getElement(),"hass-more-info",{entityId:t})}}class $v extends ov{async execute(e){await super.execute(e),await(e.getMediaLoadedInfoManager().get()?.mediaPlayerController?.mute())}}class Iv extends ov{async execute(e){await super.execute(e),this._action.navigation_replace?history.replaceState(null,"",this._action.navigation_path):history.pushState(null,"",this._action.navigation_path),tt(window,"location-changed",{replace:!!this._action.navigation_replace})}}class Ov extends ov{async execute(e){await super.execute(e)}}class Lv extends ov{async execute(e){await super.execute(e),await(e.getMediaLoadedInfoManager().get()?.mediaPlayerController?.pause())}}class Dv extends ov{async execute(e){await super.execute(e);const t=e.getHASSManager().getHASS();if(!t)return;const[n,i]=this._action.perform_action.split(".",2);await t.callService(n,i,this._action.data,this._action.target)}}class jv extends ov{async execute(e){await super.execute(e),await(e.getMediaLoadedInfoManager().get()?.mediaPlayerController?.play())}}const zv=(e,t)=>{if(e.isViewerView()){const n=e.queryResults?.getSelectedResult()?.getID()??null;return"ptz"!==t?.type&&n?{targetID:n,type:"digital"}:null}if(e.is("live")){const n=bv(e);let i="digital";return"digital"!==t?.type&&t?.cameraManager&&(Pv(t.cameraManager,n)&&(i="ptz"),"ptz"!==i&&"ptz"===t?.type)?null:{targetID:n,type:i}}return e.is("image")?{targetID:qg,type:"digital"}:null},Pv=(e,t)=>!!e.getStore().getCamera(t)?.getCapabilities()?.hasPTZCapability(),Rv=async(e,t)=>{await(t?.[e]?.inProgressAction?.stop())},Nv=(e,t,n,i)=>{qu(t,{[n]:{[e]:{inProgressAction:i}}})};class Fv extends ov{constructor(){super(...arguments),this._timer=new qd,this._stopped=!1}async stop(){this._stopped=!0,this._timer.stop()}async execute(e){await super.execute(e);const t=e.getViewManager().getView();if(!t)return;const n=this._action.camera??zv(t,{type:"ptz",cameraManager:e.getCameraManager()})?.targetID??null,i=n?e.getCameraManager().getCameraCapabilities(n)?.getPTZCapabilities():null,a=n?e.getCameraManager().getStore().getCameraConfig(n)?.ptz:null;if(!n||!i||!a)return;if(!this._action.ptz_action)return void(i.presets&&i.presets.length>=1&&await e.getCameraManager().executePTZAction(n,"preset",{phase:this._action.ptz_phase,preset:i.presets[0]}));const r=(e=>{switch(e){case"left":case"right":case"up":case"down":return e;case"zoom_in":return"zoomIn";case"zoom_out":return"zoomOut"}return null})(this._action.ptz_action);if(r&&i[r]?.includes(this._action.ptz_phase?td.Continuous:td.Relative)||"preset"===this._action.ptz_action)return await e.getCameraManager().executePTZAction(n,this._action.ptz_action,{phase:this._action.ptz_phase,preset:this._action.ptz_preset});if("start"===this._action.ptz_phase){await Rv(n,this._context.ptz),Nv(n,this._context,"ptz",this);const t=async()=>{
/* istanbul ignore else: the else path cannot be reached as ptz_action
being present is checked above -- @preserve */
this._action.ptz_action&&await e.getCameraManager().executePTZAction(n,this._action.ptz_action,{preset:this._action.ptz_preset}),this._stopped||this._timer.start(a.r2c_delay_between_calls_seconds,t)};this._stopped=!1,await t()}else"stop"===this._action.ptz_phase?await Rv(n,this._context.ptz):(this._stopped=!1,await e.getCameraManager().executePTZAction(n,this._action.ptz_action,{preset:this._action.ptz_preset,phase:"start"}),this._timer.start(a.c2r_delay_between_calls_seconds,(async()=>{
/* istanbul ignore else: the else path cannot be reached as ptz_action
being present is checked above -- @preserve */
this._action.ptz_action&&await e.getCameraManager().executePTZAction(n,this._action.ptz_action,{preset:this._action.ptz_preset,phase:"stop"})})))}}class Bv extends ov{async execute(e){await super.execute(e),e.getViewManager().setViewWithMergedContext({ptzControls:{enabled:this._action.enabled}})}}const Vv=50,Hv=50,Uv=1,qv=4,Wv=e=>void 0===e?.pan?.x&&void 0===e?.pan?.y&&void 0===e?.zoom;class Zv{constructor(e){this._context=e}modify(e){e.mergeInContext(this._context)}}const Kv=(e,t)=>({zoom:{[e]:{observed:t?.observed??void 0,requested:t?.requested??null}}}),Qv=(e,t,n)=>{t&&n&&t.setViewByParameters({modifiers:[new Zv(Kv(n,{observed:e.detail}))]})},Yv=1,Gv=10,Xv=bi.number().min(1).max(10);class Jv extends ov{constructor(){super(...arguments),this._timer=new qd}async _stepChange(e,t){e.getViewManager().setViewWithMergedContext(Kv(t,{requested:this._convertActionToZoomSettings(e.getViewManager().getView()?.context?.zoom?.[t]?.observed)}))}async stop(){this._timer.stop()}async execute(e){await super.execute(e);const t=e.getViewManager().getView();if(!t)return;const n=this._action.target_id??zv(t,{type:"digital",cameraManager:e.getCameraManager()})?.targetID;return n?this._action.absolute||!this._action.ptz_phase?await this._stepChange(e,n):
/* istanbul ignore else: the else path cannot be reached -- @preserve */
void("start"===this._action.ptz_phase?(await Rv(n,this._context.ptzDigital),Nv(n,this._context,"ptzDigital",this),await this._stepChange(e,n),this._timer.startRepeated(.1,(()=>this._stepChange(e,n)))):"stop"===this._action.ptz_phase&&(await Rv(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:xc(t+a,1,10),pan:{x:xc(n+r,0,100),y:xc(i+s,0,100)}}}}class ey extends ov{async execute(e){await super.execute(e);const t=e.getViewManager().getView();let n=null,i=null;if(this._action.target_id)n=this._action.target_id,i=Pv(e.getCameraManager(),n)?"ptz":"digital";else if(t){const a=zv(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 Fv(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",advanced_camera_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 Jv(this._context,(t={cardID:this._action.card_id,ptzPhase:this._action.ptz_phase,ptzAction:this._action.ptz_action,targetID:e},{action:"fire-dom-event",advanced_camera_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 ty extends ov{async execute(e){await super.execute(e),window.location.reload()}}const ny=(e,t="download")=>{const n=new URL(e).origin===window.location.origin,i=e.startsWith("data:");if(!n&&!i)return void window.open(e,"_blank");const a=document.createElement("a");a.setAttribute("download",t),a.href=e,a.click(),a.remove()},iy=e=>ry(e,e.naturalWidth,e.naturalHeight),ay=e=>ry(e,e.videoWidth,e.videoHeight),ry=(e,t,n)=>{const i=document.createElement("canvas");i.width=t,i.height=n;const a=i.getContext("2d");return a?(a.drawImage(e,0,0,i.width,i.height),i.toDataURL("image/jpeg")):null};class sy extends ov{async execute(e){await super.execute(e);const t=await(e.getMediaLoadedInfoManager().get()?.mediaPlayerController?.getScreenshotURL());t&&ny(t,(e=>{if(e?.is("live")||e?.is("image"))return`${e.view}_${e.camera}_${ja(new Date,"yyyy-MM-dd-HH-mm-ss")}.jpg`;if(e?.isViewerView()){const t=e.queryResults?.getSelectedResult(),n=t?.getID()??null;return`${e.view}_${e.camera}${n?`_${n}`:""}.jpg`}return"screenshot.jpg"})(e.getViewManager().getView()))}}const oy=async e=>{await new Promise((t=>setTimeout(t,1e3*e)))};class cy extends ov{async execute(e){var t;await super.execute(e),await oy((t=this._action.duration,3600*(t.h??0)+60*(t.m??0)+(t.s??0)+(t.ms??0)/1e3))}}class ly extends ov{async execute(e){switch(await super.execute(e),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 uy{modify(e){(e=>{const t=e.context?.live?.overrides;t&&t.has(e.camera)&&e.context?.live?.overrides?.delete(e.camera)})(e)}}class dy extends ov{async execute(e){await super.execute(e),e.getViewManager().setViewByParameters({modifiers:[new uy]})}}class hy{constructor(e){this._api=e}modify(e){const t=[...this._api.getCameraManager().getStore().getAllDependentCameras(e.camera,"substream")];if(t.length<=1)return;const n=bv(e),i=t.indexOf(n),a=i<0?0:(i+1)%t.length;xv(e,t[a])}}class py extends ov{async execute(e){await super.execute(e),e.getViewManager().setViewByParameters({modifiers:[new hy(e)]})}}class my{constructor(e){this._substreamID=e}modify(e){xv(e,this._substreamID)}}class fy extends ov{async execute(e){await super.execute(e),e.getViewManager().setViewByParameters({modifiers:[new my(this._action.camera)]})}}const gy=e=>e.substring(0,e.indexOf(".")),_y=["off","closed","locked"],vy=["on","open","unlocked"];class yy extends ov{async execute(e){await super.execute(e);const t=e.getHASSManager().getHASS(),n=this._config?.entity;if(!t||!n)return;const i=t.states[n]?.state;if(!i)return;const a=_y.includes(i),r=gy(n),s="group"===r?"homeassistant":r,o="lock"===r?a?"unlock":"lock":"cover"===r?a?"open_cover":"close_cover":a?"turn_on":"turn_off";await t.callService(s,o,{entity_id:n})}}class by extends ov{async execute(e){await super.execute(e),await(e.getMediaLoadedInfoManager().get()?.mediaPlayerController?.unmute())}}class wy extends ov{async execute(e){await super.execute(e),window.open(this._action.url_path)}}class xy extends ov{async execute(e){await super.execute(e),await e.getViewManager().setViewByParametersWithNewQuery({params:{view:this._action.advanced_camera_card_action},...this._action.folder&&{queryExecutorOptions:{folder:this._action.folder}}})}}class My{createAction(e,t,n){if(t.card_id&&t.card_id!==n?.cardID)return null;switch(t.action){case"more-info":return new Tv(e,t,n?.config);case"toggle":return new yy(e,t,n?.config);case"navigate":return new Iv(e,t,n?.config);case"url":return new wy(e,t,n?.config);case"perform-action":return new Dv(e,t,n?.config);case"call-service":return new cv(e,t,n?.config);case"none":return new Ov(e,t,n?.config)}if(!Hd(t))return new dv(e,t,n?.config);switch(t.advanced_camera_card_action){case"default":return new hv(e,t,n?.config);case"clip":case"clips":case"folder":case"folders":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":case"diagnostics":return new xy(e,t,n?.config);case"sleep":return new cy(e,t,n?.config);case"download":return new mv(e,t,n?.config);case"camera_ui":return new uv(e,t,n?.config);case"effect":return new gv(e,t,n?.config);case"expand":return new fv(e,t,n?.config);case"fullscreen":return new _v(e,t,n?.config);case"menu_toggle":return new kv(e,t,n?.config);case"camera_select":return new lv(e,t,n?.config);case"live_substream_select":return new fy(e,t,n?.config);case"live_substream_off":return new dy(e,t,n?.config);case"live_substream_on":return new py(e,t,n?.config);case"media_player":return new Mv(e,t,n?.config);case"microphone_connect":return new Cv(e,t,n?.config);case"microphone_disconnect":return new Sv(e,t,n?.config);case"microphone_mute":return new Ev(e,t,n?.config);case"microphone_unmute":return new Av(e,t,n?.config);case"mute":return new $v(e,t,n?.config);case"unmute":return new by(e,t,n?.config);case"play":return new jv(e,t,n?.config);case"pause":return new Lv(e,t,n?.config);case"screenshot":return new sy(e,t,n?.config);case"display_mode_select":return new pv(e,t,n?.config);case"ptz":return new Fv(e,t,n?.config);case"ptz_digital":return new Jv(e,t,n?.config);case"ptz_multi":return new ey(e,t,n?.config);case"ptz_controls":return new Bv(e,t,n?.config);case"log":return new yv(e,t,n?.config);case"status_bar":return new ly(e,t,n?.config);case"reload":return new ty(e,t,n?.config);case Ti:return new vv(e,t,n?.config)}
/* istanbul ignore next: this path cannot be reached -- @preserve */
/* istanbul ignore next: this path cannot be reached -- @preserve */
return console.warn(`Advanced Camera Card received unknown card action: ${t.advanced_camera_card_action}`),null}}class ky{constructor(e,t,n){this._actions=[],this._factory=new My,this._stopped=!1,this._context=e;for(const i of dd(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 Cy=bi.object({action:bi.enum(["tap","double_tap","hold","start_tap","end_tap"])}),Sy=bi.object({detail:Cy});class Ey{constructor(e,t){this._actionsInFlight=[],this._actionContext={},this.handleInteractionEvent=async e=>{const t=Sy.safeParse(e);if(!t.success)return;const n=t.data.detail.action,i=this.getMergedActions(),a=Bd(n,i);i&&n&&a&&await this.executeActions({actions:a,config:i})},this.handleCustomActionEvent=async e=>{if(!("detail"in e))return;const t=e.detail;Hd(t)&&await this.executeActions({actions:t},!0)},this.handleActionExecutionRequestEvent=async e=>{await this.executeActions(e.detail)},this._api=e,this._templateRenderer=t??null}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?.isMediaGalleryView())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}}async uninitialize(){await bd(this._actionsInFlight,(e=>e.stop()))}async executeActions(e,t=!0){const n=this._api.getHASSManager().getHASS(),i=t&&n&&this._templateRenderer?this._templateRenderer.renderRecursively(n,e.actions,{conditionState:this._api.getConditionStateManager().getState(),triggerData:e?.triggerData}):e.actions,a=new ky(this._actionContext,i,{config:e.config,cardID:this._api.getConfigManager().getConfig()?.card_id});this._actionsInFlight.push(a);try{await a.execute(this._api),av("success")}catch(e){md(e),av("warning")}this._actionsInFlight=this._actionsInFlight.filter((e=>e!==a))}}var Ay,Ty={exports:{}};
/*! Browser bundle of nunjucks 3.2.4 */"undefined"!=typeof self&&self,Ay=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){var i=Array.prototype,a=Object.prototype,r={"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","\\":"&#92;"},s=/[&"'<>\\]/g;function o(e,t){return a.hasOwnProperty.call(e,t)}function c(e){return r[e]}function l(e,t,n){var i,a,r;if(e instanceof Error&&(e=(a=e).name+": "+a.message),Object.setPrototypeOf?(i=new Error(e),Object.setPrototypeOf(i,l.prototype)):(i=this,Object.defineProperty(i,"message",{enumerable:!1,writable:!0,value:e})),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),a){var s=Object.getOwnPropertyDescriptor(a,"stack");(r=s&&(s.get||function(){return s.value}))||(r=function(){return a.stack})}else{var o=new Error(e).stack;r=function(){return o}}return Object.defineProperty(i,"stack",{get:function(){return r.call(i)}}),Object.defineProperty(i,"cause",{value:a}),i.lineno=t,i.colno=n,i.firstUpdate=!0,i.Update=function(e){var t="("+(e||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?t+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(t+=" [Line "+this.lineno+"]")),t+="\n ",this.firstUpdate&&(t+=" "),this.message=t+(this.message||""),this.firstUpdate=!1,this},i}function u(e){return"[object Function]"===a.toString.call(e)}function d(e){return"[object Array]"===a.toString.call(e)}function h(e){return"[object String]"===a.toString.call(e)}function p(e){return"[object Object]"===a.toString.call(e)}function m(e){var t,n=(t=e)?"string"==typeof t?t.split("."):[t]:[];return function(e){for(var t=e,i=0;i<n.length;i++){var a=n[i];if(!o(t,a))return;t=t[a]}return t}}function f(e){return Array.prototype.slice.call(e)}function g(e,t,n){return Array.prototype.indexOf.call(e||[],t,n)}function _(e){var t=[];for(var n in e)o(e,n)&&t.push(n);return t}(t=e.exports={}).hasOwnProp=o,t._prettifyError=function(e,n,i){if(i.Update||(i=new t.TemplateError(i)),i.Update(e),!n){var a=i;(i=new Error(a.message)).name=a.name}return i},Object.setPrototypeOf?Object.setPrototypeOf(l.prototype,Error.prototype):l.prototype=Object.create(Error.prototype,{constructor:{value:l}}),t.TemplateError=l,t.escape=function(e){return e.replace(s,c)},t.isFunction=u,t.isArray=d,t.isString=h,t.isObject=p,t.getAttrGetter=m,t.groupBy=function(e,t,n){for(var i={},a=u(t)?t:m(t),r=0;r<e.length;r++){var s=e[r],o=a(s,r);if(void 0===o&&!0===n)throw new TypeError('groupby: attribute "'+t+'" resolved to undefined');(i[o]||(i[o]=[])).push(s)}return i},t.toArray=f,t.without=function(e){var t=[];if(!e)return t;for(var n=e.length,i=f(arguments).slice(1),a=-1;++a<n;)-1===g(i,e[a])&&t.push(e[a]);return t},t.repeat=function(e,t){for(var n="",i=0;i<t;i++)n+=e;return n},t.each=function(e,t,n){if(null!=e)if(i.forEach&&e.forEach===i.forEach)e.forEach(t,n);else if(e.length===+e.length)for(var a=0,r=e.length;a<r;a++)t.call(n,e[a],a,e)},t.map=function(e,t){var n=[];if(null==e)return n;if(i.map&&e.map===i.map)return e.map(t);for(var a=0;a<e.length;a++)n[n.length]=t(e[a],a);return e.length===+e.length&&(n.length=e.length),n},t.asyncIter=function(e,t,n){var i=-1;!function a(){++i<e.length?t(e[i],i,a,n):n()}()},t.asyncFor=function(e,t,n){var i=_(e||{}),a=i.length,r=-1;!function s(){r++;var o=i[r];r<a?t(o,e[o],r,a,s):n()}()},t.indexOf=g,t.keys=_,t._entries=function(e){return _(e).map((function(t){return[t,e[t]]}))},t._values=function(e){return _(e).map((function(t){return e[t]}))},t._assign=t.extend=function(e,t){return e=e||{},_(t).forEach((function(n){e[n]=t[n]})),e},t.inOperator=function(e,t){if(d(t)||h(t))return-1!==t.indexOf(e);if(p(t))return e in t;throw new Error('Cannot use "in" operator to search for "'+e+'" in unexpected types.')}},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,r=void 0,"symbol"==typeof(r=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?r:String(r)),i)}var a,r}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}var o=n(16),c=n(0);function l(e,t,n){n=n||{},c.keys(n).forEach((function(t){n[t]=function(e,t){return"function"!=typeof e||"function"!=typeof t?t:function(){var n=this.parent;this.parent=e;var i=t.apply(this,arguments);return this.parent=n,i}}(e.prototype[t],n[t])}));var i=function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),a(n,[{key:"typename",get:function(){return t}}]),n}(e);return c._assign(i.prototype,n),i}var u=function(){function e(){this.init.apply(this,arguments)}return e.prototype.init=function(){},e.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),l(this,e,t)},a(e,[{key:"typename",get:function(){return this.constructor.name}}]),e}(),d=function(e){function t(){var t,n;return(t=n=e.call(this)||this).init.apply(t,arguments),n}return r(t,e),t.prototype.init=function(){},t.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),l(this,e,t)},a(t,[{key:"typename",get:function(){return this.constructor.name}}]),t}(o);e.exports={Obj:u,EmitterObj:d}},function(e,t,n){var i=n(0),a=Array.from,r="function"==typeof Symbol&&Symbol.iterator&&"function"==typeof a,s=function(){function e(e,t){this.variables=Object.create(null),this.parent=e,this.topLevel=!1,this.isolateWrites=t}var t=e.prototype;return t.set=function(e,t,n){var i=e.split("."),a=this.variables,r=this;if(n&&(r=this.resolve(i[0],!0)))r.set(e,t);else{for(var s=0;s<i.length-1;s++){var o=i[s];a[o]||(a[o]={}),a=a[o]}a[i[i.length-1]]=t}},t.get=function(e){var t=this.variables[e];return void 0!==t?t:null},t.lookup=function(e){var t=this.parent,n=this.variables[e];return void 0!==n?n:t&&t.lookup(e)},t.resolve=function(e,t){var n=t&&this.isolateWrites?void 0:this.parent;return void 0!==this.variables[e]?this:n&&n.resolve(e)},t.push=function(t){return new e(this,t)},t.pop=function(){return this.parent},e}();function o(e){return e&&Object.prototype.hasOwnProperty.call(e,"__keywords")}function c(e){var t=e.length;return 0===t?0:o(e[t-1])?t-1:t}function l(e){if("string"!=typeof e)return e;this.val=e,this.length=e.length}l.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),l.prototype.valueOf=function(){return this.val},l.prototype.toString=function(){return this.val},e.exports={Frame:s,makeMacro:function(e,t,n){return function(){for(var i=arguments.length,a=new Array(i),r=0;r<i;r++)a[r]=arguments[r];var s,l=c(a),u=function(e){var t=e.length;if(t){var n=e[t-1];if(o(n))return n}return{}}(a);if(l>e.length)s=a.slice(0,e.length),a.slice(s.length,l).forEach((function(e,n){n<t.length&&(u[t[n]]=e)})),s.push(u);else if(l<e.length){s=a.slice(0,l);for(var d=l;d<e.length;d++){var h=e[d];s.push(u[h]),delete u[h]}s.push(u)}else s=a;return n.apply(this,s)}},makeKeywordArgs:function(e){return e.__keywords=!0,e},numArgs:c,suppressValue:function(e,t){return e=null!=e?e:"",!t||e instanceof l||(e=i.escape(e.toString())),e},ensureDefined:function(e,t,n){if(null==e)throw new i.TemplateError("attempted to output null or undefined value",t+1,n+1);return e},memberLookup:function(e,t){if(null!=e)return"function"==typeof e[t]?function(){for(var n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];return e[t].apply(e,i)}:e[t]},contextOrFrameLookup:function(e,t,n){var i=t.lookup(n);return void 0!==i?i:e.lookup(n)},callWrap:function(e,t,n,i){if(!e)throw new Error("Unable to call `"+t+"`, which is undefined or falsey");if("function"!=typeof e)throw new Error("Unable to call `"+t+"`, which is not a function");return e.apply(n,i)},handleError:function(e,t,n){return e.lineno?e:new i.TemplateError(e,t,n)},isArray:i.isArray,keys:i.keys,SafeString:l,copySafeness:function(e,t){return e instanceof l?new l(t):t.toString()},markSafe:function(e){var t=typeof e;return"string"===t?new l(e):"function"!==t?e:function(t){var n=e.apply(this,arguments);return"string"==typeof n?new l(n):n}},asyncEach:function(e,t,n,a){if(i.isArray(e)){var r=e.length;i.asyncIter(e,(function(e,i,a){switch(t){case 1:n(e,i,r,a);break;case 2:n(e[0],e[1],i,r,a);break;case 3:n(e[0],e[1],e[2],i,r,a);break;default:e.push(i,r,a),n.apply(this,e)}}),a)}else i.asyncFor(e,(function(e,t,i,a,r){n(e,t,i,a,r)}),a)},asyncAll:function(e,t,n,a){var r,s,o=0;function c(e,t){o++,s[e]=t,o===r&&a(null,s.join(""))}if(i.isArray(e))if(r=e.length,s=new Array(r),0===r)a(null,"");else for(var l=0;l<e.length;l++){var u=e[l];switch(t){case 1:n(u,l,r,c);break;case 2:n(u[0],u[1],l,r,c);break;case 3:n(u[0],u[1],u[2],l,r,c);break;default:u.push(l,r,c),n.apply(this,u)}}else{var d=i.keys(e||{});if(r=d.length,s=new Array(r),0===r)a(null,"");else for(var h=0;h<d.length;h++){var p=d[h];n(p,e[p],h,r,c)}}},inOperator:i.inOperator,fromIterator:function(e){return"object"!=typeof e||null===e||i.isArray(e)?e:r&&Symbol.iterator in e?a(e):e}}},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,r=void 0,"symbol"==typeof(r=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?r:String(r)),i)}var a,r}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function o(e,t,n){e instanceof t&&n.push(e),e instanceof c&&e.findAll(t,n)}var c=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.init=function(e,t){for(var n=arguments,i=this,a=arguments.length,r=new Array(a>2?a-2:0),s=2;s<a;s++)r[s-2]=arguments[s];this.lineno=e,this.colno=t,this.fields.forEach((function(e,t){var a=n[t+2];void 0===a&&(a=null),i[e]=a}))},n.findAll=function(e,t){var n=this;return t=t||[],this instanceof u?this.children.forEach((function(n){return o(n,e,t)})):this.fields.forEach((function(i){return o(n[i],e,t)})),t},n.iterFields=function(e){var t=this;this.fields.forEach((function(n){e(t[n],n)}))},t}(n(1).Obj),l=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),a(t,[{key:"typename",get:function(){return"Value"}},{key:"fields",get:function(){return["value"]}}]),t}(c),u=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.init=function(t,n,i){e.prototype.init.call(this,t,n,i||[])},n.addChild=function(e){this.children.push(e)},a(t,[{key:"typename",get:function(){return"NodeList"}},{key:"fields",get:function(){return["children"]}}]),t}(c),d=u.extend("Root"),h=l.extend("Literal"),p=l.extend("Symbol"),m=u.extend("Group"),f=u.extend("Array"),g=c.extend("Pair",{fields:["key","value"]}),_=u.extend("Dict"),v=c.extend("LookupVal",{fields:["target","val"]}),y=c.extend("If",{fields:["cond","body","else_"]}),b=y.extend("IfAsync"),w=c.extend("InlineIf",{fields:["cond","body","else_"]}),x=c.extend("For",{fields:["arr","name","body","else_"]}),M=x.extend("AsyncEach"),k=x.extend("AsyncAll"),C=c.extend("Macro",{fields:["name","args","body"]}),S=C.extend("Caller"),E=c.extend("Import",{fields:["template","target","withContext"]}),A=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.prototype.init=function(t,n,i,a,r){e.prototype.init.call(this,t,n,i,a||new u,r)},a(t,[{key:"typename",get:function(){return"FromImport"}},{key:"fields",get:function(){return["template","names","withContext"]}}]),t}(c),T=c.extend("FunCall",{fields:["name","args"]}),$=T.extend("Filter"),I=$.extend("FilterAsync",{fields:["name","args","symbol"]}),O=_.extend("KeywordArgs"),L=c.extend("Block",{fields:["name","body"]}),D=c.extend("Super",{fields:["blockName","symbol"]}),j=c.extend("TemplateRef",{fields:["template"]}).extend("Extends"),z=c.extend("Include",{fields:["template","ignoreMissing"]}),P=c.extend("Set",{fields:["targets","value"]}),R=c.extend("Switch",{fields:["expr","cases","default"]}),N=c.extend("Case",{fields:["cond","body"]}),F=u.extend("Output"),B=c.extend("Capture",{fields:["body"]}),V=h.extend("TemplateData"),H=c.extend("UnaryOp",{fields:["target"]}),U=c.extend("BinOp",{fields:["left","right"]}),q=U.extend("In"),W=U.extend("Is"),Z=U.extend("Or"),K=U.extend("And"),Q=H.extend("Not"),Y=U.extend("Add"),G=U.extend("Concat"),X=U.extend("Sub"),J=U.extend("Mul"),ee=U.extend("Div"),te=U.extend("FloorDiv"),ne=U.extend("Mod"),ie=U.extend("Pow"),ae=H.extend("Neg"),re=H.extend("Pos"),se=c.extend("Compare",{fields:["expr","ops"]}),oe=c.extend("CompareOperand",{fields:["expr","type"]}),ce=c.extend("CallExtension",{init:function(e,t,n,i){this.parent(),this.extName=e.__name||e,this.prop=t,this.args=n||new u,this.contentArgs=i||[],this.autoescape=e.autoescape},fields:["extName","prop","args","contentArgs"]}),le=ce.extend("CallExtensionAsync");function ue(e,t,n){var i=e.split("\n");i.forEach((function(e,a){e&&(n&&a>0||!n)&&process.stdout.write(" ".repeat(t));var r=a===i.length-1?"":"\n";process.stdout.write(""+e+r)}))}e.exports={Node:c,Root:d,NodeList:u,Value:l,Literal:h,Symbol:p,Group:m,Array:f,Pair:g,Dict:_,Output:F,Capture:B,TemplateData:V,If:y,IfAsync:b,InlineIf:w,For:x,AsyncEach:M,AsyncAll:k,Macro:C,Caller:S,Import:E,FromImport:A,FunCall:T,Filter:$,FilterAsync:I,KeywordArgs:O,Block:L,Super:D,Extends:j,Include:z,Set:P,Switch:R,Case:N,LookupVal:v,BinOp:U,In:q,Is:W,Or:Z,And:K,Not:Q,Add:Y,Concat:G,Sub:X,Mul:J,Div:ee,FloorDiv:te,Mod:ne,Pow:ie,Neg:ae,Pos:re,Compare:se,CompareOperand:oe,CallExtension:ce,CallExtensionAsync:le,printNodes:function e(t,n){if(n=n||0,ue(t.typename+": ",n),t instanceof u)ue("\n"),t.children.forEach((function(t){e(t,n+2)}));else if(t instanceof ce)ue(t.extName+"."+t.prop+"\n"),t.args&&e(t.args,n+2),t.contentArgs&&t.contentArgs.forEach((function(t){e(t,n+2)}));else{var i=[],a=null;t.iterFields((function(e,t){e instanceof c?i.push([t,e]):(a=a||{})[t]=e})),a?ue(JSON.stringify(a,null,2)+"\n",null,!0):ue("\n"),i.forEach((function(t){var i=t[0],a=t[1];ue("["+i+"] =>",n+2),e(a,n+4)}))}}}},function(e,t){},function(e,t,n){function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}var a=n(8),r=n(17),s=n(3),o=n(0).TemplateError,c=n(2).Frame,l=n(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},d=function(e){var t,n;function a(){return e.apply(this,arguments)||this}n=e,(t=a).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n);var r=a.prototype;return r.init=function(e,t){this.templateName=e,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=t},r.fail=function(e,t,n){throw void 0!==t&&(t+=1),void 0!==n&&(n+=1),new o(e,t,n)},r._pushBuffer=function(){var e=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=e,this._emit("var "+this.buffer+' = "";'),e},r._popBuffer=function(){this.buffer=this.bufferStack.pop()},r._emit=function(e){this.codebuf.push(e)},r._emitLine=function(e){this._emit(e+"\n")},r._emitLines=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach((function(t){return e._emitLine(t)}))},r._emitFuncBegin=function(e,t){this.buffer="output",this._scopeClosers="",this._emitLine("function "+t+"(env, context, frame, runtime, cb) {"),this._emitLine("var lineno = "+e.lineno+";"),this._emitLine("var colno = "+e.colno+";"),this._emitLine("var "+this.buffer+' = "";'),this._emitLine("try {")},r._emitFuncEnd=function(e){e||this._emitLine("cb(null, "+this.buffer+");"),this._closeScopeLevels(),this._emitLine("} catch (e) {"),this._emitLine(" cb(runtime.handleError(e, lineno, colno));"),this._emitLine("}"),this._emitLine("}"),this.buffer=null},r._addScopeLevel=function(){this._scopeClosers+="})"},r._closeScopeLevels=function(){this._emitLine(this._scopeClosers+";"),this._scopeClosers=""},r._withScopedSyntax=function(e){var t=this._scopeClosers;this._scopeClosers="",e.call(this),this._closeScopeLevels(),this._scopeClosers=t},r._makeCallback=function(e){var t=this._tmpid();return"function("+t+(e?","+e:"")+") {\nif("+t+") { cb("+t+"); return; }"},r._tmpid=function(){return this.lastId++,"t_"+this.lastId},r._templateName=function(){return null==this.templateName?"undefined":JSON.stringify(this.templateName)},r._compileChildren=function(e,t){var n=this;e.children.forEach((function(e){n.compile(e,t)}))},r._compileAggregate=function(e,t,n,i){var a=this;n&&this._emit(n),e.children.forEach((function(e,n){n>0&&a._emit(","),a.compile(e,t)})),i&&this._emit(i)},r._compileExpression=function(e,t){this.assertType(e,s.Literal,s.Symbol,s.Group,s.Array,s.Dict,s.FunCall,s.Caller,s.Filter,s.LookupVal,s.Compare,s.InlineIf,s.In,s.Is,s.And,s.Or,s.Not,s.Add,s.Concat,s.Sub,s.Mul,s.Div,s.FloorDiv,s.Mod,s.Pow,s.Neg,s.Pos,s.Compare,s.NodeList),this.compile(e,t)},r.assertType=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];n.some((function(t){return e instanceof t}))||this.fail("assertType: invalid type: "+e.typename,e.lineno,e.colno)},r.compileCallExtension=function(e,t,n){var i=this,a=e.args,r=e.contentArgs,o="boolean"!=typeof e.autoescape||e.autoescape;if(n||this._emit(this.buffer+" += runtime.suppressValue("),this._emit('env.getExtension("'+e.extName+'")["'+e.prop+'"]('),this._emit("context"),(a||r)&&this._emit(","),a&&(a instanceof s.NodeList||this.fail("compileCallExtension: arguments must be a NodeList, use `parser.parseSignature`"),a.children.forEach((function(e,n){i._compileExpression(e,t),(n!==a.children.length-1||r.length)&&i._emit(",")}))),r.length&&r.forEach((function(e,n){if(n>0&&i._emit(","),e){i._emitLine("function(cb) {"),i._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var a=i._pushBuffer();i._withScopedSyntax((function(){i.compile(e,t),i._emitLine("cb(null, "+a+");")})),i._popBuffer(),i._emitLine("return "+a+";"),i._emitLine("}")}else i._emit("null")})),n){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+o+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+o+" && env.opts.autoescape);\n")},r.compileCallExtensionAsync=function(e,t){this.compileCallExtension(e,t,!0)},r.compileNodeList=function(e,t){this._compileChildren(e,t)},r.compileLiteral=function(e){if("string"==typeof e.value){var t=e.value.replace(/\\/g,"\\\\");t=(t=(t=(t=(t=t.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+t+'"')}else null===e.value?this._emit("null"):this._emit(e.value.toString())},r.compileSymbol=function(e,t){var n=e.value,i=t.lookup(n);i?this._emit(i):this._emit('runtime.contextOrFrameLookup(context, frame, "'+n+'")')},r.compileGroup=function(e,t){this._compileAggregate(e,t,"(",")")},r.compileArray=function(e,t){this._compileAggregate(e,t,"[","]")},r.compileDict=function(e,t){this._compileAggregate(e,t,"{","}")},r.compilePair=function(e,t){var n=e.key,i=e.value;n instanceof s.Symbol?n=new s.Literal(n.lineno,n.colno,n.value):n instanceof s.Literal&&"string"==typeof n.value||this.fail("compilePair: Dict keys must be strings or names",n.lineno,n.colno),this.compile(n,t),this._emit(": "),this._compileExpression(i,t)},r.compileInlineIf=function(e,t){this._emit("("),this.compile(e.cond,t),this._emit("?"),this.compile(e.body,t),this._emit(":"),null!==e.else_?this.compile(e.else_,t):this._emit('""'),this._emit(")")},r.compileIn=function(e,t){this._emit("runtime.inOperator("),this.compile(e.left,t),this._emit(","),this.compile(e.right,t),this._emit(")")},r.compileIs=function(e,t){var n=e.right.name?e.right.name.value:e.right.value;this._emit('env.getTest("'+n+'").call(context, '),this.compile(e.left,t),e.right.args&&(this._emit(","),this.compile(e.right.args,t)),this._emit(") === true")},r._binOpEmitter=function(e,t,n){this.compile(e.left,t),this._emit(n),this.compile(e.right,t)},r.compileOr=function(e,t){return this._binOpEmitter(e,t," || ")},r.compileAnd=function(e,t){return this._binOpEmitter(e,t," && ")},r.compileAdd=function(e,t){return this._binOpEmitter(e,t," + ")},r.compileConcat=function(e,t){return this._binOpEmitter(e,t,' + "" + ')},r.compileSub=function(e,t){return this._binOpEmitter(e,t," - ")},r.compileMul=function(e,t){return this._binOpEmitter(e,t," * ")},r.compileDiv=function(e,t){return this._binOpEmitter(e,t," / ")},r.compileMod=function(e,t){return this._binOpEmitter(e,t," % ")},r.compileNot=function(e,t){this._emit("!"),this.compile(e.target,t)},r.compileFloorDiv=function(e,t){this._emit("Math.floor("),this.compile(e.left,t),this._emit(" / "),this.compile(e.right,t),this._emit(")")},r.compilePow=function(e,t){this._emit("Math.pow("),this.compile(e.left,t),this._emit(", "),this.compile(e.right,t),this._emit(")")},r.compileNeg=function(e,t){this._emit("-"),this.compile(e.target,t)},r.compilePos=function(e,t){this._emit("+"),this.compile(e.target,t)},r.compileCompare=function(e,t){var n=this;this.compile(e.expr,t),e.ops.forEach((function(e){n._emit(" "+u[e.type]+" "),n.compile(e.expr,t)}))},r.compileLookupVal=function(e,t){this._emit("runtime.memberLookup(("),this._compileExpression(e.target,t),this._emit("),"),this._compileExpression(e.val,t),this._emit(")")},r._getNodeName=function(e){switch(e.typename){case"Symbol":return e.value;case"FunCall":return"the return value of ("+this._getNodeName(e.name)+")";case"LookupVal":return this._getNodeName(e.target)+'["'+this._getNodeName(e.val)+'"]';case"Literal":return e.value.toString();default:return"--expression--"}},r.compileFunCall=function(e,t){this._emit("(lineno = "+e.lineno+", colno = "+e.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(e.name,t),this._emit(', "'+this._getNodeName(e.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(e.args,t,"[","])"),this._emit(")")},r.compileFilter=function(e,t){var n=e.name;this.assertType(n,s.Symbol),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emit(")")},r.compileFilterAsync=function(e,t){var n=e.name,i=e.symbol.value;this.assertType(n,s.Symbol),t.set(i,i),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emitLine(", "+this._makeCallback(i)),this._addScopeLevel()},r.compileKeywordArgs=function(e,t){this._emit("runtime.makeKeywordArgs("),this.compileDict(e,t),this._emit(")")},r.compileSet=function(e,t){var n=this,i=[];e.targets.forEach((function(e){var a=e.value,r=t.lookup(a);null==r&&(r=n._tmpid(),n._emitLine("var "+r+";")),i.push(r)})),e.value?(this._emit(i.join(" = ")+" = "),this._compileExpression(e.value,t),this._emitLine(";")):(this._emit(i.join(" = ")+" = "),this.compile(e.body,t),this._emitLine(";")),e.targets.forEach((function(e,t){var a=i[t],r=e.value;n._emitLine('frame.set("'+r+'", '+a+", true);"),n._emitLine("if(frame.topLevel) {"),n._emitLine('context.setVariable("'+r+'", '+a+");"),n._emitLine("}"),"_"!==r.charAt(0)&&(n._emitLine("if(frame.topLevel) {"),n._emitLine('context.addExport("'+r+'", '+a+");"),n._emitLine("}"))}))},r.compileSwitch=function(e,t){var n=this;this._emit("switch ("),this.compile(e.expr,t),this._emit(") {"),e.cases.forEach((function(e,i){n._emit("case "),n.compile(e.cond,t),n._emit(": "),n.compile(e.body,t),e.body.children.length&&n._emitLine("break;")})),e.default&&(this._emit("default:"),this.compile(e.default,t)),this._emit("}")},r.compileIf=function(e,t,n){var i=this;this._emit("if("),this._compileExpression(e.cond,t),this._emitLine(") {"),this._withScopedSyntax((function(){i.compile(e.body,t),n&&i._emit("cb()")})),e.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){i.compile(e.else_,t),n&&i._emit("cb()")}))):n&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},r.compileIfAsync=function(e,t){this._emit("(function(cb) {"),this.compileIf(e,t,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},r._emitLoopBindings=function(e,t,n,i){var a=this;[{name:"index",val:n+" + 1"},{name:"index0",val:n},{name:"revindex",val:i+" - "+n},{name:"revindex0",val:i+" - "+n+" - 1"},{name:"first",val:n+" === 0"},{name:"last",val:n+" === "+i+" - 1"},{name:"length",val:i}].forEach((function(e){a._emitLine('frame.set("loop.'+e.name+'", '+e.val+");")}))},r.compileFor=function(e,t){var n=this,i=this._tmpid(),a=this._tmpid(),r=this._tmpid();if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+r+" = "),this._compileExpression(e.arr,t),this._emitLine(";"),this._emit("if("+r+") {"),this._emitLine(r+" = runtime.fromIterator("+r+");"),e.name instanceof s.Array){this._emitLine("var "+i+";"),this._emitLine("if(runtime.isArray("+r+")) {"),this._emitLine("var "+a+" = "+r+".length;"),this._emitLine("for("+i+"=0; "+i+" < "+r+".length; "+i+"++) {"),e.name.children.forEach((function(a,s){var o=n._tmpid();n._emitLine("var "+o+" = "+r+"["+i+"]["+s+"];"),n._emitLine('frame.set("'+a+'", '+r+"["+i+"]["+s+"]);"),t.set(e.name.children[s].value,o)})),this._emitLoopBindings(e,r,i,a),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("} else {");var o=e.name.children,c=o[0],l=o[1],u=this._tmpid(),d=this._tmpid();t.set(c.value,u),t.set(l.value,d),this._emitLine(i+" = -1;"),this._emitLine("var "+a+" = runtime.keys("+r+").length;"),this._emitLine("for(var "+u+" in "+r+") {"),this._emitLine(i+"++;"),this._emitLine("var "+d+" = "+r+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+d+");"),this._emitLoopBindings(e,r,i,a),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();t.set(e.name.value,h),this._emitLine("var "+a+" = "+r+".length;"),this._emitLine("for(var "+i+"=0; "+i+" < "+r+".length; "+i+"++) {"),this._emitLine("var "+h+" = "+r+"["+i+"];"),this._emitLine('frame.set("'+e.name.value+'", '+h+");"),this._emitLoopBindings(e,r,i,a),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}")}this._emitLine("}"),e.else_&&(this._emitLine("if (!"+a+") {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r._compileAsyncLoop=function(e,t,n){var i=this,a=this._tmpid(),r=this._tmpid(),o=this._tmpid(),c=n?"asyncAll":"asyncEach";if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+o+" = runtime.fromIterator("),this._compileExpression(e.arr,t),this._emitLine(");"),e.name instanceof s.Array){var l=e.name.children.length;this._emit("runtime."+c+"("+o+", "+l+", function("),e.name.children.forEach((function(e){i._emit(e.value+",")})),this._emit(a+","+r+",next) {"),e.name.children.forEach((function(e){var n=e.value;t.set(n,n),i._emitLine('frame.set("'+n+'", '+n+");")}))}else{var u=e.name.value;this._emitLine("runtime."+c+"("+o+", 1, function("+u+", "+a+", "+r+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),t.set(u,u)}this._emitLoopBindings(e,o,a,r),this._withScopedSyntax((function(){var r;n&&(r=i._pushBuffer()),i.compile(e.body,t),i._emitLine("next("+a+(r?","+r:"")+");"),n&&i._popBuffer()}));var d=this._tmpid();this._emitLine("}, "+this._makeCallback(d)),this._addScopeLevel(),n&&this._emitLine(this.buffer+" += "+d+";"),e.else_&&(this._emitLine("if (!"+o+".length) {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r.compileAsyncEach=function(e,t){this._compileAsyncLoop(e,t)},r.compileAsyncAll=function(e,t){this._compileAsyncLoop(e,t,!0)},r._compileMacro=function(e,t){var n=this,i=[],a=null,r="macro_"+this._tmpid(),o=void 0!==t;e.args.children.forEach((function(t,r){r===e.args.children.length-1&&t instanceof s.Dict?a=t:(n.assertType(t,s.Symbol),i.push(t))}));var l,u=[].concat(i.map((function(e){return"l_"+e.value})),["kwargs"]),d=i.map((function(e){return'"'+e.value+'"'})),h=(a&&a.children||[]).map((function(e){return'"'+e.key.value+'"'}));l=o?t.push(!0):new c,this._emitLines("var "+r+" = runtime.makeMacro(","["+d.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(o?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),i.forEach((function(e){n._emitLine('frame.set("'+e.value+'", l_'+e.value+");"),l.set(e.value,"l_"+e.value)})),a&&a.children.forEach((function(e){var t=e.key.value;n._emit('frame.set("'+t+'", '),n._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+t+'")'),n._emit(' ? kwargs["'+t+'"] : '),n._compileExpression(e.value,l),n._emit(");")}));var p=this._pushBuffer();return this._withScopedSyntax((function(){n.compile(e.body,l)})),this._emitLine("frame = "+(o?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+p+");"),this._emitLine("});"),this._popBuffer(),r},r.compileMacro=function(e,t){var n=this._compileMacro(e),i=e.name.value;t.set(i,n),t.parent?this._emitLine('frame.set("'+i+'", '+n+");"):("_"!==e.name.value.charAt(0)&&this._emitLine('context.addExport("'+i+'");'),this._emitLine('context.setVariable("'+i+'", '+n+");"))},r.compileCaller=function(e,t){this._emit("(function (){");var n=this._compileMacro(e,t);this._emit("return "+n+";})()")},r._compileGetTemplate=function(e,t,n,i){var a=this._tmpid(),r=this._templateName(),s=this._makeCallback(a),o=n?"true":"false",c=i?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(e.template,t),this._emitLine(", "+o+", "+r+", "+c+", "+s),a},r.compileImport=function(e,t){var n=e.target.value,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),t.set(n,i),t.parent?this._emitLine('frame.set("'+n+'", '+i+");"):this._emitLine('context.setVariable("'+n+'", '+i+");")},r.compileFromImport=function(e,t){var n=this,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),e.names.children.forEach((function(e){var a,r,o=n._tmpid();e instanceof s.Pair?(a=e.key.value,r=e.value.value):r=a=e.value,n._emitLine("if(Object.prototype.hasOwnProperty.call("+i+', "'+a+'")) {'),n._emitLine("var "+o+" = "+i+"."+a+";"),n._emitLine("} else {"),n._emitLine("cb(new Error(\"cannot import '"+a+"'\")); return;"),n._emitLine("}"),t.set(r,o),t.parent?n._emitLine('frame.set("'+r+'", '+o+");"):n._emitLine('context.setVariable("'+r+'", '+o+");")}))},r.compileBlock=function(e){var t=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+e.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(t)),this._emitLine(this.buffer+" += "+t+";"),this._addScopeLevel()},r.compileSuper=function(e,t){var n=e.blockName.value,i=e.symbol.value,a=this._makeCallback(i);this._emitLine('context.getSuper(env, "'+n+'", b_'+n+", frame, runtime, "+a),this._emitLine(i+" = runtime.markSafe("+i+");"),this._addScopeLevel(),t.set(i,i)},r.compileExtends=function(e,t){var n=this._tmpid(),i=this._compileGetTemplate(e,t,!0,!1);this._emitLine("parentTemplate = "+i),this._emitLine("for(var "+n+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+n+", parentTemplate.blocks["+n+"]);"),this._emitLine("}"),this._addScopeLevel()},r.compileInclude=function(e,t){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var n=this._compileGetTemplate(e,t,!1,e.ignoreMissing);this._emitLine("callback(null,"+n+");});"),this._emitLine("});");var i=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(i)),this._emitLine("callback(null,"+i+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},r.compileTemplateData=function(e,t){this.compileLiteral(e,t)},r.compileCapture=function(e,t){var n=this,i=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=i},r.compileOutput=function(e,t){var n=this;e.children.forEach((function(i){i instanceof s.TemplateData?i.value&&(n._emit(n.buffer+" += "),n.compileLiteral(i,t),n._emitLine(";")):(n._emit(n.buffer+" += runtime.suppressValue("),n.throwOnUndefined&&n._emit("runtime.ensureDefined("),n.compile(i,t),n.throwOnUndefined&&n._emit(","+e.lineno+","+e.colno+")"),n._emit(", env.opts.autoescape);\n"))}))},r.compileRoot=function(e,t){var n=this;t&&this.fail("compileRoot: root node can't have frame"),t=new c,this._emitFuncBegin(e,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(e,t),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var i=[],a=e.findAll(s.Block);a.forEach((function(e,t){var a=e.name.value;if(-1!==i.indexOf(a))throw new Error('Block "'+a+'" defined more than once.');i.push(a),n._emitFuncBegin(e,"b_"+a);var r=new c;n._emitLine("var frame = frame.push(true);"),n.compile(e.body,r),n._emitFuncEnd()})),this._emitLine("return {"),a.forEach((function(e,t){var i="b_"+e.name.value;n._emitLine(i+": "+i+",")})),this._emitLine("root: root\n};")},r.compile=function(e,t){var n=this["compile"+e.typename];n?n.call(this,e,t):this.fail("compile: Cannot compile node: "+e.typename,e.lineno,e.colno)},r.getCode=function(){return this.codebuf.join("")},a}(l);e.exports={compile:function(e,t,n,i,s){void 0===s&&(s={});var o=new d(i,s.throwOnUndefined),c=(n||[]).map((function(e){return e.preprocess})).filter((function(e){return!!e})),l=c.reduce((function(e,t){return t(e)}),e);return o.compile(r.transform(a.parse(l,n,s),t,i)),o.getCode()},Compiler:d}},function(e,t,n){function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}var a=n(4),r=n(1).EmitterObj;e.exports=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n);var s=r.prototype;return s.resolve=function(e,t){return a.resolve(a.dirname(e),t)},s.isRelative=function(e){return 0===e.indexOf("./")||0===e.indexOf("../")},r}(r)},function(e,t,n){function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,a(e,t)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}var r=n(12),s=n(15),o=n(0),c=n(5),l=n(18),u=n(10),d=u.FileSystemLoader,h=u.WebLoader,p=u.PrecompiledLoader,m=n(20),f=n(21),g=n(1),_=g.Obj,v=g.EmitterObj,y=n(2),b=y.handleError,w=y.Frame,x=n(22);function M(e,t,n){r((function(){e(t,n)}))}var k={type:"code",obj:{root:function(e,t,n,i,a){try{a(null,"")}catch(e){a(b(e,null,null))}}}},C=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.init=function(e,t){var n=this;t=this.opts=t||{},this.opts.dev=!!t.dev,this.opts.autoescape=null==t.autoescape||t.autoescape,this.opts.throwOnUndefined=!!t.throwOnUndefined,this.opts.trimBlocks=!!t.trimBlocks,this.opts.lstripBlocks=!!t.lstripBlocks,this.loaders=[],e?this.loaders=o.isArray(e)?e:[e]:d?this.loaders=[new d("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new p(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],o._entries(l).forEach((function(e){var t=e[0],i=e[1];return n.addFilter(t,i)})),o._entries(m).forEach((function(e){var t=e[0],i=e[1];return n.addTest(t,i)}))},n._initLoaders=function(){var e=this;this.loaders.forEach((function(t){t.cache={},"function"==typeof t.on&&(t.on("update",(function(n,i){t.cache[n]=null,e.emit("update",n,i,t)})),t.on("load",(function(n,i){e.emit("load",n,i,t)})))}))},n.invalidateCache=function(){this.loaders.forEach((function(e){e.cache={}}))},n.addExtension=function(e,t){return t.__name=e,this.extensions[e]=t,this.extensionsList.push(t),this},n.removeExtension=function(e){var t=this.getExtension(e);t&&(this.extensionsList=o.without(this.extensionsList,t),delete this.extensions[e])},n.getExtension=function(e){return this.extensions[e]},n.hasExtension=function(e){return!!this.extensions[e]},n.addGlobal=function(e,t){return this.globals[e]=t,this},n.getGlobal=function(e){if(void 0===this.globals[e])throw new Error("global not found: "+e);return this.globals[e]},n.addFilter=function(e,t,n){var i=t;return n&&this.asyncFilters.push(e),this.filters[e]=i,this},n.getFilter=function(e){if(!this.filters[e])throw new Error("filter not found: "+e);return this.filters[e]},n.addTest=function(e,t){return this.tests[e]=t,this},n.getTest=function(e){if(!this.tests[e])throw new Error("test not found: "+e);return this.tests[e]},n.resolveTemplate=function(e,t,n){return e.isRelative&&t&&e.isRelative(n)&&e.resolve?e.resolve(t,n):n},n.getTemplate=function(e,t,n,i,a){var r,s=this,c=this,l=null;if(e&&e.raw&&(e=e.raw),o.isFunction(n)&&(a=n,n=null,t=t||!1),o.isFunction(t)&&(a=t,t=!1),e instanceof E)l=e;else{if("string"!=typeof e)throw new Error("template names must be a string: "+e);for(var u=0;u<this.loaders.length;u++){var d=this.loaders[u];if(l=d.cache[this.resolveTemplate(d,n,e)])break}}return l?(t&&l.compile(),a?void a(null,l):l):(o.asyncIter(this.loaders,(function(t,i,a,r){function s(e,n){e?r(e):n?(n.loader=t,r(null,n)):a()}e=c.resolveTemplate(t,n,e),t.async?t.getSource(e,s):s(null,t.getSource(e))}),(function(n,o){if(o||n||i||(n=new Error("template not found: "+e)),n){if(a)return void a(n);throw n}var c;o?(c=new E(o.src,s,o.path,t),o.noCache||(o.loader.cache[e]=c)):c=new E(k,s,"",t),a?a(null,c):r=c})),r)},n.express=function(e){return x(this,e)},n.render=function(e,t,n){o.isFunction(t)&&(n=t,t=null);var i=null;return this.getTemplate(e,(function(e,a){if(e&&n)M(n,e);else{if(e)throw e;i=a.render(t,n)}})),i},n.renderString=function(e,t,n,i){return o.isFunction(n)&&(i=n,n={}),new E(e,this,(n=n||{}).path).render(t,i)},n.waterfall=function(e,t,n){return s(e,t,n)},t}(v),S=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.init=function(e,t,n){var i=this;this.env=n||new C,this.ctx=o.extend({},e),this.blocks={},this.exported=[],o.keys(t).forEach((function(e){i.addBlock(e,t[e])}))},n.lookup=function(e){return e in this.env.globals&&!(e in this.ctx)?this.env.globals[e]:this.ctx[e]},n.setVariable=function(e,t){this.ctx[e]=t},n.getVariables=function(){return this.ctx},n.addBlock=function(e,t){return this.blocks[e]=this.blocks[e]||[],this.blocks[e].push(t),this},n.getBlock=function(e){if(!this.blocks[e])throw new Error('unknown block "'+e+'"');return this.blocks[e][0]},n.getSuper=function(e,t,n,i,a,r){var s=o.indexOf(this.blocks[t]||[],n),c=this.blocks[t][s+1];if(-1===s||!c)throw new Error('no super block available for "'+t+'"');c(e,this,i,a,r)},n.addExport=function(e){this.exported.push(e)},n.getExported=function(){var e=this,t={};return this.exported.forEach((function(n){t[n]=e.ctx[n]})),t},t}(_),E=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.init=function(e,t,n,i){if(this.env=t||new C,o.isObject(e))switch(e.type){case"code":this.tmplProps=e.obj;break;case"string":this.tmplStr=e.obj;break;default:throw new Error("Unexpected template object type "+e.type+"; expected 'code', or 'string'")}else{if(!o.isString(e))throw new Error("src must be a string or an object describing the source");this.tmplStr=e}if(this.path=n,i)try{this._compile()}catch(e){throw o._prettifyError(this.path,this.env.opts.dev,e)}else this.compiled=!1},n.render=function(e,t,n){var i=this;"function"==typeof e?(n=e,e={}):"function"==typeof t&&(n=t,t=null);var a=!t;try{this.compile()}catch(e){var r=o._prettifyError(this.path,this.env.opts.dev,e);if(n)return M(n,r);throw r}var s=new S(e||{},this.blocks,this.env),c=t?t.push(!0):new w;c.topLevel=!0;var l=null,u=!1;return this.rootRenderFunc(this.env,s,c,y,(function(e,t){if(!u||!n||void 0===t)if(e&&(e=o._prettifyError(i.path,i.env.opts.dev,e),u=!0),n)a?M(n,e,t):n(e,t);else{if(e)throw e;l=t}})),l},n.getExported=function(e,t,n){"function"==typeof e&&(n=e,e={}),"function"==typeof t&&(n=t,t=null);try{this.compile()}catch(e){if(n)return n(e);throw e}var i=t?t.push():new w;i.topLevel=!0;var a=new S(e||{},this.blocks,this.env);this.rootRenderFunc(this.env,a,i,y,(function(e){e?n(e,null):n(null,a.getExported())}))},n.compile=function(){this.compiled||this._compile()},n._compile=function(){var e;if(this.tmplProps)e=this.tmplProps;else{var t=c.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts);e=new Function(t)()}this.blocks=this._getBlocks(e),this.rootRenderFunc=e.root,this.compiled=!0},n._getBlocks=function(e){var t={};return o.keys(e).forEach((function(n){"b_"===n.slice(0,2)&&(t[n.slice(2)]=e[n])})),t},t}(_);e.exports={Environment:C,Template:E}},function(e,t,n){function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}var a=n(9),r=n(3),s=n(1).Obj,o=n(0),c=function(e){var t,n;function s(){return e.apply(this,arguments)||this}n=e,(t=s).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n);var c=s.prototype;return c.init=function(e){this.tokens=e,this.peeked=null,this.breakOnBlocks=null,this.dropLeadingWhitespace=!1,this.extensions=[]},c.nextToken=function(e){var t;if(this.peeked){if(e||this.peeked.type!==a.TOKEN_WHITESPACE)return t=this.peeked,this.peeked=null,t;this.peeked=null}if(t=this.tokens.nextToken(),!e)for(;t&&t.type===a.TOKEN_WHITESPACE;)t=this.tokens.nextToken();return t},c.peekToken=function(){return this.peeked=this.peeked||this.nextToken(),this.peeked},c.pushToken=function(e){if(this.peeked)throw new Error("pushToken: can only push one token on between reads");this.peeked=e},c.error=function(e,t,n){if(void 0===t||void 0===n){var i=this.peekToken()||{};t=i.lineno,n=i.colno}return void 0!==t&&(t+=1),void 0!==n&&(n+=1),new o.TemplateError(e,t,n)},c.fail=function(e,t,n){throw this.error(e,t,n)},c.skip=function(e){var t=this.nextToken();return!(!t||t.type!==e)||(this.pushToken(t),!1)},c.expect=function(e){var t=this.nextToken();return t.type!==e&&this.fail("expected "+e+", got "+t.type,t.lineno,t.colno),t},c.skipValue=function(e,t){var n=this.nextToken();return!(!n||n.type!==e||n.value!==t)||(this.pushToken(n),!1)},c.skipSymbol=function(e){return this.skipValue(a.TOKEN_SYMBOL,e)},c.advanceAfterBlockEnd=function(e){var t;return e||((t=this.peekToken())||this.fail("unexpected end of file"),t.type!==a.TOKEN_SYMBOL&&this.fail("advanceAfterBlockEnd: expected symbol token or explicit name to be passed"),e=this.nextToken().value),(t=this.nextToken())&&t.type===a.TOKEN_BLOCK_END?"-"===t.value.charAt(0)&&(this.dropLeadingWhitespace=!0):this.fail("expected block end in "+e+" statement"),t},c.advanceAfterVariableEnd=function(){var e=this.nextToken();e&&e.type===a.TOKEN_VARIABLE_END?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.VARIABLE_END.length-1):(this.pushToken(e),this.fail("expected variable end"))},c.parseFor=function(){var e,t,n=this.peekToken();if(this.skipSymbol("for")?(e=new r.For(n.lineno,n.colno),t="endfor"):this.skipSymbol("asyncEach")?(e=new r.AsyncEach(n.lineno,n.colno),t="endeach"):this.skipSymbol("asyncAll")?(e=new r.AsyncAll(n.lineno,n.colno),t="endall"):this.fail("parseFor: expected for{Async}",n.lineno,n.colno),e.name=this.parsePrimary(),e.name instanceof r.Symbol||this.fail("parseFor: variable name expected for loop"),this.peekToken().type===a.TOKEN_COMMA){var i=e.name;for(e.name=new r.Array(i.lineno,i.colno),e.name.addChild(i);this.skip(a.TOKEN_COMMA);){var s=this.parsePrimary();e.name.addChild(s)}}return this.skipSymbol("in")||this.fail('parseFor: expected "in" keyword for loop',n.lineno,n.colno),e.arr=this.parseExpression(),this.advanceAfterBlockEnd(n.value),e.body=this.parseUntilBlocks(t,"else"),this.skipSymbol("else")&&(this.advanceAfterBlockEnd("else"),e.else_=this.parseUntilBlocks(t)),this.advanceAfterBlockEnd(),e},c.parseMacro=function(){var e=this.peekToken();this.skipSymbol("macro")||this.fail("expected macro");var t=this.parsePrimary(!0),n=this.parseSignature(),i=new r.Macro(e.lineno,e.colno,t,n);return this.advanceAfterBlockEnd(e.value),i.body=this.parseUntilBlocks("endmacro"),this.advanceAfterBlockEnd(),i},c.parseCall=function(){var e=this.peekToken();this.skipSymbol("call")||this.fail("expected call");var t=this.parseSignature(!0)||new r.NodeList,n=this.parsePrimary();this.advanceAfterBlockEnd(e.value);var i=this.parseUntilBlocks("endcall");this.advanceAfterBlockEnd();var a=new r.Symbol(e.lineno,e.colno,"caller"),s=new r.Caller(e.lineno,e.colno,a,t,i),o=n.args.children;return o[o.length-1]instanceof r.KeywordArgs||o.push(new r.KeywordArgs),o[o.length-1].addChild(new r.Pair(e.lineno,e.colno,a,s)),new r.Output(e.lineno,e.colno,[n])},c.parseWithContext=function(){var e=this.peekToken(),t=null;return this.skipSymbol("with")?t=!0:this.skipSymbol("without")&&(t=!1),null!==t&&(this.skipSymbol("context")||this.fail("parseFrom: expected context after with/without",e.lineno,e.colno)),t},c.parseImport=function(){var e=this.peekToken();this.skipSymbol("import")||this.fail("parseImport: expected import",e.lineno,e.colno);var t=this.parseExpression();this.skipSymbol("as")||this.fail('parseImport: expected "as" keyword',e.lineno,e.colno);var n=this.parseExpression(),i=this.parseWithContext(),a=new r.Import(e.lineno,e.colno,t,n,i);return this.advanceAfterBlockEnd(e.value),a},c.parseFrom=function(){var e=this.peekToken();this.skipSymbol("from")||this.fail("parseFrom: expected from");var t=this.parseExpression();this.skipSymbol("import")||this.fail("parseFrom: expected import",e.lineno,e.colno);for(var n,i=new r.NodeList;;){var s=this.peekToken();if(s.type===a.TOKEN_BLOCK_END){i.children.length||this.fail("parseFrom: Expected at least one import name",e.lineno,e.colno),"-"===s.value.charAt(0)&&(this.dropLeadingWhitespace=!0),this.nextToken();break}i.children.length>0&&!this.skip(a.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",e.lineno,e.colno);var o=this.parsePrimary();if("_"===o.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",o.lineno,o.colno),this.skipSymbol("as")){var c=this.parsePrimary();i.addChild(new r.Pair(o.lineno,o.colno,o,c))}else i.addChild(o);n=this.parseWithContext()}return new r.FromImport(e.lineno,e.colno,t,i,n)},c.parseBlock=function(){var e=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",e.lineno,e.colno);var t=new r.Block(e.lineno,e.colno);t.name=this.parsePrimary(),t.name instanceof r.Symbol||this.fail("parseBlock: variable name expected",e.lineno,e.colno),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(t.name.value);var n=this.peekToken();return n||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(n.value),t},c.parseExtends=function(){var e="extends",t=this.peekToken();this.skipSymbol(e)||this.fail("parseTemplateRef: expected "+e);var n=new r.Extends(t.lineno,t.colno);return n.template=this.parseExpression(),this.advanceAfterBlockEnd(t.value),n},c.parseInclude=function(){var e="include",t=this.peekToken();this.skipSymbol(e)||this.fail("parseInclude: expected "+e);var n=new r.Include(t.lineno,t.colno);return n.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(n.ignoreMissing=!0),this.advanceAfterBlockEnd(t.value),n},c.parseIf=function(){var e,t=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?e=new r.If(t.lineno,t.colno):this.skipSymbol("ifAsync")?e=new r.IfAsync(t.lineno,t.colno):this.fail("parseIf: expected if, elif, or elseif",t.lineno,t.colno),e.cond=this.parseExpression(),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("elif","elseif","else","endif");var n=this.peekToken();switch(n&&n.value){case"elseif":case"elif":e.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),e.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":e.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return e},c.parseSet=function(){var e=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",e.lineno,e.colno);for(var t,n=new r.Set(e.lineno,e.colno,[]);(t=this.parsePrimary())&&(n.targets.push(t),this.skip(a.TOKEN_COMMA)););return this.skipValue(a.TOKEN_OPERATOR,"=")?(n.value=this.parseExpression(),this.advanceAfterBlockEnd(e.value)):this.skip(a.TOKEN_BLOCK_END)?(n.body=new r.Capture(e.lineno,e.colno,this.parseUntilBlocks("endset")),n.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",e.lineno,e.colno),n},c.parseSwitch=function(){var e="switch",t="endswitch",n="case",i="default",a=this.peekToken();this.skipSymbol(e)||this.skipSymbol(n)||this.skipSymbol(i)||this.fail('parseSwitch: expected "switch," "case" or "default"',a.lineno,a.colno);var s=this.parseExpression();this.advanceAfterBlockEnd(e),this.parseUntilBlocks(n,i,t);var o,c=this.peekToken(),l=[];do{this.skipSymbol(n);var u=this.parseExpression();this.advanceAfterBlockEnd(e);var d=this.parseUntilBlocks(n,i,t);l.push(new r.Case(c.line,c.col,u,d)),c=this.peekToken()}while(c&&c.value===n);switch(c.value){case i:this.advanceAfterBlockEnd(),o=this.parseUntilBlocks(t),this.advanceAfterBlockEnd();break;case t:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new r.Switch(a.lineno,a.colno,s,l,o)},c.parseStatement=function(){var e=this.peekToken();if(e.type!==a.TOKEN_SYMBOL&&this.fail("tag name expected",e.lineno,e.colno),this.breakOnBlocks&&-1!==o.indexOf(this.breakOnBlocks,e.value))return null;switch(e.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var t=0;t<this.extensions.length;t++){var n=this.extensions[t];if(-1!==o.indexOf(n.tags||[],e.value))return n.parse(this,r,a)}this.fail("unknown block tag: "+e.value,e.lineno,e.colno)}},c.parseRaw=function(e){for(var t="end"+(e=e||"raw"),n=new RegExp("([\\s\\S]*?){%\\s*("+e+"|"+t+")\\s*(?=%})%}"),i=1,a="",s=null,o=this.advanceAfterBlockEnd();(s=this.tokens._extractRegex(n))&&i>0;){var c=s[0],l=s[1],u=s[2];u===e?i+=1:u===t&&(i-=1),0===i?(a+=l,this.tokens.backN(c.length-l.length)):a+=c}return new r.Output(o.lineno,o.colno,[new r.TemplateData(o.lineno,o.colno,a)])},c.parsePostfix=function(e){for(var t,n=this.peekToken();n;){if(n.type===a.TOKEN_LEFT_PAREN)e=new r.FunCall(n.lineno,n.colno,e,this.parseSignature());else if(n.type===a.TOKEN_LEFT_BRACKET)(t=this.parseAggregate()).children.length>1&&this.fail("invalid index"),e=new r.LookupVal(n.lineno,n.colno,e,t.children[0]);else{if(n.type!==a.TOKEN_OPERATOR||"."!==n.value)break;this.nextToken();var i=this.nextToken();i.type!==a.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+i.value,i.lineno,i.colno),t=new r.Literal(i.lineno,i.colno,i.value),e=new r.LookupVal(n.lineno,n.colno,e,t)}n=this.peekToken()}return e},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var e=this.parseOr();if(this.skipSymbol("if")){var t=this.parseOr(),n=e;(e=new r.InlineIf(e.lineno,e.colno)).body=n,e.cond=t,this.skipSymbol("else")?e.else_=this.parseOr():e.else_=null}return e},c.parseOr=function(){for(var e=this.parseAnd();this.skipSymbol("or");){var t=this.parseAnd();e=new r.Or(e.lineno,e.colno,e,t)}return e},c.parseAnd=function(){for(var e=this.parseNot();this.skipSymbol("and");){var t=this.parseNot();e=new r.And(e.lineno,e.colno,e,t)}return e},c.parseNot=function(){var e=this.peekToken();return this.skipSymbol("not")?new r.Not(e.lineno,e.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var e=this.parseIs();;){var t=this.nextToken();if(!t)break;var n=t.type===a.TOKEN_SYMBOL&&"not"===t.value;if(n||this.pushToken(t),!this.skipSymbol("in")){n&&this.pushToken(t);break}var i=this.parseIs();e=new r.In(e.lineno,e.colno,e,i),n&&(e=new r.Not(e.lineno,e.colno,e))}return e},c.parseIs=function(){var e=this.parseCompare();if(this.skipSymbol("is")){var t=this.skipSymbol("not"),n=this.parseCompare();e=new r.Is(e.lineno,e.colno,e,n),t&&(e=new r.Not(e.lineno,e.colno,e))}return e},c.parseCompare=function(){for(var e=["==","===","!=","!==","<",">","<=",">="],t=this.parseConcat(),n=[];;){var i=this.nextToken();if(!i)break;if(-1===e.indexOf(i.value)){this.pushToken(i);break}n.push(new r.CompareOperand(i.lineno,i.colno,this.parseConcat(),i.value))}return n.length?new r.Compare(n[0].lineno,n[0].colno,t,n):t},c.parseConcat=function(){for(var e=this.parseAdd();this.skipValue(a.TOKEN_TILDE,"~");){var t=this.parseAdd();e=new r.Concat(e.lineno,e.colno,e,t)}return e},c.parseAdd=function(){for(var e=this.parseSub();this.skipValue(a.TOKEN_OPERATOR,"+");){var t=this.parseSub();e=new r.Add(e.lineno,e.colno,e,t)}return e},c.parseSub=function(){for(var e=this.parseMul();this.skipValue(a.TOKEN_OPERATOR,"-");){var t=this.parseMul();e=new r.Sub(e.lineno,e.colno,e,t)}return e},c.parseMul=function(){for(var e=this.parseDiv();this.skipValue(a.TOKEN_OPERATOR,"*");){var t=this.parseDiv();e=new r.Mul(e.lineno,e.colno,e,t)}return e},c.parseDiv=function(){for(var e=this.parseFloorDiv();this.skipValue(a.TOKEN_OPERATOR,"/");){var t=this.parseFloorDiv();e=new r.Div(e.lineno,e.colno,e,t)}return e},c.parseFloorDiv=function(){for(var e=this.parseMod();this.skipValue(a.TOKEN_OPERATOR,"//");){var t=this.parseMod();e=new r.FloorDiv(e.lineno,e.colno,e,t)}return e},c.parseMod=function(){for(var e=this.parsePow();this.skipValue(a.TOKEN_OPERATOR,"%");){var t=this.parsePow();e=new r.Mod(e.lineno,e.colno,e,t)}return e},c.parsePow=function(){for(var e=this.parseUnary();this.skipValue(a.TOKEN_OPERATOR,"**");){var t=this.parseUnary();e=new r.Pow(e.lineno,e.colno,e,t)}return e},c.parseUnary=function(e){var t,n=this.peekToken();return t=this.skipValue(a.TOKEN_OPERATOR,"-")?new r.Neg(n.lineno,n.colno,this.parseUnary(!0)):this.skipValue(a.TOKEN_OPERATOR,"+")?new r.Pos(n.lineno,n.colno,this.parseUnary(!0)):this.parsePrimary(),e||(t=this.parseFilter(t)),t},c.parsePrimary=function(e){var t,n=this.nextToken(),i=null;if(n?n.type===a.TOKEN_STRING?t=n.value:n.type===a.TOKEN_INT?t=parseInt(n.value,10):n.type===a.TOKEN_FLOAT?t=parseFloat(n.value):n.type===a.TOKEN_BOOLEAN?"true"===n.value?t=!0:"false"===n.value?t=!1:this.fail("invalid boolean: "+n.value,n.lineno,n.colno):n.type===a.TOKEN_NONE?t=null:n.type===a.TOKEN_REGEX&&(t=new RegExp(n.value.body,n.value.flags)):this.fail("expected expression, got end of file"),void 0!==t?i=new r.Literal(n.lineno,n.colno,t):n.type===a.TOKEN_SYMBOL?i=new r.Symbol(n.lineno,n.colno,n.value):(this.pushToken(n),i=this.parseAggregate()),e||(i=this.parsePostfix(i)),i)return i;throw this.error("unexpected token: "+n.value,n.lineno,n.colno)},c.parseFilterName=function(){for(var e=this.expect(a.TOKEN_SYMBOL),t=e.value;this.skipValue(a.TOKEN_OPERATOR,".");)t+="."+this.expect(a.TOKEN_SYMBOL).value;return new r.Symbol(e.lineno,e.colno,t)},c.parseFilterArgs=function(e){return this.peekToken().type===a.TOKEN_LEFT_PAREN?this.parsePostfix(e).args.children:[]},c.parseFilter=function(e){for(;this.skip(a.TOKEN_PIPE);){var t=this.parseFilterName();e=new r.Filter(t.lineno,t.colno,t,new r.NodeList(t.lineno,t.colno,[e].concat(this.parseFilterArgs(e))))}return e},c.parseFilterStatement=function(){var e=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var t=this.parseFilterName(),n=this.parseFilterArgs(t);this.advanceAfterBlockEnd(e.value);var i=new r.Capture(t.lineno,t.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var a=new r.Filter(t.lineno,t.colno,t,new r.NodeList(t.lineno,t.colno,[i].concat(n)));return new r.Output(t.lineno,t.colno,[a])},c.parseAggregate=function(){var e,t=this.nextToken();switch(t.type){case a.TOKEN_LEFT_PAREN:e=new r.Group(t.lineno,t.colno);break;case a.TOKEN_LEFT_BRACKET:e=new r.Array(t.lineno,t.colno);break;case a.TOKEN_LEFT_CURLY:e=new r.Dict(t.lineno,t.colno);break;default:return null}for(;;){var n=this.peekToken().type;if(n===a.TOKEN_RIGHT_PAREN||n===a.TOKEN_RIGHT_BRACKET||n===a.TOKEN_RIGHT_CURLY){this.nextToken();break}if(e.children.length>0&&(this.skip(a.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",t.lineno,t.colno)),e instanceof r.Dict){var i=this.parsePrimary();this.skip(a.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",t.lineno,t.colno);var s=this.parseExpression();e.addChild(new r.Pair(i.lineno,i.colno,i,s))}else{var o=this.parseExpression();e.addChild(o)}}return e},c.parseSignature=function(e,t){var n=this.peekToken();if(!t&&n.type!==a.TOKEN_LEFT_PAREN){if(e)return null;this.fail("expected arguments",n.lineno,n.colno)}n.type===a.TOKEN_LEFT_PAREN&&(n=this.nextToken());for(var i=new r.NodeList(n.lineno,n.colno),s=new r.KeywordArgs(n.lineno,n.colno),o=!1;;){if(n=this.peekToken(),!t&&n.type===a.TOKEN_RIGHT_PAREN){this.nextToken();break}if(t&&n.type===a.TOKEN_BLOCK_END)break;if(o&&!this.skip(a.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",n.lineno,n.colno);else{var c=this.parseExpression();this.skipValue(a.TOKEN_OPERATOR,"=")?s.addChild(new r.Pair(c.lineno,c.colno,c,this.parseExpression())):i.addChild(c)}o=!0}return s.children.length&&i.addChild(s),i},c.parseUntilBlocks=function(){for(var e=this.breakOnBlocks,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];this.breakOnBlocks=n;var a=this.parse();return this.breakOnBlocks=e,a},c.parseNodes=function(){for(var e,t=[];e=this.nextToken();)if(e.type===a.TOKEN_DATA){var n=e.value,i=this.peekToken(),s=i&&i.value;this.dropLeadingWhitespace&&(n=n.replace(/^\s*/,""),this.dropLeadingWhitespace=!1),i&&(i.type===a.TOKEN_BLOCK_START&&"-"===s.charAt(s.length-1)||i.type===a.TOKEN_VARIABLE_START&&"-"===s.charAt(this.tokens.tags.VARIABLE_START.length)||i.type===a.TOKEN_COMMENT&&"-"===s.charAt(this.tokens.tags.COMMENT_START.length))&&(n=n.replace(/\s*$/,"")),t.push(new r.Output(e.lineno,e.colno,[new r.TemplateData(e.lineno,e.colno,n)]))}else if(e.type===a.TOKEN_BLOCK_START){this.dropLeadingWhitespace=!1;var o=this.parseStatement();if(!o)break;t.push(o)}else if(e.type===a.TOKEN_VARIABLE_START){var c=this.parseExpression();this.dropLeadingWhitespace=!1,this.advanceAfterVariableEnd(),t.push(new r.Output(e.lineno,e.colno,[c]))}else e.type===a.TOKEN_COMMENT?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.COMMENT_END.length-1):this.fail("Unexpected token at top-level: "+e.type,e.lineno,e.colno);return t},c.parse=function(){return new r.NodeList(0,0,this.parseNodes())},c.parseAsRoot=function(){return new r.Root(0,0,this.parseNodes())},s}(s);e.exports={parse:function(e,t,n){var i=new c(a.lex(e,n));return void 0!==t&&(i.extensions=t),i.parseAsRoot()},Parser:c}},function(e,t,n){var i=n(0),a=" \n\t\r ",r="()[]{}%*-+~/#,:|.<>=!",s="string",o="whitespace",c="data",l="block-start",u="block-end",d="variable-start",h="variable-end",p="comment",m="left-paren",f="right-paren",g="left-bracket",_="right-bracket",v="left-curly",y="right-curly",b="operator",w="comma",x="colon",M="tilde",k="pipe",C="float",S="boolean",E="none",A="symbol",T="regex";function $(e,t,n,i){return{type:e,value:t,lineno:n,colno:i}}var I=function(){function e(e,t){this.str=e,this.index=0,this.len=e.length,this.lineno=0,this.colno=0,this.in_code=!1;var n=(t=t||{}).tags||{};this.tags={BLOCK_START:n.blockStart||"{%",BLOCK_END:n.blockEnd||"%}",VARIABLE_START:n.variableStart||"{{",VARIABLE_END:n.variableEnd||"}}",COMMENT_START:n.commentStart||"{#",COMMENT_END:n.commentEnd||"#}"},this.trimBlocks=!!t.trimBlocks,this.lstripBlocks=!!t.lstripBlocks}var t=e.prototype;return t.nextToken=function(){var e,t=this.lineno,n=this.colno;if(this.in_code){var I=this.current();if(this.isFinished())return null;if('"'===I||"'"===I)return $(s,this._parseString(I),t,n);if(e=this._extract(a))return $(o,e,t,n);if((e=this._extractString(this.tags.BLOCK_END))||(e=this._extractString("-"+this.tags.BLOCK_END)))return this.in_code=!1,this.trimBlocks&&("\n"===(I=this.current())?this.forward():"\r"===I&&(this.forward(),"\n"===(I=this.current())?this.forward():this.back())),$(u,e,t,n);if((e=this._extractString(this.tags.VARIABLE_END))||(e=this._extractString("-"+this.tags.VARIABLE_END)))return this.in_code=!1,$(h,e,t,n);if("r"===I&&"/"===this.str.charAt(this.index+1)){this.forwardN(2);for(var O="";!this.isFinished();){if("/"===this.current()&&"\\"!==this.previous()){this.forward();break}O+=this.current(),this.forward()}for(var L=["g","i","m","y"],D="";!this.isFinished()&&-1!==L.indexOf(this.current());)D+=this.current(),this.forward();return $(T,{body:O,flags:D},t,n)}if(-1!==r.indexOf(I)){this.forward();var j,z=["==","===","!=","!==","<=",">=","//","**"],P=I+this.current();switch(-1!==i.indexOf(z,P)&&(this.forward(),I=P,-1!==i.indexOf(z,P+this.current())&&(I=P+this.current(),this.forward())),I){case"(":j=m;break;case")":j=f;break;case"[":j=g;break;case"]":j=_;break;case"{":j=v;break;case"}":j=y;break;case",":j=w;break;case":":j=x;break;case"~":j=M;break;case"|":j=k;break;default:j=b}return $(j,I,t,n)}if((e=this._extractUntil(a+r)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var R=this._extract("0123456789");return $(C,e+"."+R,t,n)}return $("int",e,t,n)}if(e.match(/^(true|false)$/))return $(S,e,t,n);if("none"===e)return $(E,e,t,n);if("null"===e)return $(E,e,t,n);if(e)return $(A,e,t,n);throw new Error("Unexpected value while parsing: "+e)}var N,F=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((e=this._extractString(this.tags.BLOCK_START+"-"))||(e=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,$(l,e,t,n);if((e=this._extractString(this.tags.VARIABLE_START+"-"))||(e=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,$(d,e,t,n);e="";var B=!1;for(this._matches(this.tags.COMMENT_START)&&(B=!0,e=this._extractString(this.tags.COMMENT_START));null!==(N=this._extractUntil(F));){if(e+=N,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!B){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=e.length){var V=e.slice(-this.colno);if(/^\s+$/.test(V)&&!(e=e.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!B)throw new Error("unexpected end of comment");e+=this._extractString(this.tags.COMMENT_END);break}e+=this.current(),this.forward()}if(null===N&&B)throw new Error("expected end of comment, got end of file");return $(B?p:c,e,t,n)},t._parseString=function(e){this.forward();for(var t="";!this.isFinished()&&this.current()!==e;){var n=this.current();if("\\"===n){switch(this.forward(),this.current()){case"n":t+="\n";break;case"t":t+="\t";break;case"r":t+="\r";break;default:t+=this.current()}this.forward()}else t+=n,this.forward()}return this.forward(),t},t._matches=function(e){return this.index+e.length>this.len?null:this.str.slice(this.index,this.index+e.length)===e},t._extractString=function(e){return this._matches(e)?(this.forwardN(e.length),e):null},t._extractUntil=function(e){return this._extractMatching(!0,e||"")},t._extract=function(e){return this._extractMatching(!1,e)},t._extractMatching=function(e,t){if(this.isFinished())return null;var n=t.indexOf(this.current());if(e&&-1===n||!e&&-1!==n){var i=this.current();this.forward();for(var a=t.indexOf(this.current());(e&&-1===a||!e&&-1!==a)&&!this.isFinished();)i+=this.current(),this.forward(),a=t.indexOf(this.current());return i}return""},t._extractRegex=function(e){var t=this.currentStr().match(e);return t?(this.forwardN(t[0].length),t):null},t.isFinished=function(){return this.index>=this.len},t.forwardN=function(e){for(var t=0;t<e;t++)this.forward()},t.forward=function(){this.index++,"\n"===this.previous()?(this.lineno++,this.colno=0):this.colno++},t.backN=function(e){for(var t=0;t<e;t++)this.back()},t.back=function(){if(this.index--,"\n"===this.current()){this.lineno--;var e=this.src.lastIndexOf("\n",this.index-1);this.colno=-1===e?this.index:this.index-e}else this.colno--},t.current=function(){return this.isFinished()?"":this.str.charAt(this.index)},t.currentStr=function(){return this.isFinished()?"":this.str.substr(this.index)},t.previous=function(){return this.str.charAt(this.index-1)},e}();e.exports={lex:function(e,t){return new I(e,t)},TOKEN_STRING:s,TOKEN_WHITESPACE:o,TOKEN_DATA:c,TOKEN_BLOCK_START:l,TOKEN_BLOCK_END:u,TOKEN_VARIABLE_START:d,TOKEN_VARIABLE_END:h,TOKEN_COMMENT:p,TOKEN_LEFT_PAREN:m,TOKEN_RIGHT_PAREN:f,TOKEN_LEFT_BRACKET:g,TOKEN_RIGHT_BRACKET:_,TOKEN_LEFT_CURLY:v,TOKEN_RIGHT_CURLY:y,TOKEN_OPERATOR:b,TOKEN_COMMA:w,TOKEN_COLON:x,TOKEN_TILDE:M,TOKEN_PIPE:k,TOKEN_INT:"int",TOKEN_FLOAT:C,TOKEN_BOOLEAN:S,TOKEN_NONE:E,TOKEN_SYMBOL:A,TOKEN_SPECIAL:"special",TOKEN_REGEX:T}},function(e,t,n){function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}var a=n(6),r=n(19).PrecompiledLoader,s=function(e){var t,n;function a(t,n){var i;return(i=e.call(this)||this).baseURL=t||".",n=n||{},i.useCache=!!n.useCache,i.async=!!n.async,i}n=e,(t=a).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n);var r=a.prototype;return r.resolve=function(e,t){throw new Error("relative templates not support in the browser yet")},r.getSource=function(e,t){var n,i=this,a=this.useCache;return this.fetch(this.baseURL+"/"+e,(function(r,s){if(r)if(t)t(r.content);else{if(404!==r.status)throw r.content;n=null}else n={src:s,path:e,noCache:!a},i.emit("load",e,n),t&&t(null,n)})),n},r.fetch=function(e,t){if("undefined"==typeof window)throw new Error("WebLoader can only by used in a browser");var n=new XMLHttpRequest,i=!0;n.onreadystatechange=function(){4===n.readyState&&i&&(i=!1,0===n.status||200===n.status?t(null,n.responseText):t({status:n.status,content:n.responseText}))},e+=(-1===e.indexOf("?")?"?":"&")+"s="+(new Date).getTime(),n.open("GET",e,this.async),n.send()},a}(a);e.exports={WebLoader:s,PrecompiledLoader:r}},function(e,t,n){var i,a=n(0),r=n(7),s=r.Environment,o=r.Template,c=n(6),l=n(10),u=n(23),d=n(5),h=n(8),p=n(9),m=n(2),f=n(3),g=n(25);function _(e,t){var n;return t=t||{},a.isObject(e)&&(t=e,e=null),l.FileSystemLoader?n=new l.FileSystemLoader(e,{watch:t.watch,noCache:t.noCache}):l.WebLoader&&(n=new l.WebLoader(e,{useCache:t.web&&t.web.useCache,async:t.web&&t.web.async})),i=new s(n,t),t&&t.express&&i.express(t.express),i}e.exports={Environment:s,Template:o,Loader:c,FileSystemLoader:l.FileSystemLoader,NodeResolveLoader:l.NodeResolveLoader,PrecompiledLoader:l.PrecompiledLoader,WebLoader:l.WebLoader,compiler:d,parser:h,lexer:p,runtime:m,lib:a,nodes:f,installJinjaCompat:g,configure:_,reset:function(){i=void 0},compile:function(e,t,n,a){return i||_(),new o(e,t,n,a)},render:function(e,t,n){return i||_(),i.render(e,t,n)},renderString:function(e,t,n){return i||_(),i.renderString(e,t,n)},precompile:u?u.precompile:void 0,precompileString:u?u.precompileString:void 0}},function(e,t,n){var i=n(13),a=[],r=[],s=i.makeRequestCallFromTimer((function(){if(r.length)throw r.shift()}));function o(e){var t;(t=a.length?a.pop():new c).task=e,i(t)}function c(){this.task=null}e.exports=o,c.prototype.call=function(){try{this.task.call()}catch(e){o.onerror?o.onerror(e):(r.push(e),s())}finally{this.task=null,a[a.length]=this}}},function(e,t,n){(function(t){function n(e){a.length||i(),a[a.length]=e}e.exports=n;var i,a=[],r=0;function s(){for(;r<a.length;){var e=r;if(r+=1,a[e].call(),r>1024){for(var t=0,n=a.length-r;t<n;t++)a[t]=a[t+r];a.length-=r,r=0}}a.length=0,r=0}var o,c,l,u=void 0!==t?t:self,d=u.MutationObserver||u.WebKitMutationObserver;function h(e){return function(){var t=setTimeout(i,0),n=setInterval(i,50);function i(){clearTimeout(t),clearInterval(n),e()}}}"function"==typeof d?(o=1,c=new d(s),l=document.createTextNode(""),c.observe(l,{characterData:!0}),i=function(){o=-o,l.data=o}):i=h(s),n.requestFlush=i,n.makeRequestCallFromTimer=h}).call(t,n(14))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var i,a,r,s,o;a=function(){var e=Array.prototype.slice.call(arguments);"function"==typeof e[0]&&e[0].apply(null,e.splice(1))},r=function(e){"function"==typeof setImmediate?setImmediate(e):"undefined"!=typeof process&&process.nextTick?process.nextTick(e):setTimeout(e,0)},s=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=function(e,t,n){var i=n?r:a;if(t=t||function(){},!s(e)){var o=new Error("First argument to waterfall must be an array of functions");return t(o)}if(!e.length)return t();var c=function(e){return function(n){if(n)t.apply(null,arguments),t=function(){};else{var a=Array.prototype.slice.call(arguments,1),r=e.next();r?a.push(c(r)):a.push(t),i((function(){e.apply(null,a)}))}}};c(function(e){var t=function(n){var i=function(){return e.length&&e[n].apply(null,arguments),i.next()};return i.next=function(){return n<e.length-1?t(n+1):null},i};return t(0)}(e))()},void 0===(i=function(){return o}.apply(t,[]))||(e.exports=i)},function(e,t,n){var i,a="object"==typeof Reflect?Reflect:null,r=a&&"function"==typeof a.apply?a.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};i=a&&"function"==typeof a.ownKeys?a.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(n,i){function a(n){e.removeListener(t,r),i(n)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",a),n([].slice.call(arguments))}_(e,t,r,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&_(e,"error",t,n)}(e,a,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var c=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function d(e,t,n,i){var a,r,s,o;if(l(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),s=r[t]),void 0===s)s=r[t]=n,++e._eventsCount;else if("function"==typeof s?s=r[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(a=u(e))>0&&s.length>a&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,o=c,console&&console.warn&&console.warn(o)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},a=h.bind(i);return a.listener=n,i.wrapFn=a,a}function m(e,t,n){var i=e._events;if(void 0===i)return[];var a=i[t];return void 0===a?[]:"function"==typeof a?n?[a.listener||a]:[a]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(a):g(a,a.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function g(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function _(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function a(r){i.once&&e.removeEventListener(t,a),n(r)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var c=a[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var l=c.length,u=g(c,l);for(n=0;n<l;++n)r(u[n],this,t)}return!0},o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)},o.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,i,a,r,s;if(l(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(a=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){s=n[r].listener,a=r;break}if(a<0)return this;0===a?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,a),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var a,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(a=r[i])&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return m(this,e,!0)},o.prototype.rawListeners=function(e){return m(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,n){var i=n(3),a=n(0),r=0;function s(){return"hole_"+r++}function o(e,t){for(var n=null,i=0;i<e.length;i++){var a=t(e[i]);a!==e[i]&&(n||(n=e.slice()),n[i]=a)}return n||e}function c(e,t,n){if(!(e instanceof i.Node))return e;if(!n){var a=t(e);if(a&&a!==e)return a}if(e instanceof i.NodeList){var r=o(e.children,(function(e){return c(e,t,n)}));r!==e.children&&(e=new i[e.typename](e.lineno,e.colno,r))}else if(e instanceof i.CallExtension){var s=c(e.args,t,n),l=o(e.contentArgs,(function(e){return c(e,t,n)}));s===e.args&&l===e.contentArgs||(e=new i[e.typename](e.extName,e.prop,s,l))}else{var u=e.fields.map((function(t){return e[t]})),d=o(u,(function(e){return c(e,t,n)}));d!==u&&(e=new i[e.typename](e.lineno,e.colno),d.forEach((function(t,n){e[e.fields[n]]=t})))}return n&&t(e)||e}function l(e,t){return c(e,t,!0)}function u(e,t,n){var r=[],o=l(n?e[n]:e,(function(e){var n;return e instanceof i.Block?e:((e instanceof i.Filter&&-1!==a.indexOf(t,e.name.value)||e instanceof i.CallExtensionAsync)&&(n=new i.Symbol(e.lineno,e.colno,s()),r.push(new i.FilterAsync(e.lineno,e.colno,e.name,e.args,n))),n)}));return n?e[n]=o:e=o,r.length?(r.push(e),new i.NodeList(e.lineno,e.colno,r)):e}function d(e,t){return function(e){return l(e,(function(e){if(e instanceof i.If||e instanceof i.For){var t=!1;if(c(e,(function(e){if(e instanceof i.FilterAsync||e instanceof i.IfAsync||e instanceof i.AsyncEach||e instanceof i.AsyncAll||e instanceof i.CallExtensionAsync)return t=!0,e})),t){if(e instanceof i.If)return new i.IfAsync(e.lineno,e.colno,e.cond,e.body,e.else_);if(e instanceof i.For&&!(e instanceof i.AsyncAll))return new i.AsyncEach(e.lineno,e.colno,e.arr,e.name,e.body,e.else_)}}}))}(function(e){return c(e,(function(e){if(e instanceof i.Block){var t=!1,n=s();e.body=c(e.body,(function(e){if(e instanceof i.FunCall&&"super"===e.name.value)return t=!0,new i.Symbol(e.lineno,e.colno,n)})),t&&e.body.children.unshift(new i.Super(0,0,e.name,new i.Symbol(0,0,n)))}}))}(function(e,t){return l(e,(function(e){return e instanceof i.Output?u(e,t):e instanceof i.Set?u(e,t,"value"):e instanceof i.For?u(e,t,"arr"):e instanceof i.If?u(e,t,"cond"):e instanceof i.CallExtension?u(e,t,"args"):void 0}))}(e,t)))}e.exports={transform:function(e,t){return d(e,t||[])}}},function(e,t,n){var i=n(0),a=n(2);function r(e,t){return null==e||!1===e?t:e}function s(e){return e!=e}function o(e){var t=(e=r(e,"")).toLowerCase();return a.copySafeness(e,t.charAt(0).toUpperCase()+t.slice(1))}function c(e){if(i.isString(e))return e.split("");if(i.isObject(e))return i._entries(e||{}).map((function(e){return{key:e[0],value:e[1]}}));if(i.isArray(e))return e;throw new i.TemplateError("list filter: type not iterable")}function l(e){return function(t,n,a){void 0===n&&(n="truthy");var r=this,s=r.env.getTest(n);return i.toArray(t).filter((function(t){return s.call(r,t,a)===e}))}}function u(e){return a.copySafeness(e,e.replace(/^\s*|\s*$/g,""))}(t=e.exports={}).abs=Math.abs,t.batch=function(e,t,n){var i,a=[],r=[];for(i=0;i<e.length;i++)i%t==0&&r.length&&(a.push(r),r=[]),r.push(e[i]);if(r.length){if(n)for(i=r.length;i<t;i++)r.push(n);a.push(r)}return a},t.capitalize=o,t.center=function(e,t){if(t=t||80,(e=r(e,"")).length>=t)return e;var n=t-e.length,s=i.repeat(" ",n/2-n%2),o=i.repeat(" ",n/2);return a.copySafeness(e,s+e+o)},t.default=function(e,t,n){return n?e||t:void 0!==e?e:t},t.dictsort=function(e,t,n){if(!i.isObject(e))throw new i.TemplateError("dictsort filter: val must be an object");var a,r=[];for(var s in e)r.push([s,e[s]]);if(void 0===n||"key"===n)a=0;else{if("value"!==n)throw new i.TemplateError("dictsort filter: You can only sort by either key or value");a=1}return r.sort((function(e,n){var r=e[a],s=n[a];return t||(i.isString(r)&&(r=r.toUpperCase()),i.isString(s)&&(s=s.toUpperCase())),r>s?1:r===s?0:-1})),r},t.dump=function(e,t){return JSON.stringify(e,null,t)},t.escape=function(e){return e instanceof a.SafeString?e:(e=null==e?"":e,a.markSafe(i.escape(e.toString())))},t.safe=function(e){return e instanceof a.SafeString?e:(e=null==e?"":e,a.markSafe(e.toString()))},t.first=function(e){return e[0]},t.forceescape=function(e){return e=null==e?"":e,a.markSafe(i.escape(e.toString()))},t.groupby=function(e,t){return i.groupBy(e,t,this.env.opts.throwOnUndefined)},t.indent=function(e,t,n){if(""===(e=r(e,"")))return"";t=t||4;var s=e.split("\n"),o=i.repeat(" ",t),c=s.map((function(e,t){return 0!==t||n?""+o+e:e})).join("\n");return a.copySafeness(e,c)},t.join=function(e,t,n){return t=t||"",n&&(e=i.map(e,(function(e){return e[n]}))),e.join(t)},t.last=function(e){return e[e.length-1]},t.length=function(e){var t=r(e,"");return void 0!==t?"function"==typeof Map&&t instanceof Map||"function"==typeof Set&&t instanceof Set?t.size:!i.isObject(t)||t instanceof a.SafeString?t.length:i.keys(t).length:0},t.list=c,t.lower=function(e){return(e=r(e,"")).toLowerCase()},t.nl2br=function(e){return null==e?"":a.copySafeness(e,e.replace(/\r\n|\n/g,"<br />\n"))},t.random=function(e){return e[Math.floor(Math.random()*e.length)]},t.reject=l(!1),t.rejectattr=function(e,t){return e.filter((function(e){return!e[t]}))},t.select=l(!0),t.selectattr=function(e,t){return e.filter((function(e){return!!e[t]}))},t.replace=function(e,t,n,i){var r=e;if(t instanceof RegExp)return e.replace(t,n);void 0===i&&(i=-1);var s="";if("number"==typeof t)t=""+t;else if("string"!=typeof t)return e;if("number"==typeof e&&(e=""+e),"string"!=typeof e&&!(e instanceof a.SafeString))return e;if(""===t)return s=n+e.split("").join(n)+n,a.copySafeness(e,s);var o=e.indexOf(t);if(0===i||-1===o)return e;for(var c=0,l=0;o>-1&&(-1===i||l<i);)s+=e.substring(c,o)+n,c=o+t.length,l++,o=e.indexOf(t,c);return c<e.length&&(s+=e.substring(c)),a.copySafeness(r,s)},t.reverse=function(e){var t;return t=i.isString(e)?c(e):i.map(e,(function(e){return e})),t.reverse(),i.isString(e)?a.copySafeness(e,t.join("")):t},t.round=function(e,t,n){t=t||0;var i=Math.pow(10,t);return("ceil"===n?Math.ceil:"floor"===n?Math.floor:Math.round)(e*i)/i},t.slice=function(e,t,n){for(var i=Math.floor(e.length/t),a=e.length%t,r=[],s=0,o=0;o<t;o++){var c=s+o*i;o<a&&s++;var l=s+(o+1)*i,u=e.slice(c,l);n&&o>=a&&u.push(n),r.push(u)}return r},t.sum=function(e,t,n){return void 0===n&&(n=0),t&&(e=i.map(e,(function(e){return e[t]}))),n+e.reduce((function(e,t){return e+t}),0)},t.sort=a.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(e,t,n,a){var r=this,s=i.map(e,(function(e){return e})),o=i.getAttrGetter(a);return s.sort((function(e,s){var c=a?o(e):e,l=a?o(s):s;if(r.env.opts.throwOnUndefined&&a&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+a+'" resolved to undefined');return!n&&i.isString(c)&&i.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),c<l?t?1:-1:c>l?t?-1:1:0})),s})),t.string=function(e){return a.copySafeness(e,e)},t.striptags=function(e,t){var n=u((e=r(e,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,"")),i="";return i=t?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),a.copySafeness(e,i)},t.title=function(e){var t=(e=r(e,"")).split(" ").map((function(e){return o(e)}));return a.copySafeness(e,t.join(" "))},t.trim=u,t.truncate=function(e,t,n,i){var s=e;if(t=t||255,(e=r(e,"")).length<=t)return e;if(n)e=e.substring(0,t);else{var o=e.lastIndexOf(" ",t);-1===o&&(o=t),e=e.substring(0,o)}return e+=null!=i?i:"...",a.copySafeness(s,e)},t.upper=function(e){return(e=r(e,"")).toUpperCase()},t.urlencode=function(e){var t=encodeURIComponent;return i.isString(e)?t(e):(i.isArray(e)?e:i._entries(e)).map((function(e){var n=e[0],i=e[1];return t(n)+"="+t(i)})).join("&")};var d=/^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,p=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;t.urlize=function(e,t,n){s(t)&&(t=1/0);var i=!0===n?' rel="nofollow"':"";return e.split(/(\s+)/).filter((function(e){return e&&e.length})).map((function(e){var n=e.match(d),a=n?n[1]:e,r=a.substr(0,t);return p.test(a)?'<a href="'+a+'"'+i+">"+r+"</a>":m.test(a)?'<a href="http://'+a+'"'+i+">"+r+"</a>":h.test(a)?'<a href="mailto:'+a+'">'+a+"</a>":f.test(a)?'<a href="http://'+a+'"'+i+">"+r+"</a>":e})).join("")},t.wordcount=function(e){var t=(e=r(e,""))?e.match(/\w+/g):null;return t?t.length:null},t.float=function(e,t){var n=parseFloat(e);return s(n)?t:n};var g=a.makeMacro(["value","default","base"],[],(function(e,t,n){void 0===n&&(n=10);var i=parseInt(e,n);return s(i)?t:i}));t.int=g,t.d=t.default,t.e=t.escape},function(e,t,n){function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}var a=function(e){var t,n;function a(t){var n;return(n=e.call(this)||this).precompiled=t||{},n}return n=e,(t=a).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n),a.prototype.getSource=function(e){return this.precompiled[e]?{src:{type:"code",obj:this.precompiled[e]},path:e}:null},a}(n(6));e.exports={PrecompiledLoader:a}},function(e,t,n){var i=n(2).SafeString;t.callable=function(e){return"function"==typeof e},t.defined=function(e){return void 0!==e},t.divisibleby=function(e,t){return e%t==0},t.escaped=function(e){return e instanceof i},t.equalto=function(e,t){return e===t},t.eq=t.equalto,t.sameas=t.equalto,t.even=function(e){return e%2==0},t.falsy=function(e){return!e},t.ge=function(e,t){return e>=t},t.greaterthan=function(e,t){return e>t},t.gt=t.greaterthan,t.le=function(e,t){return e<=t},t.lessthan=function(e,t){return e<t},t.lt=t.lessthan,t.lower=function(e){return e.toLowerCase()===e},t.ne=function(e,t){return e!==t},t.null=function(e){return null===e},t.number=function(e){return"number"==typeof e},t.odd=function(e){return e%2==1},t.string=function(e){return"string"==typeof e},t.truthy=function(e){return!!e},t.undefined=function(e){return void 0===e},t.upper=function(e){return e.toUpperCase()===e},t.iterable=function(e){return"undefined"!=typeof Symbol?!!e[Symbol.iterator]:Array.isArray(e)||"string"==typeof e},t.mapping=function(e){var t=null!=e&&"object"==typeof e&&!Array.isArray(e);return Set?t&&!(e instanceof Set):t}},function(e,t,n){e.exports=function(){return{range:function(e,t,n){void 0===t?(t=e,e=0,n=1):n||(n=1);var i=[];if(n>0)for(var a=e;a<t;a+=n)i.push(a);else for(var r=e;r>t;r+=n)i.push(r);return i},cycler:function(){return e=Array.prototype.slice.call(arguments),t=-1,{current:null,reset:function(){t=-1,this.current=null},next:function(){return++t>=e.length&&(t=0),this.current=e[t],this.current}};var e,t},joiner:function(e){return function(e){e=e||",";var t=!0;return function(){var n=t?"":e;return t=!1,n}}(e)}}}},function(e,t,n){var i=n(4);e.exports=function(e,t){function n(e,t){if(this.name=e,this.path=e,this.defaultEngine=t.defaultEngine,this.ext=i.extname(e),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return n.prototype.render=function(t,n){e.render(this.name,t,n)},t.set("view",n),t.set("nunjucksEnv",e),e}},function(e,t,n){var i=n(4),a=n(4),r=n(0)._prettifyError,s=n(5),o=n(7).Environment,c=n(24);function l(e,t){return!!Array.isArray(t)&&t.some((function(t){return e.match(t)}))}function u(e,t){(t=t||{}).isString=!0;var n=t.env||new o([]),i=t.wrapper||c;if(!t.name)throw new Error('the "name" option is required when compiling a string');return i([d(e,t.name,n)],t)}function d(e,t,n){var i,a=(n=n||new o([])).asyncFilters,c=n.extensionsList;t=t.replace(/\\/g,"/");try{i=s.compile(e,a,c,t,n.opts)}catch(e){throw r(t,!1,e)}return{name:t,template:i}}e.exports={precompile:function(e,t){var n=(t=t||{}).env||new o([]),r=t.wrapper||c;if(t.isString)return u(e,t);var s=i.existsSync(e)&&i.statSync(e),h=[],p=[];if(s.isFile())h.push(d(i.readFileSync(e,"utf-8"),t.name||e,n));else if(s.isDirectory()){!function n(r){i.readdirSync(r).forEach((function(s){var o=a.join(r,s),c=o.substr(a.join(e,"/").length),u=i.statSync(o);u&&u.isDirectory()?l(c+="/",t.exclude)||n(o):l(c,t.include)&&p.push(o)}))}(e);for(var m=0;m<p.length;m++){var f=p[m].replace(a.join(e,"/"),"");try{h.push(d(i.readFileSync(p[m],"utf-8"),f,n))}catch(e){if(!t.force)throw e;console.error(e)}}}return r(h,t)},precompileString:u}},function(e,t,n){e.exports=function(e,t){var n="";t=t||{};for(var i=0;i<e.length;i++){var a=JSON.stringify(e[i].name);n+="(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["+a+"] = (function() {\n"+e[i].template+"\n})();\n",t.asFunction&&(n+="return function(ctx, cb) { return nunjucks.render("+a+", ctx, cb); }\n"),n+="})();\n"}return n}},function(e,t,n){e.exports=function(){var e,t,n=this.runtime,i=this.lib,a=this.compiler.Compiler,r=this.parser.Parser,s=this.nodes,o=this.lexer,c=n.contextOrFrameLookup,l=n.memberLookup;function u(e){return{index:e.index,lineno:e.lineno,colno:e.colno}}if(a&&(e=a.prototype.assertType),r&&(t=r.prototype.parseAggregate),n.contextOrFrameLookup=function(e,t,n){var i=c.apply(this,arguments);if(void 0!==i)return i;switch(n){case"True":return!0;case"False":return!1;case"None":return null;default:return}},s&&a&&r){var d=s.Node.extend("Slice",{fields:["start","stop","step"],init:function(e,t,n,i,a){n=n||new s.Literal(e,t,null),i=i||new s.Literal(e,t,null),a=a||new s.Literal(e,t,1),this.parent(e,t,n,i,a)}});a.prototype.assertType=function(t){t instanceof d||e.apply(this,arguments)},a.prototype.compileSlice=function(e,t){this._emit("("),this._compileExpression(e.start,t),this._emit("),("),this._compileExpression(e.stop,t),this._emit("),("),this._compileExpression(e.step,t),this._emit(")")},r.prototype.parseAggregate=function(){var e=this,n=u(this.tokens);n.colno--,n.index--;try{return t.apply(this)}catch(t){var a=u(this.tokens),r=function(){return i._assign(e.tokens,a),t};i._assign(this.tokens,n),this.peeked=!1;var c=this.peekToken();if(c.type!==o.TOKEN_LEFT_BRACKET)throw r();this.nextToken();for(var l=new d(c.lineno,c.colno),h=!1,p=0;p<=l.fields.length&&!this.skip(o.TOKEN_RIGHT_BRACKET);p++){if(p===l.fields.length){if(!h)break;this.fail("parseSlice: too many slice components",c.lineno,c.colno)}this.skip(o.TOKEN_COLON)?h=!0:(l[l.fields[p]]=this.parseExpression(),h=this.skip(o.TOKEN_COLON)||h)}if(!h)throw r();return new s.Array(c.lineno,c.colno,[l])}}}function h(e,t,i,a){e=e||[],null===t&&(t=a<0?e.length-1:0),null===i?i=a<0?-1:e.length:i<0&&(i+=e.length),t<0&&(t+=e.length);for(var r=[],s=t;!(s<0||s>e.length||a>0&&s>=i||a<0&&s<=i);s+=a)r.push(n.memberLookup(e,s));return r}function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var m={pop:function(e){if(void 0===e)return this.pop();if(e>=this.length||e<0)throw new Error("KeyError");return this.splice(e,1)},append:function(e){return this.push(e)},remove:function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return this.splice(t,1);throw new Error("ValueError")},count:function(e){for(var t=0,n=0;n<this.length;n++)this[n]===e&&t++;return t},index:function(e){var t;if(-1===(t=this.indexOf(e)))throw new Error("ValueError");return t},find:function(e){return this.indexOf(e)},insert:function(e,t){return this.splice(e,0,t)}},f={items:function(){return i._entries(this)},values:function(){return i._values(this)},keys:function(){return i.keys(this)},get:function(e,t){var n=this[e];return void 0===n&&(n=t),n},has_key:function(e){return p(this,e)},pop:function(e,t){var n=this[e];if(void 0===n&&void 0!==t)n=t;else{if(void 0===n)throw new Error("KeyError");delete this[e]}return n},popitem:function(){var e=i.keys(this);if(!e.length)throw new Error("KeyError");var t=e[0],n=this[t];return delete this[t],[t,n]},setdefault:function(e,t){return void 0===t&&(t=null),e in this||(this[e]=t),this[e]},update:function(e){return i._assign(this,e),null}};return f.iteritems=f.items,f.itervalues=f.values,f.iterkeys=f.keys,n.memberLookup=function(e,t,n){return 4===arguments.length?h.apply(this,arguments):(e=e||{},i.isArray(e)&&p(m,t)?m[t].bind(e):i.isObject(e)&&p(f,t)?f[t].bind(e):l.apply(this,arguments))},function(){n.contextOrFrameLookup=c,n.memberLookup=l,a&&(a.prototype.assertType=e),r&&(r.prototype.parseAggregate=t)}}}])};var $y=Yd(Ty.exports=Ay());function Iy(e,t){try{if(t){if(e.entities[t]){if(e.entities[t].area_id)return e.entities[t].area_id;t=e.entities[t].device_id??t}if(e.devices[t])return e.devices[t].area_id;for(const n in e.areas)if(e.areas[n].name==t)return n}return}catch{return}}function Oy(e,t){try{if(t){let n=t;if(e.entities[t]&&(n=e.entities[t].area_id??n,t=e.entities[t].device_id??t),e.devices[t]&&(n=e.devices[t].area_id??n),e.areas[n])return e.areas[n].name}return}catch{return}}function Ly(e,t){try{const n=[];if(t){const i=Dy(e,t);for(const t of i)for(const i in e.entities)e.entities[i].device_id==t&&n.push(i);n.sort()}return n}catch{return[]}}function Dy(e,t){try{const n=[];if(t){if(!(t in e.areas))for(const n in e.areas)if(e.areas[n].name==t){t=n;break}for(const i in e.devices)e.devices[i].area_id==t&&n.push(i);n.sort()}return n}catch{return[]}}function jy(e,t){return!!Array.isArray(e)&&e?.includes(t)}function zy(e,t,n,i){"object"!=typeof n||Array.isArray(n)||(i=n.with_unit??i,n=n.rounded??void 0);try{const a=e.states[t];let r=a?.state;if(i&&null==n&&(n=!0),n&&!isNaN(a?.state)){const n=e.entities[t]?.display_precision??0;r=Number(r).toPrecision(n)}return i&&a?.attributes?.unit_of_measurement&&(r=`${r} ${a?.attributes?.unit_of_measurement}`),r}catch{return}}function Py(e,t,n){try{return e.states[t].attributes[n]}catch{return}}function Ry(e,t){try{const n=zy(e,t);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch{return!1}}function Ny(e){const t={};for(const n in e.states){const[i,a]=n.split(".");t[i]=t[i]??{},t[i][a]=e.states[n]}return t}function Fy(e,t){try{const n=[];if(t)for(const i in e.entities)e.entities[i].device_id==t&&n.push(i);return n}catch{return[]}}function By(e,t,n){try{return e.devices[t]?.[n]??Py(e,t,n)}catch{return}}function Vy(e,t){try{if(t){if(e.entities[t])return e.entities[t].device_id;for(const n in e.devices){const i=e.devices[n];if(i.name==t||i.name_by_user==t)return n}}return}catch{return}}function Hy(e,t,n=!1){if(e[0]==t[0]&&e[1]==t[1])return 0;const i=1/298.257223563,a=6356752.314245,r=Math.atan((1-i)*Math.tan(e[0]*Math.PI/180)),s=Math.atan((1-i)*Math.tan(t[0]*Math.PI/180));let o=(t[1]-e[1])*Math.PI/180,c=o;const l=Math.sin(r),u=Math.cos(r),d=Math.sin(s),h=Math.cos(s);let p=0,m=0,f=0,g=0,_=0;for(let e=0;e<200;e++){const t=Math.sin(c),n=Math.cos(c);if(m=Math.sqrt((h*t)**2+(u*d-l*h*n)**2),0==m)return 0;g=l*d+u*h*n,_=Math.atan2(m,g);const a=u*h*t/m;p=1-a**2,f=0!=p?g-2*l*d/p:0;const r=i/16*p*(4+i*(4-3*p)),s=c;if(c=o+(1-r)*i*a*(_+r*m*(f+r*g*(2*f**2-1))),Math.abs(c-s)<1e-12)break;if(199==e)return null}const v=272331606109.84375*p/a**2,y=v/1024*(256+v*(v*(74-47*v)-128));let b=a*(1+v/16384*(4096+v*(v*(320-175*v)-768)))*(_-y*m*(f+y/4*(g*(2*f**2-1)-y/6*f*(4*m**2-3)*(4*f**2-3))))/1e3;return n&&(b*=.621371),b}function Uy(e,...t){function n(t){if(t.startsWith("zone."))return e.states[t].attributes.persons??[];let n=Object.keys(e.states).filter((e=>e==t||e.split(".")[0]==t));if("zone"==t){let t=[];for(const i of n)t.push(...e.states[i].attributes.persons??[]);n=Array.from(new Set(t))}return n}let i,a;if(1==t.length)i=[e.states["zone.home"].attributes.latitude,e.states["zone.home"].attributes.longitude],a=0;else if("number"==typeof t[0]){if("number"!=typeof t[1]||2==t.length)return null;i=[t[0],t[1]],a=2}else if("object"==typeof t[0]){if(Array.isArray(t[0])||!t[0].attributes)return null;i=[t[0].attributes.latitude,t[0].attributes.longitude],a=1}else{if("string"!=typeof t[0])return null;i=[e.states[t[0]].attributes.latitude,e.states[t[0]].attributes.longitude],a=1}let r=[];for(let e=a;e<t.length;e++)if("object"==typeof t[e]){let i=[];if(Array.isArray(t[e]))i=t[e];else if(t[e].entity_id)"zone"==t[e].entity_id.split(".")[0]?r.push(...t[e].attributes.persons):r.push(t[e]);else{const n=Object.keys(t[e]);if(t[e][n[0]].entity_id)i=n.map((n=>t[e][n].entity_id));else for(const a of n)i.push(...Object.keys(t[e][a]).map((n=>t[e][a][n].entity_id)))}for(const e of i)r.push(...n(e))}else"string"==typeof t[e]&&r.push(...n(t[e]));r=Array.from(new Set(r));let s=null,o=1/0;for(const t of r){let n;n="string"==typeof t?e.states[t]:t;const a=n.attributes.latitude,r=n.attributes.longitude;if(null!=a&&null!=r){const e=Hy(i,[a,r])??1/0;e<=o&&(s=n,o=e)}}return s}function qy(e,t){try{let n=t;if(e.entities[t]&&(n=e.entities[t].area_id??n,t=e.entities[t].device_id??t),t){if(e.devices[t]&&(n=e.devices[t].area_id??n),e.areas[n])return e.areas[n].floor_id;for(const n in e.areas)if(e.areas[n].name==t)return e.areas[n].floor_id}return}catch{return}}function Wy(e,t){if(e.floors[t])return e.floors[t].name;const n=qy(e,t);return n?e.floors[n].name:void 0}function Zy(e,t){try{const n=[];if(t){let i;if(e.floors[t])i=t;else for(const n in e.floors)if(e.floors[n].name==t){i=n;break}if(!i)return[];for(const t in e.areas)e.areas[t].floor_id==i&&n.push(t)}return n}catch{return[]}}function Ky(e,...t){const n=[];for(let i of t.flat(1/0))if("string"==typeof i&&(i=e.states[i]),i)if(Array.isArray(i.attributes?.entity_id))n.push(...Ky(e,...i.attributes?.entity_id));else if(i?.attributes?.persons)n.push(...Ky(e,...i.attributes.persons));else if(i.entity_id)n.push(i);else{const t=Object.values(i);if(t[0]?.entity_id)n.push(...t);else for(const i of t){const t=Object.values(i);for(const i of t)i?.attributes?.persons?n.push(...Ky(e,...i.attributes.persons)):n.push(i)}}return n.filter(((e,t,n)=>t==n.findIndex((t=>t.entity_id==e.entity_id)))).sort(((e,t)=>e.entity_id.localeCompare(t.entity_id)))}function Qy(e,t,n,i,a){if("object"!=typeof n||Array.isArray(n)||(a=n.if_none??a,i=n.if_false??i,n=n.if_true??void 0),a){const n=cM(e,t);if([void 0,null,"undefined","null","None"].includes(n))return a}return cM(e,`\n\t\t{% if ${t} %}\n\t\t${n??!0}\n\t\t{% else %}\n\t\t${i??!1}\n\t\t{% endif %}\n\t`)}const Yy={};function Gy(e,t){try{return t?e.entities[t]?.labels??e.devices[t]?.labels??e.areas[t]?.labels??[]:Object.keys(Yy)}catch{return[]}}function Xy(e){for(const t in Yy)if(Yy[t].name==e)return t}function Jy(e){return Yy[e]?.name}function eb(e,t){try{const n=[];let i;if(t){if(i=Yy[t]?t:Xy(t),!i)return[];for(const t in e.areas)(e.areas[t].labels??[]).includes(i)&&n.push(t);n.sort()}return n}catch{return[]}}function tb(e,t){try{const n=[];if(t){let i;if(i=Yy[t]?t:Xy(t),!i)return[];for(const t in e.devices)(e.devices[t].labels??[]).includes(i)&&n.push(t);n.sort()}return n}catch{return[]}}function nb(e,t){try{const n=[];if(t){let i;if(i=Yy[t]?t:Xy(t),!i)return[];for(const t in e.entities)(e.entities[t].labels??[]).includes(i)&&n.push(t);n.sort()}return n}catch{return[]}}function ib(e){return e.toString()}function ab(e){if(e.toString().includes("NaN"))throw Error("Result returned NaN.")}function rb(e){return e!=1/0&&!isNaN(e)}function sb(e,t){if("number"==typeof e)return 0!=e;if("boolean"==typeof e)return e;if(e=e.toLowerCase(),["true","yes","on","enable","1"].includes(e))return!0;if(["false","no","off","disable","0"].includes(e))return!1;if(t)return t;throw Error("Invalid input")}function ob(e,t=Math.E,n){try{const n=Math.log(e)/Math.log(t);return ab(n.toString()),n}catch(e){if(n)return n;throw e}}function cb(e,t){try{const t=Math.sin(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function lb(e,t){try{const t=Math.cos(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function ub(e,t){try{const t=Math.tan(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function db(e,t){try{const t=Math.asin(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function hb(e,t){try{const t=Math.acos(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function pb(e,t){try{const t=Math.atan(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function mb(e,t,n){try{const n=Math.atan2(e,t);return ab(n.toString()),n}catch(e){if(n)return n;throw e}}function fb(e,t){try{const t=Math.sqrt(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}}function gb(...e){return Math.max(...e.flat(1/0))}function _b(...e){return Math.min(...e.flat(1/0))}function vb(e,t){try{if((e=e.flat(1/0)).some((e=>isNaN(e))))throw Error("Non-numeric values provided");return e.reduce(((e,t)=>e+t))/e.length}catch(e){if(t)return t;throw e}}function yb(e,t){try{if((e=e.flat(1/0)).some((e=>isNaN(e))))throw Error("Non-numeric values provided");if(!e.length)throw Error("Empty array provided");e=e.sort(((e,t)=>e-t));const t=Math.floor(e.length/2);return e.length%2?e[t]:(e[t-1]+e[t])/2}catch(e){if(t)return t;throw e}}function bb(e,t){try{if((e=e.flat(1/0)).some((e=>isNaN(e))))throw Error("Non-numeric values provided");if(!e.length)throw Error("Empty array provided");const t={};for(const n of e)t[n]||(t[n]=0),t[n]++;let n=e[0],i=0;for(const e in t)t[e]>i&&(n=Number(e),i=t[e]);return n}catch(e){if(t)return t;throw e}}const wb=Math.E,xb=Math.PI,Mb=2*Math.PI,kb=1/0;function Cb(e,t,n){try{return e.formatEntityState(e.states[t],n)}catch{return n??e.states[t]?.state??void 0}}function Sb(e,t,n){try{return e.formatEntityAttributeName(e.states[t],n)}catch{return n??e.states[t]?.attributes?.[n]??void 0}}function Eb(e,t,n,i){try{return e.formatEntityAttributeValue(e.states[t],n,i)}catch{return i??e.states[t]?.attributes?.[n]??void 0}}const Ab=new Date,Tb=new Date;function $b(e,t,n,i){function a(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return a.floor=t=>(e(t=new Date(+t)),t),a.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),a.round=e=>{const t=a(e),n=a.ceil(e);return e-t<n-e?t:n},a.offset=(e,n)=>(t(e=new Date(+e),null==n?1:Math.floor(n)),e),a.range=(n,i,r)=>{const s=[];if(n=a.ceil(n),r=null==r?1:Math.floor(r),!(n<i&&r>0))return s;let o;do{s.push(o=new Date(+n)),t(n,r),e(n)}while(o<n&&n<i);return s},a.filter=n=>$b((t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)}),((e,i)=>{if(e>=e)if(i<0)for(;++i<=0;)for(;t(e,-1),!n(e););else for(;--i>=0;)for(;t(e,1),!n(e););})),n&&(a.count=(t,i)=>(Ab.setTime(+t),Tb.setTime(+i),e(Ab),e(Tb),Math.floor(n(Ab,Tb))),a.every=e=>(e=Math.floor(e),isFinite(e)&&e>0?e>1?a.filter(i?t=>i(t)%e==0:t=>a.count(0,t)%e==0):a:null)),a}const Ib=6e4,Ob=864e5,Lb=6048e5,Db=$b((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ib)/Ob),(e=>e.getDate()-1));Db.range;const jb=$b((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Ob),(e=>e.getUTCDate()-1));jb.range;const zb=$b((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Ob),(e=>Math.floor(e/Ob)));function Pb(e){return $b((t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),((e,t)=>{e.setDate(e.getDate()+7*t)}),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ib)/Lb))}zb.range;const Rb=Pb(0),Nb=Pb(1),Fb=Pb(2),Bb=Pb(3),Vb=Pb(4),Hb=Pb(5),Ub=Pb(6);function qb(e){return $b((t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+7*t)}),((e,t)=>(t-e)/Lb))}Rb.range,Nb.range,Fb.range,Bb.range,Vb.range,Hb.range,Ub.range;const Wb=qb(0),Zb=qb(1),Kb=qb(2),Qb=qb(3),Yb=qb(4),Gb=qb(5),Xb=qb(6);Wb.range,Zb.range,Kb.range,Qb.range,Yb.range,Gb.range,Xb.range;const Jb=$b((e=>{e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,t)=>{e.setFullYear(e.getFullYear()+t)}),((e,t)=>t.getFullYear()-e.getFullYear()),(e=>e.getFullYear()));Jb.every=e=>isFinite(e=Math.floor(e))&&e>0?$b((t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,n)=>{t.setFullYear(t.getFullYear()+n*e)})):null,Jb.range;const ew=$b((e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)}),((e,t)=>t.getUTCFullYear()-e.getUTCFullYear()),(e=>e.getUTCFullYear()));function tw(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function nw(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function iw(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}ew.every=e=>isFinite(e=Math.floor(e))&&e>0?$b((t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null,ew.range;var aw,rw,sw,ow,cw,lw={"-":"",_:" ",0:"0"},uw=/^\s*\d+/,dw=/^%/,hw=/[\\^$*+?|[\]().{}]/g;function pw(e,t,n){var i=e<0?"-":"",a=(i?-e:e)+"",r=a.length;return i+(r<n?new Array(n-r+1).join(t)+a:a)}function mw(e){return e.replace(hw,"\\$&")}function fw(e){return new RegExp("^(?:"+e.map(mw).join("|")+")","i")}function gw(e){return new Map(e.map(((e,t)=>[e.toLowerCase(),t])))}function _w(e,t,n){var i=uw.exec(t.slice(n,n+1));return i?(e.w=+i[0],n+i[0].length):-1}function vw(e,t,n){var i=uw.exec(t.slice(n,n+1));return i?(e.u=+i[0],n+i[0].length):-1}function yw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.U=+i[0],n+i[0].length):-1}function bw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.V=+i[0],n+i[0].length):-1}function ww(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.W=+i[0],n+i[0].length):-1}function xw(e,t,n){var i=uw.exec(t.slice(n,n+4));return i?(e.y=+i[0],n+i[0].length):-1}function Mw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function kw(e,t,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return i?(e.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function Cw(e,t,n){var i=uw.exec(t.slice(n,n+1));return i?(e.q=3*i[0]-3,n+i[0].length):-1}function Sw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.m=i[0]-1,n+i[0].length):-1}function Ew(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.d=+i[0],n+i[0].length):-1}function Aw(e,t,n){var i=uw.exec(t.slice(n,n+3));return i?(e.m=0,e.d=+i[0],n+i[0].length):-1}function Tw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.H=+i[0],n+i[0].length):-1}function $w(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.M=+i[0],n+i[0].length):-1}function Iw(e,t,n){var i=uw.exec(t.slice(n,n+2));return i?(e.S=+i[0],n+i[0].length):-1}function Ow(e,t,n){var i=uw.exec(t.slice(n,n+3));return i?(e.L=+i[0],n+i[0].length):-1}function Lw(e,t,n){var i=uw.exec(t.slice(n,n+6));return i?(e.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function Dw(e,t,n){var i=dw.exec(t.slice(n,n+1));return i?n+i[0].length:-1}function jw(e,t,n){var i=uw.exec(t.slice(n));return i?(e.Q=+i[0],n+i[0].length):-1}function zw(e,t,n){var i=uw.exec(t.slice(n));return i?(e.s=+i[0],n+i[0].length):-1}function Pw(e,t){return pw(e.getDate(),t,2)}function Rw(e,t){return pw(e.getHours(),t,2)}function Nw(e,t){return pw(e.getHours()%12||12,t,2)}function Fw(e,t){return pw(1+Db.count(Jb(e),e),t,3)}function Bw(e,t){return pw(e.getMilliseconds(),t,3)}function Vw(e,t){return Bw(e,t)+"000"}function Hw(e,t){return pw(e.getMonth()+1,t,2)}function Uw(e,t){return pw(e.getMinutes(),t,2)}function qw(e,t){return pw(e.getSeconds(),t,2)}function Ww(e){var t=e.getDay();return 0===t?7:t}function Zw(e,t){return pw(Rb.count(Jb(e)-1,e),t,2)}function Kw(e){var t=e.getDay();return t>=4||0===t?Vb(e):Vb.ceil(e)}function Qw(e,t){return e=Kw(e),pw(Vb.count(Jb(e),e)+(4===Jb(e).getDay()),t,2)}function Yw(e){return e.getDay()}function Gw(e,t){return pw(Nb.count(Jb(e)-1,e),t,2)}function Xw(e,t){return pw(e.getFullYear()%100,t,2)}function Jw(e,t){return pw((e=Kw(e)).getFullYear()%100,t,2)}function ex(e,t){return pw(e.getFullYear()%1e4,t,4)}function tx(e,t){var n=e.getDay();return pw((e=n>=4||0===n?Vb(e):Vb.ceil(e)).getFullYear()%1e4,t,4)}function nx(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+pw(t/60|0,"0",2)+pw(t%60,"0",2)}function ix(e,t){return pw(e.getUTCDate(),t,2)}function ax(e,t){return pw(e.getUTCHours(),t,2)}function rx(e,t){return pw(e.getUTCHours()%12||12,t,2)}function sx(e,t){return pw(1+jb.count(ew(e),e),t,3)}function ox(e,t){return pw(e.getUTCMilliseconds(),t,3)}function cx(e,t){return ox(e,t)+"000"}function lx(e,t){return pw(e.getUTCMonth()+1,t,2)}function ux(e,t){return pw(e.getUTCMinutes(),t,2)}function dx(e,t){return pw(e.getUTCSeconds(),t,2)}function hx(e){var t=e.getUTCDay();return 0===t?7:t}function px(e,t){return pw(Wb.count(ew(e)-1,e),t,2)}function mx(e){var t=e.getUTCDay();return t>=4||0===t?Yb(e):Yb.ceil(e)}function fx(e,t){return e=mx(e),pw(Yb.count(ew(e),e)+(4===ew(e).getUTCDay()),t,2)}function gx(e){return e.getUTCDay()}function _x(e,t){return pw(Zb.count(ew(e)-1,e),t,2)}function vx(e,t){return pw(e.getUTCFullYear()%100,t,2)}function yx(e,t){return pw((e=mx(e)).getUTCFullYear()%100,t,2)}function bx(e,t){return pw(e.getUTCFullYear()%1e4,t,4)}function wx(e,t){var n=e.getUTCDay();return pw((e=n>=4||0===n?Yb(e):Yb.ceil(e)).getUTCFullYear()%1e4,t,4)}function xx(){return"+0000"}function Mx(){return"%"}function kx(e){return+e}function Cx(e){return Math.floor(+e/1e3)}aw=function(e){var t=e.dateTime,n=e.date,i=e.time,a=e.periods,r=e.days,s=e.shortDays,o=e.months,c=e.shortMonths,l=fw(a),u=gw(a),d=fw(r),h=gw(r),p=fw(s),m=gw(s),f=fw(o),g=gw(o),_=fw(c),v=gw(c),y={a:function(e){return s[e.getDay()]},A:function(e){return r[e.getDay()]},b:function(e){return c[e.getMonth()]},B:function(e){return o[e.getMonth()]},c:null,d:Pw,e:Pw,f:Vw,g:Jw,G:tx,H:Rw,I:Nw,j:Fw,L:Bw,m:Hw,M:Uw,p:function(e){return a[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:kx,s:Cx,S:qw,u:Ww,U:Zw,V:Qw,w:Yw,W:Gw,x:null,X:null,y:Xw,Y:ex,Z:nx,"%":Mx},b={a:function(e){return s[e.getUTCDay()]},A:function(e){return r[e.getUTCDay()]},b:function(e){return c[e.getUTCMonth()]},B:function(e){return o[e.getUTCMonth()]},c:null,d:ix,e:ix,f:cx,g:yx,G:wx,H:ax,I:rx,j:sx,L:ox,m:lx,M:ux,p:function(e){return a[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:kx,s:Cx,S:dx,u:hx,U:px,V:fx,w:gx,W:_x,x:null,X:null,y:vx,Y:bx,Z:xx,"%":Mx},w={a:function(e,t,n){var i=p.exec(t.slice(n));return i?(e.w=m.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(e,t,n){var i=d.exec(t.slice(n));return i?(e.w=h.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(e,t,n){var i=_.exec(t.slice(n));return i?(e.m=v.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(e,t,n){var i=f.exec(t.slice(n));return i?(e.m=g.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(e,n,i){return k(e,t,n,i)},d:Ew,e:Ew,f:Lw,g:Mw,G:xw,H:Tw,I:Tw,j:Aw,L:Ow,m:Sw,M:$w,p:function(e,t,n){var i=l.exec(t.slice(n));return i?(e.p=u.get(i[0].toLowerCase()),n+i[0].length):-1},q:Cw,Q:jw,s:zw,S:Iw,u:vw,U:yw,V:bw,w:_w,W:ww,x:function(e,t,i){return k(e,n,t,i)},X:function(e,t,n){return k(e,i,t,n)},y:Mw,Y:xw,Z:kw,"%":Dw};function x(e,t){return function(n){var i,a,r,s=[],o=-1,c=0,l=e.length;for(n instanceof Date||(n=new Date(+n));++o<l;)37===e.charCodeAt(o)&&(s.push(e.slice(c,o)),null!=(a=lw[i=e.charAt(++o)])?i=e.charAt(++o):a="e"===i?" ":"0",(r=t[i])&&(i=r(n,a)),s.push(i),c=o+1);return s.push(e.slice(c,o)),s.join("")}}function M(e,t){return function(n){var i,a,r=iw(1900,void 0,1);if(k(r,e,n+="",0)!=n.length)return null;if("Q"in r)return new Date(r.Q);if("s"in r)return new Date(1e3*r.s+("L"in r?r.L:0));if(t&&!("Z"in r)&&(r.Z=0),"p"in r&&(r.H=r.H%12+12*r.p),void 0===r.m&&(r.m="q"in r?r.q:0),"V"in r){if(r.V<1||r.V>53)return null;"w"in r||(r.w=1),"Z"in r?(a=(i=nw(iw(r.y,0,1))).getUTCDay(),i=a>4||0===a?Zb.ceil(i):Zb(i),i=jb.offset(i,7*(r.V-1)),r.y=i.getUTCFullYear(),r.m=i.getUTCMonth(),r.d=i.getUTCDate()+(r.w+6)%7):(a=(i=tw(iw(r.y,0,1))).getDay(),i=a>4||0===a?Nb.ceil(i):Nb(i),i=Db.offset(i,7*(r.V-1)),r.y=i.getFullYear(),r.m=i.getMonth(),r.d=i.getDate()+(r.w+6)%7)}else("W"in r||"U"in r)&&("w"in r||(r.w="u"in r?r.u%7:"W"in r?1:0),a="Z"in r?nw(iw(r.y,0,1)).getUTCDay():tw(iw(r.y,0,1)).getDay(),r.m=0,r.d="W"in r?(r.w+6)%7+7*r.W-(a+5)%7:r.w+7*r.U-(a+6)%7);return"Z"in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,nw(r)):tw(r)}}function k(e,t,n,i){for(var a,r,s=0,o=t.length,c=n.length;s<o;){if(i>=c)return-1;if(37===(a=t.charCodeAt(s++))){if(a=t.charAt(s++),!(r=w[a in lw?t.charAt(s++):a])||(i=r(e,n,i))<0)return-1}else if(a!=n.charCodeAt(i++))return-1}return i}return y.x=x(n,y),y.X=x(i,y),y.c=x(t,y),b.x=x(n,b),b.X=x(i,b),b.c=x(t,b),{format:function(e){var t=x(e+="",y);return t.toString=function(){return e},t},parse:function(e){var t=M(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=x(e+="",b);return t.toString=function(){return e},t},utcParse:function(e){var t=M(e+="",!0);return t.toString=function(){return e},t}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),rw=aw.format,sw=aw.parse,ow=aw.utcFormat,cw=aw.utcParse;var Sx="%Y-%m-%dT%H:%M:%S.%LZ";Date.prototype.toISOString||ow(Sx);var Ex=+new Date("2000-01-01T00:00:00.000Z")?function(e){var t=new Date(e);return isNaN(t)?null:t}:cw(Sx),Ax=Ex;const Tx=["weeks","days","hours","minutes","seconds","milliseconds"],$x={weeks:604800,days:86400,hours:3600,minutes:60,seconds:1,milliseconds:.001};function Ix(e){return"object"==typeof e&&!Array.isArray(e)}class Ox{constructor(e=0,t=0,n=0,i=0,a=0,r=0){this.days=0,this.seconds=0,this.milliseconds=0;let s={days:e,seconds:t,milliseconds:n,minutes:i,hours:a,weeks:r};Ix(e)&&(delete s.days,Object.assign(s,e));let o=0;if(Tx.forEach((e=>{o+=(s[e]??0)*$x[e]})),o<this.minSeconds||o>this.maxSeconds)throw RangeError("value out of range, must have magnitude less than 999999999 days");if(o.toString().includes(".")){const e=o.toString();this.milliseconds=Math.trunc(parseFloat(`0.${e.split(".")[1]}`)/$x.milliseconds),e.startsWith("-")&&(this.milliseconds*=-1),o=Math.trunc(o)}this.days=Math.trunc(o/$x.days),this.days=this.days||0,this.seconds=o-this.days*$x.days,this.seconds=this.seconds||0}total_seconds(){return this.days*$x.days+this.seconds+this.milliseconds*$x.milliseconds}valueOf(){return this.total_seconds()}toString(){return`${0!=this.days?`${this.days} day${Math.abs(this.days)>1?"s,":","}`:""} ${ow("%-H:%M:%S"+(this.milliseconds?".%f":""))(new Date(1e3*this.valueOf()))}`.trim()}static get min(){return new Ox(-1e8)}get minSeconds(){return-864e10}static get max(){return new Ox(1e8)}get maxSeconds(){return 864e10}static get resolution(){return new Ox({milliseconds:1})}}class Lx{constructor(e=0,t=0,n=0,i=0){this.hour=0,this.minute=0,this.second=0,this.millisecond=0;let a={hour:e,minute:t,second:n,millisecond:i};Ix(e)&&(delete a.hour,Object.assign(a,e));for(const e in a)if(!Number.isInteger(a[e]))throw TypeError("'float' object cannot be interpreted as an integer");if((a.hour??0)<0||(a.hour??0)>23)throw RangeError("hour must be in 0..23");if((a.minute??0)<0||(a.minute??0)>59)throw RangeError("minute must be in 0..59");if((a.second??0)<0||(a.second??0)>59)throw RangeError("second must be in 0..59");if((a.millisecond??0)<0||(a.millisecond??0)>999)throw RangeError("millisecond must be in 0..999");Object.assign(this,a)}replace(e=this.hour,t=this.minute,n=this.second,i=this.millisecond){let a={hour:e,minute:t,second:n,millisecond:i};return Ix(e)&&(delete a.hour,Object.assign(a,e)),new Lx(a.hour??this.hour,a.minute??this.minute,a.second??this.second,a.millisecond??this.millisecond)}isoformat(e="auto"){let t;switch(e){case"hours":t="%H";break;case"minutes":t="%H:%M";break;case"seconds":t="%H:%M:%S";break;case"milliseconds":t="%H:%M:%S.%f";break;default:t="%H:%M:%S"+(this.millisecond?".%f":"")}return this.strftime(t)}valueOf(){return this.hour*$x.hours+this.minute*$x.minutes+this.second*$x.seconds+this.millisecond*$x.milliseconds}toString(){return this.isoformat()}strftime(e){return ow(e)(this.jsDate)}get jsDate(){return new Date(1e3*this.valueOf())}static get min(){return new Lx(0,0,0,0)}static get max(){return new Lx(23,59,59,999)}static get resolution(){return Ox.resolution}static fromisoformat(e){const t=Ax(`1970-01-01T${e}`);if(t)return new Lx(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());throw SyntaxError("Unable to parse date string")}}const Dx=100,jx=9999,zx=36160,Px=3652059,Rx=["year","month","day","hour","minute","second","millisecond"];class Nx{constructor(e,t,n,i=0,a=0,r=0,s=0,o=!1){this.year=1970,this.month=1,this.day=1,this.hour=0,this.minute=0,this.second=0,this.millisecond=0,this.utc=!1;const c={year:e,month:t,day:n,hour:i,minute:a,second:r,millisecond:s,utc:o};if(Ix(e)&&(delete c.year,Object.assign(c,e)),!c.year||!c.month||!c.day)throw SyntaxError("Missing required argument year, month, or day");for(const e in c)if(Rx.includes(e)&&!Number.isInteger(c[e]))throw TypeError(`Argument ${e} value ${c[e]} is not an integer`);if(c.year<Dx||c.year>jx)throw RangeError(`year ${c.year} is out of range`);if(c.month<1||c.month>12)throw RangeError(`month ${c.month} is out of range`);if(c.day<1||c.day>new Date(c.year,c.month,0).getDate())throw RangeError(`day ${n} is out of range for month`);if((c.hour??0)<0||(c.hour??0)>23)throw RangeError("hour must be in 0..23");if((c.minute??0)<0||(c.minute??0)>59)throw RangeError("minute must be in 0..59");if((c.second??0)<0||(c.second??0)>59)throw RangeError("second must be in 0..59");if((c.millisecond??0)<0||(c.millisecond??0)>999)throw RangeError("millisecond must be in 0..999");Object.assign(this,c)}date(){return new Fx(this.year,this.month,this.day)}time(){return new Lx(this.hour,this.minute,this.second,this.millisecond)}replace(e=this.year,t=this.month,n=this.day,i=this.hour,a=this.minute,r=this.second,s=this.millisecond){const o={year:e,month:t,day:n,hour:i,minute:a,second:r,millisecond:s};return Ix(e)&&(delete o.year,Object.assign(o,e)),new Nx({year:o.year??this.year,month:o.month??this.month,day:o.day??this.day,hour:o.hour??this.hour,minute:o.minute??this.minute,second:o.second??this.second,millisecond:o.millisecond??this.millisecond})}toordinal(){return this.date().toordinal()}timestamp(){let e;return e=this.utc?Date.UTC(this.year,this.month-1,this.day||1,this.hour||0,this.minute||0,this.second||0,this.millisecond||0):this.jsDate.getTime(),e/1e3}weekday(){return this.date().weekday()}isoweekday(){return this.weekday()+1}isocalendar(){const[e,t,n]=ow("%G-%V-%u")(this.jsDate).split("-");return[Number(e),Number(t),Number(n)]}isoformat(e="T",t="auto"){const n={sep:e,timespec:t};let i;switch(Ix(e)&&(delete n.sep,Object.assign(n,e),n.sep=n.sep??"T"),n.timespec){case"hours":i=`%Y-%m-%d${n.sep}%H`;break;case"minutes":i=`%Y-%m-%d${n.sep}%H:%M`;break;case"seconds":i=`%Y-%m-%d${n.sep}%H:%M:%S`;break;case"milliseconds":i=`%Y-%m-%d${n.sep}%H:%M:%S.%f`;break;default:i=`%Y-%m-%d${n.sep}%H:%M:%S${this.millisecond?".%f":""}`}return this.strftime(i)}valueOf(){return this.timestamp()}toString(){return this.isoformat(" ")}ctime(){return rw("%a %b %-e %H:%M:%S %Y")(this.jsDate)}strftime(e){return this.utc?ow(e)(this.jsDate):rw(e)(this.jsDate)}get jsDate(){return this.utc?new Date(1e3*this.valueOf()):new Date(this.year,this.month-1,this.day||1,this.hour||0,this.minute||0,this.second||0,this.millisecond||0)}static get min(){return new Nx(Dx,1,1)}static get max(){return new Nx(jx,12,31,23,59,59,999)}static get resolution(){return Ox.resolution}static today(){return Nx.now()}static now(){return Nx.fromjsdate(new Date)}static utcnow(){return Nx.utcfromjsdate(new Date)}static fromtimestamp(e){const t=new Date(1e3*e);return Nx.fromjsdate(t)}static utcfromtimestamp(e){const t=new Date(1e3*e);return Nx.utcfromjsdate(t)}static fromjsdate(e){return new Nx({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}static utcfromjsdate(e){return new Nx({year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),millisecond:e.getUTCMilliseconds(),utc:!0})}static fromordinal(e){if(e<zx||e>Px)throw RangeError(`ordinal ${e} is out of range`);return Nx.fromtimestamp(Fx.min.valueOf()+new Ox({days:e-zx}).valueOf())}static combine(e,t){return new Nx({year:e.year,month:e.month,day:e.day,hour:t.hour,minute:t.minute,second:t.second,millisecond:t.millisecond})}static fromisoformat(e){const t=Ax(e);if(t)return Nx.fromjsdate(t);throw SyntaxError("Unable to parse date string")}static fromisocalendar(e,t,n){return Nx.strptime(`${e}-${t}-${n}`,"%G-%V-%u")}static strptime(e,t,n=!1){const i=(n?cw:sw)(t)(e);if(!i)throw Error(`'${e}' does not match format '${t}'`);return n?Nx.utcfromjsdate(i):Nx.fromjsdate(i)}}class Fx{constructor(e,t,n){if(this.year=1970,this.month=1,this.day=1,!Number.isInteger(e)||e<Dx||e>jx)throw RangeError(`year ${e} is out of range`);if(!Number.isInteger(t)||t<1||t>12)throw RangeError(`month ${t} is out of range`);if(!Number.isInteger(n)||n<1||n>new Date(e,t,0).getDate())throw RangeError(`day ${n} is out of range for month`);Object.assign(this,{year:e,month:t,day:n})}replace(e=this.year,t=this.month,n=this.day){const i={year:e,month:t,day:n};return Ix(e)&&(delete i.year,Object.assign(i,e)),new Fx(i.year??this.year,i.month??this.month,i.day??this.day)}toordinal(){return Math.trunc((this.valueOf()+new Ox({days:719163}).total_seconds())/$x.days)}weekday(){return(this.jsDate.getDay()+6)%7}isoweekday(){return this.weekday()+1}isocalendar(){const[e,t,n]=ow("%G-%V-%u")(this.jsDate).split("-");return[Number(e),Number(t),Number(n)]}isoformat(){return ow("%Y-%m-%d")(this.jsDate)}valueOf(){return this.jsDate.getTime()/1e3}toString(){return this.isoformat()}ctime(){return rw("%a %b %-e 00:00:00 %Y")(this.jsDate)}strftime(e){return rw(e)(this.jsDate)}get jsDate(){return new Date(this.year,this.month-1,this.day)}static get min(){return new Fx(Dx,1,1)}static get max(){return new Fx(jx,12,31)}static get resolution(){return new Ox({days:1})}static today(){const e=Nx.now();return new Fx(e.year,e.month,e.day)}static fromtimestamp(e){const t=Nx.fromtimestamp(e);return new Fx(t.year,t.month,t.day)}static fromordinal(e){if(e<zx||e>Px)throw RangeError(`ordinal ${e} is out of range`);return Fx.fromtimestamp(Fx.min.valueOf()+new Ox({days:e-zx}).valueOf())}static fromisoformat(e){const t=Ax(e);if(t)return new Fx(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate());throw SyntaxError("Unable to parse date string")}static fromisocalendar(e,t,n){const i=Nx.strptime(`${e}-${t}-${n}`,"%G-%V-%u");return new Fx(Number(i.year),Number(i.month),Number(i.day))}}const Bx=(...e)=>new Ox(...e);Bx.min=Ox.min,Bx.max=Ox.max,Bx.resolution=Ox.resolution;const Vx=(...e)=>new Fx(...e);Vx.min=Fx.min,Vx.max=Fx.max,Vx.resolution=Fx.resolution,Vx.today=Fx.today,Vx.fromtimestamp=Fx.fromtimestamp,Vx.fromordinal=Fx.fromordinal,Vx.fromisoformat=Fx.fromisoformat,Vx.fromisocalendar=Fx.fromisocalendar;const Hx=(...e)=>new Nx(...e);Hx.min=Nx.min,Hx.max=Nx.max,Hx.resolution=Nx.resolution,Hx.today=Nx.today,Hx.now=Nx.now,Hx.utcnow=Nx.utcnow,Hx.fromtimestamp=Nx.fromtimestamp,Hx.utcfromtimestamp=Nx.utcfromtimestamp,Hx.fromjsdate=Nx.fromjsdate,Hx.utcfromjsdate=Nx.utcfromjsdate,Hx.fromordinal=Nx.fromordinal,Hx.combine=Nx.combine,Hx.fromisoformat=Nx.fromisoformat,Hx.fromisocalendar=Nx.fromisocalendar,Hx.strptime=Nx.strptime;const Ux=(...e)=>new Lx(...e);Ux.min=Lx.min,Ux.max=Lx.max,Ux.resolution=Lx.resolution,Ux.fromisoformat=Lx.fromisoformat;const qx={MINYEAR:Dx,MAXYEAR:jx,MINYEAR_ORDINAL:zx,MAXYEAR_ORDINAL:Px,timedelta:Bx,date:Vx,datetime:Hx,time:Ux};function Wx(){return qx.datetime.now()}function Zx(e="00:00"){const[t,n,i,a]=e.split(":"),r=qx.datetime.now(),s=qx.datetime(r.year,r.month,r.day,Number(t??0),Number(n??0),Number(i??0),Number(a??0));return ab(s.toString()),s}function Kx(e,t=void 0,n=!0){"object"!=typeof t||Array.isArray(t)||(n=t.utc??n,t=t.fallback??void 0);try{let t;if("string"==typeof e)if(/[^\d]/g.test(e)){e=e.replace(/T/g," ");const i=["%Y-%m-%d %H:%M:%S.%f%Z","%Y-%m-%d %H:%M:%S.%f","%Y-%m-%d %H:%M:%S%Z","%Y-%m-%d %H:%M:%S"];for(const a of i)try{t=qx.datetime.strptime(e,a,n);break}catch{}t||(e=parseFloat(e))}else e=parseFloat(e);else t="number"==typeof e?n?qx.datetime.utcfromtimestamp(e):qx.datetime.fromtimestamp(e):e instanceof Fx?qx.datetime(e.year,e.month,e.day):e;return ab((t??"NaN").toString()),t}catch(e){if(t)return t;throw e}}function Qx(e,t){try{let t;return"string"==typeof e?(e.includes(" ")||e.includes("T")||(e+=" 00:00:00"),t=Date.parse(e)/1e3):t="number"==typeof e?qx.datetime.utcfromtimestamp(e).jsDate.getTime()/1e3:e.jsDate.getTime()/1e3,ab(t.toString()),t}catch(e){if(t)return t;throw e}}function Yx(e){return qx.datetime.fromjsdate(qx.datetime(e).jsDate)}function Gx(e,t=1,n=!1){if(!(e instanceof Nx))return e;let i=Wx().valueOf()-Yx(e).valueOf();if(n&&(i*=-1),i<=0)return e;(0==t||t>6)&&(t=6);const a={year:31536e3,month:2592e3,day:86400,hour:3600,minute:60,second:1},r=Object.keys(a);let s="",o=!1;for(let e=0;e<t;e++){let n=i/a[r[e]];n=e==t-1?Math.round(n):Math.floor(n),(o||n>0)&&(o=!0,s+=` ${n} ${r[e]}${1!=n?"s":""}`,i-=n*a[r[e]])}return s.trim()}function Xx(e,t=1){return Gx(e,t)}function Jx(e,t=1){return Gx(e,t,!0)}const eM={states:zy,state_attr:Py,has_value:Ry,state_translated:Cb,attr_name_translated:Sb,attr_value_translated:Eb,expand:Ky,device_entities:Fy,device_attr:By,device_id:Vy,floor_id:qy,floor_name:Wy,floor_areas:Zy,area_id:Iy,area_name:Oy,area_entities:Ly,area_devices:Dy,labels:Gy,label_areas:eb,label_devices:tb,label_entities:nb,iif:Qy,closest:Uy},tM={label_id:Xy,label_name:Jy,today_at:Zx,as_datetime:Kx,as_timestamp:Qx,as_local:Yx,time_since:Xx,time_until:Jx,timestamp_local:function(e,t){try{const t=qx.datetime.fromtimestamp(e).strftime("%Y-%m-%dT%H:%M:%S%Z");return ab(t),t}catch(e){if(t)return t;throw e}},timestamp_utc:function(e,t){try{const t=qx.datetime.utcfromtimestamp(e).strftime("%Y-%m-%dT%H:%M:%S%Z");return ab(t),t}catch(e){if(t)return t;throw e}},timestamp_custom:function(e,t,n=!0,i=void 0){"object"!=typeof n||Array.isArray(n)||(i=n.fallback??i,n=n.local??!0);try{const i=(n?qx.datetime.fromtimestamp(e):qx.datetime.utcfromtimestamp(e)).strftime(t);return ab(i),i}catch(e){if(i)return i;throw e}},to_json:function(e,t=!1,n=!1,i=!1){"object"!=typeof t||Array.isArray(t)||(i=t.sort_keys??i,n=t.pretty_print??n,t=t.ensure_ascii??!1),i&&(e=Object.keys(e).sort().reduce(((t,n)=>(t[n]=e[n],t)),{}));let a=JSON.stringify(e,void 0,n?2:void 0);return t&&(a=a.replace(/[\u007F-\uFFFF]/g,(e=>`\\u'${("0000"+e.charCodeAt(0).toString(16)).substring(-4)}`))),a},from_json:function(e){return JSON.parse(e)},closest:Uy,contains:jy,is_number:rb,bool:sb,log:ob,sin:cb,cos:lb,tan:ub,asin:db,acos:hb,atan:pb,atan2:mb,sqrt:fb,max:gb,min:_b,average:vb,median:yb,statistical_mode:bb,bitwise_and:function(e,t){return e&t},bitwise_or:function(e,t){return e|t},bitwise_xor:function(e,t){return e^t},bitwise_not:function(e){return~e},ord:function(e){if(1==e.length)return e.codePointAt(0);throw Error("Expected a character, but received a string")},multiply:function(e,t){return Number(e)*Number(t)},add:function(e,t){return Number(e)+Number(t)},regex_replace:function(e,t="",n=""){return e.replace(new RegExp(t,"g"),n)},regex_findall:function(e,t=""){return e.match(new RegExp(t,"g"))??[]},regex_findall_index:function(e,t="",n=0){return(e.match(new RegExp(t,"g"))??[])[n]},str:ib};const nM={states:zy,is_state:function(e,t,n){try{const i=zy(e,t);return Array.isArray(n)?n.includes(i):i==n}catch{return!1}},state_attr:Py,is_state_attr:function(e,t,n,i){try{return Py(e,t,n)==i}catch{return!1}},has_value:Ry,state_translated:Cb,attr_name_translated:Sb,attr_value_translated:Eb,expand:Ky,is_hidden_entity:function(e,t){try{return e.entities[t].hidden??!1}catch{return!1}},device_entities:Fy,device_attr:By,is_device_attr:function(e,t,n,i){try{return null!=i&&By(e,t,n)==i}catch{return!1}},device_id:Vy,floors:function(e){return Object.keys(e.floors)},floor_id:qy,floor_name:Wy,floor_areas:Zy,areas:function(e){try{return Object.keys(e.areas)}catch{return[]}},area_id:Iy,area_name:Oy,area_entities:Ly,area_devices:Dy,integration_entities:function(e,t){try{const n=[];if(t){for(const i in e.entities)e.entities[i].platform==t&&n.push(i);n.sort()}return n}catch{return[]}},labels:Gy,label_areas:eb,label_devices:tb,label_entities:nb,iif:Qy,distance:function(e,...t){try{let n,i,a,r,s=0;if("string"==typeof t[0])n=e.states[t[0]].attributes.latitude,a=e.states[t[0]].attributes.longitude,s=1;else if("object"!=typeof t[0]||Array.isArray(t[0])){if("number"!=typeof t[0])return null;if("number"!=typeof t[1])throw Error("Latitude provided but not longitude 1");n=t[0],a=t[1],s=2}else n=t[0].attributes.latitude,a=t[0].attributes.longitude,s=1;if("string"==typeof t[s])i=e.states[t[s]].attributes.latitude,r=e.states[t[s]].attributes.longitude;else if("object"!=typeof t[s]||Array.isArray(t[s]))if("number"==typeof t[s]){if("number"!=typeof t[s+1])throw Error("Latitude provided but not longitude 2");i=t[s],r=t[s+1]}else i=e.states["zone.home"].attributes.latitude,r=e.states["zone.home"].attributes.longitude;else i=t[s].attributes.latitude,r=t[s].attributes.longitude;return Hy([n,a],[i,r],"mi"==e.config.unit_system.length)}catch{return null}},closest:Uy},iM={label_id:Xy,label_name:Jy,now:Wx,utcnow:function(){return qx.datetime.utcnow()},today_at:Zx,as_datetime:Kx,as_timestamp:Qx,as_local:Yx,strptime:function(e,t,n=void 0,i=!1){"object"!=typeof n||Array.isArray(n)||n instanceof Nx||n instanceof Fx||(i=n.utc??i,n=n.fallback??void 0);try{t=t.replace(/%z/g,"%Z");const n=qx.datetime.strptime(e,t,i);return ab(n.toString()),n}catch(e){if(n)return n;throw e}},time_since:Xx,time_until:Jx,as_timedelta:function(e){try{let t;if(e.includes(":")||e.includes(" ")||/^\d*\.?\d*$/.test(e)){let n,i;e.includes(" ")?e.includes("days")?[n,i]=e.split(" days "):[n,i]=e.split(" "):(n=0,i=e);const[a,r,s]=i.split(":").reverse();t=qx.timedelta(Number(n),Number(a.replace(",",".")??0),0,Number(r??0),Number(s??0))}else{if(!e.startsWith("P"))return null;{const n=e.replace(/P|T/g,"").match(/(\d*?)[A-Z]/g);if(!n)return null;const i={};for(const e of n){const t=e.match(/^(\d*)/),n=e.match(/[A-Z]$/);t&&n&&(i[n[0]]=parseFloat(t[0]))}t=qx.timedelta(i.D,i.S,0,i.M,i.H,i.W)}}return ab(t.toString()),t}catch{return null}},float:function(e,t){try{const t=parseFloat(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}},is_number:rb,int:function(e,t){try{const t=parseInt(e);return ab(t.toString()),t}catch(e){if(t)return t;throw e}},bool:sb,log:ob,sin:cb,cos:lb,tan:ub,asin:db,acos:hb,atan:pb,atan2:mb,sqrt:fb,max:gb,min:_b,average:vb,median:yb,statistical_mode:bb,set:function(...e){return new Set(e.flat(1/0))},list:function(...e){return e.map((e=>Array.from(e))).flat(1/0)},zip:function(...e){if(e.length>1)return e[0].map(((t,n)=>{const i=[t];for(let t=1;t<e.length;t++)i.push(e[t][n]);return i}));{e=e[0];const t=[];for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)t[i]||t.push([]),t[i].push(e[n][i]);return t}},match_media:function(e){return window.matchMedia(e).matches},str:ib},aM={e:wb,pi:xb,tau:Mb,inf:kb};const rM={list:function(e){return Array.isArray(e)},set:function(e){return e instanceof Set},datetime:function(e){return e instanceof Nx},string_like:function(e){return"string"==typeof e||e instanceof Buffer||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof ArrayBuffer},contains:jy,match:function(e,t){return new RegExp(`^${t}`).test(e)},search:function(e,t){return new RegExp(t,"g").test(e)},test:function(e,t){return new RegExp(t).test(e)}};let sM;$y.installJinjaCompat();const oM=function(e){for(const t in rM)e.addTest(t,(function(...e){return rM[t](...e)}));return e}(function(e){for(const t in tM)e.addFilter(t,(function(...e){return tM[t](...e)}));for(const t in eM)e.addFilter(t,(function(...e){return eM[t](sM,...e)}));return e}(function(e){for(const t in iM)e.addGlobal(t,(function(...e){return iM[t](...e)}));for(const t in nM)e.addGlobal(t,(function(...e){return nM[t](sM,...e)}));for(const t in aM)e.addGlobal(t,aM[t]);return e.addGlobal("dt",qx),e.addGlobal("date",Fx),e.addGlobal("time",Lx),e.addGlobal("datetime",Nx),e.addGlobal("timedelta",Ox),e}(new $y.Environment)));function cM(e,t,n){return sM||async function(e){if(e.connection){const t=await e.connection.sendMessagePromise({type:"config/label_registry/list"});t.sort(((e,t)=>e.name.localeCompare(t.name)));for(const e of t)Yy[e.label_id]=e}}(e),sM=e,"string"==typeof t&&(t.includes("{{")&&t.includes("}}")||t.includes("{%")&&t.includes("%}"))?(t=oM.renderString(structuredClone(t),{hass:e,_states:Ny(e),...n}).trim(),[void 0,null,"undefined","null","None"].includes(t)?"":"true"==t.toLowerCase()||"false"!=t.toLowerCase()&&t):t}class lM{constructor(){this.renderRecursively=(e,t,n)=>this._renderTemplateRecursively(e,t,this._generateTemplateContext(n))}_generateTemplateContext(e){if(!(e?.conditionState?.camera||e?.conditionState?.view||e?.triggerData||e?.mediaData))return;const t={...e?.conditionState?.camera&&{camera:e.conditionState.camera},...e?.conditionState?.view&&{view:e.conditionState.view},...e?.triggerData&&{trigger:e.triggerData},...e?.mediaData&&{media:e.mediaData}};return{acc:t,advanced_camera_card:t}}_renderTemplateRecursively(e,t,n){if("string"==typeof t)return cM(e,t,n);if(Array.isArray(t))return t.map((t=>this._renderTemplateRecursively(e,t,n)));if("object"==typeof t&&null!==t){const i={};for(const a in t)i[a]=this._renderTemplateRecursively(e,t[a],n);return i}return t}}const uM=(e,t,n)=>{Xu(e,t,n)},dM=(e,t,n)=>cc(e,t,n),hM=(e,t)=>{!function(e,t){null==e||Wu(e,t)}(e,t)},pM=e=>Nl(e),mM=(e,t)=>e.replace("#",`[${t.toString()}]`),fM=function(e){let t=!1;for(let n=0;n<EM.length;n++)t=EM[n](e)||t;return t},gM=function(e){return fM(pM(e))},_M=function(e,t,n){return function(i){return((e,t,n,i)=>{const a=dM(e,t);if(void 0===a)return!1;const r=i?.transform?i.transform(a):a;return!(t===n&&Uu(a,r)||(null===r?i?.keepOriginal||(hM(e,t),0):void 0===r||(i?.keepOriginal||hM(e,t),uM(e,n,r),0)))})(i,e,t,n)}},vM=function(e,t,n){return function(i){let a=_M(e,t,n)(i);return a=wM(Og,_M(e,t,n),(e=>e.merge&&"object"==typeof e.merge?e.merge:void 0))(i)||a,a=wM(Og,_M(e,t,n),(e=>e.set&&"object"==typeof e.set?e.set:void 0))(i)||a,a}},yM=function(e,t){return vM(e,e,{transform:t})},bM=function(e){return vM(e,e,{transform:e=>null})},wM=function(e,t,n){return function(i){let a=!1;const r=dM(i,e);return Array.isArray(r)&&r.forEach((e=>{const i=n?n(e):e;i&&"object"==typeof i&&(a=t(i)||a)})),a}},xM=(e,t)=>{const n=i=>{let a=!1;if(i&&"object"==typeof i){const r=t?t(i):i;r&&(a=e(r)||a),Array.isArray(i)?i.forEach((e=>{a=n(e)||a})):Object.keys(i).forEach((e=>{a=n(i[e])||a}))}return a};return n},MM=e=>{if("object"!=typeof e||!e||"object"!=typeof e.conditions||!e.conditions)return!1;const t=e.conditions,n=[];if(void 0!==t.view&&n.push({condition:"view",views:t.view}),void 0!==t.fullscreen&&n.push({condition:"fullscreen",fullscreen:t.fullscreen}),void 0!==t.expand&&n.push({condition:"expand",expand:t.expand}),void 0!==t.camera&&n.push({condition:"camera",cameras:t.camera}),void 0!==t.media_loaded&&n.push({condition:"media_loaded",media_loaded:t.media_loaded}),void 0!==t.state&&Array.isArray(t.state))for(const e of t.state)"object"!=typeof e||!e||void 0===e.state&&void 0===e.state_not&&void 0===e.entity||n.push({condition:"state",...e.state&&{state:e.state},...e.state_not&&{state_not:e.state_not},...e.entity&&{entity:e.entity}});return void 0!==t.media_query&&n.push({condition:"screen",media_query:t.media_query}),!!n.length&&(e.conditions=n,!0)},kM=e=>!("object"!=typeof e||!e||"call-service"!==e.action||"string"!=typeof e.service)&&(e.action="perform-action",e.perform_action=e.service,delete e.service,!0),CM=e=>!("object"!=typeof e||!e||"call-service"!==e.action||void 0===e.service||void 0===e.service_data||void 0!==e.data)&&(e.data=e.service_data,delete e.service_data,!0),SM=e=>{const t=[{oldKey:"type",oldValue:"custom:frigate-card",newValue:"custom:advanced-camera-card"},{oldKey:"action",oldValue:"custom:frigate-card-action",newValue:"custom:advanced-camera-card-action"},{oldKey:"type",oldValue:"custom:frigate-card-menu-icon",newValue:"custom:advanced-camera-card-menu-icon"},{oldKey:"type",oldValue:"custom:frigate-card-menu-state-icon",newValue:"custom:advanced-camera-card-menu-state-icon"},{oldKey:"type",oldValue:"custom:frigate-card-menu-submenu",newValue:"custom:advanced-camera-card-menu-submenu"},{oldKey:"type",oldValue:"custom:frigate-card-menu-submenu-select",newValue:"custom:advanced-camera-card-menu-submenu-select"},{oldKey:"type",oldValue:"custom:frigate-card-status-bar-icon",newValue:"custom:advanced-camera-card-status-bar-icon"},{oldKey:"type",oldValue:"custom:frigate-card-status-bar-image",newValue:"custom:advanced-camera-card-status-bar-image"},{oldKey:"type",oldValue:"custom:frigate-card-status-bar-string",newValue:"custom:advanced-camera-card-status-bar-string"},{oldKey:"type",oldValue:"custom:frigate-card-conditional",newValue:"custom:advanced-camera-card-conditional"},{oldKey:"type",oldValue:"custom:frigate-card-conditional",newValue:"custom:advanced-camera-card-conditional"},{oldKey:"frigate_card_action",newKey:"advanced_camera_card_action"}];let n=!1;for(const i of t)i.oldValue&&i.newValue&&e[i.oldKey]===i.oldValue&&(e[i.newKey??i.oldKey]=i.newValue,n=!0),i.oldKey in e&&i.newKey&&(e[i.newKey]=e[i.oldKey],delete e[i.oldKey],n=!0);return n},EM=[e=>xM(CM)("object"==typeof e&&e?e:{}),function(e){if("object"!=typeof e||!e||!($p in e)||!Array.isArray(e[$p]))return!1;let t=!1;const n=n=>{if(!t){if(!cc(e,"live.controls.ptz")){const{type:t,...i}=n;Xu(e,"live.controls.ptz",i)}t=!0}},i=e=>{const t=[];for(const a of e)if("custom:advanced-camera-card-ptz"===a.type)n(a);else if("conditional"!==a.type&&"custom:advanced-camera-card-conditional"!==a.type||!Array.isArray(a.elements))t.push(a);else{const e=i(a.elements);e.length&&(a.elements=e,t.push(a))}return t},a=i(e[$p]);return t&&(a.length?e[$p]=a:delete e[$p]),t},vM("view.timeout_seconds",Bp),yM("live.lazy_unload",(e=>"all"===e?["unselected","hidden"]:"never"===e?null:dd(e))),yM("live.auto_play",(e=>"all"===e?null:"never"===e?[]:dd(e))),yM("live.auto_pause",(e=>"all"===e?["unselected","hidden"]:"never"===e?null:dd(e))),yM("live.auto_mute",(e=>"all"===e?null:"never"===e?[]:dd(e))),yM("live.auto_unmute",(e=>"all"===e?["selected","visible","microphone"]:"never"===e?null:dd(e))),yM("media_viewer.auto_play",(e=>"all"===e?null:"never"===e?[]:dd(e))),yM("media_viewer.auto_pause",(e=>"all"===e?null:"never"===e?[]:dd(e))),yM("media_viewer.auto_mute",(e=>"all"===e?null:"never"===e?[]:dd(e))),yM("media_viewer.auto_unmute",(e=>"all"===e?["selected","visible"]:"never"===e?null:dd(e))),vM("live.controls.thumbnails.media",ff),vM("timeline.media",eg),vM("live.controls.timeline.media",Mf),vM("media_viewer.controls.timeline.media",Hm),vM("view.scan",am),vM("view.triggers.enabled",lm,{transform:e=>!0===e?"live":null,keepOriginal:!0}),vM("view.triggers.enabled",sm,{transform:e=>!0!==e&&null}),vM("view.triggers.untrigger_reset",um,{transform:e=>e?"default":null}),vM("live.layout",Ap),bM("media_viewer.layout"),bM("image.layout"),wM(Og,MM),e=>xM(MM)("object"==typeof e&&e?e[$p]:{}),e=>xM(MM)("object"==typeof e&&e?e.automations:{}),wM(wh,vM("hide","capabilities",{transform:e=>!0===e?{disable_except:["substream"]}:null})),vM("performance.profile",Vg,{transform:e=>"low"===e?["low-performance"]:null}),wM(Og,_M("overrides","merge")),vM("live.controls.ptz",Tp,{transform:e=>{if("object"!=typeof e||!e)return;const t=["data_left","data_right","data_up","data_down","data_zoom_in","data_zoom_out","service"],n=["actions_left","actions_right","actions_up","actions_down","actions_zoom_in","actions_zoom_out"],i=[...t,...n,"data_home","actions_home"];if(!Object.keys(e).some((e=>i.includes(e))))return;const a={};t.filter((t=>t in e)).reduce(((t,n)=>(t[n]=e[n],t)),a),n.filter((t=>t in e)).reduce(((t,n)=>("object"==typeof e[n]&&"tap_action"in e[n]&&(t[n]=e[n].tap_action),t)),a);const r=()=>{a.presets="presets"in e&&"object"==typeof e.presets&&e.presets?e.presets:{}};return"actions_home"in e&&"object"==typeof e.actions_home&&e.actions_home&&"tap_action"in e.actions_home?(r(),a.presets.home=e.actions_home.tap_action):"data_home"in e&&"object"==typeof e.data_home&&e.data_home&&"string"==typeof e.service&&(r(),a.presets.service=e.service,a.presets.data_home=e.data_home),a},keepOriginal:!0}),yM("live.controls.ptz",(e=>{if("object"!=typeof e||!e)return e;const t=["mode","position","orientation","hide_pan_tilt","hide_zoom","hide_home","style"],n=Object.keys(e);return n.some((e=>!t.includes(e)))?n.filter((e=>t.includes(e))).reduce(((t,n)=>(t[n]=e[n],t)),{}):void 0})),vM("view.update_cycle_camera",Gp),vM("view.update_force",Jp,{transform:e=>!0===e?"all":null}),vM("view.update_seconds",em),vM("view.update_entities",tm),_M("live.controls.title",xg,{transform:e=>"object"==typeof e&&e&&"string"==typeof e.mode?"none"===e.mode?{style:"none"}:e.mode.includes("bottom")?{position:"bottom"}:e.mode.includes("top")?{position:"top"}:null:null}),bM("live.controls.title"),bM("media_viewer.controls.title"),e=>xM(kM)("object"==typeof e&&e?e:{}),vM("dimensions.max_height",Ig),bM("dimensions.min_height"),vM("view.dark_mode",Fp,{transform:e=>"on"===e}),e=>xM(SM)("object"==typeof e&&e?e:{}),yM("view.theme.overrides",(e=>{if("object"!=typeof e||!e||Array.isArray(e))return e;const t={...e},n=new RegExp(/^--frigate-card-/);for(const i of Object.keys(e))if(i.match(n)){t[i.replace(n,"--advanced-camera-card-")]=e[i],delete t[i]}return t})),vM("menu.buttons.frigate","menu.buttons.iris")];class AM{constructor(e,t){this._listeners=[],this._mediaQueries=[],this._evaluation={result:!1},this._templateRenderer=new lM,this._mediaQueryHandler=()=>this._evaluate(),this._stateManagerHandler=e=>{this._evaluate({stateChange:e})},this._conditions=e,e.forEach((e=>{if("screen"===e.condition){const t=window.matchMedia(e.media_query);t.addEventListener("change",this._mediaQueryHandler),this._mediaQueries.push(t)}})),this._stateManager=t??null,this._evaluate({callListeners:!1}),this._stateManager?.addListener(this._stateManagerHandler)}destroy(){this._stateManager?.removeListener(this._stateManagerHandler),this._listeners.forEach((e=>this.removeListener(e))),this._mediaQueries.forEach((e=>e.removeEventListener("change",this._mediaQueryHandler))),this._mediaQueries=[],this._conditions=[]}addListener(e){this._listeners.includes(e)||this._listeners.push(e)}removeListener(e){this._listeners=this._listeners.filter((t=>t!==e))}getEvaluation(){return this._evaluation}_evaluate(e){const t=e?.stateChange?.new??this._stateManager?.getState();let n=!0,i={};for(const a of this._conditions){const r=this._evaluateCondition(a,t,e?.stateChange?.old);if(!r.result){n=!1;break}i={...i,...r.triggerData}}const a=n?{result:n,triggerData:i}:{result:n};(a.result!==this._evaluation.result||a.triggerData&&Object.keys(a.triggerData).length)&&(this._evaluation=a,(e?.callListeners??1)&&this._listeners.forEach((e=>this._evaluation&&e(this._evaluation))))}_evaluateCondition(e,t,n){switch(e.condition){case void 0:case"state":{const i=n?.hass?.states?.[e.entity]?.state,a=t?.hass?.states?.[e.entity]?.state;return{result:!e.state&&!e.state_not&&a!==i||(!!e.state||!!e.state_not)&&!!a&&(!e.state||(Array.isArray(e.state)?e.state.includes(a):e.state===a))&&(!e.state_not||(Array.isArray(e.state_not)?!e.state_not.includes(a):e.state_not!==a)),...i!==a&&{triggerData:{state:{entity:e.entity,...i&&{from:i},...a&&{to:a}}}}}}case"view":{const i=n?.view,a=t?.view;return{result:!!a&&e.views?.includes(a)||a!==i&&!e.views?.length,...i!==a&&{triggerData:{...(n?.view||t?.view)&&{view:{...n?.view&&{from:n.view},...t?.view&&{to:t.view}}}}}}}case"fullscreen":return{result:void 0!==t?.fullscreen&&e.fullscreen===t.fullscreen};case"expand":return{result:void 0!==t?.expand&&e.expand===t.expand};case"camera":{const i=n?.camera,a=t?.camera;return{result:!!a&&!!e.cameras?.includes(a)||a!==i&&!e.cameras?.length,...a!==i&&{triggerData:{...(n?.camera||t?.camera)&&{camera:{...n?.camera&&{from:n?.camera},...t?.camera&&{to:t?.camera}}}}}}}case"numeric_state":return{result:!!t?.hass?.states&&e.entity in t.hass?.states&&void 0!==t.hass.states[e.entity].state&&(void 0===e.above||Number(t.hass.states[e.entity].state)>e.above)&&(void 0===e.below||Number(t.hass.states[e.entity].state)<e.below)};case"user":return{result:!!t?.hass?.user&&e.users.includes(t.hass.user.id)};case"media_loaded":return{result:void 0!==t?.mediaLoadedInfo&&e.media_loaded===!!t.mediaLoadedInfo};case"screen":return{result:window.matchMedia(e.media_query).matches};case"display_mode":return{result:!!t?.displayMode&&e.display_mode===t.displayMode};case"triggered":return{result:e.triggered.some((e=>t?.triggered?.has(e)))};case"interaction":return{result:void 0!==t?.interaction&&e.interaction===t.interaction};case"microphone":return{result:!(void 0!==e.connected&&t?.microphone?.connected!==e.connected||void 0!==e.muted&&t?.microphone?.muted!==e.muted)};case"key":return{result:!(!t?.keys||!(e.key in t.keys)||(e.state??"down")!==t.keys[e.key].state||void 0!==e.ctrl&&e.ctrl!==!!t.keys[e.key].ctrl||void 0!==e.alt&&e.alt!==!!t.keys[e.key].alt||void 0!==e.meta&&e.meta!==!!t.keys[e.key].meta||void 0!==e.shift&&e.shift!==!!t.keys[e.key].shift)};case"user_agent":return{result:!!t?.userAgent&&(!e.user_agent||e.user_agent===t.userAgent)&&(void 0===e.companion||e.companion===(i=t.userAgent,!!i.match(/Home ?Assistant/)))&&(void 0===e.user_agent_re||new RegExp(e.user_agent_re).test(t.userAgent))};case"config":{const i=t?.config,a=n?.config;return{result:!!i&&i!==a&&(!e.paths?.length||e.paths.some((e=>dM(i,e)!==(a?dM(a,e):void 0)))),...i!==a&&{triggerData:{config:{...(n?.config||t?.config)&&{...n?.config&&{from:n?.config},...t?.config&&{to:t?.config}}}}}}}case"initialized":return{result:!!t?.initialized};case"or":for(const i of e.conditions){const e=this._evaluateCondition(i,t,n);if(e.result)return e}return{result:!1};case"and":{let i={};for(const a of e.conditions){const e=this._evaluateCondition(a,t,n);if(!e.result)return{result:!1};i={...i,...e.triggerData}}return{result:!0,triggerData:i}}case"not":return{result:!this._evaluateCondition({...e,condition:"and"},t,n).result};case"template":return{result:!!t?.hass&&!0===this._templateRenderer.renderRecursively(t.hass,e.value_template,{conditionState:t})}}var i}}class TM{constructor(e){this._automations=new Map,this._nestedAutomationExecutions=0,this._api=e}deleteAutomations(e){for(const[t,n]of this._automations)t.tag===e&&(this._automations.delete(t),n.destroy())}addAutomations(e){for(const t of e){const e=new AM(t.conditions,this._api.getConditionStateManager());e.addListener((e=>this._execute(t,e))),this._automations.set(t,e)}}_execute(e,t){if(!this._api.getHASSManager().hasHASS()||!this._api.getInitializationManager().isInitializedMandatory()||this._api.getMessageManager().hasErrorMessage())return;const n=t.result?e.actions:e.actions_not;if(!n?.length)return;(async e=>{++this._nestedAutomationExecutions,this._nestedAutomationExecutions>10?this._api.getMessageManager().setMessageIfHigherPriority({type:"error",message:u_("error.too_many_automations")}):(await this._api.getActionsManager().executeActions({actions:e,triggerData:t.triggerData}),--this._nestedAutomationExecutions)})(n)}}class $M{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&&lh.isMedia(t)&&{media:t}})??null:null;return n?.ui?.endpoint??null}}const IM=()=>!!navigator.userAgent.match(/CrKey\//),OM=async()=>{if(["ha-button-menu","ha-button","ha-camera-stream","ha-card","ha-combo-box","ha-hls-player","ha-icon-button","ha-icon","ha-menu-button","ha-selector","ha-spinner","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.whenDefined("hui-picture-glance-card");const t=customElements.get("hui-picture-glance-card");if(!t)return!1;const n=new t;return await n.constructor.getConfigElement(),!0};class LM{constructor(){this._initialized=new Set}async initializeMultipleIfNecessary(e){return(await bd(Object.entries(e),(async([e,t])=>await this.initializeIfNecessary(e,t)))).every(Boolean)}async initializeIfNecessary(e,t){return!!this._initialized.has(e)||(t?!!await t()&&(this._initialized.add(e),!0):(this._initialized.add(e),!0))}uninitialize(e){this._initialized.delete(e)}isInitialized(e){return this._initialized.has(e)}isInitializedMultiple(e){return e.every((e=>this.isInitialized(e)))}}var DM;!function(e){e.LANGUAGES="languages",e.SIDE_LOAD_ELEMENTS="side-load-elements",e.CAMERAS="cameras",e.MICROPHONE_CONNECT="microphone-connect",e.VIEW="view",e.INITIAL_TRIGGER="initial-trigger"}(DM||(DM={}));class jM{constructor(e,t){this._initializationQueue=new ah({concurrency:1}),this._everInitialized=!1,this._api=e,this._initializer=t??new LM}wasEverInitialized(){return this._everInitialized}isInitialized(e){return this._initializer.isInitialized(e)}isInitializedMandatory(){return!!this._api.getConfigManager().getConfig()&&this._initializer.isInitializedMultiple([DM.LANGUAGES,DM.SIDE_LOAD_ELEMENTS,DM.CAMERAS,...this._api.getMicrophoneManager().shouldConnectOnInitialization()?[DM.MICROPHONE_CONNECT]:[],DM.VIEW,DM.INITIAL_TRIGGER])}async initializeMandatory(){await this._initializationQueue.add((()=>this._initializeMandatory()))}async _initializeMandatory(){const e=this._api.getHASSManager().getHASS();if(!e||this.isInitializedMandatory())return;if(!await this._initializer.initializeMultipleIfNecessary({[DM.LANGUAGES]:async()=>await(async e=>{const t=l_(e);return"ca"===t?o_[t]=await import("./lang-ca-f85ce535.js"):"de"===t?o_[t]=await import("./lang-de-6dc05ec2.js"):"fr"===t?o_[t]=await import("./lang-fr-163f03e7.js"):"it"===t?o_[t]=await import("./lang-it-e52e5194.js"):"pt"===t?o_[t]=await import("./lang-pt-PT-64e6e903.js"):"pt_BR"===t&&(o_[t]=await import("./lang-pt-BR-78c23b42.js")),t&&(c_=t),!0})(e),[DM.SIDE_LOAD_ELEMENTS]:async()=>await OM()}))return;const t=this._api.getConfigManager().getConfig();t&&await this._initializer.initializeMultipleIfNecessary({[DM.CAMERAS]:async()=>(this._api.createCameraManager(),await this._api.getCameraManager().initializeCamerasFromConfig()),...this._api.getMicrophoneManager().shouldConnectOnInitialization()&&{[DM.MICROPHONE_CONNECT]:async()=>(this._api.createMicrophoneManager(),await this._api.getMicrophoneManager().connect())}})&&!this._api.getMessageManager().hasMessage()&&await this._initializer.initializeIfNecessary(DM.VIEW,this._api.getViewManager().initialize)&&await this._initializer.initializeIfNecessary(DM.INITIAL_TRIGGER,(async()=>(await this._api.getTriggersManager().handleInitialCameraTriggers(),this._api.getCardElementManager().update(),!0)))&&(this._everInitialized=!0,this._api.getConditionStateManager().setState({config:t,initialized:this._everInitialized}),this._api.getCardElementManager().update())}uninitialize(e){this._initializer.uninitialize(e)}}class zM{constructor(e,t,n,i){this.update=()=>{this._element.requestUpdate()},this._api=e,this._element=t,this._scrollCallback=n,this._menuToggleCallback=i}getElement(){return this._element}scrollReset(){this._scrollCallback()}toggleMenu(){this._menuToggleCallback()}hasUpdated(){return this._element.hasUpdated}elementConnected(){this._api.getInteractionManager().initialize(),this._api.getFullscreenManager().initialize(),this._api.getExpandManager().initialize(),this._api.getMediaLoadedInfoManager().initialize(),this._api.getMicrophoneManager().initialize(),this._api.getKeyboardStateManager().initialize(),this._api.getDefaultManager().initialize(),this._api.getMediaPlayerManager().initialize(),this._api.getHASSManager().getStateWatcher()?.subscribe(this.update,[...this._api.getConfigManager().getConfig()?.view.render_entities??[],...this._api.getMediaPlayerManager().getMediaPlayers()??[]]),Md(this._element,(e=>{const t=e.getRootNode();return!!(t&&t instanceof ShadowRoot&&"HUI-PANEL-VIEW"===t.host.tagName)})(this._element),"panel"),Md(this._element,IM(),"casted"),this._api.getFullscreenManager().connect(),this._element.addEventListener("mousemove",this._api.getInteractionManager().reportInteraction),this._element.addEventListener("wheel",this._api.getInteractionManager().reportInteraction),this._element.addEventListener("touchstart",this._api.getInteractionManager().reportInteraction),this._element.addEventListener("touchmove",this._api.getInteractionManager().reportInteraction),this._element.addEventListener("ll-custom",this._api.getActionsManager().handleCustomActionEvent),this._element.addEventListener("action",this._api.getActionsManager().handleInteractionEvent),this._element.addEventListener("action",this._api.getInteractionManager().reportInteraction),this._element.addEventListener("advanced-camera-card:action:execution-request",this._api.getActionsManager().handleActionExecutionRequestEvent),window.addEventListener("location-changed",this._api.getQueryStringManager().requestExecution),window.addEventListener("popstate",this._api.getQueryStringManager().requestExecution),this._api.getConditionStateManager()?.setState({userAgent:navigator.userAgent}),this._api.getQueryStringManager().requestExecution(),this._element.requestUpdate()}elementDisconnected(){Md(this._element,!1,"panel"),Md(this._element,!1,"tabindex"),Md(this._element,!1,"casted"),this._api.getMediaLoadedInfoManager().clear(),this._api.getFullscreenManager().disconnect(),this._api.getKeyboardStateManager().uninitialize(),this._api.getActionsManager().uninitialize(),this._api.getDefaultManager().uninitialize(),this._api.getHASSManager().getStateWatcher()?.unsubscribe(this.update),this._api.getInitializationManager().uninitialize(DM.CAMERAS),this._api.getCameraManager().destroy(),this._element.removeEventListener("mousemove",this._api.getInteractionManager().reportInteraction),this._element.removeEventListener("wheel",this._api.getInteractionManager().reportInteraction),this._element.removeEventListener("touchstart",this._api.getInteractionManager().reportInteraction),this._element.removeEventListener("touchmove",this._api.getInteractionManager().reportInteraction),this._element.removeEventListener("ll-custom",this._api.getActionsManager().handleCustomActionEvent),this._element.removeEventListener("action",this._api.getActionsManager().handleInteractionEvent),this._element.removeEventListener("action",this._api.getInteractionManager().reportInteraction),this._element.removeEventListener("advanced-camera-card:action:execution-request",this._api.getActionsManager().handleActionExecutionRequestEvent),window.removeEventListener("location-changed",this._api.getQueryStringManager().requestExecution),window.removeEventListener("popstate",this._api.getQueryStringManager().requestExecution)}}function PM(e){if(e instanceof bi.ZodDefault)return PM(e.removeDefault());if(e instanceof bi.ZodObject){const t={};for(const n in e.shape){const i=e.shape[n];t[n]=bi.ZodOptional.create(PM(i))}return new bi.ZodObject({...e._def,shape:()=>t})}return e instanceof bi.ZodArray?bi.ZodArray.create(PM(e.element)).min(e._def.minLength?.value,e._def.minLength?.message).max(e._def.maxLength?.value,e._def.maxLength?.message).length(e._def.exactLength?.value,e._def.exactLength?.message):e instanceof bi.ZodOptional?bi.ZodOptional.create(PM(e.unwrap())):e instanceof bi.ZodNullable?bi.ZodNullable.create(PM(e.unwrap())):e instanceof bi.ZodTuple?bi.ZodTuple.create(e.items.map((e=>PM(e)))):e}const RM=e=>{const t=new Set;if(e.issues.length)for(const n of e.issues)if("invalid_union"===n.code){const e=n.unionErrors;for(const n of e)RM(n).forEach(t.add,t)}else t.add(NM(n.path));return t},NM=e=>{let t="";for(let n=0;n<e.length;n++){const i=e[n];"number"==typeof i?t+="["+i+"]":t?t+=" -> "+i:t=i}return t},FM=bi.object({enabled:bi.boolean().default(!0).optional(),priority:bi.number().min(0).max(100).default(50).optional()}),BM=Ai.extend({advanced_camera_card_action:bi.literal("camera_select"),camera:bi.string().optional(),triggered:bi.boolean().optional()}),VM=bi.enum(["single","grid"]),HM=bi.enum(["default","first","last"]),UM=bi.object({mode:VM.optional(),grid_selected_position:HM.optional(),grid_selected_width_factor:bi.number().min(0).optional(),grid_max_columns:bi.number().min(0).optional(),grid_columns:bi.number().min(0).optional()}).optional(),qM=Ai.extend({advanced_camera_card_action:bi.literal("display_mode_select"),display_mode:VM}),WM=bi.enum(["fireworks","ghost","hearts","shamrocks","snow"]),ZM=bi.enum(["start","stop","toggle"]),KM=Ai.extend({advanced_camera_card_action:bi.literal("effect"),effect:WM,effect_action:ZM.default("toggle")}),QM=Ai.extend({advanced_camera_card_action:bi.enum(["camera_ui","default","download","expand","fullscreen","live_substream_off","live_substream_on","menu_toggle","microphone_connect","microphone_disconnect","microphone_mute","microphone_unmute","mute","pause","play","reload","screenshot","unmute"])}),YM=Ai.extend({advanced_camera_card_action:bi.literal("log"),message:bi.string(),level:bi.enum(["debug","info","warn","error"]).default("info")}),GM=Ai.extend({advanced_camera_card_action:bi.literal("media_player"),media_player:bi.string(),media_player_action:bi.enum(["play","stop"])}),XM=Ai.extend({advanced_camera_card_action:bi.literal("ptz_controls"),enabled:bi.boolean()}),JM=bi.object({x:bi.number().min(0).max(100).optional(),y:bi.number().min(0).max(100).optional()}),ek=Ai.extend({advanced_camera_card_action:bi.literal("ptz_digital"),target_id:bi.string().optional(),absolute:bi.object({zoom:Xv.optional(),pan:JM.optional()}).optional(),ptz_action:bi.enum(ph).optional(),ptz_phase:bi.enum(mh).optional()}),tk=Ai.extend({advanced_camera_card_action:bi.literal("ptz_multi"),target_id:bi.string().optional(),ptz_action:bi.enum(ph).optional(),ptz_phase:bi.enum(mh).optional(),ptz_preset:bi.string().optional()}),nk=bi.object({ms:bi.number().optional(),s:bi.number().optional(),m:bi.number().optional(),h:bi.number().optional()}),ik=Ai.extend({advanced_camera_card_action:bi.literal("sleep"),duration:nk.optional().default({s:1})}),ak=Ai.extend({advanced_camera_card_action:bi.literal("live_substream_select"),camera:bi.string()}),rk=Ai.extend({advanced_camera_card_action:bi.enum(Si),folder:bi.string().optional()}),sk=bi.object({entity_id:bi.string().or(bi.string().array()).optional(),device_id:bi.string().or(bi.string().array()).optional(),area_id:bi.string().or(bi.string().array()).optional(),floor_id:bi.string().or(bi.string().array()).optional(),label_id:bi.string().or(bi.string().array()).optional()}),ok=Ei.extend({action:bi.literal("call-service"),service:bi.string(),data:bi.object({}).passthrough().optional(),target:sk.optional()}),ck=Ei.extend({action:bi.literal("fire-dom-event")}).passthrough(),lk=Ei.extend({action:bi.literal("more-info"),entity:bi.string().optional()}),uk=Ei.extend({action:bi.literal("navigate"),navigation_path:bi.string(),navigation_replace:bi.boolean().optional()}),dk=Ei.extend({action:bi.literal("none")}),hk=Ei.extend({action:bi.literal("perform-action"),perform_action:bi.string(),data:bi.object({}).passthrough().optional(),target:sk.optional()}),pk=Ei.extend({action:bi.literal("toggle")}),mk=Ei.extend({action:bi.literal("url"),url_path:bi.string()}),fk=bi.union([ok,ck,lk,uk,dk,hk,pk,mk]),gk=Ai.extend({advanced_camera_card_action:bi.literal("status_bar"),status_bar_action:bi.enum(["add","remove","reset"]),items:bi.lazy((()=>Ck)).array().optional()}),_k=bi.union([BM,KM,QM,$i,YM,GM,fh,XM,ek,tk,ik,gk,ak,rk,qM]),vk=bi.union([fk,_k]),yk=bi.object({tap_action:vk.or(vk.array()).optional(),hold_action:vk.or(vk.array()).optional(),double_tap_action:vk.or(vk.array()).optional(),start_tap_action:vk.or(vk.array()).optional(),end_tap_action:vk.or(vk.array()).optional()}).passthrough(),bk=bi.object({actions:yk.optional()}),wk=FM.extend({sufficient:bi.boolean().default(!1).optional(),exclusive:bi.boolean().default(!1).optional(),expand:bi.boolean().default(!1).optional(),actions:yk.optional()}),xk=wk.extend({type:bi.literal("custom:advanced-camera-card-status-bar-icon"),icon:bi.string()}),Mk=wk.extend({type:bi.literal("custom:advanced-camera-card-status-bar-image"),image:bi.string()}),kk=wk.extend({type:bi.literal("custom:advanced-camera-card-status-bar-string"),string:bi.string()}),Ck=bi.union([xk,Mk,kk]),Sk=bi.object({condition:bi.literal("camera"),cameras:bi.string().array().optional()}),Ek=bi.object({condition:bi.literal("config"),paths:bi.string().array().optional()}),Ak=bi.object({condition:bi.literal("display_mode"),display_mode:VM}),Tk=bi.object({condition:bi.literal("expand"),expand:bi.boolean()}),$k=bi.object({condition:bi.literal("fullscreen"),fullscreen:bi.boolean()}),Ik=bi.object({condition:bi.literal("initialized")}),Ok=bi.object({condition:bi.literal("interaction"),interaction:bi.boolean()}),Lk=bi.object({condition:bi.literal("key"),key:bi.string(),state:bi.enum(["down","up"]).optional(),ctrl:bi.boolean().optional(),shift:bi.boolean().optional(),alt:bi.boolean().optional(),meta:bi.boolean().optional()}),Dk=bi.object({condition:bi.literal("media_loaded"),media_loaded:bi.boolean()}),jk=bi.object({condition:bi.literal("microphone"),connected:bi.boolean().optional(),muted:bi.boolean().optional()}),zk=bi.object({condition:bi.literal("triggered"),triggered:bi.string().array()}),Pk=bi.string().refine((e=>{try{new RegExp(e)}catch{return!1}return!0}),{message:"Invalid regular expression"}),Rk=bi.object({condition:bi.literal("user_agent"),user_agent:bi.string().optional(),user_agent_re:Pk.optional(),companion:bi.boolean().optional()}),Nk=bi.object({condition:bi.literal("view"),views:bi.string().array().optional()}),Fk=bi.object({condition:bi.literal("numeric_state"),entity:bi.string(),above:bi.number().optional(),below:bi.number().optional()}),Bk=bi.object({condition:bi.literal("screen"),media_query:bi.string()}),Vk=bi.object({condition:bi.literal("state").optional(),entity:bi.string(),state:bi.string().or(bi.string().array()).optional(),state_not:bi.string().or(bi.string().array()).optional()}),Hk=bi.object({condition:bi.literal("template"),value_template:bi.string()}),Uk=bi.object({condition:bi.literal("user"),users:bi.string().array().min(1)}),qk=bi.object({condition:bi.literal("or"),conditions:bi.lazy((()=>Kk)).array().min(1)}),Wk=bi.object({condition:bi.literal("and"),conditions:bi.lazy((()=>Kk)).array().min(1)}),Zk=bi.object({condition:bi.literal("not"),conditions:bi.lazy((()=>Kk)).array().min(1)}),Kk=bi.union([Fk,Bk,Vk,Uk,qk,Wk,Zk,Hk,Sk,Ek,Ak,Tk,$k,Ik,Ok,Lk,Dk,jk,zk,Rk,Nk]),Qk=vk.array(),Yk=bi.object({conditions:Kk.array(),actions:Qk.optional(),actions_not:Qk.optional()}).refine((e=>e.actions?.length||e.actions_not?.length),"Automations must include at least one action").array(),Gk=bi.object({fit:bi.enum(["contain","cover","fill"]).optional(),position:bi.object({x:bi.number().min(0).max(100).optional(),y:bi.number().min(0).max(100).optional()}).optional(),view_box:bi.object({bottom:bi.number().min(0).max(100).optional().default(0),left:bi.number().min(0).max(100).optional().default(0),right:bi.number().min(0).max(100).optional().default(0),top:bi.number().min(0).max(100).optional().default(0)}).optional(),pan:JM.optional(),zoom:Xv.optional()}),Xk={r2c_delay_between_calls_seconds:.5,c2r_delay_between_calls_seconds:.2},Jk=function(e){return t=>{if(!t||"object"!=typeof t||!t.service)return t;const n={...t};return Object.keys(t).forEach((i=>{const a=i.match(/^data_(.+)$/),r=a?.[1];r&&!(`${e}${r}`in t)&&(n[`${e}${r}`]={action:"perform-action",perform_action:t.service,data:t[i]},delete n[i],delete n.service)})),n}},eC=bi.preprocess(Jk("actions_"),bi.object({actions_left:hk.optional(),actions_left_start:hk.optional(),actions_left_stop:hk.optional(),actions_right:hk.optional(),actions_right_start:hk.optional(),actions_right_stop:hk.optional(),actions_up:hk.optional(),actions_up_start:hk.optional(),actions_up_stop:hk.optional(),actions_down:hk.optional(),actions_down_start:hk.optional(),actions_down_stop:hk.optional(),actions_zoom_in:hk.optional(),actions_zoom_in_start:hk.optional(),actions_zoom_in_stop:hk.optional(),actions_zoom_out:hk.optional(),actions_zoom_out_start:hk.optional(),actions_zoom_out_stop:hk.optional(),r2c_delay_between_calls_seconds:bi.number().default(Xk.r2c_delay_between_calls_seconds),c2r_delay_between_calls_seconds:bi.number().default(Xk.c2r_delay_between_calls_seconds),presets:bi.preprocess(Jk(""),bi.union([bi.record(hk),bi.object({service:bi.string().optional()})])).optional(),service:bi.string().optional()}).passthrough()),tC=bi.number().array().length(2).or(bi.string().regex(/^\s*\d+\.?\d*\s*[:/]\s*\d+\.?\d*\s*$/).transform((e=>e.split(/[:\/]/).map((e=>Number(e)))))),nC={mode:"auto",refresh_seconds:1,zoomable:!0},iC=bi.object({mode:bi.enum(["auto","camera","entity","screensaver","url"]).default(nC.mode),refresh_seconds:bi.number().min(0).default(nC.refresh_seconds),url:bi.string().optional(),entity:bi.string().optional(),entity_parameters:bi.string().optional()}),aC=["events","clips","snapshots"],rC=bi.object({url:bi.string().transform((e=>e.replace(/\/+$/,""))).optional(),host:bi.string().optional(),modes:bi.enum(["webrtc","mse","mp4","mjpeg"]).array().optional(),stream:bi.string().optional()}),sC=bi.object({entity:bi.string().optional(),url:bi.string().optional()}).passthrough(),oC=bi.object({options:bi.object({audio:bi.boolean().optional(),video:bi.boolean().optional(),pauseWhenHidden:bi.boolean().optional(),disableGl:bi.boolean().optional(),disableWebAssembly:bi.boolean().optional(),preserveDrawingBuffer:bi.boolean().optional(),progressive:bi.boolean().optional(),throttled:bi.boolean().optional(),chunkSize:bi.number().optional(),maxAudioLag:bi.number().optional(),videoBufferSize:bi.number().optional(),audioBufferSize:bi.number().optional()}).optional()}),cC=bi.object({method:bi.enum(["standard","dashboard"]).default("standard").optional(),dashboard:bi.object({dashboard_path:bi.string().optional(),view_path:bi.string().optional()}).optional()}),lC={dependencies:{all_cameras:!1,cameras:[]},engine:"auto",frigate:{client_id:"frigate"},live_provider:"auto",motioneye:{images:{directory_pattern:"%Y-%m-%d",file_pattern:"%H-%M-%S"},movies:{directory_pattern:"%Y-%m-%d",file_pattern:"%H-%M-%S"}},reolink:{media_resolution:"low"},ptz:Xk,triggers:{motion:!1,occupancy:!1,events:[...aC],entities:[]},proxy:{dynamic:!0,live:"auto",media:"auto",ssl_ciphers:"auto",ssl_verification:"auto"},always_error_if_entity_unavailable:!1},uC=bi.object({live:bi.boolean().or(bi.literal("auto")).default(lC.proxy.live),media:bi.boolean().or(bi.literal("auto")).default(lC.proxy.media),dynamic:bi.boolean().default(lC.proxy.dynamic),ssl_verification:bi.boolean().or(bi.literal("auto")).default(lC.proxy.ssl_verification),ssl_ciphers:bi.enum(["default","insecure","intermediate","modern"]).or(bi.literal("auto")).default(lC.proxy.ssl_ciphers)}),dC=bi.literal(0).or(bi.literal(90)).or(bi.literal(180)).or(bi.literal(270)),hC=bi.object({width_factor:bi.number().min(.1).optional()}),pC=bi.object({aspect_ratio:tC.optional(),layout:Gk.optional(),rotation:dC.optional(),grid:hC.optional()}),mC=bi.object({camera_entity:bi.string().optional(),icon:bi.string().optional(),title:bi.string().optional(),capabilities:bi.object({disable:bi.enum(od).array().optional(),disable_except:bi.enum(od).array().optional()}).optional(),id:bi.string().optional(),dependencies:bi.object({all_cameras:bi.boolean().default(lC.dependencies.all_cameras),cameras:bi.string().array().default(lC.dependencies.cameras)}).default(lC.dependencies),triggers:bi.object({motion:bi.boolean().default(lC.triggers.motion),occupancy:bi.boolean().default(lC.triggers.occupancy),entities:bi.string().array().default(lC.triggers.entities),events:bi.enum(aC).array().default(lC.triggers.events)}).default(lC.triggers),engine:bi.enum(["auto","frigate","generic","motioneye","reolink","tplink"]).default("auto"),frigate:bi.object({url:bi.string().optional(),client_id:bi.string().default(lC.frigate.client_id),camera_name:bi.string().optional(),labels:bi.string().array().optional(),zones:bi.string().array().optional()}).default(lC.frigate),motioneye:bi.object({url:bi.string().optional(),images:bi.object({directory_pattern:bi.string().includes("%").default(lC.motioneye.images.directory_pattern),file_pattern:bi.string().includes("%").default(lC.motioneye.images.file_pattern)}).default(lC.motioneye.images),movies:bi.object({directory_pattern:bi.string().includes("%").default(lC.motioneye.movies.directory_pattern),file_pattern:bi.string().includes("%").default(lC.motioneye.movies.file_pattern)}).default(lC.motioneye.movies)}).default(lC.motioneye),reolink:bi.object({url:bi.string().optional(),media_resolution:bi.enum(["high","low"]).default(lC.reolink.media_resolution)}).default(lC.reolink),live_provider:bi.enum(["auto","image","ha","jsmpeg","go2rtc","webrtc-card"]).default(lC.live_provider),go2rtc:rC.optional(),image:iC.optional().default(nC),jsmpeg:oC.optional(),webrtc_card:sC.optional(),cast:cC.optional(),ptz:eC.default(lC.ptz),dimensions:pC.optional(),proxy:uC.default(lC.proxy),always_error_if_entity_unavailable:bi.boolean().default(lC.always_error_if_entity_unavailable)}).default(lC),fC=mC.array().min(1),gC=bi.enum(["all","clips","snapshots"]),_C=75,vC=100,yC=300,bC={size:100,show_details:!0,show_favorite_control:!0,show_timeline_control:!0,show_download_control:!0},wC=bi.object({size:bi.number().min(75).max(300).default(bC.size),show_details:bi.boolean().default(bC.show_details),show_favorite_control:bi.boolean().default(bC.show_favorite_control),show_timeline_control:bi.boolean().default(bC.show_timeline_control),show_download_control:bi.boolean().default(bC.show_download_control)}),xC={...bC,mode:"right"},MC=wC.extend({mode:bi.enum(["none","above","below","left","right"]).default(xC.mode)}),kC={clustering_threshold:3,events_media_type:"all",window_seconds:3600,show_recordings:!0,style:"stack",pan_mode:"pan",format:{"24h":!0}},CC=bi.enum(["pan","seek","seek-in-media","seek-in-camera"]),SC=bi.object({"24h":bi.boolean().optional().default(kC.format["24h"])}),EC=bi.object({clustering_threshold:bi.number().optional().default(kC.clustering_threshold),events_media_type:gC.optional().default(kC.events_media_type),window_seconds:bi.number().min(60).max(86400).optional().default(kC.window_seconds),show_recordings:bi.boolean().optional().default(kC.show_recordings),style:bi.enum(["stack","ribbon"]).optional().default(kC.style),pan_mode:CC.optional().default(kC.pan_mode),format:SC.optional().default(kC.format)}),AC={...kC,mode:"none",style:"ribbon"},TC=EC.extend({mode:bi.enum(["none","above","below"]).default(AC.mode),style:EC.shape.style.default(AC.style)}),$C={...kC,controls:{thumbnails:xC}},IC={logging:!1},OC=bi.object({logging:bi.boolean().default(IC.logging)}).default(IC),LC={aspect_ratio_mode:"dynamic",aspect_ratio:[16,9],height:"auto"},DC=bi.object({aspect_ratio_mode:bi.enum(["dynamic","static","unconstrained"]).default(LC.aspect_ratio_mode),aspect_ratio:tC.default(LC.aspect_ratio),height:bi.string().default(LC.height)}).default(LC),jC=bi.discriminatedUnion("condition",[Vk,Fk,Bk,Uk]),zC=yk.extend({style:bi.record(bi.string().nullable().or(bi.undefined()).or(bi.number())).optional(),title:bi.string().nullable().optional()}),PC=zC.extend({type:bi.literal("icon"),icon:bi.string(),entity:bi.string().optional()}),RC=bi.object({enabled:bi.boolean().default(!0).optional(),priority:bi.number().min(0).max(100).default(50).optional(),alignment:bi.enum(["matching","opposing"]).default("matching").optional(),icon:bi.string().optional(),permanent:bi.boolean().default(!1).optional()}),NC=RC.merge(PC).extend({type:bi.literal("custom:advanced-camera-card-menu-icon")}),FC=zC.extend({type:bi.literal("state-icon"),entity:bi.string(),icon:bi.string().optional(),state_color:bi.boolean().default(!0)}),BC=RC.merge(FC).extend({type:bi.literal("custom:advanced-camera-card-menu-state-icon")}).merge(RC),VC=zC.extend({entity:bi.string().optional(),icon:bi.string().optional(),state_color:bi.boolean().default(!0).optional(),selected:bi.boolean().default(!1).optional(),subtitle:bi.string().optional(),enabled:bi.boolean().default(!0).optional()}),HC=RC.merge(PC).extend({type:bi.literal("custom:advanced-camera-card-menu-submenu"),items:VC.array()}),UC=RC.merge(FC).extend({type:bi.literal("custom:advanced-camera-card-menu-submenu-select"),options:bi.record(VC.deepPartial()).optional()}),qC=bi.object({type:bi.string().superRefine(((e,t)=>{e.match(/^custom:(?!advanced-camera-card).+/)||t.addIssue({code:bi.ZodIssueCode.custom,message:"advanced-camera-card custom elements must match specific schemas",fatal:!0})}))}).passthrough(),WC=zC.extend({type:bi.literal("image"),entity:bi.string().optional(),image:bi.string().optional(),camera_image:bi.string().optional(),camera_view:bi.string().optional(),state_image:bi.object({}).passthrough().optional(),filter:bi.string().optional(),state_filter:bi.object({}).passthrough().optional(),aspect_ratio:bi.string().optional()}),ZC=zC.extend({type:bi.literal("service-button"),title:bi.string(),service:bi.string(),service_data:bi.object({}).passthrough().optional()}),KC=zC.extend({type:bi.literal("state-badge"),entity:bi.string()}),QC=zC.extend({type:bi.literal("state-label"),entity:bi.string(),attribute:bi.string().optional(),prefix:bi.string().optional(),suffix:bi.string().optional()}),YC=bi.object({type:bi.literal("conditional"),conditions:jC.array(),elements:bi.lazy((()=>XC))}),GC=bi.object({type:bi.literal("custom:advanced-camera-card-conditional"),conditions:Kk.array(),elements:bi.lazy((()=>XC))}),XC=bi.union([YC,qC,GC,PC,WC,NC,BC,HC,UC,ZC,KC,FC,QC,xk,Mk,kk]).array().optional(),JC="media-source://",eS=bi.enum(["ha"]),tS="ha",nS={},iS=bi.object({type:bi.literal("startdate"),format:bi.string().optional(),regexp:Pk.optional()}),aS=iS.extend({type:bi.literal("date")}),rS=bi.discriminatedUnion("type",[aS,iS]),sS=bi.object({type:bi.literal("startdate"),since:bi.object({years:bi.number().int().min(0).optional(),months:bi.number().int().min(0).optional(),days:bi.number().int().min(0).optional(),hours:bi.number().int().min(0).optional(),minutes:bi.number().int().min(0).optional()})}),oS=sS.extend({type:bi.literal("date")}),cS=bi.object({type:bi.literal("template"),value_template:bi.string()}),lS=bi.object({type:bi.literal("title"),regexp:Pk.optional(),title:bi.string().optional()}),uS=bi.object({type:bi.literal("or"),matchers:bi.array(bi.lazy((()=>dS)))}),dS=bi.union([oS,uS,sS,cS,lS]),hS=bi.object({id:bi.string().optional(),parsers:rS.array().optional(),matchers:dS.array().optional()}),pS=bi.object({url:bi.string().transform((e=>{let t=e;try{t=new URL(e).pathname}catch(e){}const n=decodeURIComponent(t).split(",").filter(Cd).slice(1),i=[{id:JC},...n.slice(0,-1).map((e=>({id:e.replace(/\/[^/]+$/,"")}))),...n.slice(-1).map((e=>({id:e})))];for(const t of i)if(t.id&&!t.id.startsWith(JC))throw new sd(`Could not parse media source URL: ${e}`);return i})).or(hS.array().min(1)).optional(),path:hS.array().nonempty().optional()}),mS=bi.object({type:eS.default(tS),id:bi.string().optional(),ha:pS.default(nS).optional(),title:bi.string().optional(),icon:bi.string().optional()}).array(),fS=iC.extend({zoomable:bi.boolean().default(nC.zoomable)}).merge(bk).default(nC),gS=bi.object({style:bi.enum(["none","chevrons","icons","thumbnails"]),size:bi.number().min(20)}),_S={orientation:"horizontal",mode:"auto",hide_pan_tilt:!1,hide_zoom:!1,hide_home:!1,position:"bottom-right"},vS=bi.object({mode:bi.enum(["off","auto","on"]).default(_S.mode),position:bi.enum(["top-left","top-right","bottom-left","bottom-right"]).default(_S.position),orientation:bi.enum(["vertical","horizontal"]).default(_S.orientation),hide_pan_tilt:bi.boolean().default(_S.hide_pan_tilt),hide_zoom:bi.boolean().default(_S.hide_zoom),hide_home:bi.boolean().default(_S.hide_home),style:bi.object({}).passthrough().optional()}),yS=["selected","visible"],bS=["unselected","hidden"],wS=[...bS,"microphone"],xS=[...yS,"microphone"],MS=bi.enum(["none","slide"]),kS={always_connected:!1,disconnect_seconds:90,mute_after_microphone_mute_seconds:60},CS=bi.object({always_connected:bi.boolean().default(kS.always_connected),disconnect_seconds:bi.number().min(0).default(kS.disconnect_seconds),mute_after_microphone_mute_seconds:bi.number().min(0).default(kS.mute_after_microphone_mute_seconds)}).default(kS),SS={...xC,media_type:"events",events_media_type:"all"},ES={auto_play:[...yS],auto_pause:[],auto_mute:[...wS],auto_unmute:["microphone"],preload:!1,lazy_load:!0,lazy_unload:[],draggable:!0,zoomable:!0,transition_effect:"slide",show_image_during_load:!0,mode:"single",controls:{builtin:!0,next_previous:{size:48,style:"chevrons"},ptz:_S,thumbnails:SS,timeline:AC,wheel:!0},microphone:{...kS}},AS=MC.extend({media_type:bi.enum(["events","recordings"]).default(ES.controls.thumbnails.media_type),events_media_type:gC.default(ES.controls.thumbnails.events_media_type)}),TS=bi.object({auto_pause:bi.enum(bS).array().default(ES.auto_pause),auto_play:bi.enum(yS).array().default(ES.auto_play),auto_mute:bi.enum(wS).array().default(ES.auto_mute),auto_unmute:bi.enum(xS).array().default(ES.auto_unmute),controls:bi.object({builtin:bi.boolean().default(ES.controls.builtin),next_previous:gS.extend({style:bi.enum(["none","chevrons","icons"]).default(ES.controls.next_previous.style),size:gS.shape.size.default(ES.controls.next_previous.size)}).default(ES.controls.next_previous),ptz:vS.default(ES.controls.ptz),thumbnails:AS.default(ES.controls.thumbnails),timeline:TC.default(ES.controls.timeline),wheel:bi.boolean().default(ES.controls.wheel)}).default(ES.controls),display:UM,draggable:bi.boolean().default(ES.draggable),lazy_load:bi.boolean().default(ES.lazy_load),lazy_unload:bi.enum(bS).array().default(ES.lazy_unload),microphone:CS.default(ES.microphone),preload:bi.boolean().default(ES.preload),show_image_during_load:bi.boolean().default(ES.show_image_during_load),transition_effect:MS.default(ES.transition_effect),zoomable:bi.boolean().default(ES.zoomable)}).merge(bk).default(ES),$S={...xC,show_details:!1},IS={controls:{thumbnails:$S,filter:{mode:"right"}}},OS=wC.extend({show_details:bi.boolean().default($S.show_details)}),LS=bi.object({controls:bi.object({thumbnails:OS.default(IS.controls.thumbnails),filter:bi.object({mode:bi.enum(["none","left","right"]).default(IS.controls.filter.mode)}).default(IS.controls.filter)}).default(IS.controls)}).merge(bk).default(IS),DS=["left","right","top","bottom"],jS=DS,zS={priority:50,enabled:!0},PS={priority:50,enabled:!1},RS={alignment:"left",button_size:40,buttons:{camera_ui:zS,cameras:zS,clips:zS,ptz_home:PS,display_mode:zS,download:zS,expand:PS,folders:zS,iris:zS,fullscreen:zS,image:PS,live:zS,media_player:zS,microphone:{...PS,type:"momentary"},mute:PS,play:PS,ptz_controls:PS,recordings:PS,screenshot:PS,snapshots:zS,substreams:zS,timeline:zS},position:"top",style:"hidden"},NS=RC.extend({enabled:RC.shape.enabled.default(zS.enabled),priority:RC.shape.priority.default(zS.priority)}),FS=RC.extend({enabled:RC.shape.enabled.default(PS.enabled),priority:RC.shape.priority.default(PS.priority)}),BS=bi.object({style:bi.enum(["none","hidden","overlay","hover","hover-card","outside"]).default(RS.style),position:bi.enum(DS).default(RS.position),alignment:bi.enum(jS).default(RS.alignment),buttons:bi.object({camera_ui:NS.default(RS.buttons.camera_ui),cameras:NS.default(RS.buttons.cameras),clips:NS.default(RS.buttons.clips),ptz_home:FS.default(RS.buttons.ptz_home),display_mode:NS.default(RS.buttons.display_mode),download:NS.default(RS.buttons.download),expand:FS.default(RS.buttons.expand),folders:NS.default(RS.buttons.folders),iris:NS.default(RS.buttons.iris),fullscreen:NS.default(RS.buttons.fullscreen),image:FS.default(RS.buttons.image),live:NS.default(RS.buttons.live),media_player:NS.default(RS.buttons.media_player),microphone:FS.extend({type:bi.enum(["momentary","toggle"]).default(RS.buttons.microphone.type)}).default(RS.buttons.microphone),mute:FS.default(RS.buttons.mute),play:FS.default(RS.buttons.play),ptz_controls:FS.default(RS.buttons.ptz_controls),recordings:FS.default(RS.buttons.recordings),screenshot:FS.default(RS.buttons.screenshot),snapshots:NS.default(RS.buttons.snapshots),substreams:NS.default(RS.buttons.substreams),timeline:NS.default(RS.buttons.timeline)}).default(RS.buttons),button_size:bi.number().min(20).default(RS.button_size)}).default(RS),VS=bi.object({conditions:Kk.array(),merge:bi.object({}).passthrough().optional(),set:bi.object({}).passthrough().optional(),delete:bi.string().array().optional()}).array().optional(),HS={features:{animated_progress_indicator:!0,card_loading_effects:!0,card_loading_indicator:!0,media_chunk_size:50},style:{border_radius:!0,box_shadow:!0}},US=bi.object({features:bi.object({animated_progress_indicator:bi.boolean().default(HS.features.animated_progress_indicator),card_loading_effects:bi.boolean().default(HS.features.card_loading_effects),card_loading_indicator:bi.boolean().default(HS.features.card_loading_indicator),media_chunk_size:bi.number().min(0).max(1e3).default(HS.features.media_chunk_size),max_simultaneous_engine_requests:bi.number().min(1).optional()}).default(HS.features),style:bi.object({border_radius:bi.boolean().default(HS.style.border_radius),box_shadow:bi.boolean().default(HS.style.box_shadow)}).default(HS.style)}).default(HS),qS=bi.enum(["casting","low-performance","scrubbing"]).array().optional(),WS={entities:{camera_priority:"card"}},ZS=bi.enum(["card","entity"]),KS=bi.object({entities:bi.object({camera:bi.string().startsWith("input_select.").optional(),camera_priority:ZS.default(WS.entities.camera_priority)}).default(WS.entities)}).default(WS),QS=20,YS={priority:50,enabled:!0},GS={height:40,items:{engine:YS,resolution:YS,technology:YS,title:YS},position:"bottom",style:"popup",popup_seconds:3},XS=bi.object({position:bi.enum(["top","bottom"]).default(GS.position),style:bi.enum(["none","overlay","hover","hover-card","outside","popup"]).default(GS.style),popup_seconds:bi.number().min(0).max(60).default(GS.popup_seconds),height:bi.number().min(20).default(GS.height),items:bi.object({engine:FM.default(GS.items.engine),technology:FM.default(GS.items.technology),resolution:FM.default(GS.items.resolution),title:FM.default(GS.items.title)}).default(GS.items)}).default(GS),JS=EC.extend({controls:bi.object({thumbnails:MC.default($C.controls.thumbnails)}).default($C.controls)}).default($C),eE=bi.object({key:bi.string(),ctrl:bi.boolean().optional(),shift:bi.boolean().optional(),alt:bi.boolean().optional(),meta:bi.boolean().optional()}),tE={enabled:!0,ptz_left:{key:"ArrowLeft"},ptz_right:{key:"ArrowRight"},ptz_up:{key:"ArrowUp"},ptz_down:{key:"ArrowDown"},ptz_zoom_in:{key:"+"},ptz_zoom_out:{key:"-"},ptz_home:{key:"h"}},nE=bi.object({enabled:bi.boolean().default(tE.enabled),ptz_left:eE.nullable().default(tE.ptz_left),ptz_right:eE.nullable().default(tE.ptz_right),ptz_up:eE.nullable().default(tE.ptz_up),ptz_down:eE.nullable().default(tE.ptz_down),ptz_zoom_in:eE.nullable().default(tE.ptz_zoom_in),ptz_zoom_out:eE.nullable().default(tE.ptz_zoom_out),ptz_home:eE.nullable().default(tE.ptz_home)}),iE={default:Ci,camera_select:"current",interaction_seconds:300,default_reset:{every_seconds:0,after_interaction:!1,entities:[],interaction_mode:"inactive"},default_cycle_camera:!1,dim:!1,theme:{themes:["traditional"]},triggers:{show_trigger_status:!1,filter_selected_camera:!0,actions:{trigger:"update",untrigger:"none"},untrigger_seconds:0},keyboard_shortcuts:tE},aE=bi.enum(["all","inactive","active"]).default("inactive"),rE=bi.object({actions:bi.object({interaction_mode:aE,trigger:bi.enum(["default","live","media","none","update"]).default(iE.triggers.actions.trigger),untrigger:bi.enum(["default","none"]).default(iE.triggers.actions.untrigger)}).default(iE.triggers.actions),filter_selected_camera:bi.boolean().default(iE.triggers.filter_selected_camera),show_trigger_status:bi.boolean().default(iE.triggers.show_trigger_status),untrigger_seconds:bi.number().default(iE.triggers.untrigger_seconds)}),sE=bi.enum(["ha","dark","light","traditional"]),oE=bi.object({themes:sE.array().default(iE.theme.themes),overrides:bi.record(bi.string()).optional()}),cE=bi.object({default:bi.enum(Si).default(iE.default),camera_select:bi.enum([...Si,"current"]).default(iE.camera_select),interaction_seconds:bi.number().default(iE.interaction_seconds),default_cycle_camera:bi.boolean().default(iE.default_cycle_camera),default_reset:bi.object({after_interaction:bi.boolean().default(iE.default_reset.after_interaction),every_seconds:bi.number().default(iE.default_reset.every_seconds),entities:bi.string().array().default(iE.default_reset.entities),interaction_mode:aE.default(iE.default_reset.interaction_mode)}).default(iE.default_reset),render_entities:bi.string().array().optional(),theme:oE.default(iE.theme),dim:bi.boolean().default(iE.dim),triggers:rE.default(iE.triggers),keyboard_shortcuts:nE.default(iE.keyboard_shortcuts)}).merge(bk).default(iE),lE={auto_play:[...yS],auto_pause:[...bS],auto_mute:[...bS],auto_unmute:[],lazy_load:!0,draggable:!0,zoomable:!0,transition_effect:"slide",snapshot_click_plays_clip:!0,display_mode:"single",controls:{builtin:!0,next_previous:{size:48,style:"thumbnails"},thumbnails:xC,timeline:AC,ptz:{..._S,mode:"off"},wheel:!0}},uE=gS.extend({style:bi.enum(["none","thumbnails","chevrons"]).default(lE.controls.next_previous.style),size:gS.shape.size.default(lE.controls.next_previous.size)}),dE=bi.object({auto_play:bi.enum(yS).array().default(lE.auto_play),auto_pause:bi.enum(bS).array().default(lE.auto_pause),auto_mute:bi.enum(bS).array().default(lE.auto_mute),auto_unmute:bi.enum(yS).array().default(lE.auto_unmute),lazy_load:bi.boolean().default(lE.lazy_load),draggable:bi.boolean().default(lE.draggable),zoomable:bi.boolean().default(lE.zoomable),transition_effect:MS.default(lE.transition_effect),snapshot_click_plays_clip:bi.boolean().default(lE.snapshot_click_plays_clip),display:UM,controls:bi.object({builtin:bi.boolean().default(lE.controls.builtin),next_previous:uE.default(lE.controls.next_previous),ptz:vS.extend({mode:bi.enum(["off","on"]).default(lE.controls.ptz.mode)}).default(lE.controls.ptz),thumbnails:MC.default(lE.controls.thumbnails),timeline:TC.default(lE.controls.timeline),wheel:bi.boolean().default(lE.controls.wheel)}).default(lE.controls)}).merge(bk).default(lE),hE=bi.object({cameras:PM(fC),cameras_global:mC,view:cE,menu:BS,status_bar:XS,live:TS,media_gallery:LS,media_viewer:dE,image:fS,elements:XC,dimensions:DC,timeline:JS,performance:US,debug:OC,automations:Yk.optional(),profiles:qS,folders:mS.optional(),overrides:VS,card_mod:bi.unknown(),card_id:bi.string().regex(wi).optional(),remote_control:KS,type:bi.string()}),pE={cameras:lC,view:iE,menu:RS,status_bar:GS,live:ES,media_gallery:IS,media_viewer:lE,image:nC,timeline:$C,performance:HS,debug:IC,remote_control:WS},mE={casting:{[af]:!1,[Lm]:!1,[pg]:"none",[`${vg}.enabled`]:!0,[`${yg}.enabled`]:!0,[`${gg}.enabled`]:!1,[`${bg}.enabled`]:!1,[nf]:["selected","visible"],[$g]:"static",[Tg]:"16:9",[Ep]:1,[Ff]:!0},"low-performance":{[gf]:"none",[zm]:"none",[ag]:"none",[Ef]:!1,[Zm]:!1,[ng]:!1,[tf]:[],[bm]:[],[wm]:[],[xm]:[],[Pf]:["unselected","hidden"],[jf]:!1,[Tm]:!1,[Nf]:"none",[Om]:"none",[Ff]:!1,[Dm]:"chevrons",[kg]:"none",[pg]:"outside",[`${_g}.enabled`]:!1,[`${wg}.enabled`]:!1,[`${wg}.enabled`]:!1,[`${bg}.enabled`]:!1,[fm]:!1,[gm]:!1,[_m]:!1,[mm]:!1,[yf]:!1,[bf]:!1,[wf]:!1,[vf]:!1,[Rm]:!1,[Nm]:!1,[Fm]:!1,[Pm]:!1,[og]:!1,[cg]:!1,[lg]:!1,[sg]:!1,[Dg]:!1,[zg]:!1,[jg]:!1,[Pg]:10,[Bg]:!1,[Fg]:!1,[Im]:!1,[Sp]:!1,[Cp]:"image",[Ep]:10,[lm]:"none",[Rg]:1},scrubbing:{[Cf]:"below",[Af]:"ribbon",[Sf]:"seek",[qm]:"below",[Km]:"ribbon",[Wm]:"seek"}},fE=(e,t,n)=>{const i=PM(hE).safeParse(e);if(!i.success)return t;const a=i.data;for(const e of n??[])e in mE&&Object.entries(mE[e]).forEach((([e,n])=>{return r=n,void(void 0===dM(a,i=e)&&uM(t,i,r));var i,r}));return t},gE=e=>{const t=gE;e.getAutomationsManager().deleteAutomations(t);const n=e.getConfigManager().getConfig()?.remote_control,i=n?.entities.camera;if(!i)return;const a=n.entities.camera_priority,r=[{conditions:[{condition:"config",paths:["cameras","remote_control.entities.camera"]}],actions:[Nd((e=>vE(i,e)))],tag:t},{conditions:[{condition:"camera"}],actions:[Nd((e=>_E(i,e.getViewManager().getView()?.camera,e)))],tag:t},{conditions:[{condition:"initialized"}],actions:["entity"===a?zd("camera_select",`{{ hass.states["${i}"].state }}`):Nd((e=>_E(i,e.getViewManager().getView()?.camera,e)))],tag:t},{conditions:[{condition:"state",entity:i}],actions:[zd("camera_select","{{ advanced_camera_card.trigger.state.to }}")],tag:t}];e.getAutomationsManager().addAutomations(r)},_E=async(e,t,n)=>{const i=n.getHASSManager().getHASS(),a=i?.states[e]?.state;t&&t!==a&&await(i?.callService("input_select","select_option",{option:t},{entity_id:e}))},vE=async(e,t)=>{const n=t.getHASSManager().getHASS(),i=t.getCameraManager().getStore().getCameraIDs(),a=(n?.states[e]?.attributes?.options??[]).sort(),r=[...i].sort();Uu(a,r)||await(n?.callService("input_select","set_options",{options:r},{entity_id:e}))},yE=e=>{const t=yE;e.getAutomationsManager().deleteAutomations(t);const n=e.getConfigManager().getConfig()?.view.keyboard_shortcuts;if(!n)return;const i=wE(t,n);i.length&&e.getAutomationsManager().addAutomations(i)},bE=e=>{switch(e){case"ptz_left":return"left";case"ptz_right":return"right";case"ptz_up":return"up";case"ptz_down":return"down";case"ptz_zoom_in":return"zoom_in";case"ptz_zoom_out":return"zoom_out"}
/* istanbul ignore next: No (current) way to reach this code -- @preserve */return null},wE=(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=bE(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:[Rd({ptzAction:r,ptzPhase:"start"})],tag:e}),n.push({conditions:[{condition:"key",key:a.key,state:"up"}],actions:[Rd({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:[Rd()],tag:e}),n};class xE extends sd{}class ME{constructor(e){this._overrides=new Map,this._callback=e}_clear(){this._overrides.forEach((e=>e.destroy())),this._overrides.clear()}hasOverrides(){return!!this._overrides.size}set(e,t){this._clear(),t?.forEach((t=>{const n=new AM(t.conditions,e);n.addListener(this._callback),this._overrides.set(t,n)}))}getConfig(e){let t=pM(e),n=!1,i=!1;for(const[e,a]of this._overrides.entries())a.getEvaluation()?.result&&(e.delete?.forEach((e=>{hM(t,e),i=!0})),Object.keys(e.set??{}).forEach((n=>{uM(t,n,e.set?.[n])})),Object.keys(e.merge??{}).forEach((n=>{uM(t,n,qu({},dM(t,n),e.merge?.[n]))})),n=!0);if(!n)return e;i&&(t=$d(t));const a=hE.safeParse(t);if(!a.success)throw new xE(u_("error.invalid_configuration_override"),[a.error.errors,t]);return a.data}}class kE{constructor(e){this._config=null,this._overriddenConfig=null,this._rawConfig=null,this._cardWideConfig=null,this._overridesManager=new ME((()=>this._processOverrideConfig())),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(u_("error.invalid_configuration"));const t=hE.safeParse(e);if(!t.success){const n=gM(e),i=RM(t.error);let a="";throw n&&(a=`${u_("error.upgrade_available")}. `),new Error(a+`${u_("error.invalid_configuration")}: `+(i&&i.size?JSON.stringify([...i],null," "):u_("error.invalid_configuration_no_hint")))}const n=fE(e,t.data,t.data.profiles);this._rawConfig=e,Uu(this._config,n)||(this._config=n,this._cardWideConfig={performance:n.performance,debug:n.debug},this._overridesManager.set(this._api.getConditionStateManager(),this._config.overrides),this._api.getConditionStateManager().setState({view:void 0,displayMode:void 0,camera:void 0}),this._api.getMediaLoadedInfoManager().clear(),this._api.getInitializationManager().uninitialize(DM.VIEW),this._api.getViewManager().reset(),this._api.getMessageManager().reset(),this._api.getStatusBarItemManager().removeAllDynamicStatusBarItems(),this._processOverrideConfig(),this._api.getCardElementManager().update())}_processOverrideConfig(){const e=this._getOverriddenConfig();if(!e||Uu(e,this._overriddenConfig))return;const t=this._overriddenConfig;var n;this._overriddenConfig=e,(e=>{e.getFoldersManager().deleteFolders();try{e.getFoldersManager().addFolders(e.getConfigManager().getConfig()?.folders??[])}catch(t){e.getMessageManager().setErrorIfHigherPriority(t)}})(this._api),this._api.getStyleManager().updateFromConfig(),yE(this._api),gE(this._api),(n=this._api).getAutomationsManager().deleteAutomations(),n.getAutomationsManager().addAutomations(n.getConfigManager().getNonOverriddenConfig()?.automations??[]),!t||Uu(t?.cameras,this._overriddenConfig?.cameras)&&Uu(t?.cameras_global,this._overriddenConfig?.cameras_global)||(this._api.getInitializationManager().uninitialize(DM.CAMERAS),this._api.getCameraManager().destroy()),t&&t?.live.microphone.always_connected!==this._overriddenConfig?.live.microphone.always_connected&&this._api.getInitializationManager().uninitialize(DM.MICROPHONE_CONNECT),this._initializeBackgroundAndUpdate(t)}_getOverriddenConfig(){
/* istanbul ignore if: No (current) way to reach this code -- @preserve */
if(!this._config)return null;try{return this._overridesManager.getConfig(this._config)}catch(e){return this._api.getMessageManager().setErrorIfHigherPriority(e),null}}async _initializeBackgroundAndUpdate(e){await this._api.getDefaultManager().initializeIfNecessary(e),await this._api.getMediaPlayerManager().initializeIfNecessary(e),this._overriddenConfig&&this._api.getInitializationManager().isInitializedMandatory()&&this._api.getConditionStateManager().setState({config:this._overriddenConfig}),this._api.getCardElementManager().update()}}class CE{constructor(e){this._timer=new qd,this._stateChangeHandler=()=>{this._setToDefaultIfAllowed()},this._api=e}async initializeIfNecessary(e){Uu(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()?.view.default_reset.after_interaction&&this._api.getAutomationsManager().addAutomations([{actions:[Dd("default")],conditions:[{condition:"interaction",interaction:!1}],tag:this}]),!0}uninitialize(){this._timer.stop(),this._api.getHASSManager().getStateWatcher().unsubscribe(this._stateChangeHandler),this._api.getAutomationsManager().deleteAutomations(this)}_setToDefaultIfAllowed(){this._isAutomatedUpdateAllowed()&&this._api.getViewManager().setViewDefault()}_isAutomatedUpdateAllowed(){const e=this._api.getConfigManager().getConfig()?.view.default_reset.interaction_mode;return!!e&&((e,t)=>{switch(e){case"all":return!0;case"active":return t;case"inactive":return!t}})(e,this._api.getInteractionManager().hasInteraction())}}class SE{constructor(e){this._expanded=!1,this._api=e}initialize(){this._setConditionState()}isExpanded(){return this._expanded}toggleExpanded(){this.setExpanded(!this._expanded)}setExpanded(e){e&&this._api.getFullscreenManager().isInFullscreen()&&this._api.getFullscreenManager().setFullscreen(!1),this._expanded=e,this._setConditionState(),Md(this._api.getCardElementManager().getElement(),e,"expanded"),this._api.getCardElementManager().update()}_setConditionState(){this._api.getConditionStateManager()?.setState({expand:this._expanded})}}const EE={album:{icon:"mdi:album"},app:{icon:"mdi:application"},artist:{icon:"mdi:account-music"},channel:{icon:"mdi:television-classic"},composer:{icon:"mdi:account-music-outline"},contributing_artist:{icon:"mdi:account-music"},directory:{icon:"mdi:folder"},episode:{icon:"mdi:television-classic"},game:{icon:"mdi:gamepad-variant"},genre:{icon:"mdi:drama-masks"},image:{icon:"mdi:image"},movie:{icon:"mdi:movie"},music:{icon:"mdi:music"},playlist:{icon:"mdi:playlist-music"},podcast:{icon:"mdi:podcast"},season:{icon:"mdi:television-classic"},track:{icon:"mdi:file-music"},tv_show:{icon:"mdi:television-classic"},url:{icon:"mdi:web"},video:{icon:"mdi:video"}},AE=e=>EE[e]?.icon??null;class TE extends oh{constructor(e,t,n){super(e,{cameraID:n?.cameraID??t._metadata?.cameraID,...n}),this._browseMedia=t,this._icon=AE(t.media_class),this._id=t._metadata?.startDate&&this._cameraID?`${this._cameraID}/${ja(t._metadata.startDate,"yyyy-MM-dd HH:mm:ss")}`:t.media_content_id}getStartTime(){return this._browseMedia._metadata?.startDate??null}getEndTime(){return this._browseMedia._metadata?.endDate??null}getVideoContentType(){return this._mediaType===rh.Clip?sh.MP4:null}getID(){return this._id}getContentID(){return this._browseMedia.media_content_id}getTitle(){const e=this.getStartTime();return e?gd(e):this._browseMedia.title}getThumbnail(){return this._browseMedia.thumbnail}getIcon(){return this._icon}getWhat(){return this._browseMedia._metadata?.what??null}getScore(){return null}getTags(){return null}isGroupableWith(e){return this.getMediaType()===e.getMediaType()&&Uu(this.getWhat(),e.getWhat())}}class $E extends ch{constructor(e,t){super(e,{id:t.media_content_id,icon:AE(t.children_media_class??t.media_class),title:t.title,thumbnail:t.thumbnail}),this._browseMedia=t}getBrowseMedia(){return this._browseMedia}}class IE{static create(e,t){if(e.can_expand)return t?.folder?new $E(t.folder,e):null;const n=e.media_class===w_?rh.Clip:e.media_class===x_?rh.Snapshot:null;return n?new TE(n,e,t):null}}const OE=(e,t)=>LE(e,t).filter((e=>lh.isMedia(e))),LE=(e,t)=>e.map((e=>IE.create(e,{cameraID:e._metadata?.cameraID,...t}))).filter(Cd);function DE(e){return!!e?.startsWith("/")}function jE(e,t){return DE(t)?e.hassUrl(t):t??null}const zE=async(e,t,n)=>{if(!t)return null;const i=await iv(e,t,n);return i?{endpoint:jE(e,i.url)}:null},PE=(e,t,n)=>{const i=t.match(e);return n?.groupName&&i?.groups?.[n.groupName]?i.groups[n.groupName]:void 0!==n?.groupNumber&&i?.[n.groupNumber]?i[n.groupNumber]:i?i[0]:null},RE="value";class NE{constructor(){this._templateRenderer=new lM}match(e,t,n){if(n?.foldersOnly&&!t.can_expand)return!1;for(const i of n?.matchers??[])switch(i.type){case"date":case"startdate":if(!this._matchStartDate(i,t))return!1;break;case"template":if(!this._matchTemplate(e,i,t,n?.conditionState))return!1;break;case"title":if(!this._matchTitle(i,t))return!1;break;case"or":if(!i.matchers.some((i=>this.match(e,t,{foldersOnly:n?.foldersOnly,matchers:[i],conditionState:n?.conditionState}))))return!1}return!0}_matchStartDate(e,t){const n=t._metadata?.startDate;return!!n&&n>=Or(new Date,{years:e.since.years??0,months:e.since.months??0,days:e.since.days??0,hours:e.since.hours??0,minutes:e.since.minutes??0})}_matchTemplate(e,t,n,i){return!0===this._templateRenderer.renderRecursively(e,t.value_template,{conditionState:i,mediaData:{title:n.title,is_folder:n.can_expand}})}_matchTitle(e,t){const n=e.regexp?PE(e.regexp,t.title,{groupName:RE}):t.title;return!!n&&(!e.title||n===e.title)}}class FE{constructor(){this._anyDateParser=null}async prepare(e){this._anyDateParser||e?.some((e=>["date","startdate"].includes(e.type)&&!e.format))&&(this._anyDateParser=(await import("./index-a94d25a3.js")).default)}generate(e,t,n){const i={...t?._metadata};for(const a of n??[]){const n=a.regexp?PE(a.regexp,e.title,{groupName:RE}):e.title;n&&("startdate"!==a.type&&"date"!==a.type||(i.startDate=this._parseDate(a,n,i.startDate??t?._metadata?.startDate)??void 0))}return Object.keys(i).length>0?i:null}_parseDate(e,t,n){return e.format?this._parseFormattedDate(e.format,t,n):this._parseUnknownDate(t,n)}_parseFormattedDate(e,t,n){const i=Ir(t,e,n??new Date);return xd(i)?i:void 0}_parseUnknownDate(e,t){if(!this._anyDateParser)return;const n=this._anyDateParser.attempt(e);if(!Object.keys(n).length)return;const i=this._anyDateParser.fromObject({...t&&{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()},...n});return xd(i)?i:void 0}}class BE{constructor(e){this._cache=new b_,this._browseMediaManager=e?.browseMediaManager??new k_,this._metadataGenerator=e?.metadataGenerator??new FE,this._mediaMatcher=e?.mediaMatcher??new NE}getItemCapabilities(e){return{canFavorite:!1,canDownload:!lh.isFolder(e)}}async getDownloadPath(e,t,n){return lh.isMedia(t)?zE(e,t.getContentID(),n?.resolvedMediaCache):null}async favorite(e,t,n){}generateDefaultFolderQuery(e){return e.type!==eS.enum.ha?null:{folder:e,path:this.getDefaultFolderPathComponents(e.ha)}}getDefaultFolderPathComponents(e){return[...!e?.url&&e?.path?.[0]?.id!==JC?[{id:JC}]:[],...e?.url??[],...e?.path??[]].map((e=>({ha:e})))}async expandFolder(e,t,n,i){if(t.folder.type!==eS.enum.ha)return null;const a=[...t.path];let r=null;for(;a.length>0;){const e=(a[0]?.folder instanceof $E?a[0].folder.getBrowseMedia():null)??a[0]?.ha?.id??null;if(!e)break;r=e,a.shift()}if(null===r)return null;await this._metadataGenerator.prepare(a.flatMap((e=>e.ha?.parsers??[])));const s=t=>{const i=a.shift();return[{targets:t,metadataGenerator:(e,t)=>this._metadataGenerator.generate(e,t,i?.ha?.parsers),...i&&{matcher:t=>this._mediaMatcher.match(e,t,{matchers:i.ha?.matchers,foldersOnly:a.length>0,conditionState:n}),advance:e=>a.length?s(e):[]}}]},o=await this._browseMediaManager.walk(e,s([r]),{...(i?.useCache??!0)&&{cache:this._cache}});return LE(o,{folder:t.folder})}generateChildFolderQuery(e,t){const n=t.getID();if(e.folder.type!==eS.enum.ha||!n)return null;const i=this.getDefaultFolderPathComponents(e.folder.ha)[e.path.length],a=i?.ha??{id:n};return{...e,path:[...e.path,{folder:t,ha:a}]}}}class VE{constructor(e){this._ha=e?.ha??new BE}generateDefaultFolderQuery(e){return this._getFolderEngine(e.type)?.generateDefaultFolderQuery(e)??null}generateChildFolderQuery(e,t){return this._getFolderEngine(e.folder.type)?.generateChildFolderQuery(e,t)??null}async expandFolder(e,t,n,i){const a=await(this._getFolderEngine(t.folder.type)?.expandFolder(e,t,n,i))??null;return a?uh(a):null}getItemCapabilities(e){return this._getFolderEngine(e.getFolder()?.type)?.getItemCapabilities(e)??null}async getDownloadPath(e,t,n){return await(this._getFolderEngine(t.getFolder()?.type)?.getDownloadPath(e,t,n)??null)}async favorite(e,t,n){return await(this._getFolderEngine(t.getFolder()?.type)?.favorite(e,t,n))}_getFolderEngine(e){return e===eS.enum.ha?this._ha:null}}class HE extends sd{}class UE{constructor(e,t){this._folders=new Map,this._api=e,this._executor=t??new VE}deleteFolders(){this._folders.clear()}addFolders(e){for(const t of e){const e=this._folders.size,n=t.id??`folder/${e.toString()}`;if(this._folders.has(n))throw new HE(u_("error.duplicate_folder_id"),t);this._folders.set(n,{title:`${u_("common.folder")} ${e}`,...Nl(t),id:n})}}hasFolders(){return this._folders.size>0}getFolderCount(){return this._folders.size}getFolders(){return this._folders.entries()}getFolder(e){return e?this._folders.get(e)??null:this._folders.values().next().value??null}generateDefaultFolderQuery(e){const t=e??this.getFolder();return t?this._executor.generateDefaultFolderQuery(t):null}generateChildFolderQuery(e,t){return this._executor.generateChildFolderQuery(e,t)}async expandFolder(e,t,n){const i=this._api.getHASSManager().getHASS();return i?this._executor.expandFolder(i,e,t,n):null}getItemCapabilities(e){return this._executor.getItemCapabilities(e)}async getDownloadPath(e){return await this._executor.getDownloadPath(this._api.getHASSManager().getHASS(),e,{resolvedMediaCache:this._api.getResolvedMediaCache()})}async favorite(e,t){return await this._executor.favorite(this._api.getHASSManager().getHASS(),e,t)}}const qE=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],WE=(()=>{if("undefined"==typeof document)return!1;const e=qE[0],t={};for(const n of qE){const i=n?.[1];if(i in document){for(const[i,a]of n.entries())t[e[i]]=a;return t}}return!1})(),ZE={change:WE.fullscreenchange,error:WE.fullscreenerror};let KE={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{const a=()=>{KE.off("change",a),n()};KE.on("change",a);const r=e[WE.requestFullscreen](t);r instanceof Promise&&r.then(a).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!KE.isFullscreen)return void e();const n=()=>{KE.off("change",n),e()};KE.on("change",n);const i=document[WE.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>KE.isFullscreen?KE.exit():KE.request(e,t),onchange(e){KE.on("change",e)},onerror(e){KE.on("error",e)},on(e,t){const n=ZE[e];n&&document.addEventListener(n,t,!1)},off(e,t){const n=ZE[e];n&&document.removeEventListener(n,t,!1)},raw:WE};Object.defineProperties(KE,{isFullscreen:{get:()=>Boolean(document[WE.fullscreenElement])},element:{enumerable:!0,get:()=>document[WE.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>Boolean(document[WE.fullscreenEnabled])}}),WE||(KE={isEnabled:!1});var QE=KE;class YE{constructor(e,t){this._api=e,this._handler=t}}class GE extends YE{connect(){QE.isEnabled&&QE.on("change",this._handler)}disconnect(){QE.isEnabled&&QE.off("change",this._handler)}isInFullscreen(){return QE.isEnabled&&QE.isFullscreen}isSupported(){return QE.isEnabled}setFullscreen(e){this.isSupported()&&(e?QE.request(this._api.getCardElementManager().getElement()):QE.exit())}}class XE extends YE{constructor(){super(...arguments),this._playTimer=new qd,this._stateChangeHandler=e=>{if(e.old.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement()!==e.new.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement()){const t=e.old.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement();t?.removeEventListener("webkitbeginfullscreen",this._handler),t?.removeEventListener("webkitendfullscreen",this._endHandler);const n=e.new.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement();n?.addEventListener("webkitbeginfullscreen",this._handler),n?.addEventListener("webkitendfullscreen",this._endHandler)}},this._endHandler=()=>{this._handler(),this._playTimer.start(.5,(()=>{this._getVideoElement()?.play()}))}}connect(){this._api.getConditionStateManager().addListener(this._stateChangeHandler)}disconnect(){this._api.getConditionStateManager().removeListener(this._stateChangeHandler)}_getVideoElement(){const e=this._api.getMediaLoadedInfoManager().get()?.mediaPlayerController?.getFullscreenElement();return e instanceof HTMLVideoElement?e:null}isInFullscreen(){return!!this._getVideoElement()?.webkitDisplayingFullscreen}isSupported(){return!!this._getVideoElement()?.webkitSupportsFullscreen}setFullscreen(e){if(!this.isSupported())return;const t=this._getVideoElement();e?t?.webkitEnterFullscreen?.():t?.webkitExitFullscreen?.()}}class JE{static create(e,t){if(QE.isEnabled)return new GE(e,t);return document.createElement("video").webkitEnterFullscreen?new XE(e,t):null}}class eA{constructor(e,t){this._fullscreenHandler=()=>{this._api.getExpandManager().setExpanded(!1),this._setConditionState(),this._api.getCardElementManager().update()},this._api=e,this._provider=t??JE.create(e,this._fullscreenHandler)}connect(){this._provider?.connect()}disconnect(){this._provider?.disconnect()}setFullscreen(e){this._provider?.setFullscreen(e)}isInFullscreen(){return this._provider?.isInFullscreen()??!1}isSupported(){return!IM()&&(this._provider?.isSupported()??!1)}initialize(){this._setConditionState()}toggleFullscreen(){this._provider?.isInFullscreen()?this._provider.setFullscreen(!1):this._provider?.setFullscreen(!0)}_setConditionState(){this._api.getConditionStateManager()?.setState({fullscreen:this.isInFullscreen()})}}function tA(e,t,n,i){if(!e||!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}class nA{constructor(){this._watcherCallbacks=new Map}setHASS(e,t){if(e)for(const[n,i]of this._watcherCallbacks.entries()){const a=tA(t,e,i,{stateOnly:!0,firstOnly:!0});a.length&&n(a[0])}}subscribe(e,t){return!!t.length&&(this._watcherCallbacks.has(e)?this._watcherCallbacks.get(e)?.push(...t):this._watcherCallbacks.set(e,t),!0)}unsubscribe(e){this._watcherCallbacks.delete(e)}}class iA{constructor(e){this._hass=null,this._stateWatcher=new nA,this._api=e}getHASS(){return this._hass}hasHASS(){return!!this._hass}getStateWatcher(){return this._stateWatcher}setHASS(e){if(((e,t)=>e?.connected!==t?.connected)(this._hass,e)&&(e?.connected?this._api.getMessageManager().resetType("connection"):this._api.getMessageManager().setMessageIfHigherPriority({message:u_("error.reconnecting"),icon:"mdi:lan-disconnect",type:"connection",dotdotdot:!0})),!e)return;const t=this._hass;this._hass=e,this._api.getConditionStateManager().setState({hass:this._hass}),this._api.getStyleManager().applyTheme(),this._stateWatcher.setHASS(t,e)}}class aA{constructor(e){this._timer=new qd,this._interacted=!1,this.reportInteraction=ed((()=>{this._reportInteraction()}),1e3),this._api=e}initialize(){this._setInteraction(!1)}hasInteraction(){return this._interacted}_setInteraction(e){this._interacted=e,Md(this._api.getCardElementManager().getElement(),e,"interaction"),this._api.getConditionStateManager().setState({interaction:e})}_reportInteraction(){this._timer.stop(),this._setInteraction(!0);const e=this._api.getConfigManager().getConfig()?.view.interaction_seconds;e&&this._timer.start(e,(()=>{this._setInteraction(!1)}))}}class rA{constructor(e){this._state={},this._handleKeydown=e=>{const t={state:"down",ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey,shift:e.shiftKey};Uu(this._state[e.key],t)||(this._state[e.key]=t,this._processStateChange())},this._handleKeyup=e=>{e.key in this._state&&"down"===this._state[e.key].state&&(this._state[e.key].state="up",this._processStateChange())},this._handleBlur=()=>{Object.keys(this._state).length&&(this._state={},this._processStateChange())},this._api=e}initialize(){const e=this._api.getCardElementManager().getElement();e.addEventListener("keydown",this._handleKeydown),e.addEventListener("keyup",this._handleKeyup),e.addEventListener("blur",this._handleBlur)}uninitialize(){const e=this._api.getCardElementManager().getElement();e.removeEventListener("keydown",this._handleKeydown),e.removeEventListener("keyup",this._handleKeyup),e.removeEventListener("blur",this._handleBlur)}_processStateChange(){this._api.getConditionStateManager().setState({keys:this._state})}}function sA(e,t,n,i){e.dispatchEvent(new CustomEvent(`advanced-camera-card:${t}`,{bubbles:i?.bubbles??!0,composed:i?.composed??!0,cancelable:i?.cancelable??!1,detail:n}))}function oA(e,t){let n;return n=e instanceof Event?e.composedPath()[0]:e,n instanceof HTMLImageElement?{width:n.naturalWidth,height:n.naturalHeight,...t}:n instanceof HTMLVideoElement?{width:n.videoWidth,height:n.videoHeight,...t}:n instanceof HTMLCanvasElement?{width:n.width,height:n.height,mediaPlayerController:t?.mediaPlayerController,...t}:null}function cA(e,t,n){const i=oA(t,n);i&&lA(e,i)}function lA(e,t){sA(e,"media:loaded",t)}function uA(e){sA(e,"media:unloaded")}function dA(e){sA(e,"media:volumechange")}function hA(e){sA(e,"media:play")}function pA(e){sA(e,"media:pause")}class mA{constructor(e){this._current=null,this._lastKnown=null,this._api=e}initialize(){this.clear()}set(e){var t;(t=e).height>=50&&t.width>=50&&(h_(this._api.getConfigManager().getCardWideConfig(),"Advanced Camera Card media load: ",e),this._current=e,this._lastKnown=e,this._api.getConditionStateManager().setState({mediaLoadedInfo:e}),this._api.getStyleManager().setExpandedMode(),this._api.getCardElementManager().update())}get(){return this._current}getLastKnown(){return this._lastKnown}clear(){this._current=null,this._api.getConditionStateManager().setState({mediaLoadedInfo:null})}has(){return!!this._current}}const fA=(e,t)=>!!((e.attributes.supported_features??0)&t);class gA{constructor(e){this._mediaPlayers=[],this._api=e}getMediaPlayers(){return this._mediaPlayers}hasMediaPlayers(){return this._mediaPlayers.length>0}async initializeIfNecessary(e){e?.menu.buttons.media_player.enabled!==this._api.getConfigManager().getConfig()?.menu.buttons.media_player.enabled&&await this.initialize()}async initialize(){const e=this._api.getHASSManager().getHASS();if(!e||!this._api.getConfigManager().getConfig()?.menu.buttons.media_player.enabled)return!1;const t=Object.keys(e.states).filter((t=>{if(t.startsWith("media_player.")){const n=e.states[t];if(n&&"unavailable"!==n.state&&fA(n,131072))return!0}return!1}));let n=null;try{n=await this._api.getEntityRegistryManager().getEntities(e,t)}catch(e){md(e)}return this._mediaPlayers=t.filter((e=>{const t=n?.get(e);return!t||!t.hidden_by})),!0}async stop(e){const t=this._api.getHASSManager().getHASS(),n=t?.states[e];if(!n)return;let i;if(fA(n,4096))i="media_stop";else{if(!fA(n,256))return;i="turn_off"}await t.callService("media_player",i,{entity_id:e})}async playLive(e,t){const n=this._api.getCameraManager().getStore().getCameraConfig(t);n&&("dashboard"===n.cast?.method?await this._playLiveDashboard(e,n):await this._playLiveStandard(e,t,n))}async _playLiveStandard(e,t,n){const i=this._api.getHASSManager().getHASS(),a=n?.camera_entity??null;if(!i||!a)return;const r=this._api.getCameraManager().getCameraMetadata(t)?.title??null,s=i.states[a]?.attributes?.entity_picture??null;await i.callService("media_player","play_media",{entity_id:e,media_content_id:`media-source://camera/${a}`,media_content_type:"application/vnd.apple.mpegurl",extra:{...r&&{title:r},...s&&{thumb:s}}})}async _playLiveDashboard(e,t){const n=this._api.getHASSManager().getHASS();if(!n)return;const i=t.cast?.dashboard;i?.dashboard_path&&i?.view_path?await n.callService("cast","show_lovelace_view",{entity_id:e,dashboard_path:i.dashboard_path,view_path:i.view_path}):this._api.getMessageManager().setMessageIfHigherPriority({type:"error",icon:"mdi:cast",message:u_("error.no_dashboard_or_view")})}async playMedia(e,t){const n=this._api.getHASSManager().getHASS();if(!n||!t)return;const i=t.getTitle(),a=t.getThumbnail();await n.callService("media_player","play_media",{entity_id:e,media_content_id:t.getContentID(),media_content_type:lh.isVideo(t)?"video":"image",extra:{...i&&{title:i},...a&&{thumb:a}}})}}const _A={info:10,error:20,connection:30,diagnostics:40};class vA{constructor(e){this._message=null,this._api=e}getMessage(){return this._message}hasMessage(){return!!this._message}hasErrorMessage(){return"error"===this._message?.type}reset(){const e=this.hasMessage();this._message=null,e&&this._api.getCardElementManager().update()}resetType(e){this._message?.type===e&&this.reset()}setErrorIfHigherPriority(e,t){e&&"object"==typeof e&&"message"in e&&(md(e),this.setMessageIfHigherPriority({message:t?`${t}: ${e.message}`:String(e.message),type:"error",...e instanceof sd&&{context:e.context}}))}setMessageIfHigherPriority(e){const t=e=>e.type??"info",n=this._message?_A[t(this._message)]:0,i=_A[t(e)];return!(this._message&&i<n)&&(this._message=e,this._api.getMediaLoadedInfoManager().clear(),this._api.getCardElementManager().scrollReset(),this._api.getCardElementManager().update(),!0)}}class yA{constructor(e){this._timer=new qd,this._state={connected:!1,muted:!0,forbidden:!1},this._desireMute=!0,this._api=e}getState(){return this._state}initialize(){this._setState()}shouldConnectOnInitialization(){return!!this._api.getConfigManager().getConfig()?.live.microphone?.always_connected&&this.isSupported()}isSupported(){return!!navigator.mediaDevices?.getUserMedia}async connect(){if(!this.isSupported())return!1;try{this._stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}catch(e){return md(e),this._stream=null,this._setState(),!1}return this._setDesiredMuteOnStream(),this._setState(),!0}disconnect(){this._stream?.getTracks().forEach((e=>e.stop())),this._stream=void 0,this._setState()}getStream(){return this._stream??void 0}mute(){this._desireMute=!0,this._setDesiredMuteOnStream(),this._setState()}async unmute(){this.isSupported()&&(this._desireMute=!1,this.isConnected()||this.isForbidden()?this.isConnected()&&(this._setDesiredMuteOnStream(),this._setState()):await this.connect())}isConnected(){return!!this._stream}isForbidden(){return null===this._stream}isMuted(){return!this._stream||this._stream.getTracks().every((e=>!e.enabled))}_setDesiredMuteOnStream(){this._stream?.getTracks().forEach((e=>{e.enabled=!this._desireMute})),this._startDisconnectTimer()}_startDisconnectTimer(){const e=this._api.getConfigManager().getConfig()?.live.microphone;if(e?.always_connected)return;const t=e?.disconnect_seconds??0;t&&this._timer.start(t,(()=>{this.disconnect()}))}_setState(){this._state={stream:this._stream,connected:this.isConnected(),muted:this.isMuted(),forbidden:this.isForbidden()},this._api.getConditionStateManager().setState({microphone:this._state}),this._api.getCardElementManager().update()}}class bA{constructor(e){this._shouldRun=!0,this.requestExecution=()=>{this._shouldRun=!0,this._api.getCardElementManager().update()},this.executeIfNecessary=async()=>{this._shouldRun&&(this._shouldRun=!1,await this._executeViewRelated(this._calculateIntent()),await this._executeNonViewRelated(this._calculateIntent()))},this._isViewAction=e=>{switch(e.advanced_camera_card_action){case"clip":case"clips":case"diagnostics":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":return!0}return!1},this._api=e}hasViewRelatedActionsToRun(){return!!this._calculateIntent().view&&this._shouldRun}async _executeViewRelated(e){e.view&&(e.view.default?await this._api.getViewManager().setViewDefaultWithNewQuery({params:{camera:e.view.camera},...e.view.substream&&{modifiers:[new my(e.view.substream)]}}):await this._api.getViewManager().setViewByParametersWithNewQuery({params:{...e.view.view&&{view:e.view.view},...e.view.camera&&{camera:e.view.camera}},...e.view.substream&&{modifiers:[new my(e.view.substream)]}}))}async _executeNonViewRelated(e){e.other&&await this._api.getActionsManager().executeActions({actions:e.other})}_calculateIntent(){const e={};for(const t of this._getActions())this._isViewAction(t)?((e.view??={}).view=t.advanced_camera_card_action,(e.view??={}).default=void 0):"default"===t.advanced_camera_card_action?((e.view??={}).default=!0,(e.view??={}).view=void 0):"camera_select"===t.advanced_camera_card_action?(e.view??={}).camera=t.camera:"live_substream_select"===t.advanced_camera_card_action?(e.view??={}).substream=t.camera:(e.other??=[]).push(t);return e}_getActions(){const e=new URLSearchParams(window.location.search),t=[],n=this._api.getConfigManager().getConfig()?.card_id,i=new RegExp(/^(advanced-camera-card|frigate-card)-action([.:](?<cardID>\w+))?[.:](?<action>\w+)/);for(const[a,r]of e.entries()){const e=a.match(i);if(!e||!e.groups)continue;const s=e.groups.cardID,o=e.groups.action;if(s&&s!==n)continue;let c=null;switch(o){case"camera_select":case"live_substream_select":r&&(c=zd(o,r,{cardID:s}));break;case"camera_ui":case"default":case"download":case"expand":case"menu_toggle":c=Dd(o,{cardID:s});break;case"clip":case"clips":case"diagnostics":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":c=jd(o,{cardID:s});break;default:console.warn(`Advanced Camera Card received unknown card action in query string: ${o}`)}c&&t.push(c)}return t}}class wA{constructor(e){this._items=[],this._dynamicItems=[],this._api=e}addDynamicStatusBarItem(e){this._dynamicItems.includes(e)||this._dynamicItems.push(e),this._api.getCardElementManager().update()}removeDynamicStatusBarItem(e){this._dynamicItems=this._dynamicItems.filter((t=>!Uu(t,e))),this._api.getCardElementManager().update()}removeAllDynamicStatusBarItems(){this._dynamicItems=[],this._api.getCardElementManager().update()}calculateItems(e){const t=e?.view?e?.cameraManager?.getCameraMetadata(e?.view?.camera):null,n=t?.engineIcon??null,i=e?.view?.is("live")?t?.title??null:e?.view?.isViewerView()?e?.view.queryResults?.getSelectedResult()?.getTitle()??null:null,a=e?.mediaLoadedInfo?this._calculateResolution(e?.mediaLoadedInfo):null,r=e?.mediaLoadedInfo?.technology?.length?e?.mediaLoadedInfo.technology[0]:null;return[...i?[{type:"custom:advanced-camera-card-status-bar-string",string:i,expand:!0,sufficient:!0,...e?.statusConfig?.items.title}]:[],...a?[{type:"custom:advanced-camera-card-status-bar-string",string:a,...e?.statusConfig?.items.resolution}]:[],...r&&"webrtc"===r?[{type:"custom:advanced-camera-card-status-bar-icon",icon:"mdi:webrtc",...e?.statusConfig?.items.technology}]:r?[{type:"custom:advanced-camera-card-status-bar-string",string:r.toUpperCase(),...e?.statusConfig?.items.technology}]:[],...n?[{type:"custom:advanced-camera-card-status-bar-icon",icon:n,...e?.statusConfig?.items.engine}]:[],...this._dynamicItems]}_matchesWidthHeight(e,t,n){const i=.99*t,a=1.01*t,r=.99*n,s=1.01*n,o=(e,t,n)=>e>=t&&e<=n;return!!e&&(o(e.width,i,a)&&o(e.height,r,s)||o(e.height,i,a)&&o(e.width,r,s))}_calculateResolution(e){return this._matchesWidthHeight(e,1920,1080)?"1080p":this._matchesWidthHeight(e,1280,720)?"720p":this._matchesWidthHeight(e,640,480)?"VGA":this._matchesWidthHeight(e,3840,2160)?"4K":this._matchesWidthHeight(e,720,480)?"480p":this._matchesWidthHeight(e,720,576)?"576p":this._matchesWidthHeight(e,7680,4320)?"8K":`${e.width}x${e.height}`}}class xA{constructor(e){this._api=e}setExpandedMode(){const e=this._api.getCardElementManager().getElement(),t=this._api.getViewManager().getView(),n=this._api.getMediaLoadedInfoManager().getLastKnown();e.style.setProperty("--advanced-camera-card-expand-aspect-ratio",t?.isAnyMediaView()&&n?`${n.width} / ${n.height}`:"unset");const i=t?.isGrid();e.style.setProperty("--advanced-camera-card-expand-width",!i&&t?.isAnyMediaView()?"none":"var(--advanced-camera-card-expand-max-width)"),e.style.setProperty("--advanced-camera-card-expand-height",!i&&t?.isAnyMediaView()?"none":"var(--advanced-camera-card-expand-max-height)")}updateFromConfig(){this.applyTheme(),this._setMinMaxHeight(),this._setPerformance(),this._setDimmable()}applyTheme(){const e=this._api.getConfigManager().getConfig()?.view.theme;if(!e)return;const t=this._api.getCardElementManager().getElement(),n=this._getThemeNames(e);if(Md(t,!!n,"themes",n?.join(" ")),e.overrides)for(const[n,i]of Object.entries(e.overrides))t.style.setProperty(n,i)}_getThemeNames(e){return e.themes.length?e.themes:pE.view.theme.themes}_setDimmable(){const e=this._api.getConfigManager().getConfig();Md(this._api.getCardElementManager().getElement(),!!e?.view.dim,"dimmable")}_setMinMaxHeight(){const e=this._api.getConfigManager().getConfig();if(e){this._api.getCardElementManager().getElement().style.setProperty("--advanced-camera-card-height",e.dimensions.height)}}_setPerformance(){const e={box_shadow:{cssKey:"--advanced-camera-card-box-shadow-override",value:"none"},border_radius:{cssKey:"--advanced-camera-card-border-radius-override",value:"0px"}},t=this._api.getCardElementManager().getElement(),n=this._api.getConfigManager().getCardWideConfig()?.performance,i=n?.style??{};for(const n of Object.keys(i)){const a=e[n];kd(t,!i[n],a.cssKey,a.value)}}_isAspectRatioEnforced(e,t){const n=e.dimensions.aspect_ratio_mode;return!(this._api.getFullscreenManager().isInFullscreen()||this._api.getExpandManager().isExpanded()||"unconstrained"===n||"dynamic"===n&&(!t||t?.isAnyMediaView()||t?.is("timeline")||t?.is("diagnostics")))}getAspectRatioStyle(){const e=this._api.getConfigManager().getConfig(),t=this._api.getViewManager().getView();if(e){if(!this._isAspectRatioEnforced(e,t))return Td();const n=e.dimensions.aspect_ratio_mode,i=this._api.getMediaLoadedInfoManager().getLastKnown();return Td(i&&"dynamic"===n?{ratio:[i.width,i.height]}:{ratio:e.dimensions.aspect_ratio})}return Td({defaultStatic:!0})}}const MA=e=>!!e&&vy.includes(e);class kA{constructor(e){this._triggeredCameras=new Map,this._triggeredCameraTimers=new Map,this._throttledTriggerAction=ed(this._triggerAction.bind(this),1e3,{trailing:!0}),this.handleInitialCameraTriggers=async()=>{const e=this._api.getHASSManager().getHASS();let t=!1;for(const[n,i]of this._api.getCameraManager().getStore().getCameras())i.getConfig().triggers.entities.some((t=>MA(e?.states[t]?.state)))&&(t=!0,await this.handleCameraEvent({cameraID:n,type:"new"}));return t},this._api=e}getTriggeredCameraIDs(){return new Set(this._triggeredCameras.keys())}isTriggered(){return!!this._triggeredCameras.size}getMostRecentlyTriggeredCameraID(){const e=Qu([...this._triggeredCameras.entries()],(e=>e[1].getTime()),"desc");return e.length?e[0][0]:null}async handleCameraEvent(e){const t=this._api.getConfigManager().getConfig()?.view.triggers,n=this._api.getViewManager().getView()?.camera;if(!t||!n)return;const i=this._api.getCameraManager().getStore().getAllDependentCameras(n);t.filter_selected_camera&&!i.has(e.cameraID)||("end"!==e.type?(this._triggeredCameras.set(e.cameraID,new Date),this._setConditionStateIfNecessary(),await this._throttledTriggerAction(e)):this._startUntriggerTimer(e.cameraID))}_hasAllowableInteractionStateForAction(){const e=this._api.getConfigManager().getConfig()?.view.triggers,t=this._api.getInteractionManager().hasInteraction();return!!e&&("all"===e.actions.interaction_mode||"active"===e.actions.interaction_mode&&t||"inactive"===e.actions.interaction_mode&&!t)}async _triggerAction(e){const t=this._api.getConfigManager().getConfig()?.view.triggers.actions.trigger,n=this._api.getConfigManager().getConfig()?.view.default;("high"!==e.fidelity||e.snapshot||e.clip||"live"===t||"default"===t&&"live"===n)&&(this._hasAllowableInteractionStateForAction()&&("update"===t?await this._api.getViewManager().setViewByParametersWithNewQuery({queryExecutorOptions:{useCache:!1}}):"live"===t?await this._api.getViewManager().setViewByParametersWithNewQuery({params:{view:"live",camera:e.cameraID}}):"default"===t?await this._api.getViewManager().setViewDefaultWithNewQuery({params:{camera:e.cameraID}}):"high"===e.fidelity&&"media"===t&&await this._api.getViewManager().setViewByParametersWithNewQuery({params:{view:e.clip?"clip":"snapshot",camera:e.cameraID}})),this._api.getCardElementManager().update())}_setConditionStateIfNecessary(){const e=new Set(this._triggeredCameras.keys()),t=e.size?e:void 0;this._api.getConditionStateManager().setState({triggered:t})}async _untriggerAction(e){const t=this._api.getConfigManager().getConfig()?.view.triggers.actions.untrigger;"default"===t&&this._hasAllowableInteractionStateForAction()&&await this._api.getViewManager().setViewDefaultWithNewQuery(),this._triggeredCameras.delete(e),this._deleteTimer(e),this._setConditionStateIfNecessary(),this._api.getCardElementManager().update()}_startUntriggerTimer(e){this._deleteTimer(e);const t=new qd;this._triggeredCameraTimers.set(e,t),t.start(
/* 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)}}async function CA(e,t,n){const i={type:"auth/sign_path",path:t,expires:n},a=await m_(e,cd,i);return a?e.hassUrl(a.path):null}var SA;!function(e){e.Camera="camera",e.Folder="folder"}(SA||(SA={}));class EA{constructor(e){this._api=e}getCapabilities(e){const t=this._getMediaSource(e);return t===SA.Camera&&lh.isMedia(e)?this._api.getCameraManager().getMediaCapabilities(e):t===SA.Folder?this._api.getFoldersManager().getItemCapabilities(e):null}async download(e){try{await this._download(e)}catch(e){return this._api.getMessageManager().setErrorIfHigherPriority(e),!1}return!0}async favorite(e,t){const n=this._getMediaSource(e);return n===SA.Camera&&lh.isMedia(e)?await this._api.getCameraManager().favoriteMedia(e,t):
/* istanbul ignore else: this path cannot be reached -- @preserve */
n===SA.Folder?this._api.getFoldersManager().favorite(e,t):void 0}_getMediaSource(e){return lh.isMedia(e)&&e.getCameraID()?SA.Camera:lh.isFolder(e)||e.getFolder()?SA.Folder:null
/* istanbul ignore next: this path cannot be reached -- @preserve */}async _download(e){const t=this._api.getHASSManager().getHASS();if(!t)return;const n=this._getMediaSource(e),i=n===SA.Camera&&lh.isMedia(e)?await this._api.getCameraManager().getMediaDownloadPath(e):n===SA.Folder?await this._api.getFoldersManager().getDownloadPath(e):null;if(!i)throw new sd(u_("error.download_no_media"));let a=i.endpoint;if(i.sign){let e;try{e=await CA(t,i.endpoint)}catch(e){md(e)}if(!e)throw new sd(u_("error.download_sign_failed"));a=e}ny(a,this._generateDownloadFilename(e))}_generateDownloadFilename(e){const t=e=>e.toLowerCase().replaceAll(/[^a-z0-9]/gi,"-");if(lh.isMedia(e)){const n=e.getCameraID(),i=e.getID(),a=e.getStartTime();return(n?t(n):"media")+(i?`_${t(i)}`:"")+(a?`_${ja(a,"yyyy-MM-dd-HH-mm-ss")}`:"")+"."+("clip"===e.getMediaType()?"mp4":"jpg")}
/* istanbul ignore else: this path cannot be reached -- @preserve */return lh.isFolder(e)?t(e.getTitle()??"media"):"download"
/* istanbul ignore next: this path cannot be reached -- @preserve */}}class AA{constructor(e){this._query=null,e&&(this._query=e)}getQuery(){return this._query}setQuery(e){return this._query=e,this}clone(){return Nl(this)}isEqual(e){return Uu(this._query,e.getQuery())}}class TA extends AA{getQueryCameraIDs(){if(!this._query)return null;const e=new Set;return this._query.forEach((t=>[...t.cameraIDs].forEach((t=>e.add(t))))),e}setQueryCameraIDs(e){if(!this._query)return this;const t=[];return this._query.forEach((n=>t.push({...n,cameraIDs:hd(e)}))),this._query=rd(t,Uu),this}hasQueriesForCameraIDs(e){for(const t of e)if(!this._query?.some((e=>e.cameraIDs.has(t))))return!1;return!0}isSupersetOf(e){for(const t of e.getQuery()??[]){let e=!1;for(const n of this._query??[])if(Uu({...n,end:null,start:null},{...t,end:null,start:null})&&(!n.start&&!t.start||n.start&&t.start&&n.start<=t.start)&&(!n.end&&!t.end||n.end&&t.end&&n.end>=t.end)){e=!0;break}if(!e)return!1}return!0}}class $A extends TA{convertToClipsQueries(){for(const e of this._query??[])delete e.hasSnapshot,e.hasClip=!0;return this}}class IA extends TA{}class OA extends AA{}class LA{static isEventQuery(e){return e instanceof $A}static isRecordingQuery(e){return e instanceof IA}static isMediaQuery(e){return this.isEventQuery(e)||this.isRecordingQuery(e)}static isFolderQuery(e){return e instanceof OA}static isClipsQuery(e){return this.isEventQuery(e)&&!!e?.getQuery()?.every((e=>e.hasClip))}static isSnapshotQuery(e){return this.isEventQuery(e)&&!!e?.getQuery()?.every((e=>e.hasSnapshot))}static getQueryType(e){return this.isEventQuery(e)?"event":this.isRecordingQuery(e)?"recording":this.isFolderQuery(e)?"folder":null}static getMediaType(e){return this.isClipsQuery(e)?"clips":this.isSnapshotQuery(e)?"snapshots":this.isRecordingQuery(e)?"recordings":null}}const DA=(e,t)=>qu({},e,t);class jA{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 jA({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 jA({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=DA(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}isMediaGalleryView(){return["clips","folders","snapshots","recordings"].includes(this.view)}isAnyMediaView(){return this.isViewerView()||this.is("live")||this.is("image")}isAnyFolderView(){return["folder","folders"].includes(this.view)}isViewerView(){return["folder","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 zA=(e,t,n,i)=>{const a=n.getFolder();switch(e){case"diagnostics":case"image":case"media":return t.getStore().getCameraIDs();case"folder":case"folders":return a?t.getStore().getCameraIDs():new Set;case"live":case"clip":case"clips":case"snapshot":case"snapshots":case"recording":case"recordings":const n={inclusive:"live"!==e},r="clip"===e?"clips":"snapshot"===e?"snapshots":"recording"===e?"recordings":e;return i?t.getStore().getAllDependentCameras(i,r,n):t.getStore().getCameraIDsWithCapability(r,n);case"timeline":return a?t.getStore().getCameraIDs():t.getStore().getCameraIDsWithCapability({anyCapabilities:["clips","snapshots","recordings"]})}},PA=(e,t,n,i)=>!!zA(e,t,n,i)?.size,RA=(e,t)=>{t?.forEach((t=>t.modify(e)))};class NA extends sd{}class FA extends sd{}class BA{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=[...zA(i,this._api.getCameraManager(),this._api.getFoldersManager())];if(a.length&&e?.baseView?.camera&&t.view.default_cycle_camera){const t=a.indexOf(e.baseView.camera);n=a[t+1>=a.length?0:t+1]}else n=a[0]??null}return this.getViewByParameters({params:{...e?.params,view:i,camera:n},baseView:e?.baseView})}getViewByParameters(e){const t=this._api.getConfigManager().getConfig();if(!t)return null;let n=e?.params?.camera??e?.baseView?.camera??null,i=e?.params?.view??e?.baseView?.view??t.view.default;const a=this._api.getCameraManager().getStore().getCameraIDs();if(!n||!a.has(n)){const e=zA(i,this._api.getCameraManager(),this._api.getFoldersManager());n=e?.keys().next().value??null}if(!n){const e=[...this._api.getCameraManager().getStore().getCameras()].reduce(((e,[t,n])=>{const i=n.getCapabilities()?.getRawCapabilities();return i&&(e[t]=i),e}),{});throw new NA(u_("error.no_supported_cameras"),{view:i,cameras_capabilities:e})}if(!PA(i,this._api.getCameraManager(),this._api.getFoldersManager(),n)){if(!e?.failSafe||!PA(Ci,this._api.getCameraManager(),this._api.getFoldersManager(),n)){const e=this._api.getCameraManager().getStore().getCamera(n)?.getCapabilities()?.getRawCapabilities();throw new FA(u_("error.no_supported_camera"),{view:i,camera:n,...e&&{camera_capabilities:e}})}i=Ci}const r=this._getDefaultDisplayModeForView(i,t),s=(i!==e?.baseView?.view?r:null)??e?.params?.displayMode??e?.baseView?.displayMode??r??"single",o={...e?.params,view:i,camera:n,displayMode:s},c=e?.baseView?e.baseView.evolve(o):new jA(o);return RA(c,e?.modifiers),c}_getDefaultDisplayModeForView(e,t){let n=null;switch(e){case"media":case"clip":case"recording":case"snapshot":n=t.media_viewer.display?.mode??null;break;case"live":n=t.live.display?.mode??null}return n}}class VA{constructor(e,t){this._key=e,this._property=t}modify(e){e.removeContextProperty(this._key,this._property)}}class HA{constructor(e){this._query=e?.query,this._queryResults=e?.queryResults}modify(e){void 0!==this._query&&(e.query=this._query),void 0!==this._queryResults&&(e.queryResults=this._queryResults)}}const UA=(e,t,n)=>{let i;for(const[a,r]of e.entries()){if(!lh.isMedia(r))continue;const e=r.getStartTime(),s=r.getUsableEndTime();if(r.includesTime(t)&&e&&s){const t=s.getTime()-e.getTime();(!i||n&&i.cameraID!==n&&r.getCameraID()===n||t>i.duration&&(!n||i.cameraID!==n||r.getCameraID()===n))&&(i={index:a,duration:t,cameraID:r.getCameraID()})}}return i?i.index:null};class qA{constructor(e){this._results=e?.results??[],this._selectedIndex=this._getInitialSelectedIndex(e)}_getInitialSelectedIndex(e){return null!=e?.selectedIndex?e.selectedIndex:e?.results&&e.results.length?e?.selectApproach&&"last"!==e?.selectApproach?0:e.results.length-1:null}clone(){return new qA({results:this._results,selectedIndex:this._selectedIndex})}getResults(){return this._results}getSelectedIndex(){return this._selectedIndex}getResultsCount(){return this.getResults().length}hasResults(){return 0!==this.getResultsCount()}getResult(e){return void 0===e?null:this._results[e]}getSelectedResult(){const e=this.getSelectedIndex();return null!==e?this.getResult(e):null}hasSelectedResult(){return null!==this.getSelectedResult()}resetSelectedResult(){this._selectedIndex=null}selectIndex(e){(null===e||e>=0&&e<this._results.length)&&(this._selectedIndex=e)}selectResultIfFound(e){for(const[t,n]of this._results.entries())if(e(n)){this.selectIndex(t);break}}selectBestResult(e){const t=e(this._results);null!==t&&this.selectIndex(t)}}class WA{constructor(e){this._resultsTimestamp=null,this._cameras=new Map,this._resultsTimestamp=new Date,this._main=new qA(e),this._buildByCameraSlices(e?.selectApproach)}_buildByCameraSlices(e){const t=new Map;for(const e of this._main.getResults()){const n=lh.isMedia(e)?e.getCameraID():null;if(n){const i=t.get(n)??[];i.push(e),t.set(n,i)}}for(const[n,i]of t.entries())this._cameras.set(n,new qA({results:i,selectApproach:e}))}clone(){const e=new WA;e._resultsTimestamp=this._resultsTimestamp,e._main=this._main.clone();for(const[t,n]of this._cameras.entries())e._cameras.set(t,n.clone());return e}isSupersetOf(e){const t=new Set(this._main.getResults()?.map((e=>e.getID()))),n=new Set(e._main.getResults()?.map((e=>e.getID())));return!(!t.size||!n.size||t.has(null)||n.has(null))&&((e,t)=>{for(const n of t)if(!e.has(n))return!1;return!0})(t,n)}getCameraIDs(){return new Set(this._cameras.keys())}getSlice(e){return e?this._cameras.get(e)??null:this._main}getResults(e){return this.getSlice(e)?.getResults()??null}getResultsCount(e){return this.getSlice(e)?.getResultsCount()??0}hasResults(e){return 0!==this.getSlice(e)?.getResultsCount()}getResult(e,t){return this.getSlice(t)?.getResult(e)??null}getSelectedIndex(e){return this.getSlice(e)?.getSelectedIndex()??null}getSelectedResult(e){return this.getSlice(e)?.getSelectedResult()??null}getMultipleSelectedResults(e){const t=[];if(!e||e.main){const e=this.getSelectedResult();e&&t.push(e)}const n=this._getCameraIDsFromCriteria(e);for(const e of n??[]){const n=this.getSelectedResult(e);n&&t.push(n)}return t}hasSelectedResult(e){return this.getSlice(e)?.hasSelectedResult()??!1}resetSelectedResult(e){return this.getSlice(e)?.resetSelectedResult(),this}getResultsTimestamp(){return this._resultsTimestamp}selectIndex(e,t){return this.getSlice(t)?.selectIndex(e),t||this.demoteMainSelectionToCameraSelection(),this}demoteMainSelectionToCameraSelection(){const e=this.getSelectedResult(),t=lh.isMedia(e)?e?.getCameraID():null;return e&&t&&(this.resetSelectedResult(t),this.selectResultIfFound((t=>t===e),{cameraID:t})),this}promoteCameraSelectionToMainSelection(e){const t=this.getSelectedResult(e);return this.resetSelectedResult(),this.selectResultIfFound((e=>e===t)),this}_getCameraIDsFromCriteria(e){return e?.allCameras?this.getCameraIDs():e?.cameraID?new Set([e.cameraID]):null}selectResultIfFound(e,t){t&&!t?.main||(this._main.selectResultIfFound(e),this.demoteMainSelectionToCameraSelection());const n=this._getCameraIDsFromCriteria(t);for(const t of n??[])this.getSlice(t)?.selectResultIfFound(e);return this}selectBestResult(e,t){t&&!t.main||(this._main.selectBestResult(e),this.demoteMainSelectionToCameraSelection());const n=this._getCameraIDsFromCriteria(t);for(const t of n??[])this.getSlice(t)?.selectBestResult(e);return this}}class ZA{constructor(e){this._api=e}async executeDefaultEventQuery(e){const t=e?.eventsMediaType&&"all"!==e?.eventsMediaType?e.eventsMediaType:{anyCapabilities:["clips","snapshots"]},n=this._api.getCameraManager(),i=e?.cameraID?n.getStore().getAllDependentCameras(e.cameraID,t):n.getStore().getCameraIDsWithCapability(t);if(!i.size)return null;const a=n.generateDefaultEventQueries(i,{limit:this._getChunkLimit(),..."clips"===e?.eventsMediaType&&{hasClip:!0},..."snapshots"===e?.eventsMediaType&&{hasSnapshot:!0}});if(!a)return null;const r=new $A(a);return await this.executeMediaQuery(r,e?.executorOptions)}async executeDefaultRecordingQuery(e){const t=this._api.getCameraManager(),n=e?.cameraID?t.getStore().getAllDependentCameras(e.cameraID,"recordings"):t.getStore().getCameraIDsWithCapability("recordings");if(!n.size)return null;const i=t.generateDefaultRecordingQueries(n,{limit:this._getChunkLimit()});if(!i)return null;const a=new IA(i);return await this.executeMediaQuery(a,e?.executorOptions)}async executeQuery(e,t){
/* istanbul ignore else: this path cannot be reached -- @preserve */
return LA.isMediaQuery(e)?await this.executeMediaQuery(e,t):LA.isFolderQuery(e)?await this._executeFolderQuery(e,t):null
/* istanbul ignore next: this path cannot be reached -- @preserve */}async executeMediaQuery(e,t){const n=e.getQuery();if(!n)return null;const i=await this._api.getCameraManager().executeMediaQueries(n,{useCache:t?.useCache}),a=i?this._generateQueriesResults(i,t):null;return a?{query:e,queryResults:a}:null}_generateQueriesResults(e,t){const n=new WA({results:e});return t?.rejectResults?.(n)?null:(t?.selectResult?.id?n.selectBestResult((e=>e.findIndex((e=>e.getID()===t.selectResult?.id)))):t?.selectResult?.func?n.selectResultIfFound(t.selectResult.func):t?.selectResult?.time&&n.selectBestResult((e=>UA(e,t.selectResult?.time?.time,t.selectResult?.time?.favorCameraID))),n)}async executeFolderQuery(e){const t=this._api.getFoldersManager().getFolder(e?.folder);if(!t)return null;const n=this._api.getFoldersManager().generateDefaultFolderQuery(t);return n?this._executeFolderQuery(new OA(n),e):null}async _executeFolderQuery(e,t){const n=e.getQuery();if(!n)return null;const i=await this._api.getFoldersManager().expandFolder(n,this._api.getConditionStateManager().getState(),{useCache:t?.useCache}),a=i?this._generateQueriesResults(i,t):null;return a?{query:e,queryResults:a}:null}_getChunkLimit(){const e=this._api.getConfigManager().getCardWideConfig();return e?.performance?.features.media_chunk_size??50}}class KA{constructor(e,t){this._api=e,this._executor=t??new ZA(e)}async getExistingQueryModifiers(e,t){return e.query?[new HA({queryResults:(await this._executor.executeQuery(e.query,t))?.queryResults})]:[]}async getNewQueryModifiers(e,t){return await this._executeNewQuery(e,{useCache:!1,...t})}async _executeNewQuery(e,t){const n=this._api.getConfigManager().getConfig();if(!n)return null;const i=e?.getDefaultMediaType(),a=[],r=async n=>{
/* 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 HA(i)]:[]},s=async()=>{const e=await this._executor.executeFolderQuery(t);return e?[new HA(e)]:[]};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));break;case"folder":case"folders":a.push(...await s())}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:Or(e,{seconds:t.controls.timeline.window_seconds}),end:e}}})]:[]}return[new VA("timeline","window")]}_getSeekTimeModifier(e){return e?[new Zv({mediaViewer:{seek:e}})]:[new VA("mediaViewer","seek")]}}class QA{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 BA(e),this._viewQueryExecutor=t?.viewQueryExecutor??new KA(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){if(!this._isAllowedToSetView())return;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")}_isAllowedToSetView(){return this._api.getInitializationManager().isInitialized(DM.CAMERAS)}async _setViewThenModifyAsync(e,t,n){if(!this._isAllowedToSetView())return;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),RA(o,r),this._setView(o)}_shouldAdoptQueryAndResults(e){const t=this._view?.isViewerView()&&e?.isMediaGalleryView(),n=e?.getDefaultMediaType(),i=LA.getMediaType(this._view?.query)===n;return!!t&&i}setViewWithMergedContext(e){if(this._view)return this._setView(this._view?.clone().mergeInContext(e))}hasMajorMediaChange(e,t){const n=t??this._view;return!!e!=!!n||e?.view!==n?.view||e?.camera!==n?.camera||"live"===n?.view&&e&&bv(e)!==bv(n)||"live"!==n?.view&&e?.queryResults!==n?.queryResults}_setView(e){const t=this._view;h_(this._api.getConfigManager().getCardWideConfig(),"Advanced Camera 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.getConditionStateManager()?.setState({view:e?.view,camera:e?.camera,displayMode:e?.displayMode??void 0}),this._api.getCardElementManager().update()}}class YA{constructor(e,t,n,i){this._conditionStateManager=new U_,this._deviceRegistryManager=new K_(new Z_),this._entityRegistryManager=new X_(new G_),this._resolvedMediaCache=new nv,this._actionsManager=new Ey(this,new lM),this._automationsManager=new TM(this),this._cameraManager=new H_(this),this._cameraURLManager=new $M(this),this._configManager=new kE(this),this._defaultManager=new CE(this),this._expandManager=new SE(this),this._foldersManager=new UE(this),this._fullscreenManager=new eA(this),this._hassManager=new iA(this),this._initializationManager=new jM(this),this._interactionManager=new aA(this),this._keyboardStateManager=new rA(this),this._mediaLoadedInfoManager=new mA(this),this._mediaPlayerManager=new gA(this),this._messageManager=new vA(this),this._microphoneManager=new yA(this),this._queryStringManager=new bA(this),this._statusBarItemManager=new wA(this),this._styleManager=new xA(this),this._triggersManager=new kA(this),this._viewManager=new QA(this),this._viewItemManager=new EA(this),e.addController(this),this._cardElementManager=new zM(this,e,t,n),this._effectsControllerAPICallback=i}getActionsManager(){return this._actionsManager}getAutomationsManager(){return this._automationsManager}getCameraManager(){return this._cameraManager}createCameraManager(){this._cameraManager=new H_(this)}getCameraURLManager(){return this._cameraURLManager}getCardElementManager(){return this._cardElementManager}getConditionStateManager(){return this._conditionStateManager}static async getConfigElement(){return await import("./editor-6e3decb6.js"),document.createElement("advanced-camera-card-editor")}getConfigManager(){return this._configManager}getDefaultManager(){return this._defaultManager}getDeviceRegistryManager(){return this._deviceRegistryManager}getEffectsControllerAPI(){return this._effectsControllerAPICallback()}getEntityRegistryManager(){return this._entityRegistryManager}getExpandManager(){return this._expandManager}getFoldersManager(){return this._foldersManager}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}createMicrophoneManager(){this._microphoneManager=new yA(this)}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}getViewItemManager(){return this._viewItemManager}hostConnected(){this.getCardElementManager().elementConnected()}hostDisconnected(){this.getCardElementManager().elementDisconnected()}}function GA(e,t){return t?e?.states[t]?.attributes?.friendly_name??null:null}class XA{constructor(){this._dynamicMenuButtons=[]}addDynamicMenuButton(e){this._dynamicMenuButtons.includes(e)||this._dynamicMenuButtons.push(e)}removeDynamicMenuButton(e){this._dynamicMenuButtons=this._dynamicMenuButtons.filter((t=>t!=e))}calculateButtons(e,t,n,i,a){return[this._getIrisButton(t),this._getCamerasButton(t,n,a?.view),this._getSubstreamsButton(t,n,a?.view),this._getLiveButton(t,n,i,a?.view),this._getClipsButton(t,n,i,a?.view),this._getSnapshotsButton(t,n,i,a?.view),this._getRecordingsButton(t,n,i,a?.view),this._getImageButton(t,n,i,a?.view),this._getTimelineButton(t,n,i,a?.view),this._getDownloadButton(t,n,a?.view),this._getCameraUIButton(t,a?.showCameraUIButton),this._getMicrophoneButton(t,n,a?.view,a?.microphoneManager),this._getExpandButton(t,a?.inExpandedMode),this._getFullscreenButton(t,a?.fullscreenManager),this._getCastButton(e,t,n,a?.view,a?.mediaPlayerController),this._getPlayPauseButton(t,a?.currentMediaLoadedInfo),this._getMuteUnmuteButton(t,a?.currentMediaLoadedInfo),this._getScreenshotButton(t,a?.currentMediaLoadedInfo),this._getDisplayModeButton(t,n,i,a?.view),this._getPTZControlsButton(t,n,a?.view),this._getPTZHomeButton(t,n,a?.view),this._getFoldersButton(t,i,a?.view),...this._dynamicMenuButtons.map((e=>({style:this._getStyleFromActions(t,e,a),...e})))].filter(Cd)}_getIrisButton(e){return{icon:"iris",...e.menu.buttons.iris,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.iris"),permanent:!0,tap_action:"hidden"===e.menu?.style?Dd("menu_toggle"):Dd("default"),hold_action:jd("diagnostics")}}_getCamerasButton(e,t,n){const i=t.getStore().getCameraIDsWithCapability("menu");if(i.size>1){const a=Array.from(i,(e=>{const i=zd("camera_select",e),a=t.getCameraMetadata(e);return{enabled:!0,icon:a?.icon.icon,entity:a?.icon.entity,state_color:!0,title:a?.title,selected:n?.camera===e,...i&&{tap_action:i}}}));return{icon:"mdi:video-switch",...e.menu.buttons.cameras,type:"custom:advanced-camera-card-menu-submenu",title:u_("config.menu.buttons.cameras"),items:a}}return null}_getSubstreamsButton(e,t,n){if(!n)return null;const i=t.getStore().getAllDependentCameras(n.camera,"substream");if(i.size&&n.is("live")){const a=[...i].filter((e=>e!==n.camera)),r=[n.camera,...a],s=bv(n);if(2===r.length)return{icon:"mdi:video-input-component",style:s!==n.camera?this._getEmphasizedStyle():{},title:u_("config.menu.buttons.substreams"),...e.menu.buttons.substreams,type:"custom:advanced-camera-card-menu-icon",tap_action:Dd(wv(n)?"live_substream_off":"live_substream_on")};if(r.length>2){const i=Array.from(r,(e=>{const n=zd("live_substream_select",e),i=t.getCameraMetadata(e)??void 0;return{enabled:!0,icon:i?.icon.icon,entity:i?.icon.entity,state_color:!0,title:i?.title,selected:s===e,...n&&{tap_action:n}}}));return{icon:"mdi:video-input-component",title:u_("config.menu.buttons.substreams"),style:s!==n.camera?this._getEmphasizedStyle():{},...e.menu.buttons.substreams,type:"custom:advanced-camera-card-menu-submenu",items:i}}}return null}_getLiveButton(e,t,n,i){return i&&PA("live",t,n,i.camera)?{icon:"mdi:cctv",...e.menu.buttons.live,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.live"),style:i.is("live")?this._getEmphasizedStyle():{},tap_action:jd("live")}:null}_getClipsButton(e,t,n,i){return i&&PA("clips",t,n,i.camera)?{icon:"mdi:filmstrip",...e.menu.buttons.clips,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.clips"),style:i?.is("clips")?this._getEmphasizedStyle():{},tap_action:jd("clips"),hold_action:jd("clip")}:null}_getSnapshotsButton(e,t,n,i){return i&&PA("snapshots",t,n,i.camera)?{icon:"mdi:camera",...e.menu.buttons.snapshots,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.snapshots"),style:i?.is("snapshots")?this._getEmphasizedStyle():{},tap_action:jd("snapshots"),hold_action:jd("snapshot")}:null}_getRecordingsButton(e,t,n,i){return i&&PA("recordings",t,n,i.camera)?{icon:"mdi:album",...e.menu.buttons.recordings,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.recordings"),style:i.is("recordings")?this._getEmphasizedStyle():{},tap_action:jd("recordings"),hold_action:jd("recording")}:null}_getImageButton(e,t,n,i){return i&&PA("image",t,n,i.camera)?{icon:"mdi:image",...e.menu.buttons.image,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.image"),style:i?.is("image")?this._getEmphasizedStyle():{},tap_action:jd("image")}:null}_getTimelineButton(e,t,n,i){return i&&PA("timeline",t,n,i.camera)?{icon:"mdi:chart-gantt",...e.menu.buttons.timeline,type:"custom:advanced-camera-card-menu-icon",title:u_("config.view.views.timeline"),style:i.is("timeline")?this._getEmphasizedStyle():{},tap_action:jd("timeline")}:null}_getDownloadButton(e,t,n){const i=n?.queryResults?.getSelectedResult(),a=i&&lh.isMedia(i)?t?.getMediaCapabilities(i):null;return n?.isViewerView()&&a?.canDownload&&!IM()?{icon:"mdi:download",...e.menu.buttons.download,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.download"),tap_action:Dd("download")}:null}_getCameraUIButton(e,t){return t?{icon:"mdi:web",...e.menu.buttons.camera_ui,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.camera_ui"),tap_action:Dd("camera_ui")}:null}_getMicrophoneButton(e,t,n,i){if(!n)return null;const a=t.getCameraCapabilities(bv(n));if(i&&a?.has("2-way-audio")){const t=i.isForbidden()||!i.isSupported(),n=i.isMuted(),a=e.menu.buttons.microphone.type;return{icon:t?"mdi:microphone-message-off":n?"mdi:microphone-off":"mdi:microphone",...e.menu.buttons.microphone,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.microphone"),style:t||n?{}:this._getEmphasizedStyle(!0),...!t&&"momentary"===a&&{start_tap_action:Dd("microphone_unmute"),end_tap_action:Dd("microphone_mute")},...!t&&"toggle"===a&&{tap_action:Dd(n?"microphone_unmute":"microphone_mute")}}}return null}_getExpandButton(e,t){return{icon:t?"mdi:arrow-collapse-all":"mdi:arrow-expand-all",...e.menu.buttons.expand,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.expand"),tap_action:Dd("expand"),style:t?this._getEmphasizedStyle():{}}}_getFullscreenButton(e,t){const n=t?.isInFullscreen();return t?.isSupported()?{icon:n?"mdi:fullscreen-exit":"mdi:fullscreen",...e.menu.buttons.fullscreen,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.fullscreen"),tap_action:Dd("fullscreen"),style:n?this._getEmphasizedStyle():{}}:null}_getCastButton(e,t,n,i,a){if(!i)return null;const r=n.getStore().getCameraConfig(i.camera);if(a?.hasMediaPlayers()&&(i.isViewerView()||i.is("live")&&r?.camera_entity)){const n=a.getMediaPlayers().map((t=>{const n=GA(e,t)||t,i=e.states[t],a=Pd(t,"play"),r=Pd(t,"stop"),s=!i||"unavailable"===i.state;return{enabled:!0,selected:!1,entity:t,state_color:!1,title:n,disabled:s,...!s&&a&&{tap_action:a},...!s&&r&&{hold_action:r}}}));return{icon:"mdi:cast",...t.menu.buttons.media_player,type:"custom:advanced-camera-card-menu-submenu",title:u_("config.menu.buttons.media_player"),items:n}}return null}_getPlayPauseButton(e,t){if(t&&t.mediaPlayerController&&t.capabilities?.supportsPause){const n=t.mediaPlayerController?.isPaused();return{icon:n?"mdi:play":"mdi:pause",...e.menu.buttons.play,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.play"),tap_action:Dd(n?"play":"pause")}}return null}_getMuteUnmuteButton(e,t){if(t&&t.mediaPlayerController&&t?.capabilities?.hasAudio){const n=t.mediaPlayerController?.isMuted();return{icon:n?"mdi:volume-off":"mdi:volume-high",...e.menu.buttons.mute,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.mute"),tap_action:Dd(n?"unmute":"mute")}}return null}_getScreenshotButton(e,t){return t&&t.mediaPlayerController?{icon:"mdi:monitor-screenshot",...e.menu.buttons.screenshot,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.screenshot"),tap_action:Dd("screenshot")}:null}_getDisplayModeButton(e,t,n,i){const a=i?zA(i.view,t,n):null;if(i?.supportsMultipleDisplayModes()&&a&&a.size>1){const t=i.isGrid();return{icon:t?"mdi:grid-off":"mdi:grid",...e.menu.buttons.display_mode,style:t?this._getEmphasizedStyle():{},type:"custom:advanced-camera-card-menu-icon",title:u_(t?"display_modes.single":"display_modes.grid"),tap_action:(r=t?"single":"grid",{action:"fire-dom-event",advanced_camera_card_action:"display_mode_select",display_mode:r,...s?.cardID&&{card_id:s.cardID}})}}var r,s;return null}_getPTZControlsButton(e,t,n){const i=n?.is("live")?e.live.controls.ptz:n?.isViewerView()?e.media_viewer.controls.ptz:null;if(!n||!i)return null;const a=zv(n,{cameraManager:t});if(a){const t=void 0!==n.context?.ptzControls?.enabled?n.context.ptzControls.enabled:"on"===i.mode||"auto"===i.mode&&"ptz"===a.type;return{icon:"mdi:pan",...e.menu.buttons.ptz_controls,style:t?this._getEmphasizedStyle():{},type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.ptz_controls"),tap_action:(r=!t,{action:"fire-dom-event",advanced_camera_card_action:"ptz_controls",enabled:r,...s?.cardID&&{card_id:s.cardID}})}}var r,s;return null}_getPTZHomeButton(e,t,n){const i=n?zv(n,{cameraManager:t}):null;return!i||(("digital"===i.type&&n?.context?.zoom?.[i.targetID]?.observed?.isDefault)??1)?null:{icon:"mdi:home",...e.menu.buttons.ptz_home,type:"custom:advanced-camera-card-menu-icon",title:u_("config.menu.buttons.ptz_home"),tap_action:Rd({targetID:i.targetID})}}_getFoldersButton(e,t,n){const i=[...t?.getFolders()??[]];if(!i?.length)return null;if(1===i.length){const t=LA.isFolderQuery(n?.query)&&n.query.getQuery()?.folder.id===i[0][0],a=i[0][1];return{icon:a.icon??"mdi:folder",...e.menu.buttons.folders,type:"custom:advanced-camera-card-menu-icon",title:a.title??u_("config.menu.buttons.folders"),style:t?this._getEmphasizedStyle():{},tap_action:jd("folders"),hold_action:jd("folder")}}const a=i.map((([e,t])=>{const i=LA.isFolderQuery(n?.query)&&n.query.getQuery()?.folder.id===e;return{enabled:!0,title:t.title??t.id,icon:t.icon??"mdi:folder",selected:i,style:i?this._getEmphasizedStyle():{},tap_action:jd("folders",{folderID:e}),hold_action:jd("folder",{folderID:e})}}));return{icon:"mdi:folder-multiple",...e.menu.buttons.folders,type:"custom:advanced-camera-card-menu-submenu",title:u_("config.menu.buttons.folders"),items:a,style:n?.isAnyFolderView()?this._getEmphasizedStyle():{}}}_getEmphasizedStyle(e){return e?{animation:"pulse 3s infinite",color:"var(--advanced-camera-card-menu-button-critical-color)"}:{color:"var(--advanced-camera-card-menu-button-active-color)"}}_getStyleFromActions(e,t,n){for(const i of[t.tap_action,t.double_tap_action,t.hold_action,t.start_tap_action,t.end_tap_action])for(const t of dd(i))if(Hd(t)&&(Si.some((e=>e===t.advanced_camera_card_action&&n?.view?.is(t.advanced_camera_card_action)))||"default"===t.advanced_camera_card_action&&n?.view?.is(e.view.default)||"fullscreen"===t.advanced_camera_card_action&&n?.fullscreenManager?.isInFullscreen()||"camera_select"===t.advanced_camera_card_action&&n?.view?.camera===t.camera))return this._getEmphasizedStyle();return{}}}const JA={fireworks:async()=>({default:(await import("./fireworks-0f5c32a9.js")).AdvancedCameraCardEffectFireworks}),ghost:async()=>({default:(await import("./ghost-481fd276.js")).AdvancedCameraCardEffectGhost}),hearts:async()=>({default:(await import("./hearts-0953f310.js")).AdvancedCameraCardEffectHearts}),shamrocks:async()=>({default:(await import("./shamrocks-07bce7f3.js")).AdvancedCameraCardEffectShamrocks}),snow:async()=>({default:(await import("./snow-e135bd60.js")).AdvancedCameraCardEffectSnow})};class eT{constructor(){this._importedModules=new Map,this._activeInstances=new Map,this._container=null}setContainer(e){this._container=e}async startEffect(e,t){if(!this._container||this._activeInstances.has(e))return;this._activeInstances.set(e,null);const n=await this._importEffectModule(e);if(!n||!this._activeInstances.has(e))return void this._activeInstances.delete(e);const i=new n.default;i.fadeIn=t?.fadeIn??!0,this._container.appendChild(i),this._activeInstances.set(e,i)}async stopEffect(e){if(!this._activeInstances.has(e))return;const t=this._activeInstances.get(e);this._activeInstances.delete(e),t&&(await t.startFadeOut(),t.remove())}async toggleEffect(e,t){this._activeInstances.has(e)?await this.stopEffect(e):await this.startEffect(e,t)}async _importEffectModule(e){const t=this._importedModules.get(e);if(t)return t;const n=await(JA[e]?.());return n?(this._importedModules.set(e,n),n):null}}let tT=class extends le{constructor(){super(...arguments),this._controller=new eT}async startEffect(e,t){await this._controller.startEffect(e,t)}stopEffect(e){this._controller.stopEffect(e)}async toggleEffect(e,t){await this._controller.toggleEffect(e,t)}updated(){this._controller.setContainer(this.renderRoot)}static get styles(){return s('/************\n * Managing z-indicies and stacking contexts is very challenging on the card,\n * due to the volume of different potentially overlapping surfaces. In\n * particular, care must be taken to not generate new stacking contexts\n * inadvertently which would make "z-index" weaving challenging (e.g. submenu\n * shown for PTZ presets, needs to render "over" the media drawer open/close\n * control).\n *************/\n:host {\n display: block;\n position: absolute;\n inset: 0;\n overflow: hidden;\n pointer-events: none;\n z-index: 7;\n}')}};tT=e([de("advanced-camera-card-effects")],tT);const nT=(e,t)=>{t instanceof Error&&sA(e,"message",{message:t.message,type:"error",...t instanceof sd&&{context:t.context}})};class iT extends Event{constructor(e){super("advanced-camera-card:condition-state-manager:get",e)}}let aT=class extends le{constructor(){super(...arguments),this._root=null,this._templateRenderer=new lM,this._setNewRoot=()=>{if(!this.hass)return;const e=this._templateRenderer.renderRecursively(this.hass,this.elements,{conditionState:this.conditionStateManager?.getState()});if(!this._root||!Uu(this._renderedElements,e))try{this._renderedElements=e,this._root=this._createRoot()}catch(e){return nT(this,e)}}}createRenderRoot(){return this}_createRoot(){const e=customElements.get("hui-conditional-element");if(!e||!this.hass)throw new Error(u_("error.could_not_render_elements"));const t=new e;t.hass=this.hass;const n={type:"conditional",conditions:[],elements:this._renderedElements};try{t.setConfig(n)}catch(e){throw md(e,console.error),new sd(u_("error.invalid_elements_config"))}return t}connectedCallback(){super.connectedCallback(),this.conditionStateManager?.addListener(this._setNewRoot)}disconnectedCallback(){this.conditionStateManager?.removeListener(this._setNewRoot),super.disconnectedCallback()}willUpdate(e){e.has("conditionStateManager")&&this.conditionStateManager&&(e.get("conditionStateManager")?.removeEventListener(this._setNewRoot),this.conditionStateManager.addListener(this._setNewRoot)),(!this._root||e.has("elements")||e.has("conditionStateManager"))&&this._setNewRoot()}render(){return q`${this._root||""}`}updated(){this.hass&&this._root&&(this._root.hass=this.hass)}};e([me({attribute:!1})],aT.prototype,"hass",void 0),e([me({attribute:!1})],aT.prototype,"elements",void 0),e([me({attribute:!1})],aT.prototype,"conditionStateManager",void 0),e([fe()],aT.prototype,"_root",void 0),aT=e([de("advanced-camera-card-elements-core")],aT);let rT=class extends le{constructor(){super(...arguments),this._menuRemoveHandler=e=>{sA(this,"menu:remove",e.detail)},this._statusBarRemoveHandler=e=>{sA(this,"status-bar:remove",e.detail)},this._menuAddHandler=e=>{const t=e.composedPath();t.length&&this._addHandler(t[0],"advanced-camera-card:menu:remove",this._menuRemoveHandler)},this._statusBarAddHandler=e=>{const t=e.composedPath();t.length&&this._addHandler(t[0],"advanced-camera-card:status-bar:remove",this._statusBarRemoveHandler)}}_addHandler(e,t,n){e.removeEventListener(t,n),e.addEventListener(t,n)}connectedCallback(){super.connectedCallback(),this.addEventListener("advanced-camera-card:menu:add",this._menuAddHandler),this.addEventListener("advanced-camera-card:status-bar:add",this._statusBarAddHandler)}disconnectedCallback(){this.removeEventListener("advanced-camera-card:menu:add",this._menuAddHandler),this.addEventListener("advanced-camera-card:status-bar:add",this._statusBarAddHandler),super.disconnectedCallback()}render(){return q`<advanced-camera-card-elements-core
.conditionStateManager=${this.conditionStateManager}
.hass=${this.hass}
.elements=${this.elements}
>
</advanced-camera-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([me({attribute:!1})],rT.prototype,"hass",void 0),e([me({attribute:!1})],rT.prototype,"elements",void 0),e([me({attribute:!1})],rT.prototype,"conditionStateManager",void 0),rT=e([de("advanced-camera-card-elements")],rT);let sT=class extends le{constructor(){super(...arguments),this._conditionManager=null}setConfig(e){this._config=e,this._createConditionManager()}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.className="",this._createConditionManager()}disconnectedCallback(){this._conditionManager?.destroy(),super.disconnectedCallback()}_createConditionManager(){const e=function(e){const t=new iT({bubbles:!0,composed:!0});return e.dispatchEvent(t),t.conditionStateManager??null}(this);this._config&&e&&(this._conditionManager?.destroy(),this._conditionManager=new AM(this._config.conditions,e),this._conditionManager.addListener((()=>this.requestUpdate())))}render(){if(this._conditionManager?.getEvaluation()?.result)return q` <advanced-camera-card-elements-core
.hass=${this.hass}
.elements=${this._config?.elements}
>
</advanced-camera-card-elements-core>`}};e([me({attribute:!1,hasChanged:()=>!0})],sT.prototype,"hass",void 0),sT=e([de("advanced-camera-card-conditional")],sT);class oT extends le{constructor(e){super(),this._config=null,this._eventCategory=e}setConfig(e){this._config=e}connectedCallback(){super.connectedCallback(),this._config&&sA(this,`${this._eventCategory}:add`,this._config)}disconnectedCallback(){this._config&&sA(this,`${this._eventCategory}:remove`,this._config),super.disconnectedCallback()}}e([fe()],oT.prototype,"_config",void 0);class cT extends oT{constructor(){super("menu")}}let lT=class extends cT{};lT=e([de("advanced-camera-card-menu-icon")],lT);let uT=class extends cT{};uT=e([de("advanced-camera-card-menu-state-icon")],uT);let dT=class extends cT{};dT=e([de("advanced-camera-card-menu-submenu")],dT);let hT=class extends cT{};hT=e([de("advanced-camera-card-menu-submenu-select")],hT);class pT extends oT{constructor(){super("status-bar")}}let mT=class extends pT{};mT=e([de("advanced-camera-card-status-bar-icon")],mT);let fT=class extends pT{};fT=e([de("advanced-camera-card-status-bar-image")],fT);let gT=class extends pT{};gT=e([de("advanced-camera-card-status-bar-string")],gT);var _T="Sat, 27 Dec 2025 20:43:44 GMT",vT="b7ac853",yT="Sat, 27 Dec 2025 12:42:43 -0800";const bT=bi.object({domain:bi.string(),version:bi.string().optional()}).passthrough(),wT="hass_web_proxy",xT=(e,t)=>`/api/${wT}/v${t?.version??0}/${t?.websocket?"ws":""}?url=${encodeURIComponent(e)}`,MT=(e,t,n="media")=>(e=>e.config.components.includes(wT))(e)&&!!t[n];const kT=async(e,t,n,i)=>{if(!n||!MT(e,n,i?.context??"media"))return t;if(n.dynamic){const a=t.endpoint.split(/#/)[0];await async function(e,t,n){await e.callService(wT,"create_proxied_url",{url_pattern:t,...n&&{url_id:n.urlID,ssl_verification:n.sslVerification??n?.proxyConfig?.ssl_verification,ssl_ciphers:n.sslCiphers??n?.proxyConfig?.ssl_ciphers,open_limit:n.openLimit,ttl:n.ttl,allow_unauthenticated:n.allowUnauthenticated}})}(e,a,{proxyConfig:n,ttl:i?.ttl,openLimit:i?.openLimit??0})}return{endpoint:xT(t.endpoint,{websocket:i?.websocket}),sign:!0}},CT=async(e,t)=>{let n=null;if(t)try{n=await(async(e,t)=>await m_(e,bT,{type:"manifest/get",integration:t}))(t,e)}catch(e){}return{detected:!!n,...n?.version&&{version:n.version}}};class ST{getCustomIcon(e){switch(e?.icon){case"frigate":return'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.876 22.744c.087.692.812 1.163.379 1.271-.433.109-2.327-3.436-2.76-4.952-.433-1.515-.677-3.22-.569-4.194.109-.974 5.71-2.49 5.71-2.895 0-.406-1.813-.028-1.894-.352-.081-.325 1.37-.13 1.759-.65.609-.811 1.38-.676 1.867-1.11.487-.432 1.082-2.083 1.19-2.786.109-.704-1.082-1.516-1.407-2.057-.324-.541.704-.92 3.194-1.948C14.835 2.042 22.735-.231 22.844.04c.108.27-2.598 1.407-4.492 2.11-1.894.704-4.98 2.057-4.98 2.436s.163.677.055 1.543c-.108.866-.121 1.27-.325 1.84-.135.379-.27 1.272 0 2.083.217.65.92 1.137 1.245 1.245.27.018 1.017.043 1.84 0 1.028-.054 2.49.054 2.49.325 0 .27-2.22.108-2.22.487s2.274-.054 2.22.325c-.054.378-1.895.216-2.869.216-.78 0-1.93-.036-2.435-.216l-.108.378c-.18 0-.558.109-.948.109-.487 0-.514.162-1.407.162s-.622-.054-1.434-.108c-.812-.054-3.842 2.273-4.384 3.03-.54.758-.216 2.598-.216 3.437 0 .754-.108 2.436 0 3.302z" fill="#000" style="fill:#fff;fill-opacity:1;stroke:none;stroke-width:.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/></svg>';case"motioneye":return'<svg xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><defs><linearGradient id="d"><stop style="stop-color:#fff;stop-opacity:1" offset="0"/><stop style="stop-color:#585858;stop-opacity:1" offset="1"/></linearGradient><linearGradient id="b"><stop style="stop-color:#fff;stop-opacity:1" offset="0"/><stop style="stop-color:gray;stop-opacity:1" offset="1"/></linearGradient><linearGradient id="a"><stop style="stop-color:#4aa3e0;stop-opacity:1" offset="0"/><stop style="stop-color:#3096db;stop-opacity:1" offset="1"/></linearGradient><linearGradient id="c"><stop style="stop-color:#fff;stop-opacity:1" offset="0"/><stop style="stop-color:#585858;stop-opacity:1" offset="1"/></linearGradient><linearGradient xlink:href="#a" id="i" x1="26.602" y1="43.035" x2="26.602" y2="29.466" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.96429 0 0 .96429 .914 .914)"/><linearGradient xlink:href="#b" id="e" gradientUnits="userSpaceOnUse" x1="26.446" y1="47.518" x2="26.446" y2="3.818"/><linearGradient xlink:href="#c" id="f" gradientUnits="userSpaceOnUse" x1="26.446" y1="47.518" x2="26.446" y2="3.818"/><linearGradient xlink:href="#d" id="g" gradientUnits="userSpaceOnUse" x1="26.446" y1="47.518" x2="26.446" y2="3.818"/><filter style="color-interpolation-filters:sRGB" id="h" x="-.02" y="-.14" width="1.041" height="1.208"><feFlood flood-opacity=".588" flood-color="#000" result="flood"/><feComposite in="flood" in2="SourceGraphic" operator="in" result="composite1"/><feGaussianBlur in="composite1" stdDeviation=".2" result="blur"/><feOffset dy="-.5" result="offset"/><feComposite in="SourceGraphic" in2="offset" result="composite2"/></filter></defs><path d="M8.935 40.515C5.365 36.547 3.2 31.358 3.2 25.6c0-12.371 10.029-22.4 22.4-22.4C37.971 3.2 48 13.229 48 25.6c0 5.737-2.161 10.952-5.708 14.915-1.696-.623-3.388-1.349-5.061-2.288a7.777 7.777 0 0 0 5.6-7.458c0-4.26-3.47-7.754-7.754-7.754-3.634 0-6.69 2.51-7.539 5.87h-3.876a7.784 7.784 0 0 0-7.539-5.87c-4.284 0-7.78 3.494-7.78 7.754 0 3.561 2.456 6.586 5.76 7.485-1.675.912-3.404 1.62-5.168 2.261zM25.6 26.462c.533-1.982 1.102-3.948 3.446-5.17L25.6 16.123l-3.446 5.17c2.053 1.454 3 3.237 3.446 5.169z" style="fill:url(#e);fill-opacity:1;stroke:none;filter:url(#filter4327)" transform="matrix(.49239 0 0 -.49239 -.605 24.564)"/><path d="M16.123 33.354a2.585 2.585 0 1 1 0-5.17 2.585 2.585 0 0 1 0 5.17z" style="fill:url(#f);fill-opacity:1;stroke:none;filter:url(#filter4327)" transform="matrix(.49239 0 0 -.49239 -.605 24.564)"/><path d="M35.077 33.354a2.585 2.585 0 1 1 0-5.17 2.585 2.585 0 0 1 0 5.17z" style="fill:url(#g);fill-opacity:1;stroke:none;filter:url(#filter4327)" transform="matrix(.49239 0 0 -.49239 -.605 24.564)"/><path style="fill:#d9d9d9;fill-opacity:1;stroke:none;filter:url(#h)" d="M25.6 47.2c-4.374 0-8.437-1.4-11.838-3.635 3.677-.394 7.305-1.343 11.423-3.375 4.166 2.123 8.434 3.01 12.28 3.453A21.465 21.465 0 0 1 25.6 47.2Z" transform="matrix(.51063 0 0 -.51063 -1.072 25.031)"/><path style="fill:url(#i);fill-opacity:1;stroke:none;filter:url(#filter4315)" d="M39.723 42.553c-4.329-.029-10.243-2.156-14.538-4.12-4.516 1.631-9.15 4.216-14.383 4.094a20.537 20.537 0 0 1-1.039-.052l-4.101-.337 3.894-1.299c5.342-1.74 10.04-2.85 14.175-10.026h3.738c4.12 7.134 9.06 8.325 14.15 10.026l3.842 1.247-3.998.389c-.545.052-1.121.082-1.74.078z" transform="matrix(.51063 0 0 -.51063 -1.072 25.031)"/></svg>';case"reolink":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path style="fill:#fff;stroke-width:.0393282;fill-opacity:1" d="M17.037 23.965a1.724 1.724 0 0 1-.711-.285c-.13-.086-1.782-1.727-4.108-4.078-2.14-2.164-3.998-4.02-4.128-4.123a3.023 3.023 0 0 0-1.591-.677c-.185-.021-1.42-.039-2.745-.039H1.345l.007-7.394V-.025h6.204c3.98 0 6.36.015 6.637.041a7.269 7.269 0 0 1 5.579 3.501c.686 1.131 1.02 2.278 1.067 3.655.063 1.885-.574 3.66-1.831 5.1a7.592 7.592 0 0 1-2.93 2.025l-.319.118-1.951-1.98-1.951-1.979 1.046-.023c.576-.013 1.1-.037 1.165-.053.596-.151.95-.314 1.322-.611a3.05 3.05 0 0 0 1.138-2.067c.168-1.506-.771-2.87-2.263-3.29l-.315-.089-4.152-.012-4.159-.013V10.437h1.419c1.627.001 1.779.02 2.31.28.31.152.39.22 1.082.915 3.027 3.043 12.194 12.309 12.205 12.337.016.044-5.365.04-5.618-.004z"/></svg>';case"tplink":return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M155.984.844c26.145-.723 49.96 7.646 69.387 25.312 18.885 18.09 27.164 43.113 27.879 68.781-.322 27.379-10.768 51.065-29.625 70.75-19.395 18.801-43.883 25.77-70.375 25.438L139 191v-54l23-1c12.007-1.863 20.944-5.548 28.5-15.375 6.847-10.193 8.793-21.53 7.074-33.621-2.071-9.773-6.297-17.937-14.387-24.004-10.393-6.498-22.397-7.925-34.343-5.309-11.197 3.759-19.53 10.246-25.13 20.711-2.785 6.001-3.81 11.368-4.03 17.993l-.116 3.284-.13 4.133L119 117H65c-.602-33.1 2.548-61.717 26-87C108.41 12.165 131.231 2.14 155.984.844Z" fill="#48C8D3"/><path d="M0 135h121v121c-50 0-50 0-55-4-2.145-3.149-2.244-5.74-2.227-9.503v-3.336l.032-3.583.008-3.682c.011-3.882.037-7.764.062-11.646.01-2.632.02-5.263.027-7.895.022-6.451.056-12.903.098-19.355l-1.927.02c-6.635.067-13.27.112-19.905.145-2.475.015-4.949.035-7.423.061-3.562.037-7.124.054-10.686.067-1.102.015-2.203.03-3.338.047-6.03.001-10.432-.347-15.721-3.34-13.497-14.207-5-36.984-5-55Z" fill="#49C8D3"/></svg>';case"iris":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g style="fill-opacity:.05;fill:#fff;stroke-width:1.0015748;stroke-dasharray:none"><path d="m13.73 15-3.9 6.76a9.984 9.984 0 0 0 8.49-2.01l-3.66-6.35M2.46 15c.92 2.92 3.15 5.26 5.99 6.34L12.12 15m-3.58-3-3.9-6.75A9.855 9.855 0 0 0 2 12c0 .68.07 1.35.2 2h7.49m12.11-4h-7.49l.29.5 4.76 8.25A9.93 9.93 0 0 0 22 12c0-.69-.07-1.36-.2-2m-.26-1c-.92-2.93-3.15-5.26-5.99-6.34L11.88 9M9.4 10.5l4.77-8.26C13.47 2.09 12.75 2 12 2c-2.4 0-4.6.84-6.32 2.25l3.66 6.35z" style="fill-opacity:1;fill:#fff;opacity:1;stroke-width:1.0015748;stroke-dasharray:none"/></g></svg>';default:return null}}createStateObjectForStateBadge(e,t){return e.states[t]?{...e.states[t],attributes:{...e.states[t].attributes,entity_picture:void 0,entity_picture_local:void 0}}:null}}let ET=class extends le{constructor(){super(...arguments),this.allowOverrideNonActiveStyles=!1,this._controller=new ST,this._svg=null}willUpdate(e){if(e.has("icon")){const e=this._controller.getCustomIcon(this.icon);if(e){const t=document.createElement("svg");t.innerHTML=e,this._svg=t}else this._svg=null}}render(){if(this._svg)return q`${this._svg}`;if(this.hass&&this.icon?.entity){const e=this._controller.createStateObjectForStateBadge(this.hass,this.icon.entity);if(e)return q`<state-badge
.color="${this.style.color??void 0}"
.stateColor=${this.icon.stateColor??!0}
.hass=${this.hass}
.stateObj=${e}
.overrideIcon=${this.icon.icon}
></state-badge>`}return this.icon?.icon?q`<ha-icon icon="${this.icon.icon}"></ha-icon>`: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\nha-icon,\nstate-badge,\nsvg {\n display: block;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n}\n\nsvg path {\n fill: currentColor !important;\n}\n\n:host([allow-override-non-active-styles]) state-badge {\n --state-inactive-color: inherit;\n}")}};e([me({attribute:!1})],ET.prototype,"hass",void 0),e([me({attribute:!1})],ET.prototype,"icon",void 0),e([me({attribute:"allow-override-non-active-styles",type:Boolean})],ET.prototype,"allowOverrideNonActiveStyles",void 0),ET=e([de("advanced-camera-card-icon")],ET);const AT={"01-01":"fireworks","02-14":"hearts","03-17":"shamrocks","10-31":"ghost","12-25":"snow"};let TT=class extends le{constructor(){super(...arguments),this.loaded=!1,this._effectName=null}disconnectedCallback(){super.disconnectedCallback(),this._stopEffect()}updated(){const e=(()=>{const e=new Date,t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return AT[`${t}-${n}`]??null})();e?this.loaded?this._stopEffect():this._startEffect(e):this._stopEffect()}_startEffect(e){this.effectsControllerAPI?.startEffect(e,{fadeIn:!1}),this._effectName=e}_stopEffect(){this._effectName&&this.effectsControllerAPI?.stopEffect(this._effectName),this._effectName=null}render(){return q`<advanced-camera-card-icon
.icon=${{icon:"iris"}}
></advanced-camera-card-icon
><span>${"7.26.0"}</span>`}static get styles(){return s(":host {\n width: intrinsic;\n height: intrinsic;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n background-color: var(--advanced-camera-card-loading-background-color);\n color: var(--advanced-camera-card-loading-foreground-color);\n transition: opacity 1.5s ease-in;\n opacity: 1;\n}\n\n:host([loaded]) {\n opacity: 0;\n}\n\nadvanced-camera-card-icon {\n margin-bottom: 20px;\n height: 25%;\n width: auto;\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}\nspan {\n font-size: x-large;\n}")}};e([me({attribute:!1})],TT.prototype,"effectsControllerAPI",void 0),e([me({type:Boolean,reflect:!0})],TT.prototype,"loaded",void 0),TT=e([de("advanced-camera-card-loading")],TT);const $T=(e,t)=>{sA(e,"action:execution-request",t)};class IT{constructor(e){this._config=null,this._buttons=[],this._expanded=!1,this._host=e}setMenuConfig(e){this._config=e,this._host.style.setProperty("--advanced-camera-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(){return this._expanded}setButtons(e){this._buttons=e,this._sortButtons(),this._host.requestUpdate()}getButtons(e){const t=e=>!this._isHidingMenu()||this._expanded||!!e.permanent;return this._buttons.filter((n=>(e=>!1!==e.enabled)(n)&&(t=>t.alignment===e||"matching"===e&&!t.alignment)(n)&&t(n)))}setExpanded(e){this._expanded=e,Md(this._host,e,"expanded"),this._host.requestUpdate()}toggleExpanded(){this.setExpanded(!this._expanded)}handleAction(e,t){e.stopPropagation();const n=t??e.detail.item??null;if(!n)return;const i=e.detail.action,a=Bd(i,n);if(!a)return;const r=dd(a);let s=!1;const o=r.filter((e=>Cd(e)&&!this._isMenuToggleAction(e)));if(o.length!=r.length&&(s=!0),o.length&&$T(this._host,{actions:r,config:n}),this._isHidingMenu())if(s)this.setExpanded(!this._expanded);else{const e=Bd("hold",n),t=Bd("double_tap",n),a=Bd("tap",n),r=Bd("end_tap",n);"end_tap"!==i&&("start_tap"!==i||e||t||a||r)&&("end_tap"===i||r)||this.setExpanded(!1)}}_sortButtons(){this._buttons=Qu(this._buttons,(e=>(e.priority??0)+(this._isHidingMenu()&&e.permanent?100:0)),["desc"])}_isHidingMenu(){return"hidden"===this._config?.style}_isMenuToggleAction(e){return"fire-dom-event"===e.action&&"menu_toggle"===e.advanced_camera_card_action}}const OT=(e,t,n)=>{const i=e.states[t],a=n?.state?n.state:i?i.state:null;if(!a)return null;const r=gy(t),s=i?i.attributes:null;return n?.entity?.translation_key&&e.localize(`component.${n.entity.platform}.entity.${r}.${n.entity.translation_key}.state.${a}`)||s?.device_class&&e.localize(`component.${r}.state.${s.device_class}.${a}`)||e.localize(`component.${r}.state._.${a}`)||a};function LT(e,t,n,i){return!!tA(e,t,n,{...i,firstOnly:!0}).length}var DT="ha-icon-button {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\n border-radius: var(--advanced-camera-card-button-border-radius);\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n}\n\nha-icon-button {\n --state-inactive-color: var(--advanced-camera-card-button-color);\n color: var(--advanced-camera-card-menu-button-inactive-color);\n background-color: var(--advanced-camera-card-menu-button-background);\n}";let jT=class extends le{_renderItem(e){if(!this.hass)return;const t=e.title??GA(this.hass,e.entity),n=He(e.style||{});return q`
<mwc-list-item
graphic=${be(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.item=e}}
.actionHandler=${Kd({allowPropagation:!0,hasHold:Vd(e.hold_action),hasDoubleClick:Vd(e.double_tap_action)})}
>
<span style="${n}">${t??""}</span>
${e.subtitle?q`<span slot="secondary" style="${n}">${e.subtitle}</span>`:""}
<advanced-camera-card-icon
slot="graphic"
.hass=${this.hass}
.icon=${{icon:e.icon,entity:e.entity}}
style="${n}"
></advanced-camera-card-icon>
</mwc-list-item>
`}render(){return q`
<ha-button-menu
fixed
corner=${"BOTTOM_LEFT"}
@closed=${e=>e.stopPropagation()}
@click=${e=>Ud(e)}
>
<slot slot="trigger"></slot>
${this.items?.map(this._renderItem.bind(this))}
</ha-button-menu>
`}static get styles(){return s('ha-icon-button {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\n border-radius: var(--advanced-camera-card-button-border-radius);\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n}\n\nha-icon-button {\n --state-inactive-color: var(--advanced-camera-card-button-color);\n color: var(--advanced-camera-card-menu-button-inactive-color);\n background-color: var(--advanced-camera-card-menu-button-background);\n}\n\n/************\n * Managing z-indicies and stacking contexts is very challenging on the card,\n * due to the volume of different potentially overlapping surfaces. In\n * particular, care must be taken to not generate new stacking contexts\n * inadvertently which would make "z-index" weaving challenging (e.g. submenu\n * shown for PTZ presets, needs to render "over" the media drawer open/close\n * control).\n *************/\n:host {\n pointer-events: auto;\n --mdc-menu-z-index: 5;\n}')}};e([me({attribute:!1})],jT.prototype,"hass",void 0),e([me({attribute:!1})],jT.prototype,"items",void 0),jT=e([de("advanced-camera-card-submenu")],jT);let zT=class extends le{shouldUpdate(e){const t=e.get("hass");return!e.has("hass")||!t||!this.submenuSelect||LT(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=OT(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=gy(e),n=this.hass.states[e],i=n?.attributes?.options;if(!n||!i)return;const a=[];for(const r of i){const i=this._optionTitles?.[r]??r;a.push({state_color:!0,selected:n.state===r,enabled:!0,title:i||r,...("select"===t||"input_select"===t)&&{tap_action:Fd(t,e,r)},...this.submenuSelect.options&&this.submenuSelect.options[r]})}this._generatedSubmenuItems=a,this._generatedIcon={icon:this.submenuSelect.icon,entity:e,fallback:"mdi:format-list-bulleted",stateColor:this.submenuSelect.state_color}}render(){if(!this._generatedSubmenuItems||!this._generatedIcon||!this.submenuSelect)return q``;const e=GA(this.hass,this.submenuSelect.entity),t=He(this.submenuSelect.style||{});return q` <advanced-camera-card-submenu
.hass=${this.hass}
.items=${this._generatedSubmenuItems}
>
<ha-icon-button style="${t}" .label=${e||""}>
<advanced-camera-card-icon
?allow-override-non-active-styles=${!0}
style="${t}"
title=${e||""}
.hass=${this.hass}
.icon=${this._generatedIcon}
></advanced-camera-card-icon>
</ha-icon-button>
</advanced-camera-card-submenu>`}static get styles(){return s(DT)}};e([me({attribute:!1})],zT.prototype,"hass",void 0),e([me({attribute:!1})],zT.prototype,"submenuSelect",void 0),e([me({attribute:!1})],zT.prototype,"entityRegistryManager",void 0),e([fe()],zT.prototype,"_optionTitles",void 0),zT=e([de("advanced-camera-card-submenu-select-button")],zT);let PT=class extends le{render(){if(!this.submenu)return q``;const e=He(this.submenu.style||{});return q` <advanced-camera-card-submenu
.hass=${this.hass}
.items=${this.submenu?.items}
>
<ha-icon-button style="${e}" .label=${this.submenu.title||""}>
<advanced-camera-card-icon
?allow-override-non-active-styles=${!0}
style="${e}"
title=${this.submenu.title||""}
.hass=${this.hass}
.icon=${{icon:this.submenu.icon}}
.actionHandler=${Kd({allowPropagation:!0,hasHold:Vd(this.submenu.hold_action),hasDoubleClick:Vd(this.submenu.double_tap_action)})}
></advanced-camera-card-icon>
</ha-icon-button>
</advanced-camera-card-submenu>`}static get styles(){return s(DT)}};e([me({attribute:!1})],PT.prototype,"hass",void 0),e([me({attribute:!1})],PT.prototype,"submenu",void 0),PT=e([de("advanced-camera-card-submenu-button")],PT);let RT=class extends le{constructor(){super(...arguments),this._controller=new IT(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:advanced-camera-card-menu-submenu"===e.type)return q` <advanced-camera-card-submenu-button
.hass=${this.hass}
.submenu=${e}
@action=${e=>this._controller.handleAction(e)}
>
</advanced-camera-card-submenu-button>`;if("custom:advanced-camera-card-menu-submenu-select"===e.type)return q` <advanced-camera-card-submenu-select-button
.hass=${this.hass}
.submenuSelect=${e}
.entityRegistryManager=${this.entityRegistryManager}
@action=${e=>this._controller.handleAction(e)}
>
</advanced-camera-card-submenu-select-button>`;const t=this.hass&&"custom:advanced-camera-card-menu-state-icon"===e.type&&!e.title?GA(this.hass,e.entity):e.title;return q` <ha-icon-button
.actionHandler=${Kd({hasHold:Vd(e.hold_action),hasDoubleClick:Vd(e.double_tap_action)})}
.label=${t??""}
@action=${t=>this._controller.handleAction(t,e)}
>
<advanced-camera-card-icon
?allow-override-non-active-styles=${!0}
style="${He(e.style||{})}"
.hass=${this.hass}
.icon=${{icon:e.icon,entity:e.entity,stateColor:e.state_color,fallback:"mdi:gesture-tap-button"}}
></advanced-camera-card-icon>
</ha-icon-button>`}_renderPerInstanceStyle(){const e=this._controller.getMenuConfig();if(!e)return;const t=e.position,n=e.style,i=e.alignment,a=e=>`\n var(--advanced-camera-card-menu-override-${e},\n var(--advanced-camera-card-menu-position-${t}-alignment-${i}-style-${n}-${e},\n var(--advanced-camera-card-menu-position-${t}-alignment-${i}-${e},\n var(--advanced-camera-card-menu-position-${t}-${e},\n var(--advanced-camera-card-menu-style-${n}-${e},\n var(--advanced-camera-card-menu-alignment-${i}-${e},\n var(--advanced-camera-card-menu-${e})))))))`;return q`<style>
:host(${`[data-position='${t}'][data-style='${n}'][data-alignment='${i}']`+("hidden"===n?"[expanded]":"")}) {
background: ${a("background")};
ha-icon-button {
color: ${a("button-inactive-color")};
background: ${a("button-background")};
}
}
</style>`}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` ${this._renderPerInstanceStyle()}
<div
class="matching"
style="${He({flex:String(n.length)})}"
>
${n.map((e=>this._renderButton(e)))}
</div>
<div
class="opposing"
style="${He({flex:String(i.length)})}"
>
${i.map((e=>this._renderButton(e)))}
</div>`}static get styles(){return s('ha-icon-button {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\n border-radius: var(--advanced-camera-card-button-border-radius);\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n}\n\nha-icon-button {\n --state-inactive-color: var(--advanced-camera-card-button-color);\n color: var(--advanced-camera-card-menu-button-inactive-color);\n background-color: var(--advanced-camera-card-menu-button-background);\n}\n\n:host {\n --advanced-camera-card-menu-button-size: 40px;\n --mdc-icon-button-size: var(--advanced-camera-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}\n\n:host([data-style=outside]) {\n width: 100%;\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 * 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=left]),\n:host([data-style=overlay][data-position=right]),\n:host([data-style*=hover][data-position=left]),\n:host([data-style*=hover][data-position=right]),\n:host([data-style=hidden][data-position=left]),\n:host([data-style=hidden][data-position=right]) {\n width: auto;\n height: 100%;\n}\n\n/************\n * Menu theme\n ************/\n:host([data-style=hidden]:not([expanded])) ha-icon-button {\n background: var(--advanced-camera-card-menu-background);\n}')}};
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
function NT(e){return null==e}e([me({attribute:!1})],RT.prototype,"entityRegistryManager",void 0),e([me({attribute:!1})],RT.prototype,"hass",void 0),RT=e([de("advanced-camera-card-menu")],RT);var FT=function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},BT={isNothing:NT,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:NT(e)?[]:[e]},repeat:FT,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 VT(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 HT(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=VT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}HT.prototype=Object.create(Error.prototype),HT.prototype.constructor=HT,HT.prototype.toString=function(e){return this.name+": "+VT(this,e)};var UT=HT;function qT(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 WT(e,t){return BT.repeat(" ",t-e.length)+e}var ZT=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="",u=Math.min(e.line+t.linesAfter,r.length).toString().length,d=t.maxLength-(t.indent+u+3);for(o=1;o<=t.linesBefore&&!(s-o<0);o++)c=qT(e.buffer,a[s-o],r[s-o],e.position-(a[s]-a[s-o]),d),l=BT.repeat(" ",t.indent)+WT((e.line-o+1).toString(),u)+" | "+c.str+"\n"+l;for(c=qT(e.buffer,a[s],r[s],e.position,d),l+=BT.repeat(" ",t.indent)+WT((e.line+1).toString(),u)+" | "+c.str+"\n",l+=BT.repeat("-",t.indent+u+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(s+o>=r.length);o++)c=qT(e.buffer,a[s+o],r[s+o],e.position-(a[s]-a[s+o]),d),l+=BT.repeat(" ",t.indent)+WT((e.line+o+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},KT=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],QT=["scalar","sequence","mapping"];var YT=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===KT.indexOf(t))throw new UT('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===QT.indexOf(this.kind))throw new UT('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function GT(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 XT(e){return this.extend(e)}XT.prototype.extend=function(e){var t=[],n=[];if(e instanceof YT)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 UT("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 YT))throw new UT("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new UT("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new UT("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),n.forEach((function(e){if(!(e instanceof YT))throw new UT("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var i=Object.create(XT.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=GT(i,"implicit"),i.compiledExplicit=GT(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(i);return n}(i.compiledImplicit,i.compiledExplicit),i};var JT=XT,e$=new YT("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),t$=new YT("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),n$=new YT("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}}),i$=new JT({explicit:[e$,t$,n$]});var a$=new YT("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});var r$=new YT("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function s$(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function o$(e){return 48<=e&&e<=55}function c$(e){return 48<=e&&e<=57}var l$=new YT("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n=e.length,i=0,a=!1;if(!n)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===n)return!0;if("b"===(t=e[++i])){for(i++;i<n;i++)if("_"!==(t=e[i])){if("0"!==t&&"1"!==t)return!1;a=!0}return a&&"_"!==t}if("x"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!s$(e.charCodeAt(i)))return!1;a=!0}return a&&"_"!==t}if("o"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!o$(e.charCodeAt(i)))return!1;a=!0}return a&&"_"!==t}}if("_"===t)return!1;for(;i<n;i++)if("_"!==(t=e[i])){if(!c$(e.charCodeAt(i)))return!1;a=!0}return!(!a||"_"===t)},construct:function(e){var t,n=e,i=1;if(-1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),"-"!==(t=n[0])&&"+"!==t||("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n)return 0;if("0"===t){if("b"===n[1])return i*parseInt(n.slice(2),2);if("x"===n[1])return i*parseInt(n.slice(2),16);if("o"===n[1])return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!BT.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),u$=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var d$=/^[-+]?[0-9]+e/;var h$=new YT("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!u$.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||BT.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(BT.isNegativeZero(e))return"-0.0";return n=e.toString(10),d$.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"}),p$=i$.extend({implicit:[a$,r$,l$,h$]}),m$=p$,f$=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),g$=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var _$=new YT("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==f$.exec(e)||null!==g$.exec(e))},construct:function(e){var t,n,i,a,r,s,o,c,l=0,u=null;if(null===(t=f$.exec(e))&&(t=g$.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,a=+t[3],!t[4])return new Date(Date.UTC(n,i,a));if(r=+t[4],s=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),c=new Date(Date.UTC(n,i,a,r,s,o,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(e){return e.toISOString()}});var v$=new YT("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),y$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var b$=new YT("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,a=e.length,r=y$;for(n=0;n<a;n++)if(!((t=r.indexOf(e.charAt(n)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),a=i.length,r=y$,s=0,o=[];for(t=0;t<a;t++)t%4==0&&t&&(o.push(s>>16&255),o.push(s>>8&255),o.push(255&s)),s=s<<6|r.indexOf(i.charAt(t));return 0===(n=a%4*6)?(o.push(s>>16&255),o.push(s>>8&255),o.push(255&s)):18===n?(o.push(s>>10&255),o.push(s>>2&255)):12===n&&o.push(s>>4&255),new Uint8Array(o)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",a=0,r=e.length,s=y$;for(t=0;t<r;t++)t%3==0&&t&&(i+=s[a>>18&63],i+=s[a>>12&63],i+=s[a>>6&63],i+=s[63&a]),a=(a<<8)+e[t];return 0===(n=r%3)?(i+=s[a>>18&63],i+=s[a>>12&63],i+=s[a>>6&63],i+=s[63&a]):2===n?(i+=s[a>>10&63],i+=s[a>>4&63],i+=s[a<<2&63],i+=s[64]):1===n&&(i+=s[a>>2&63],i+=s[a<<4&63],i+=s[64],i+=s[64]),i}}),w$=Object.prototype.hasOwnProperty,x$=Object.prototype.toString;var M$=new YT("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,a,r,s=[],o=e;for(t=0,n=o.length;t<n;t+=1){if(i=o[t],r=!1,"[object Object]"!==x$.call(i))return!1;for(a in i)if(w$.call(i,a)){if(r)return!1;r=!0}if(!r)return!1;if(-1!==s.indexOf(a))return!1;s.push(a)}return!0},construct:function(e){return null!==e?e:[]}}),k$=Object.prototype.toString;var C$=new YT("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,a,r,s=e;for(r=new Array(s.length),t=0,n=s.length;t<n;t+=1){if(i=s[t],"[object Object]"!==k$.call(i))return!1;if(1!==(a=Object.keys(i)).length)return!1;r[t]=[a[0],i[a[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,i,a,r,s=e;for(r=new Array(s.length),t=0,n=s.length;t<n;t+=1)i=s[t],a=Object.keys(i),r[t]=[a[0],i[a[0]]];return r}}),S$=Object.prototype.hasOwnProperty;var E$=new YT("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,n=e;for(t in n)if(S$.call(n,t)&&null!==n[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),A$=m$.extend({implicit:[_$,v$],explicit:[b$,M$,C$,E$]}),T$=Object.prototype.hasOwnProperty,$$=1,I$=2,O$=3,L$=4,D$=1,j$=2,z$=3,P$=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,R$=/[\x85\u2028\u2029]/,N$=/[,\[\]\{\}]/,F$=/^(?:!|!!|![a-z\-]+!)$/i,B$=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function V$(e){return Object.prototype.toString.call(e)}function H$(e){return 10===e||13===e}function U$(e){return 9===e||32===e}function q$(e){return 9===e||32===e||10===e||13===e}function W$(e){return 44===e||91===e||93===e||123===e||125===e}function Z$(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function K$(e){return 120===e?2:117===e?4:85===e?8:0}function Q$(e){return 48<=e&&e<=57?e-48:-1}function Y$(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"…":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function G$(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var X$=new Array(256),J$=new Array(256),eI=0;eI<256;eI++)X$[eI]=Y$(eI)?1:0,J$[eI]=Y$(eI);function tI(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||A$,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function nI(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=ZT(n),new UT(t,n)}function iI(e,t){throw nI(e,t)}function aI(e,t){e.onWarning&&e.onWarning.call(null,nI(e,t))}var rI={YAML:function(e,t,n){var i,a,r;null!==e.version&&iI(e,"duplication of %YAML directive"),1!==n.length&&iI(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&iI(e,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),r=parseInt(i[2],10),1!==a&&iI(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=r<2,1!==r&&2!==r&&aI(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,a;2!==n.length&&iI(e,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],F$.test(i)||iI(e,"ill-formed tag handle (first argument) of the TAG directive"),T$.call(e.tagMap,i)&&iI(e,'there is a previously declared suffix for "'+i+'" tag handle'),B$.test(a)||iI(e,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch(t){iI(e,"tag prefix is malformed: "+a)}e.tagMap[i]=a}};function sI(e,t,n,i){var a,r,s,o;if(t<n){if(o=e.input.slice(t,n),i)for(a=0,r=o.length;a<r;a+=1)9===(s=o.charCodeAt(a))||32<=s&&s<=1114111||iI(e,"expected valid JSON character");else P$.test(o)&&iI(e,"the stream contains non-printable characters");e.result+=o}}function oI(e,t,n,i){var a,r,s,o;for(BT.isObject(n)||iI(e,"cannot merge mappings; the provided source object is unacceptable"),s=0,o=(a=Object.keys(n)).length;s<o;s+=1)r=a[s],T$.call(t,r)||(t[r]=n[r],i[r]=!0)}function cI(e,t,n,i,a,r,s,o,c){var l,u;if(Array.isArray(a))for(l=0,u=(a=Array.prototype.slice.call(a)).length;l<u;l+=1)Array.isArray(a[l])&&iI(e,"nested arrays are not supported inside keys"),"object"==typeof a&&"[object Object]"===V$(a[l])&&(a[l]="[object Object]");if("object"==typeof a&&"[object Object]"===V$(a)&&(a="[object Object]"),a=String(a),null===t&&(t={}),"tag:yaml.org,2002:merge"===i)if(Array.isArray(r))for(l=0,u=r.length;l<u;l+=1)oI(e,t,r[l],n);else oI(e,t,r,n);else e.json||T$.call(n,a)||!T$.call(t,a)||(e.line=s||e.line,e.lineStart=o||e.lineStart,e.position=c||e.position,iI(e,"duplicated mapping key")),"__proto__"===a?Object.defineProperty(t,a,{configurable:!0,enumerable:!0,writable:!0,value:r}):t[a]=r,delete n[a];return t}function lI(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):iI(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function uI(e,t,n){for(var i=0,a=e.input.charCodeAt(e.position);0!==a;){for(;U$(a);)9===a&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),a=e.input.charCodeAt(++e.position);if(t&&35===a)do{a=e.input.charCodeAt(++e.position)}while(10!==a&&13!==a&&0!==a);if(!H$(a))break;for(lI(e),a=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===a;)e.lineIndent++,a=e.input.charCodeAt(++e.position)}return-1!==n&&0!==i&&e.lineIndent<n&&aI(e,"deficient indentation"),i}function dI(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!q$(t)))}function hI(e,t){1===t?e.result+=" ":t>1&&(e.result+=BT.repeat("\n",t-1))}function pI(e,t){var n,i,a=e.tag,r=e.anchor,s=[],o=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=s),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,iI(e,"tab characters must not be used in indentation")),45===i)&&q$(e.input.charCodeAt(e.position+1));)if(o=!0,e.position++,uI(e,!0,-1)&&e.lineIndent<=t)s.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,gI(e,t,O$,!1,!0),s.push(e.result),uI(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)iI(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!o&&(e.tag=a,e.anchor=r,e.kind="sequence",e.result=s,!0)}function mI(e){var t,n,i,a,r=!1,s=!1;if(33!==(a=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&iI(e,"duplication of a tag property"),60===(a=e.input.charCodeAt(++e.position))?(r=!0,a=e.input.charCodeAt(++e.position)):33===a?(s=!0,n="!!",a=e.input.charCodeAt(++e.position)):n="!",t=e.position,r){do{a=e.input.charCodeAt(++e.position)}while(0!==a&&62!==a);e.position<e.length?(i=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):iI(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==a&&!q$(a);)33===a&&(s?iI(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),F$.test(n)||iI(e,"named tag handle cannot contain such characters"),s=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),N$.test(i)&&iI(e,"tag suffix cannot contain flow indicator characters")}i&&!B$.test(i)&&iI(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch(t){iI(e,"tag name is malformed: "+i)}return r?e.tag=i:T$.call(e.tagMap,n)?e.tag=e.tagMap[n]+i:"!"===n?e.tag="!"+i:"!!"===n?e.tag="tag:yaml.org,2002:"+i:iI(e,'undeclared tag handle "'+n+'"'),!0}function fI(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&iI(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!q$(n)&&!W$(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&iI(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function gI(e,t,n,i,a){var r,s,o,c,l,u,d,h,p,m=1,f=!1,g=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,r=s=o=L$===n||O$===n,i&&uI(e,!0,-1)&&(f=!0,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)),1===m)for(;mI(e)||fI(e);)uI(e,!0,-1)?(f=!0,o=r,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)):o=!1;if(o&&(o=f||a),1!==m&&L$!==n||(h=$$===n||I$===n?t:t+1,p=e.position-e.lineStart,1===m?o&&(pI(e,p)||function(e,t,n){var i,a,r,s,o,c,l,u=e.tag,d=e.anchor,h={},p=Object.create(null),m=null,f=null,g=null,_=!1,v=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=h),l=e.input.charCodeAt(e.position);0!==l;){if(_||-1===e.firstTabInLine||(e.position=e.firstTabInLine,iI(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),r=e.line,63!==l&&58!==l||!q$(i)){if(s=e.line,o=e.lineStart,c=e.position,!gI(e,n,I$,!1,!0))break;if(e.line===r){for(l=e.input.charCodeAt(e.position);U$(l);)l=e.input.charCodeAt(++e.position);if(58===l)q$(l=e.input.charCodeAt(++e.position))||iI(e,"a whitespace character is expected after the key-value separator within a block mapping"),_&&(cI(e,h,p,m,f,null,s,o,c),m=f=g=null),v=!0,_=!1,a=!1,m=e.tag,f=e.result;else{if(!v)return e.tag=u,e.anchor=d,!0;iI(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!v)return e.tag=u,e.anchor=d,!0;iI(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===l?(_&&(cI(e,h,p,m,f,null,s,o,c),m=f=g=null),v=!0,_=!0,a=!0):_?(_=!1,a=!0):iI(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,l=i;if((e.line===r||e.lineIndent>t)&&(_&&(s=e.line,o=e.lineStart,c=e.position),gI(e,t,L$,!0,a)&&(_?f=e.result:g=e.result),_||(cI(e,h,p,m,f,g,s,o,c),m=f=g=null),uI(e,!0,-1),l=e.input.charCodeAt(e.position)),(e.line===r||e.lineIndent>t)&&0!==l)iI(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return _&&cI(e,h,p,m,f,null,s,o,c),v&&(e.tag=u,e.anchor=d,e.kind="mapping",e.result=h),v}(e,p,h))||function(e,t){var n,i,a,r,s,o,c,l,u,d,h,p,m=!0,f=e.tag,g=e.anchor,_=Object.create(null);if(91===(p=e.input.charCodeAt(e.position)))s=93,l=!1,r=[];else{if(123!==p)return!1;s=125,l=!0,r={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=r),p=e.input.charCodeAt(++e.position);0!==p;){if(uI(e,!0,t),(p=e.input.charCodeAt(e.position))===s)return e.position++,e.tag=f,e.anchor=g,e.kind=l?"mapping":"sequence",e.result=r,!0;m?44===p&&iI(e,"expected the node content, but found ','"):iI(e,"missed comma between flow collection entries"),h=null,o=c=!1,63===p&&q$(e.input.charCodeAt(e.position+1))&&(o=c=!0,e.position++,uI(e,!0,t)),n=e.line,i=e.lineStart,a=e.position,gI(e,t,$$,!1,!0),d=e.tag,u=e.result,uI(e,!0,t),p=e.input.charCodeAt(e.position),!c&&e.line!==n||58!==p||(o=!0,p=e.input.charCodeAt(++e.position),uI(e,!0,t),gI(e,t,$$,!1,!0),h=e.result),l?cI(e,r,_,d,u,h,n,i,a):o?r.push(cI(e,null,_,d,u,h,n,i,a)):r.push(u),uI(e,!0,t),44===(p=e.input.charCodeAt(e.position))?(m=!0,p=e.input.charCodeAt(++e.position)):m=!1}iI(e,"unexpected end of the stream within a flow collection")}(e,h)?g=!0:(s&&function(e,t){var n,i,a,r,s=D$,o=!1,c=!1,l=t,u=0,d=!1;if(124===(r=e.input.charCodeAt(e.position)))i=!1;else{if(62!==r)return!1;i=!0}for(e.kind="scalar",e.result="";0!==r;)if(43===(r=e.input.charCodeAt(++e.position))||45===r)D$===s?s=43===r?z$:j$:iI(e,"repeat of a chomping mode identifier");else{if(!((a=Q$(r))>=0))break;0===a?iI(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?iI(e,"repeat of an indentation width identifier"):(l=t+a-1,c=!0)}if(U$(r)){do{r=e.input.charCodeAt(++e.position)}while(U$(r));if(35===r)do{r=e.input.charCodeAt(++e.position)}while(!H$(r)&&0!==r)}for(;0!==r;){for(lI(e),e.lineIndent=0,r=e.input.charCodeAt(e.position);(!c||e.lineIndent<l)&&32===r;)e.lineIndent++,r=e.input.charCodeAt(++e.position);if(!c&&e.lineIndent>l&&(l=e.lineIndent),H$(r))u++;else{if(e.lineIndent<l){s===z$?e.result+=BT.repeat("\n",o?1+u:u):s===D$&&o&&(e.result+="\n");break}for(i?U$(r)?(d=!0,e.result+=BT.repeat("\n",o?1+u:u)):d?(d=!1,e.result+=BT.repeat("\n",u+1)):0===u?o&&(e.result+=" "):e.result+=BT.repeat("\n",u):e.result+=BT.repeat("\n",o?1+u:u),o=!0,c=!0,u=0,n=e.position;!H$(r)&&0!==r;)r=e.input.charCodeAt(++e.position);sI(e,n,e.position,!1)}}return!0}(e,h)||function(e,t){var n,i,a;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=a=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(sI(e,i,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;i=e.position,e.position++,a=e.position}else H$(n)?(sI(e,i,a,!0),hI(e,uI(e,!1,t)),i=a=e.position):e.position===e.lineStart&&dI(e)?iI(e,"unexpected end of the document within a single quoted scalar"):(e.position++,a=e.position);iI(e,"unexpected end of the stream within a single quoted scalar")}(e,h)||function(e,t){var n,i,a,r,s,o;if(34!==(o=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(o=e.input.charCodeAt(e.position));){if(34===o)return sI(e,n,e.position,!0),e.position++,!0;if(92===o){if(sI(e,n,e.position,!0),H$(o=e.input.charCodeAt(++e.position)))uI(e,!1,t);else if(o<256&&X$[o])e.result+=J$[o],e.position++;else if((s=K$(o))>0){for(a=s,r=0;a>0;a--)(s=Z$(o=e.input.charCodeAt(++e.position)))>=0?r=(r<<4)+s:iI(e,"expected hexadecimal character");e.result+=G$(r),e.position++}else iI(e,"unknown escape sequence");n=i=e.position}else H$(o)?(sI(e,n,i,!0),hI(e,uI(e,!1,t)),n=i=e.position):e.position===e.lineStart&&dI(e)?iI(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}iI(e,"unexpected end of the stream within a double quoted scalar")}(e,h)?g=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!q$(i)&&!W$(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&iI(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),T$.call(e.anchorMap,n)||iI(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],uI(e,!0,-1),!0}(e)?function(e,t,n){var i,a,r,s,o,c,l,u,d=e.kind,h=e.result;if(q$(u=e.input.charCodeAt(e.position))||W$(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(q$(i=e.input.charCodeAt(e.position+1))||n&&W$(i)))return!1;for(e.kind="scalar",e.result="",a=r=e.position,s=!1;0!==u;){if(58===u){if(q$(i=e.input.charCodeAt(e.position+1))||n&&W$(i))break}else if(35===u){if(q$(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&dI(e)||n&&W$(u))break;if(H$(u)){if(o=e.line,c=e.lineStart,l=e.lineIndent,uI(e,!1,-1),e.lineIndent>=t){s=!0,u=e.input.charCodeAt(e.position);continue}e.position=r,e.line=o,e.lineStart=c,e.lineIndent=l;break}}s&&(sI(e,a,r,!1),hI(e,e.line-o),a=r=e.position,s=!1),U$(u)||(r=e.position+1),u=e.input.charCodeAt(++e.position)}return sI(e,a,r,!1),!!e.result||(e.kind=d,e.result=h,!1)}(e,h,$$===n)&&(g=!0,null===e.tag&&(e.tag="?")):(g=!0,null===e.tag&&null===e.anchor||iI(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===m&&(g=o&&pI(e,p))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&iI(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c<l;c+=1)if((d=e.implicitTypes[c]).resolve(e.result)){e.result=d.construct(e.result),e.tag=d.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(T$.call(e.typeMap[e.kind||"fallback"],e.tag))d=e.typeMap[e.kind||"fallback"][e.tag];else for(d=null,c=0,l=(u=e.typeMap.multi[e.kind||"fallback"]).length;c<l;c+=1)if(e.tag.slice(0,u[c].tag.length)===u[c].tag){d=u[c];break}d||iI(e,"unknown tag !<"+e.tag+">"),null!==e.result&&d.kind!==e.kind&&iI(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+d.kind+'", not "'+e.kind+'"'),d.resolve(e.result,e.tag)?(e.result=d.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):iI(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function _I(e){var t,n,i,a,r=e.position,s=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(a=e.input.charCodeAt(e.position))&&(uI(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==a));){for(s=!0,a=e.input.charCodeAt(++e.position),t=e.position;0!==a&&!q$(a);)a=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&iI(e,"directive name must not be less than one character in length");0!==a;){for(;U$(a);)a=e.input.charCodeAt(++e.position);if(35===a){do{a=e.input.charCodeAt(++e.position)}while(0!==a&&!H$(a));break}if(H$(a))break;for(t=e.position;0!==a&&!q$(a);)a=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==a&&lI(e),T$.call(rI,n)?rI[n](e,n,i):aI(e,'unknown document directive "'+n+'"')}uI(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,uI(e,!0,-1)):s&&iI(e,"directives end mark is expected"),gI(e,e.lineIndent-1,L$,!1,!0),uI(e,!0,-1),e.checkLineBreaks&&R$.test(e.input.slice(r,e.position))&&aI(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&dI(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,uI(e,!0,-1)):e.position<e.length-1&&iI(e,"end of the stream or a document separator is expected")}function vI(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new tI(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,iI(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)_I(n);return n.documents}var yI={loadAll:function(e,t,n){null!==t&&"object"==typeof t&&void 0===n&&(n=t,t=null);var i=vI(e,n);if("function"!=typeof t)return i;for(var a=0,r=i.length;a<r;a+=1)t(i[a])},load:function(e,t){var n=vI(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new UT("expected a single document in the stream, but found more")}}},bI=Object.prototype.toString,wI=Object.prototype.hasOwnProperty,xI=65279,MI=9,kI=10,CI=13,SI=32,EI=33,AI=34,TI=35,$I=37,II=38,OI=39,LI=42,DI=44,jI=45,zI=58,PI=61,RI=62,NI=63,FI=64,BI=91,VI=93,HI=96,UI=123,qI=124,WI=125,ZI={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},KI=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],QI=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function YI(e){var t,n,i;if(t=e.toString(16).toUpperCase(),e<=255)n="x",i=2;else if(e<=65535)n="u",i=4;else{if(!(e<=4294967295))throw new UT("code point within a string may not be greater than 0xFFFFFFFF");n="U",i=8}return"\\"+n+BT.repeat("0",i-t.length)+t}var GI=1,XI=2;function JI(e){this.schema=e.schema||A$,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=BT.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){var n,i,a,r,s,o,c;if(null===t)return{};for(n={},a=0,r=(i=Object.keys(t)).length;a<r;a+=1)s=i[a],o=String(t[s]),"!!"===s.slice(0,2)&&(s="tag:yaml.org,2002:"+s.slice(2)),(c=e.compiledTypeMap.fallback[s])&&wI.call(c.styleAliases,o)&&(o=c.styleAliases[o]),n[s]=o;return n}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType='"'===e.quotingType?XI:GI,this.forceQuotes=e.forceQuotes||!1,this.replacer="function"==typeof e.replacer?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function eO(e,t){for(var n,i=BT.repeat(" ",t),a=0,r=-1,s="",o=e.length;a<o;)-1===(r=e.indexOf("\n",a))?(n=e.slice(a),a=o):(n=e.slice(a,r+1),a=r+1),n.length&&"\n"!==n&&(s+=i),s+=n;return s}function tO(e,t){return"\n"+BT.repeat(" ",e.indent*t)}function nO(e){return e===SI||e===MI}function iO(e){return 32<=e&&e<=126||161<=e&&e<=55295&&8232!==e&&8233!==e||57344<=e&&e<=65533&&e!==xI||65536<=e&&e<=1114111}function aO(e){return iO(e)&&e!==xI&&e!==CI&&e!==kI}function rO(e,t,n){var i=aO(e),a=i&&!nO(e);return(n?i:i&&e!==DI&&e!==BI&&e!==VI&&e!==UI&&e!==WI)&&e!==TI&&!(t===zI&&!a)||aO(t)&&!nO(t)&&e===TI||t===zI&&a}function sO(e,t){var n,i=e.charCodeAt(t);return i>=55296&&i<=56319&&t+1<e.length&&(n=e.charCodeAt(t+1))>=56320&&n<=57343?1024*(i-55296)+n-56320+65536:i}function oO(e){return/^\n* /.test(e)}var cO=1,lO=2,uO=3,dO=4,hO=5;function pO(e,t,n,i,a,r,s,o){var c,l=0,u=null,d=!1,h=!1,p=-1!==i,m=-1,f=function(e){return iO(e)&&e!==xI&&!nO(e)&&e!==jI&&e!==NI&&e!==zI&&e!==DI&&e!==BI&&e!==VI&&e!==UI&&e!==WI&&e!==TI&&e!==II&&e!==LI&&e!==EI&&e!==qI&&e!==PI&&e!==RI&&e!==OI&&e!==AI&&e!==$I&&e!==FI&&e!==HI}(sO(e,0))&&function(e){return!nO(e)&&e!==zI}(sO(e,e.length-1));if(t||s)for(c=0;c<e.length;l>=65536?c+=2:c++){if(!iO(l=sO(e,c)))return hO;f=f&&rO(l,u,o),u=l}else{for(c=0;c<e.length;l>=65536?c+=2:c++){if((l=sO(e,c))===kI)d=!0,p&&(h=h||c-m-1>i&&" "!==e[m+1],m=c);else if(!iO(l))return hO;f=f&&rO(l,u,o),u=l}h=h||p&&c-m-1>i&&" "!==e[m+1]}return d||h?n>9&&oO(e)?hO:s?r===XI?hO:lO:h?dO:uO:!f||s||a(e)?r===XI?hO:lO:cO}function mO(e,t,n,i,a){e.dump=function(){if(0===t.length)return e.quotingType===XI?'""':"''";if(!e.noCompatMode&&(-1!==KI.indexOf(t)||QI.test(t)))return e.quotingType===XI?'"'+t+'"':"'"+t+"'";var r=e.indent*Math.max(1,n),s=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-r),o=i||e.flowLevel>-1&&n>=e.flowLevel;switch(pO(t,o,e.indent,s,(function(t){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n<i;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}(e,t)}),e.quotingType,e.forceQuotes&&!i,a)){case cO:return t;case lO:return"'"+t.replace(/'/g,"''")+"'";case uO:return"|"+fO(t,e.indent)+gO(eO(t,r));case dO:return">"+fO(t,e.indent)+gO(eO(function(e,t){var n,i,a=/(\n+)([^\n]*)/g,r=(o=e.indexOf("\n"),o=-1!==o?o:e.length,a.lastIndex=o,_O(e.slice(0,o),t)),s="\n"===e[0]||" "===e[0];var o;for(;i=a.exec(e);){var c=i[1],l=i[2];n=" "===l[0],r+=c+(s||n||""===l?"":"\n")+_O(l,t),s=n}return r}(t,s),r));case hO:return'"'+function(e){for(var t,n="",i=0,a=0;a<e.length;i>=65536?a+=2:a++)i=sO(e,a),!(t=ZI[i])&&iO(i)?(n+=e[a],i>=65536&&(n+=e[a+1])):n+=t||YI(i);return n}(t)+'"';default:throw new UT("impossible error: invalid scalar style")}}()}function fO(e,t){var n=oO(e)?String(t):"",i="\n"===e[e.length-1];return n+(i&&("\n"===e[e.length-2]||"\n"===e)?"+":i?"":"-")+"\n"}function gO(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function _O(e,t){if(""===e||" "===e[0])return e;for(var n,i,a=/ [^ ]/g,r=0,s=0,o=0,c="";n=a.exec(e);)(o=n.index)-r>t&&(i=s>r?s:o,c+="\n"+e.slice(r,i),r=i+1),s=o;return c+="\n",e.length-r>t&&s>r?c+=e.slice(r,s)+"\n"+e.slice(s+1):c+=e.slice(r),c.slice(1)}function vO(e,t,n,i){var a,r,s,o="",c=e.tag;for(a=0,r=n.length;a<r;a+=1)s=n[a],e.replacer&&(s=e.replacer.call(n,String(a),s)),(bO(e,t+1,s,!0,!0,!1,!0)||void 0===s&&bO(e,t+1,null,!0,!0,!1,!0))&&(i&&""===o||(o+=tO(e,t)),e.dump&&kI===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=c,e.dump=o||"[]"}function yO(e,t,n){var i,a,r,s,o,c;for(r=0,s=(a=n?e.explicitTypes:e.implicitTypes).length;r<s;r+=1)if(((o=a[r]).instanceOf||o.predicate)&&(!o.instanceOf||"object"==typeof t&&t instanceof o.instanceOf)&&(!o.predicate||o.predicate(t))){if(n?o.multi&&o.representName?e.tag=o.representName(t):e.tag=o.tag:e.tag="?",o.represent){if(c=e.styleMap[o.tag]||o.defaultStyle,"[object Function]"===bI.call(o.represent))i=o.represent(t,c);else{if(!wI.call(o.represent,c))throw new UT("!<"+o.tag+'> tag resolver accepts not "'+c+'" style');i=o.represent[c](t,c)}e.dump=i}return!0}return!1}function bO(e,t,n,i,a,r,s){e.tag=null,e.dump=n,yO(e,n,!1)||yO(e,n,!0);var o,c=bI.call(e.dump),l=i;i&&(i=e.flowLevel<0||e.flowLevel>t);var u,d,h="[object Object]"===c||"[object Array]"===c;if(h&&(d=-1!==(u=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||d||2!==e.indent&&t>0)&&(a=!1),d&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(h&&d&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),"[object Object]"===c)i&&0!==Object.keys(e.dump).length?(!function(e,t,n,i){var a,r,s,o,c,l,u="",d=e.tag,h=Object.keys(n);if(!0===e.sortKeys)h.sort();else if("function"==typeof e.sortKeys)h.sort(e.sortKeys);else if(e.sortKeys)throw new UT("sortKeys must be a boolean or a function");for(a=0,r=h.length;a<r;a+=1)l="",i&&""===u||(l+=tO(e,t)),o=n[s=h[a]],e.replacer&&(o=e.replacer.call(n,s,o)),bO(e,t+1,s,!0,!0,!0)&&((c=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024)&&(e.dump&&kI===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=tO(e,t)),bO(e,t+1,o,!0,c)&&(e.dump&&kI===e.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=e.dump));e.tag=d,e.dump=u||"{}"}(e,t,e.dump,a),d&&(e.dump="&ref_"+u+e.dump)):(!function(e,t,n){var i,a,r,s,o,c="",l=e.tag,u=Object.keys(n);for(i=0,a=u.length;i<a;i+=1)o="",""!==c&&(o+=", "),e.condenseFlow&&(o+='"'),s=n[r=u[i]],e.replacer&&(s=e.replacer.call(n,r,s)),bO(e,t,r,!1,!1)&&(e.dump.length>1024&&(o+="? "),o+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),bO(e,t,s,!1,!1)&&(c+=o+=e.dump));e.tag=l,e.dump="{"+c+"}"}(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if("[object Array]"===c)i&&0!==e.dump.length?(e.noArrayIndent&&!s&&t>0?vO(e,t-1,e.dump,a):vO(e,t,e.dump,a),d&&(e.dump="&ref_"+u+e.dump)):(!function(e,t,n){var i,a,r,s="",o=e.tag;for(i=0,a=n.length;i<a;i+=1)r=n[i],e.replacer&&(r=e.replacer.call(n,String(i),r)),(bO(e,t,r,!1,!1)||void 0===r&&bO(e,t,null,!1,!1))&&(""!==s&&(s+=","+(e.condenseFlow?"":" ")),s+=e.dump);e.tag=o,e.dump="["+s+"]"}(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else{if("[object String]"!==c){if("[object Undefined]"===c)return!1;if(e.skipInvalid)return!1;throw new UT("unacceptable kind of an object to dump "+c)}"?"!==e.tag&&mO(e,e.dump,t,r,l)}null!==e.tag&&"?"!==e.tag&&(o=encodeURI("!"===e.tag[0]?e.tag.slice(1):e.tag).replace(/!/g,"%21"),o="!"===e.tag[0]?"!"+o:"tag:yaml.org,2002:"===o.slice(0,18)?"!!"+o.slice(18):"!<"+o+">",e.dump=o+" "+e.dump)}return!0}function wO(e,t){var n,i,a=[],r=[];for(xO(e,a,r),n=0,i=r.length;n<i;n+=1)t.duplicates.push(a[r[n]]);t.usedDuplicates=new Array(i)}function xO(e,t,n){var i,a,r;if(null!==e&&"object"==typeof e)if(-1!==(a=t.indexOf(e)))-1===n.indexOf(a)&&n.push(a);else if(t.push(e),Array.isArray(e))for(a=0,r=e.length;a<r;a+=1)xO(e[a],t,n);else for(a=0,r=(i=Object.keys(e)).length;a<r;a+=1)xO(e[i[a]],t,n)}function MO(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var kO={Type:YT,Schema:JT,FAILSAFE_SCHEMA:i$,JSON_SCHEMA:p$,CORE_SCHEMA:m$,DEFAULT_SCHEMA:A$,load:yI.load,loadAll:yI.loadAll,dump:{dump:function(e,t){var n=new JI(t=t||{});n.noRefs||wO(e,n);var i=e;return n.replacer&&(i=n.replacer.call({"":i},"",i)),bO(n,0,i,!0,!0)?n.dump+"\n":""}}.dump,YAMLException:UT,types:{binary:b$,float:h$,map:n$,null:a$,pairs:C$,set:E$,timestamp:_$,bool:r$,int:l$,merge:v$,omap:M$,seq:t$,str:e$},safeLoad:MO("safeLoad","load"),safeLoadAll:MO("safeLoadAll","loadAll"),safeDump:MO("safeDump","dump")};class CO{getMessageString(e){return e.message+(e.context&&"string"==typeof e.context?": "+e.context:"")}getIcon(e){return e.icon?e.icon:"error"===e.type?"mdi:alert-circle":"mdi:information-outline"}getURL(e){return e.url?e.url:"error"===e.type?{link:_h,title:u_("error.troubleshooting")}:null}getContextStrings(e){return Array.isArray(e.context)?e.context.map((e=>kO.dump(e))):"object"==typeof e.context?[kO.dump(e.context)]:"string"==typeof e.context?[e.context]:[]}}var SO='.dotdotdot:after {\n animation: dots 2s linear infinite;\n content: "";\n display: inline-block;\n width: 3em;\n}\n@keyframes dots {\n 0%, 20% {\n content: ".";\n }\n 40% {\n content: "..";\n }\n 60% {\n content: "...";\n }\n 90%, 100% {\n content: "";\n }\n}\n\n:host {\n display: flex;\n flex-direction: column;\n justify-content: center;\n user-select: text;\n -webkit-user-select: text;\n}\n\n:host(:not([overlay])) {\n height: 100%;\n width: 100%;\n background: var(--advanced-camera-card-message-background);\n color: var(--advanced-camera-card-message-color);\n}\n\n:host([overlay]) {\n position: absolute;\n inset: 5%;\n background: var(--advanced-camera-card-message-overlay-background);\n color: var(--advanced-camera-card-message-overlay-color);\n}\n\ndiv.wrapper {\n height: 100%;\n}\n\ndiv.message {\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n height: 100%;\n}\n\ndiv.message.padded {\n padding: 20px;\n}\n\ndiv.message div.contents {\n display: flex;\n flex-direction: column;\n padding: 10px;\n margin-top: auto;\n margin-bottom: auto;\n min-width: 0;\n}\n\ndiv.message div.icon {\n padding: 10px;\n}\n\n.vertical {\n flex-direction: column;\n}\n\na {\n word-break: break-word;\n}\n\n:host(:not([overlay])) a {\n color: var(--advanced-camera-card-message-color);\n}\n\n:host([overlay]) a {\n color: var(--advanced-camera-card-message-overlay-color);\n}\n\n.message pre {\n margin-top: 20px;\n overflow-x: auto;\n border: 1px dotted var(--advanced-camera-card-divider-color);\n padding: 1em;\n}';function EO(e,t){return q` <advanced-camera-card-message
.message=${e}
?overlay=${!!t?.overlay}
></advanced-camera-card-message>`}let AO=class extends le{constructor(){super(...arguments),this.overlay=!1,this._controller=new CO}render(){if(!this.message)return;const e=this._controller.getURL(this.message),t=q`
${this._controller.getMessageString(this.message)}
${e?q`. <a href="${e.link}">${e.title}</a>`:""}
`,n=this._controller.getIcon(this.message),i={dotdotdot:!!this.message?.dotdotdot};return q` <div class="wrapper">
<div class="message padded">
<div class="icon">
<advanced-camera-card-icon
part="icon"
.icon="${{icon:n}}"
></advanced-camera-card-icon>
</div>
<div class="contents">
<span class="${ye(i)}">${t}</span>
${this._controller.getContextStrings(this.message).map((e=>q`<pre>${e}</pre>`))}
</div>
</div>
</div>`}static get styles(){return s(SO)}};e([me({attribute:!1})],AO.prototype,"message",void 0),e([me({attribute:!0,type:Boolean})],AO.prototype,"overlay",void 0),AO=e([de("advanced-camera-card-message")],AO);let TO=class extends le{render(){return q`
<slot name="top"></slot>
<slot name="left"></slot>
<slot name="right"></slot>
<slot name="bottom"></slot>
`}static get styles(){return s("ha-icon-button {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\n border-radius: var(--advanced-camera-card-button-border-radius);\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\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}")}};TO=e([de("advanced-camera-card-overlay")],TO);class $O{constructor(e){this._config=null,this._popupTimer=new qd,this._items=[],this._host=e}getRenderItems(){return this._items}setItems(e){const t=e.filter((e=>!!e.exclusive)),n=Qu(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||Uu(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("--advanced-camera-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()}getConfig(){return this._config}shouldRender(){return this._items.some((e=>!1!==e.enabled&&e.sufficient))}actionHandler(e,t){e.stopPropagation();const n=Bd(e.detail.action,t);n&&$T(this._host,{actions:dd(n),config:t})}_getSufficientValue(e){
/* istanbul ignore else: cannot happen -- @preserve */
return"custom:advanced-camera-card-status-bar-icon"===e.type?e.icon:"custom:advanced-camera-card-status-bar-string"===e.type?e.string:"custom:advanced-camera-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(){Md(this._host,!1,"hide")}_hide(){Md(this._host,!0,"hide")}}let IO=class extends le{constructor(){super(...arguments),this._controller=new $O(this)}willUpdate(e){e.has("config")&&this.config&&this._controller.setConfig(this.config),e.has("items")&&this._controller.setItems(this.items??[])}_renderPerInstanceStyle(){const e=this._controller.getConfig();if(!e)return;const t=e.position,n=e.style,i=e=>`\n var(--advanced-camera-card-status-bar-override-${e},\n var(--advanced-camera-card-status-bar-position-${t}-style-${n}-${e},\n var(--advanced-camera-card-status-bar-position-${t}-${e},\n var(--advanced-camera-card-status-bar-style-${n}-${e},\n var(--advanced-camera-card-status-bar-${e})))))`;return q`<style>
:host(${`[data-position='${t}'][data-style='${n}']`}) {
color: ${i("color")};
background: ${i("background")};
}
</style>`}render(){if(this._controller.shouldRender())return q`
${this._renderPerInstanceStyle()}
<div class="status">
${this._controller.getRenderItems().map((e=>{if(!1===e.enabled)return;const t=ye({item:!0,expand:!!e.expand,action:!!Object.keys(e.actions??{}).length}),n=Kd({hasHold:Vd(e.actions?.hold_action),hasDoubleClick:Vd(e.actions?.double_tap_action)});return"custom:advanced-camera-card-status-bar-string"===e.type?q`<div
.actionHandler=${n}
class="${t}"
@action=${t=>this._controller.actionHandler(t,e.actions)}
>
${e.string}
</div>`:"custom:advanced-camera-card-status-bar-icon"===e.type?q`<advanced-camera-card-icon
.actionHandler=${n}
.icon=${{icon:e.icon}}
class="${t}"
@action=${t=>this._controller.actionHandler(t,e.actions)}
></advanced-camera-card-icon>`:"custom:advanced-camera-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 {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\n border-radius: var(--advanced-camera-card-button-border-radius);\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n}\n\n:host {\n --mdc-icon-size: calc(var(--advanced-camera-card-status-bar-height) / 2);\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 * Popup style behavior\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(--advanced-camera-card-status-bar-height);\n}\n\n.item {\n display: inline-block;\n margin: 3px 5px;\n align-content: center;\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,\nadvanced-camera-card-icon.item {\n display: block;\n height: var(--mdc-icon-size, 24px);\n width: auto;\n}\n\n/************************\n * Status bar theme hooks\n ************************/")}};e([me({attribute:!1})],IO.prototype,"items",void 0),e([me({attribute:!1})],IO.prototype,"config",void 0),IO=e([de("advanced-camera-card-status-bar")],IO);class OO{constructor(e){this._keys=e}modify(e){this._keys.forEach((t=>e.removeContext(t)))}}const LO=(e,t,n)=>{Ud(t);const i=n?.manager.getView()?.query;if(!i||!LA.isFolderQuery(i))return;const a=i?.getQuery();if(!a?.path||a?.path.length<=1)return;const r=a.path.slice(0,-1);n?.manager.setViewByParametersWithExistingQuery({params:{query:i.clone().setQuery({folder:a.folder,path:[r[0],...r.slice(1)]})}})},DO=e=>{const t=e?.query;if(!t||!LA.isFolderQuery(t))return null;const n=t.getQuery();return!n?.folder||!n?.path||n.path.length<=1?null:new ch(n.folder,{icon:"mdi:arrow-up-left"})};function jO(e){return"number"==typeof e}function zO(e){return"string"==typeof e}function PO(e){return"boolean"==typeof e}function RO(e){return"[object Object]"===Object.prototype.toString.call(e)}function NO(e){return Math.abs(e)}function FO(e){return Math.sign(e)}function BO(e,t){return NO(e-t)}function VO(e){return ZO(e).map(Number)}function HO(e){return e[UO(e)]}function UO(e){return Math.max(0,e.length-1)}function qO(e,t){return t===UO(e)}function WO(e,t=0){return Array.from(Array(e),((e,n)=>t+n))}function ZO(e){return Object.keys(e)}function KO(e,t){return[e,t].reduce(((e,t)=>(ZO(t).forEach((n=>{const i=e[n],a=t[n],r=RO(i)&&RO(a);e[n]=r?KO(i,a):a})),e)),{})}function QO(e,t){return void 0!==t.MouseEvent&&e instanceof t.MouseEvent}function YO(){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 GO(e,t,n,i){const a=YO(),r=1e3/60;let s=null,o=0,c=0;function l(e){if(!c)return;s||(s=e,n(),n());const a=e-s;for(s=e,o+=a;o>=r;)n(),o-=r;i(o/r),c&&(c=t.requestAnimationFrame(l))}function u(){t.cancelAnimationFrame(c),s=null,o=0,c=0}return{init:function(){a.add(e,"visibilitychange",(()=>{e.hidden&&(s=null,o=0)}))},destroy:function(){u(),a.clear()},start:function(){c||(c=t.requestAnimationFrame(l))},stop:u,update:n,render:i}}function XO(e=0,t=0){const n=NO(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 JO(e,t,n){const{constrain:i}=XO(0,e),a=e+1;let r=s(t);function s(e){return n?NO((a+e)%a):i(e)}function o(){return r}function c(){return JO(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 eL(e,t,n,i,a,r,s,o,c,l,u,d,h,p,m,f,g,_,v){const{cross:y,direction:b}=e,w=["INPUT","SELECT","TEXTAREA"],x={passive:!1},M=YO(),k=YO(),C=XO(50,225).constrain(p.measure(20)),S={mouse:300,touch:400},E={mouse:500,touch:600},A=m?43:25;let T=!1,$=0,I=0,O=!1,L=!1,D=!1,j=!1;function z(e){if(!QO(e,i)&&e.touches.length>=2)return P(e);const t=r.readPoint(e),n=r.readPoint(e,y),s=BO(t,$),c=BO(n,I);if(!L&&!j){if(!e.cancelable)return P(e);if(L=s>c,!L)return P(e)}const u=r.pointerMove(e);s>f&&(D=!0),l.useFriction(.3).useDuration(.75),o.start(),a.add(b(u)),e.preventDefault()}function P(e){const t=u.byDistance(0,!1).index!==d.get(),n=r.pointerUp(e)*(m?E:S)[j?"mouse":"touch"],i=function(e,t){const n=d.add(-1*FO(e)),i=u.byDistance(e,!m).distance;return m||NO(e)<C?i:g&&t?.5*i:u.byIndex(n.get(),0).distance}(b(n),t),a=function(e,t){if(0===e||0===t)return 0;if(NO(e)<=NO(t))return 0;const n=BO(NO(e),NO(t));return NO(n/e)}(n,i),s=A-10*a,o=_+a/50;L=!1,O=!1,k.clear(),l.useDuration(s).useFriction(o),c.distance(i,!m),j=!1,h.emit("pointerUp")}function R(e){D&&(e.stopPropagation(),e.preventDefault(),D=!1)}return{init:function(e){if(!v)return;function o(o){(PO(v)||v(e,o))&&function(e){const o=QO(e,i);if(j=o,D=m&&o&&!e.buttons&&T,T=BO(a.get(),s.get())>=2,o&&0!==e.button)return;if(function(e){const t=e.nodeName||"";return w.includes(t)}(e.target))return;O=!0,r.pointerDown(e),l.useFriction(0).useDuration(0),a.set(s),function(){const e=j?n:t;k.add(e,"touchmove",z,x).add(e,"touchend",P).add(e,"mousemove",z,x).add(e,"mouseup",P)}(),$=r.readPoint(e),I=r.readPoint(e,y),h.emit("pointerDown")}(o)}const c=t;M.add(c,"dragstart",(e=>e.preventDefault()),x).add(c,"touchmove",(()=>{}),x).add(c,"touchend",(()=>{})).add(c,"touchstart",o).add(c,"mousedown",o).add(c,"touchcancel",P).add(c,"contextmenu",P).add(c,"click",R,!0)},destroy:function(){M.clear(),k.clear()},pointerDown:function(){return O}}}function tL(e,t){let n,i;function a(e){return e.timeStamp}function r(n,i){const a="client"+("x"===(i||e.scroll)?"X":"Y");return(QO(n,t)?n:n.touches[0])[a]}return{pointerDown:function(e){return n=e,i=e,r(e)},pointerMove:function(e){const t=r(e)-r(i),s=a(e)-a(n)>170;return i=e,s&&(n=e),t},pointerUp:function(e){if(!n||!i)return 0;const t=r(i)-r(n),s=a(e)-a(n),o=a(e)-a(i)>170,c=t/s;return s&&!o&&NO(c)>.1?c:0},readPoint:r}}function nL(e,t,n,i,a,r,s){const o=[e].concat(i);let c,l,u=[],d=!1;function h(e){return a.measureSize(s.measure(e))}return{init:function(a){r&&(l=h(e),u=i.map(h),c=new ResizeObserver((n=>{(PO(r)||r(a,n))&&function(n){for(const r of n){if(d)return;const n=r.target===e,s=i.indexOf(r.target),o=n?l:u[s];if(NO(h(n?e:i[s])-o)>=.5){a.reInit(),t.emit("resize");break}}}(n)})),n.requestAnimationFrame((()=>{o.forEach((e=>c.observe(e)))})))},destroy:function(){d=!0,c&&c.disconnect()}}}function iL(e,t,n,i,a){const r=a.measure(10),s=a.measure(50),o=XO(.1,.99);let c=!1;function l(){return!c&&(!!e.reachedAny(n.get())&&!!e.reachedAny(t.get()))}return{shouldConstrain:l,constrain:function(a){if(!l())return;const c=e.reachedMin(t.get())?"min":"max",u=NO(e[c]-t.get()),d=n.get()-t.get(),h=o.constrain(u/s);n.subtract(d*h),!a&&NO(d)<r&&(n.set(e.constrain(n.get())),i.useDuration(25).useBaseFriction())},toggleActive:function(e){c=!e}}}function aL(e,t,n,i){const a=t.min+.1,r=t.max+.1,{reachedMin:s,reachedMax:o}=XO(a,r);const c={loop:function(t){if(!function(e){return 1===e?o(n.get()):-1===e&&s(n.get())}(t))return;const a=e*(-1*t);i.forEach((e=>e.add(a)))}};return c}function rL(e,t,n,i,a){const{reachedAny:r,removeOffset:s,constrain:o}=i;function c(e){return e.concat().sort(((e,t)=>NO(e)-NO(t)))[0]}function l(t,i){const a=[t,t+n,t-n];if(!e)return t;if(!i)return c(a);const r=a.filter((e=>FO(e)===i));return r.length?c(r):HO(a)-n}const u={byDistance:function(n,i){const c=a.get()+n,{index:u,distance:d}=function(n){const i=e?s(n):o(n),a=t.map(((e,t)=>({diff:l(e-i,0),index:t}))).sort(((e,t)=>NO(e.diff)-NO(t.diff))),{index:r}=a[0];return{index:r,distance:i}}(c),h=!e&&r(c);return!i||h?{index:u,distance:n}:{index:u,distance:n+l(t[u]-d,0)}},byIndex:function(e,n){return{index:e,distance:l(t[e]-a.get(),n)}},shortcut:l};return u}function sL(e,t,n,i,a,r,s,o){const c={passive:!0,capture:!0};let l=0;function u(e){"Tab"===e.code&&(l=(new Date).getTime())}return{init:function(d){o&&(r.add(document,"keydown",u,!1),t.forEach(((t,u)=>{r.add(t,"focus",(t=>{(PO(o)||o(d,t))&&function(t){if((new Date).getTime()-l>10)return;s.emit("slideFocusStart"),e.scrollLeft=0;const r=n.findIndex((e=>e.includes(t)));jO(r)&&(a.useDuration(0),i.index(r,0),s.emit("slideFocus"))}(u)}),c)})))}}}function oL(e){let t=e;function n(e){return jO(e)?e:e.get()}const i={get:function(){return t},set:function(e){t=n(e)},add:function(e){t+=n(e)},subtract:function(e){t-=n(e)}};return i}function cL(e,t){const n="x"===e.scroll?function(e){return`translate3d(${e}px,0px,0px)`}:function(e){return`translate3d(0px,${e}px,0px)`},i=t.style;let a=null,r=!1;return{clear:function(){r||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))},to:function(t){if(r)return;const s=(o=e.direction(t),Math.round(100*o)/100);var o;s!==a&&(i.transform=n(s),a=s)},toggleActive:function(e){r=!e}}}function lL(e,t,n,i,a,r,s,o,c){const l=.5,u=VO(a),d=VO(a).reverse(),h=function(){const e=s[0];return f(m(d,e),n,!1)}().concat(function(){const e=t-s[0]-1;return f(m(u,e),-n,!0)}());function p(e,t){return e.reduce(((e,t)=>e-a[t]),t)}function m(e,t){return e.reduce(((e,n)=>p(e,t)>0?e.concat([n]):e),[])}function f(a,s,u){const d=function(e){return r.map(((n,a)=>({start:n-i[a]+l+e,end:n+t-l+e})))}(s);return a.map((t=>{const i=u?0:-n,a=u?n:0,r=u?"end":"start",s=d[t][r];return{index:t,loopPoint:s,slideLocation:oL(-1),translate:cL(e,c[t]),target:()=>o.get()>s?i:a}}))}const g={canLoop:function(){return h.every((({index:e})=>{const n=u.filter((t=>t!==e));return p(n,t)<=.1}))},clear:function(){h.forEach((e=>e.translate.clear()))},loop:function(){h.forEach((e=>{const{target:t,translate:n,slideLocation:i}=e,a=t();a!==i.get()&&(n.to(a),i.set(a))}))},loopPoints:h};return g}function uL(e,t,n){let i,a=!1;return{init:function(r){n&&(i=new MutationObserver((e=>{a||(PO(n)||n(r,e))&&function(e){for(const n of e)if("childList"===n.type){r.reInit(),t.emit("slidesChanged");break}}(e)})),i.observe(e,{childList:!0}))},destroy:function(){i&&i.disconnect(),a=!0}}}function dL(e,t,n,i){const a={};let r,s=null,o=null,c=!1;const l={init:function(){r=new IntersectionObserver((e=>{c||(e.forEach((e=>{const n=t.indexOf(e.target);a[n]=e})),s=null,o=null,n.emit("slidesInView"))}),{root:e.parentElement,threshold:i}),t.forEach((e=>r.observe(e)))},destroy:function(){r&&r.disconnect(),c=!0},get:function(e=!0){if(e&&s)return s;if(!e&&o)return o;const t=function(e){return ZO(a).reduce(((t,n)=>{const i=parseInt(n),{isIntersecting:r}=a[i];return(e&&r||!e&&!r)&&t.push(i),t}),[])}(e);return e&&(s=t),e||(o=t),t}};return l}function hL(e,t,n,i,a,r,s,o,c){const{startEdge:l,endEdge:u,direction:d}=e,h=jO(n);const p={groupSlides:function(e){return h?function(e,t){return VO(e).filter((e=>e%t==0)).map((n=>e.slice(n,n+t)))}(e,n):function(e){return e.length?VO(e).reduce(((n,h,p)=>{const m=HO(n)||0,f=0===m,g=h===UO(e),_=a[l]-r[m][l],v=a[l]-r[h][u],y=!i&&f?d(s):0,b=NO(v-(!i&&g?d(o):0)-(_+y));return p&&b>t+c&&n.push(h),g&&n.push(e.length),n}),[]).map(((t,n,i)=>{const a=Math.max(i[n-1]||0);return e.slice(a,t)})):[]}(e)}};return p}function pL(e,t,n,i,a,r,s){const{align:o,axis:c,direction:l,startIndex:u,loop:d,duration:h,dragFree:p,dragThreshold:m,inViewThreshold:f,slidesToScroll:g,skipSnaps:_,containScroll:v,watchResize:y,watchSlides:b,watchDrag:w,watchFocus:x}=r,M={measure:function(e){const{offsetTop:t,offsetLeft:n,offsetWidth:i,offsetHeight:a}=e;return{top:t,right:n+i,bottom:t+a,left:n,width:i,height:a}}},k=M.measure(t),C=n.map(M.measure),S=function(e,t){const n="rtl"===t,i="y"===e,a=!i&&n?-1:1,r={scroll:i?"y":"x",cross:i?"x":"y",startEdge:i?"top":n?"right":"left",endEdge:i?"bottom":n?"left":"right",measureSize:function(e){const{height:t,width:n}=e;return i?t:n},direction:function(e){return e*a}};return r}(c,l),E=S.measureSize(k),A=function(e){const t={measure:function(t){return e*(t/100)}};return t}(E),T=function(e,t){const n={start:function(){return 0},center:function(e){return i(e)/2},end:i};function i(e){return t-e}const a={measure:function(i,a){return zO(e)?n[e](i):e(t,i,a)}};return a}(o,E),$=!d&&!!v,I=d||!!v,{slideSizes:O,slideSizesWithGaps:L,startGap:D,endGap:j}=function(e,t,n,i,a,r){const{measureSize:s,startEdge:o,endEdge:c}=e,l=n[0]&&a,u=function(){if(!l)return 0;const e=n[0];return NO(t[o]-e[o])}(),d=function(){if(!l)return 0;const e=r.getComputedStyle(HO(i));return parseFloat(e.getPropertyValue(`margin-${c}`))}(),h=n.map(s),p=n.map(((e,t,n)=>{const i=!t,a=qO(n,t);return i?h[t]+u:a?h[t]+d:n[t+1][o]-e[o]})).map(NO);return{slideSizes:h,slideSizesWithGaps:p,startGap:u,endGap:d}}(S,k,C,n,I,a),z=hL(S,E,g,d,k,C,D,j,2),{snaps:P,snapsAligned:R}=function(e,t,n,i,a){const{startEdge:r,endEdge:s}=e,{groupSlides:o}=a,c=o(i).map((e=>HO(e)[s]-e[0][r])).map(NO).map(t.measure),l=i.map((e=>n[r]-e[r])).map((e=>-NO(e))),u=o(l).map((e=>e[0])).map(((e,t)=>e+c[t]));return{snaps:l,snapsAligned:u}}(S,T,k,C,z),N=-HO(P)+HO(L),{snapsContained:F,scrollContainLimit:B}=function(e,t,n,i,a){const r=XO(-t+e,0),s=n.map(((e,t)=>{const{min:i,max:a}=r,s=r.constrain(e),o=!t,c=qO(n,t);return o?a:c||l(i,s)?i:l(a,s)?a:s})).map((e=>parseFloat(e.toFixed(3)))),o=function(){const e=s[0],t=HO(s);return XO(s.lastIndexOf(e),s.indexOf(t)+1)}(),c=function(){if(t<=e+a)return[r.max];if("keepSnaps"===i)return s;const{min:n,max:c}=o;return s.slice(n,c)}();function l(e,t){return BO(e,t)<=1}return{snapsContained:c,scrollContainLimit:o}}(E,N,R,v,2),V=$?F:R,{limit:H}=function(e,t,n){const i=t[0];return{limit:XO(n?i-e:HO(t),i)}}(N,V,d),U=JO(UO(V),u,d),q=U.clone(),W=VO(n),Z=GO(i,a,(()=>(({dragHandler:e,scrollBody:t,scrollBounds:n,options:{loop:i}})=>{i||n.constrain(e.pointerDown()),t.seek()})(oe)),(e=>(({scrollBody:e,translate:t,location:n,offsetLocation:i,previousLocation:a,scrollLooper:r,slideLooper:s,dragHandler:o,animation:c,eventHandler:l,scrollBounds:u,options:{loop:d}},h)=>{const p=e.settled(),m=!u.shouldConstrain(),f=d?p:p&&m,g=f&&!o.pointerDown();g&&c.stop();const _=n.get()*h+a.get()*(1-h);i.set(_),d&&(r.loop(e.direction()),s.loop()),t.to(i.get()),g&&l.emit("settle"),f||l.emit("scroll")})(oe,e))),K=V[U.get()],Q=oL(K),Y=oL(K),G=oL(K),X=oL(K),J=function(e,t,n,i,a,r){let s=0,o=0,c=a,l=r,u=e.get(),d=0;function h(e){return c=e,m}function p(e){return l=e,m}const m={direction:function(){return o},duration:function(){return c},velocity:function(){return s},seek:function(){const t=i.get()-e.get();let a=0;return c?(n.set(e),s+=t/c,s*=l,u+=s,e.add(s),a=u-d):(s=0,n.set(i),e.set(i),a=t),o=FO(a),d=u,m},settled:function(){return NO(i.get()-t.get())<.001},useBaseFriction:function(){return p(r)},useBaseDuration:function(){return h(a)},useFriction:p,useDuration:h};return m}(Q,G,Y,X,h,.68),ee=rL(d,V,N,H,X),te=function(e,t,n,i,a,r,s){function o(a){const o=a.distance,c=a.index!==t.get();r.add(o),o&&(i.duration()?e.start():(e.update(),e.render(1),e.update())),c&&(n.set(t.get()),t.set(a.index),s.emit("select"))}const c={distance:function(e,t){o(a.byDistance(e,t))},index:function(e,n){const i=t.clone().set(e);o(a.byIndex(i.get(),n))}};return c}(Z,U,q,J,ee,X,s),ne=function(e){const{max:t,length:n}=e,i={get:function(e){return n?(e-t)/-n:0}};return i}(H),ie=YO(),ae=dL(t,n,s,f),{slideRegistry:re}=function(e,t,n,i,a,r){const{groupSlides:s}=a,{min:o,max:c}=i;return{slideRegistry:function(){const i=s(r),a=!e||"keepSnaps"===t;return 1===n.length?[r]:a?i:i.slice(o,c).map(((e,t,n)=>{const i=!t,a=qO(n,t);return i?WO(HO(n[0])+1):a?WO(UO(r)-HO(n)[0]+1,HO(n)[0]):e}))}()}}($,v,V,B,z,W),se=sL(e,n,re,te,J,ie,s,x),oe={ownerDocument:i,ownerWindow:a,eventHandler:s,containerRect:k,slideRects:C,animation:Z,axis:S,dragHandler:eL(S,e,i,a,X,tL(S,a),Q,Z,te,J,ee,U,s,A,p,m,_,.68,w),eventStore:ie,percentOfView:A,index:U,indexPrevious:q,limit:H,location:Q,offsetLocation:G,previousLocation:Y,options:r,resizeHandler:nL(t,s,a,n,S,y,M),scrollBody:J,scrollBounds:iL(H,G,X,J,A),scrollLooper:aL(N,H,G,[Q,G,Y,X]),scrollProgress:ne,scrollSnapList:V.map(ne.get),scrollSnaps:V,scrollTarget:ee,scrollTo:te,slideLooper:lL(S,E,N,O,L,P,V,G,n),slideFocus:se,slidesHandler:uL(t,s,b),slidesInView:ae,slideIndexes:W,slideRegistry:re,slidesToScroll:z,target:X,translate:cL(S,t)};return oe}const mL={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function fL(e){function t(e,t){return KO(e,t||{})}const n={mergeOptions:t,optionsAtMedia:function(n){const i=n.breakpoints||{},a=ZO(i).filter((t=>e.matchMedia(t).matches)).map((e=>i[e])).reduce(((e,n)=>t(e,n)),{});return t(n,a)},optionsMediaQueries:function(t){return t.map((e=>ZO(e.breakpoints||{}))).reduce(((e,t)=>e.concat(t)),[]).map(e.matchMedia)}};return n}function gL(e,t,n){const i=e.ownerDocument,a=i.defaultView,r=fL(a),s=function(e){let t=[];const n={init:function(n,i){return t=i.filter((({options:t})=>!1!==e.optionsAtMedia(t).active)),t.forEach((t=>t.init(n,e))),i.reduce(((e,t)=>Object.assign(e,{[t.name]:t})),{})},destroy:function(){t=t.filter((e=>e.destroy()))}};return n}(r),o=YO(),c=function(){let e,t={};function n(e){return t[e]||[]}const i={init:function(t){e=t},emit:function(t){return n(t).forEach((n=>n(e,t))),i},off:function(e,a){return t[e]=n(e).filter((e=>e!==a)),i},on:function(e,a){return t[e]=n(e).concat([a]),i},clear:function(){t={}}};return i}(),{mergeOptions:l,optionsAtMedia:u,optionsMediaQueries:d}=r,{on:h,off:p,emit:m}=c,f=S;let g,_,v,y,b=!1,w=l(mL,gL.globalOptions),x=l(w),M=[];function k(t){const n=pL(e,v,y,i,a,t,c);if(t.loop&&!n.slideLooper.canLoop()){return k(Object.assign({},t,{loop:!1}))}return n}function C(t,n){b||(w=l(w,t),x=u(w),M=n||M,function(){const{container:t,slides:n}=x,i=zO(t)?e.querySelector(t):t;v=i||e.children[0];const a=zO(n)?v.querySelectorAll(n):n;y=[].slice.call(a||v.children)}(),g=k(x),d([w,...M.map((({options:e})=>e))]).forEach((e=>o.add(e,"change",S))),x.active&&(g.translate.to(g.location.get()),g.animation.init(),g.slidesInView.init(),g.slideFocus.init($),g.eventHandler.init($),g.resizeHandler.init($),g.slidesHandler.init($),g.options.loop&&g.slideLooper.loop(),v.offsetParent&&y.length&&g.dragHandler.init($),_=s.init($,M)))}function S(e,t){const n=T();E(),C(l({startIndex:n},e),t),c.emit("reInit")}function E(){g.dragHandler.destroy(),g.eventStore.clear(),g.translate.clear(),g.slideLooper.clear(),g.resizeHandler.destroy(),g.slidesHandler.destroy(),g.slidesInView.destroy(),g.animation.destroy(),s.destroy(),o.clear()}function A(e,t,n){x.active&&!b&&(g.scrollBody.useBaseFriction().useDuration(!0===t?0:x.duration),g.scrollTo.index(e,n||0))}function T(){return g.index.get()}const $={canScrollNext:function(){return g.index.add(1).get()!==T()},canScrollPrev:function(){return g.index.add(-1).get()!==T()},containerNode:function(){return v},internalEngine:function(){return g},destroy:function(){b||(b=!0,o.clear(),E(),c.emit("destroy"),c.clear())},off:p,on:h,emit:m,plugins:function(){return _},previousScrollSnap:function(){return g.indexPrevious.get()},reInit:f,rootNode:function(){return e},scrollNext:function(e){A(g.index.add(1).get(),e,-1)},scrollPrev:function(e){A(g.index.add(-1).get(),e,1)},scrollProgress:function(){return g.scrollProgress.get(g.offsetLocation.get())},scrollSnapList:function(){return g.scrollSnapList},scrollTo:A,selectedScrollSnap:T,slideNodes:function(){return y},slidesInView:function(){return g.slidesInView.get()},slidesNotInView:function(){return g.slidesInView.get(!1)}};return C(t,n),setTimeout((()=>c.emit("init")),0),$}function _L(){return _L=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_L.apply(this,arguments)}gL.globalOptions=void 0;var vL=function(e,t){return void 0===t&&(t=.996),e*t/(1-t)};function yL(e,t){if(e.length!==t.length)throw new Error("vectors must be same length");return e.map((function(e,n){return e+t[n]}))}function bL(e){return Math.max.apply(Math,e.map(Math.abs))}function wL(e){return Object.freeze(e),Object.values(e).forEach((function(e){null===e||"object"!=typeof e||Object.isFrozen(e)||wL(e)})),e}var xL=[1,18,"undefined"!=typeof window&&window.innerHeight||800];var ML=[-1,-1,-1];var kL=function(e){return _L({},e,{axisDelta:e.axisDelta.map((function(e){return function(e,t,n){return Math.min(Math.max(t,e),n)}(e,-700,700)}))})},CL=.6,SL=.96,EL=2,AL=5,TL=wL({preventWheelAction:!0,reverseSign:[!0,!0,!1]}),$L=400;function IL(){return{isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:1/0,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:$L}}function OL(e){void 0===e&&(e={});var t,n,i,a=function(){var e={};function t(t,n){e[t]=(e[t]||[]).filter((function(e){return e!==n}))}return wL({on:function(n,i){return e[n]=(e[n]||[]).concat(i),function(){return t(n,i)}},off:t,dispatch:function(t,n){t in e&&e[t].forEach((function(e){return e(n)}))}})}(),r=a.on,s=a.off,o=a.dispatch,c=TL,l=IL(),u=!1,d=function(e){Array.isArray(e)?e.forEach((function(e){return m(e)})):m(e)},h=function(e){return void 0===e&&(e={}),Object.values(e).some((function(e){return null==e}))?c:c=wL(_L({},TL,c,e))},p=function(e){var i=_L({event:t,isStart:!1,isEnding:!1,isMomentumCancel:!1,isMomentum:l.isMomentum,axisDelta:[0,0,0],axisVelocity:l.axisVelocity,axisMovement:l.axisMovement,get axisMovementProjection(){return yL(i.axisMovement,i.axisVelocity.map((function(e){return vL(e)})))}},e);o("wheel",_L({},i,{previous:n})),n=i},m=function(e){var n=kL(function(e,t){if(!t)return e;var n=!0===t?ML:t.map((function(e){return e?-1:1}));return _L({},e,{axisDelta:e.axisDelta.map((function(e,t){return e*n[t]}))})}(function(e){var t=e.deltaX*xL[e.deltaMode],n=e.deltaY*xL[e.deltaMode],i=(e.deltaZ||0)*xL[e.deltaMode];return{timeStamp:e.timeStamp,axisDelta:[t,n,i]}}(e),c.reverseSign)),i=n.axisDelta,a=n.timeStamp,r=bL(i);e.preventDefault&&function(e,t){var n=c.preventWheelAction,i=t[0],a=t[1],r=t[2];if("boolean"==typeof n)return n;switch(n){case"x":return Math.abs(i)>=e;case"y":return Math.abs(a)>=e;case"z":return Math.abs(r)>=e;default:return!1}}(r,i)&&e.preventDefault(),l.isStarted?l.isMomentum&&r>Math.max(2,2*l.lastAbsDelta)&&(k(!0),x()):x(),0===r&&Object.is&&Object.is(e.deltaX,-0)?u=!0:(t=e,l.axisMovement=yL(l.axisMovement,i),l.lastAbsDelta=r,l.scrollPointsToMerge.push({axisDelta:i,timeStamp:a}),f(),p({axisDelta:i,isStart:!l.isStartPublished}),l.isStartPublished=!0,M())},f=function(){var e;l.scrollPointsToMerge.length===EL?(l.scrollPoints.unshift({axisDeltaSum:l.scrollPointsToMerge.map((function(e){return e.axisDelta})).reduce(yL),timeStamp:(e=l.scrollPointsToMerge.map((function(e){return e.timeStamp})),e.reduce((function(e,t){return e+t}))/e.length)}),_(),l.scrollPointsToMerge.length=0,l.scrollPoints.length=1,l.isMomentum||b()):l.isStartPublished||g()},g=function(){var e;l.axisVelocity=(e=l.scrollPointsToMerge,e[e.length-1]).axisDelta.map((function(e){return e/l.willEndTimeout}))},_=function(){var e=l.scrollPoints,t=e[0],n=e[1];if(n&&t){var i=t.timeStamp-n.timeStamp;if(!(i<=0)){var a=t.axisDeltaSum.map((function(e){return e/i})),r=a.map((function(e,t){return e/(l.axisVelocity[t]||1)}));l.axisVelocity=a,l.accelerationFactors.push(r),v(i)}}},v=function(e){var t=10*Math.ceil(e/10)*1.2;l.isMomentum||(t=Math.max(100,2*t)),l.willEndTimeout=Math.min(1e3,Math.round(t))},y=function(e){return 0===e||e<=SL&&e>=CL},b=function(){if(l.accelerationFactors.length>=AL){if(u&&(u=!1,bL(l.axisVelocity)>=.2))return void w();var e=l.accelerationFactors.slice(-1*AL);e.every((function(e){var t=!!e.reduce((function(e,t){return e&&e<1&&e===t?1:0})),n=e.filter(y).length===e.length;return t||n}))&&w(),l.accelerationFactors=e}},w=function(){l.isMomentum=!0},x=function(){(l=IL()).isStarted=!0,l.startTime=Date.now(),n=void 0,u=!1},M=function(){clearTimeout(i),i=setTimeout(k,l.willEndTimeout)},k=function(e){void 0===e&&(e=!1),l.isStarted&&(l.isMomentum&&e?p({isEnding:!0,isMomentumCancel:!0}):p({isEnding:!0}),l.isMomentum=!1,l.isStarted=!1)},C=function(e){var t=[],n=function(n){n.removeEventListener("wheel",e),t=t.filter((function(e){return e!==n}))};return wL({observe:function(i){return i.addEventListener("wheel",e,{passive:!1}),t.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){t.forEach(n)}})}(d),S=C.observe,E=C.unobserve,A=C.disconnect;return h(e),wL({on:r,off:s,observe:S,unobserve:E,disconnect:A,feedWheel:d,updateOptions:h})}var LL={active:!0,breakpoints:{},wheelDraggingClass:"is-wheel-dragging",forceWheelAxis:void 0,target:void 0};function DL(e){var t;void 0===e&&(e={});var n=function(){};var i={name:"wheelGestures",options:e,init:function(i,a){var r,s,o=a.mergeOptions,c=a.optionsAtMedia,l=o(LL,DL.globalOptions),u=o(l,e);t=c(u);var d,h=i.internalEngine(),p=null!=(r=t.target)?r:i.containerNode().parentNode,m=null!=(s=t.forceWheelAxis)?s:h.options.axis,f=OL({preventWheelAction:m,reverseSign:[!0,!0,!1]}),g=f.observe(p),_=f.on("wheel",(function(e){var i=e.axisDelta,a=i[0],r=i[1],s="x"===m?a:r,o="x"===m?r:a,c=e.isMomentum&&e.previous&&!e.previous.isMomentum,l=e.isEnding&&!e.isMomentum||c;Math.abs(s)>Math.abs(o)&&!v&&!e.isMomentum&&function(e){try{x(d=new MouseEvent("mousedown",e.event))}catch(e){return n()}v=!0,document.documentElement.addEventListener("mousemove",b,!0),document.documentElement.addEventListener("mouseup",b,!0),void document.documentElement.addEventListener("mousedown",b,!0),t.wheelDraggingClass&&p.classList.add(t.wheelDraggingClass)}(e);if(!v)return;l?function(e){v=!1,x(w("mouseup",e)),y(),t.wheelDraggingClass&&p.classList.remove(t.wheelDraggingClass)}(e):x(w("mousemove",e))})),v=!1;function y(){document.documentElement.removeEventListener("mousemove",b,!0),document.documentElement.removeEventListener("mouseup",b,!0),document.documentElement.removeEventListener("mousedown",b,!0)}function b(e){v&&e.isTrusted&&e.stopImmediatePropagation()}function w(e,t){var n,i;if(m===h.options.axis){var a=t.axisMovement;n=a[0],i=a[1]}else{var r=t.axisMovement;i=r[0],n=r[1]}if(!h.options.skipSnaps&&!h.options.dragFree){var s=h.containerRect.width,o=h.containerRect.height;n=n<0?Math.max(n,-s):Math.min(n,s),i=i<0?Math.max(i,-o):Math.min(i,o)}return new MouseEvent(e,{clientX:d.clientX+n,clientY:d.clientY+i,screenX:d.screenX+n,screenY:d.screenY+i,movementX:n,movementY:i,button:0,bubbles:!0,cancelable:!0,composed:!0})}function x(e){i.containerNode().dispatchEvent(e)}n=function(){g(),_(),y()}},destroy:function(){return n()}};return i}DL.globalOptions=void 0;class jL{constructor(e,t,n){this._mutationObserver=new MutationObserver(((e,t)=>this._refreshCarouselContents())),this._refreshCarouselContents=()=>{const e=Ed(this._parent);!Uu(this._carousel.slideNodes(),e)&&(this._carousel.destroy(),this._carousel=this._createCarousel(e))},this._root=e,this._parent=t,this._direction=n?.direction??"horizontal",this._transitionEffect=n?.transitionEffect??"slide",this._startIndex=n?.startIndex??0,this._dragFree=n?.dragFree??!1,this._loop=n?.loop??!1,this._draggable=n?.dragEnabled??!0,this._plugins=n?.plugins??[],this._textDirection=n?.textDirection??"ltr",this._wheelScrolling=n?.wheelScrolling??!0,this._carousel=this._createCarousel(Ed(this._parent)),t instanceof HTMLSlotElement&&t.addEventListener("slotchange",this._refreshCarouselContents),this._mutationObserver.observe(this._parent,{childList:!0})}destroy(){this._parent instanceof HTMLSlotElement&&this._parent.removeEventListener("slotchange",this._refreshCarouselContents),this._mutationObserver.disconnect(),this._carousel.destroy()}getSlide(e){return this._carousel.slideNodes()[e]??null}getSelectedSlide(){return this.getSlide(this.getSelectedIndex())}getSelectedIndex(){return this._carousel.selectedScrollSnap()}selectSlide(e){this._carousel.scrollTo(e,"none"===this._transitionEffect);const t=this.getSlide(e);t&&sA(this._parent,"carousel:force-select",{index:e,element:t})}_createCarousel(e){const t=gL(this._root,{slides:e,axis:"horizontal"===this._direction?"x":"y",duration:20,startIndex:this._startIndex,dragFree:this._dragFree,loop:this._loop,containScroll:"trimSnaps",watchSlides:!1,watchResize:!0,watchDrag:this._draggable,direction:this._textDirection},[...this._plugins,...e.length>1&&this._wheelScrolling?[DL({forceWheelAxis:"y"})]:[]]),n=()=>{const e=(()=>{const e=t.selectedScrollSnap(),n=t.slideNodes()[e]??null;return n?{index:e,element:n}:null})();e&&sA(this._parent,"carousel:select",e)};return t.on("select",(()=>n())),t}}const zL=e=>"rtl"===getComputedStyle(e).direction?"rtl":"ltr";let PL=class extends le{constructor(){super(...arguments),this.direction="horizontal",this.dragEnabled=!0,this.selected=0,this._refParent=Pe(),this._refRoot=Pe(),this._carousel=null}connectedCallback(){super.connectedCallback(),this.requestUpdate()}disconnectedCallback(){this._carousel?.destroy(),this._carousel=null,super.disconnectedCallback()}willUpdate(e){e.has("direction")&&this.setAttribute("direction",this.direction);["direction","dragEnabled","dragFree","loop","plugins","transitionEffect"].some((t=>e.has(t)))&&(this._carousel?.destroy(),this._carousel=null)}render(){return q` <div class="embla">
<slot name="left"></slot>
<div ${Fe(this._refRoot)} class="embla__viewport">
<div class="embla__container">
<slot ${Fe(this._refParent)}></slot>
</div>
</div>
<slot name="right"></slot>
</div>`}updated(e){!this._carousel&&this._refRoot.value&&this._refParent.value&&this.isConnected?this._carousel=new jL(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:zL(this),wheelScrolling:this.wheelScrolling}):e.has("selected")&&this._carousel?.selectSlide(this.selected)}static get styles(){return s(":host {\n display: block;\n height: 100%;\n width: 100%;\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:not(:last-of-type)) {\n margin-bottom: 5px;\n}\n\n:host([direction=horizontal]) ::slotted(.embla__slide:not(:last-of-type)) {\n margin-right: 5px;\n}")}};e([me({attribute:!0,reflect:!0})],PL.prototype,"direction",void 0),e([me({attribute:!0})],PL.prototype,"transitionEffect",void 0),e([me({attribute:!1})],PL.prototype,"loop",void 0),e([me({attribute:!1})],PL.prototype,"dragFree",void 0),e([me({attribute:!1})],PL.prototype,"dragEnabled",void 0),e([me({attribute:!1})],PL.prototype,"plugins",void 0),e([me({attribute:!1})],PL.prototype,"wheelScrolling",void 0),e([me({attribute:!1})],PL.prototype,"selected",void 0),PL=e([de("advanced-camera-card-carousel")],PL);class RL{constructor(){this._details=[],this._heading=null}calculate(e,t,n){const i=lh.isMedia(t)?t.getCameraID():null,a=i?e?.getCameraMetadata(i)??null:null;this._calculateHeading(a,t),this._calculateDetails(a,t,n)}_calculateHeading(e,t){if(lh.isEvent(t)){const e=ld(t.getWhat()?.join(", "))??null,n=ld(t.getTags()?.join(", "))??null,i=e||n?(e??"")+(e&&n?": ":"")+(n??""):null,a=t.getScore(),r=a?(100*a).toFixed(2)+"%":null;this._heading=i?`${i}${r?` ${r}`:""}`:null}else this._heading=e?.title?e.title:null}_calculateDetails(e,t,n){const i=t?.getTitle()??null,a=lh.isMedia(t)?t.getStartTime():null,r=lh.isMedia(t)?t.getEndTime():null,s=a&&r?yd(a,r):null,o=lh.isMedia(t)&&t.inProgress()?u_("thumbnail.in_progress"):null,c=lh.isMedia(t)?ld(t?.getWhere()?.join(", "))??null:null,l=lh.isEvent(t)?ld(t?.getTags()?.join(", "))??null:null,u=n?ja(n,"HH:mm:ss"):null,d=[...a?[{hint:u_("thumbnail.start"),icon:{icon:"mdi:calendar-clock-outline"},title:ja(a,"yyyy-MM-dd HH:mm:ss")}]:[],...s||o?[{hint:u_("thumbnail.duration"),icon:{icon:"mdi:clock-outline"},title:`${s??""}${s&&o?" ":""}${o??""}`}]:[],...e?.title?[{hint:u_("thumbnail.camera"),title:e.title,icon:{icon:"mdi:cctv"}}]:[],...c?[{hint:u_("thumbnail.where"),title:c,icon:{icon:"mdi:map-marker-outline"}}]:[],...l?[{hint:u_("thumbnail.tag"),title:l,icon:{icon:"mdi:tag"}}]:[],...u?[{hint:u_("thumbnail.seek"),title:u,icon:{icon:"mdi:clock-fast"}}]:[]],h=!lh.isEvent(t)||!a;this._details=[...h&&i?[{title:i,...d.length>0&&{icon:{icon:"mdi:rename"},hint:u_("thumbnail.title")}}]:[],...d]}getHeading(){return this._heading}getDetails(){return this._details}}let NL=class extends le{constructor(){super(...arguments),this._controller=new RL}willUpdate(e){["item","seek","cameraManager"].some((t=>e.has(t)))&&this._controller.calculate(this.cameraManager,this.item,this.seek)}render(){const e=this._controller.getHeading(),t=this._controller.getDetails();return q`
${e?q` <div class="heading">
<span title=${e}>${e}</span>
</div>`:""}
${t?q` <div class="details">
${t.map((e=>q`<div>
${e.icon?q` <advanced-camera-card-icon
title=${e.hint??""}
.icon=${e.icon}
></advanced-camera-card-icon>`:""}
<span>${e.title}</span>
</div>`))}
</div>`:""}
`}static get styles(){return s(":host {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-left: 5px;\n padding: 5px;\n color: var(--advanced-camera-card-thumbnail-text-color);\n overflow: hidden;\n column-gap: 5%;\n}\n\ndiv.heading {\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}")}};e([me({attribute:!1})],NL.prototype,"hass",void 0),e([me({attribute:!1})],NL.prototype,"cameraManager",void 0),e([me({attribute:!1})],NL.prototype,"item",void 0),e([me({attribute:!1})],NL.prototype,"seek",void 0),NL=e([de("advanced-camera-card-thumbnail-details")],NL);const FL=e=>!!e?.startsWith("https://brands.home-assistant.io/");class BL{constructor(){this._title=null,this._subtitles=[],this._icon=null,this._thumbnail=null,this._thumbnailClass=null}calculate(e,t,n){const i=lh.isMedia(t)?t.getCameraID():null,a=i?e?.getCameraMetadata(i)??null:null;this._calculateVisuals(a,t),this._calculateTitles(a,t,n)}_calculateTitles(e,t,n){if(n)return;if(this._thumbnail&&lh.isMedia(t))return this._title=null,void(this._subtitles=[]);const i=lh.isEvent(t)||lh.isRecording(t)?t.getStartTime():null;this._title=i?ja(i,"HH:mm"):null;const a=i?ja(i,"MMM do"):null,r=t?.getTitle()??null,s=e?.title??r??null;this._subtitles=[...a?[a]:[],...s?[s]:[]]}_calculateVisuals(e,t){let n=t?.getThumbnail()??null;var i,a;n&&FL(n)&&(n=`https://brands.home-assistant.io/${(i={domain:(a=n,a.split("/")[4]),type:"icon",useFallback:!0,brand:!0}).brand?"brands/":""}${i.useFallback?"_/":""}${i.domain}/${i.darkOptimized?"dark_":""}${i.type}.png`),n?(this._thumbnail=n,this._icon=null,this._thumbnailClass=FL(n)?"brand":null):(this._thumbnail=null,this._thumbnailClass=null,this._icon=t?.getIcon()??e?.engineIcon??null)}getTitle(){return this._title}getSubtitles(){return this._subtitles}getIcon(){return this._icon}getThumbnail(){return this._thumbnail}getThumbnailClass(){return this._thumbnailClass}}
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const VL=window,HL=VL.ShadowRoot&&(void 0===VL.ShadyCSS||VL.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,UL=Symbol(),qL=new WeakMap;let WL=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==UL)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(HL&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=qL.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&qL.set(t,e))}return e}toString(){return this.cssText}};const ZL=(e,t)=>{HL?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style"),i=VL.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=t.cssText,e.appendChild(n)}))},KL=HL?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new WL("string"==typeof e?e:e+"",void 0,UL))(t)})(e):e
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/;var QL;const YL=window,GL=YL.trustedTypes,XL=GL?GL.emptyScript:"",JL=YL.reactiveElementPolyfillSupport,eD={toAttribute(e,t){switch(t){case Boolean:e=e?XL: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}},tD=(e,t)=>t!==e&&(t==t||e==e),nD={attribute:!0,type:String,converter:eD,reflect:!1,hasChanged:tD},iD="finalized";class aD 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=nD){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)||nD}static finalize(){if(this.hasOwnProperty(iD))return!1;this[iD]=!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(KL(e))}else void 0!==e&&t.push(KL(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 ZL(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=nD){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:eD).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:eD;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.constructor.getPropertyOptions(e)).hasChanged||tD)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,n))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(n)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}aD[iD]=!0,aD.elementProperties=new Map,aD.elementStyles=[],aD.shadowRootOptions={mode:"open"},null==JL||JL({ReactiveElement:aD}),(null!==(QL=YL.reactiveElementVersions)&&void 0!==QL?QL:YL.reactiveElementVersions=[]).push("1.6.3");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const rD=0,sD=Symbol();let oD=class{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===sD?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)=>tD(e,t[n]))):e!==t}};function cD(e){return q`
<advanced-camera-card-progress-indicator
class="${ye(e?.classes??{})}"
.size=${e?.size}
${e?.componentRef?Fe(e.componentRef):""}
.message=${e?.message||""}
.animated=${e?.cardWideConfig?.performance?.features.animated_progress_indicator??!0}
>
</advanced-camera-card-progress-indicator>
`}let lD=class extends le{constructor(){super(...arguments),this.message="",this.animated=!1,this.size="large"}render(){return q` <div class="message vertical">
${this.animated?q`<ha-spinner indeterminate size="${this.size}"> </ha-spinner>`:q`<advanced-camera-card-icon
.icon=${{icon:"mdi:timer-sand"}}
></advanced-camera-card-icon>`}
${this.message?q`<span>${this.message}</span>`:q``}
</div>`}static get styles(){return s(SO)}};e([me({attribute:!1})],lD.prototype,"message",void 0),e([me({attribute:!1})],lD.prototype,"animated",void 0),e([me({attribute:!1})],lD.prototype,"size",void 0),lD=e([de("advanced-camera-card-progress-indicator")],lD);const uD=(e,t,n)=>{const i={...n?.cardWideConfig&&{cardWideConfig:n.cardWideConfig}};return q` ${e.render({initial:()=>n?.inProgressFunc?.()??cD(i),pending:()=>n?.inProgressFunc?.()??cD(i),error:e=>(md(e),n?.errorFunc?.(e)),complete:t})}`},dD=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,hD=(e,t,n,i=!0)=>new oD(e,{args:()=>[!!t(),n()],task:async([e,n])=>{const i=t();return e&&i&&n?await(async(e,t)=>t.startsWith("data:")||t.match(dD)?t:new Promise(((n,i)=>{e.fetchWithAuth(t).then((e=>{if(!e.ok)throw new Error(e.statusText);return 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,n):null},autoRun:i});let pD=class extends le{constructor(){super(...arguments),this._intersectionObserver=new IntersectionObserver(this._intersectionHandler.bind(this))}connectedCallback(){super.connectedCallback(),this._intersectionObserver.observe(this)}disconnectedCallback(){this._intersectionObserver.disconnect(),super.disconnectedCallback()}willUpdate(e){e.has("thumbnail")&&(this._embedThumbnailTask=hD(this,(()=>this.hass),(()=>this.thumbnail),!1),this._intersectionObserver.unobserve(this),this._intersectionObserver.observe(this))}_intersectionHandler(e){this._embedThumbnailTask?.status===rD&&e.some((e=>e.isIntersecting))&&this._embedThumbnailTask?.run()}render(){const e=q`<advanced-camera-card-icon
.icon=${{icon:"mdi:image-off"}}
title=${u_("thumbnail.no_thumbnail")}
></advanced-camera-card-icon> `;return this._embedThumbnailTask?q`${this.thumbnail?uD(this._embedThumbnailTask,(e=>e?q`<img src="${e}" />`:q``),{inProgressFunc:()=>q`<advanced-camera-card-icon
.icon=${{icon:"mdi:image-refresh"}}
title=${u_("thumbnail.no_thumbnail")}
></advanced-camera-card-icon> `,errorFunc:()=>e}):e} `: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 {\n display: inline-block;\n width: 100%;\n height: 100%;\n vertical-align: top;\n margin: 0;\n border-radius: var(--advanced-camera-card-border-radius-final);\n object-fit: cover;\n}\n\nadvanced-camera-card-icon {\n display: flex;\n width: 50%;\n --mdc-icon-size: 100%;\n color: var(--primary-text-color);\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([me({attribute:!1})],pD.prototype,"thumbnail",void 0),e([me({attribute:!1})],pD.prototype,"hass",void 0),pD=e([de("advanced-camera-card-thumbnail-feature-thumbnail")],pD);let mD=class extends le{constructor(){super(...arguments),this._controller=new BL}willUpdate(e){["item","hasDetails","cameraManager"].some((t=>e.has(t)))&&this._controller.calculate(this.cameraManager,this.item,this.hasDetails)}render(){const e=this._controller.getTitle(),t=this._controller.getSubtitles(),n=ye({background:e||t.length}),i=this._controller.getThumbnailClass(),a=ye({...i&&{[i]:!0}});return q`
${this._controller.getThumbnail()?q` <advanced-camera-card-thumbnail-feature-thumbnail
class="${a}"
.hass=${this.hass}
.thumbnail=${this._controller.getThumbnail()}
aria-label=${this.item?.getTitle()??""}
title=${this.item?.getTitle()??""}
></advanced-camera-card-thumbnail-feature-thumbnail>`:this._controller.getIcon()?q`<advanced-camera-card-icon
class="${n}"
.icon=${{icon:this._controller.getIcon()}}
></advanced-camera-card-icon>`:""}
${e||t.length?q`
${e?q`<div class="title">${e}</div>`:""}
${t.length?q`<div>
${t.map((e=>q`<div class="subtitle">${e}</div>`))}
</div>`:""}
`:q``}
`}static get styles(){return s(":host {\n display: flex;\n flex-direction: column;\n justify-content: space-evenly;\n align-items: center;\n max-width: var(--advanced-camera-card-thumbnail-size);\n max-height: var(--advanced-camera-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(--advanced-camera-card-border-radius-final);\n box-sizing: border-box;\n position: relative;\n}\n\nadvanced-camera-card-thumbnail-feature-thumbnail {\n height: 50%;\n}\n\nadvanced-camera-card-thumbnail-feature-thumbnail.brand:only-child {\n height: 60%;\n}\n\nadvanced-camera-card-thumbnail-feature-thumbnail:not(.brand):only-child {\n height: 100%;\n}\n\nadvanced-camera-card-icon:only-child {\n width: 60%;\n height: 60%;\n --mdc-icon-size: 100%;\n}\n\nadvanced-camera-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 --mdc-icon-size: 100%;\n}\n\ndiv {\n text-align: center;\n color: var(--primary-text-color);\n}\n\ndiv.title {\n font-size: 1.5rem;\n}\n\ndiv.subtitle {\n font-size: 0.8em;\n}")}};e([me({attribute:!1})],mD.prototype,"hass",void 0),e([me({attribute:!1})],mD.prototype,"cameraManager",void 0),e([me({attribute:!1})],mD.prototype,"item",void 0),e([me({attribute:!1})],mD.prototype,"hasDetails",void 0),mD=e([de("advanced-camera-card-thumbnail-feature")],mD);let fD=class extends le{constructor(){super(...arguments),this.details=!1,this.show_favorite_control=!1,this.show_timeline_control=!1,this.show_download_control=!1}render(){if(!this.item)return;const e={star:!0,starred:lh.isMedia(this.item)&&!!this.item?.isFavorite()},t=this.show_timeline_control&&(lh.isEvent(this.item)&&this.item.getStartTime()||lh.isRecording(this.item)&&this.item.getStartTime()&&this.item.getEndTime()),n=this.viewItemManager?.getCapabilities(this.item)??null,i=this.show_favorite_control&&this.item&&this.hass&&n?.canFavorite,a=this.show_download_control&&this.hass&&this.item.getID()&&n?.canDownload;return q`
<advanced-camera-card-thumbnail-feature
.cameraManager=${this.cameraManager}
.hasDetails=${this.details}
.hass=${this.hass}
.item=${this.item}
>
</advanced-camera-card-thumbnail-feature>
${i?q` <advanced-camera-card-icon
class="${ye(e)}"
title=${u_("thumbnail.retain_indefinitely")}
.icon=${{icon:this.item.isFavorite()?"mdi:star":"mdi:star-outline"}}
@click=${async e=>{if(Ud(e),this.hass&&this.item){try{await(this.viewItemManager?.favorite(this.item,!this.item.isFavorite()))}catch(e){return void md(e)}this.requestUpdate()}}}
/></advanced-camera-card-icon>`:""}
${this.details?q`<advanced-camera-card-thumbnail-details
.hass=${this.hass}
.item=${this.item??void 0}
.cameraManager=${this.cameraManager}
.seek=${this.seek}
></advanced-camera-card-thumbnail-details>`:""}
${t?q`<advanced-camera-card-icon
class="timeline"
.icon=${{icon:"mdi:target"}}
title=${u_("thumbnail.timeline")}
@click=${e=>{Ud(e),this.viewManagerEpoch&&this.item&&this.viewManagerEpoch.manager.setViewByParameters({params:{view:"timeline",queryResults:this.viewManagerEpoch?.manager.getView()?.queryResults?.clone().selectResultIfFound((e=>e===this.item))},modifiers:[new OO(["timeline"])]})}}
></advanced-camera-card-icon>`:""}
${a?q` <advanced-camera-card-icon
class="download"
.icon=${{icon:"mdi:download"}}
title=${u_("thumbnail.download")}
@click=${async e=>{if(Ud(e),this.hass&&this.item)try{this.viewItemManager?.download(this.item)}catch(e){nT(this,e)}}}
></advanced-camera-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(--advanced-camera-card-thumbnail-border-color);\n border-radius: var(--advanced-camera-card-border-radius-final);\n padding: 2px;\n background-color: var(--advanced-camera-card-thumbnail-background);\n}\n\n:host(:hover) {\n transform: scale(1.04);\n}\n\nadvanced-camera-card-icon {\n position: absolute;\n border-radius: 50%;\n color: var(--advanced-camera-card-thumbnail-icon-color);\n cursor: pointer;\n transition: opacity 0.2s ease-in-out, color 0.2s ease-in-out;\n}\n\nadvanced-camera-card-icon:hover {\n opacity: 1;\n}\n\nadvanced-camera-card-icon.star {\n top: 3px;\n left: 3px;\n}\n\nadvanced-camera-card-icon.star.starred {\n color: var(--advanced-camera-card-thumbnail-icon-favorite-color);\n}\n\nadvanced-camera-card-icon.timeline {\n top: 3px;\n right: 3px;\n}\n\nadvanced-camera-card-icon.download {\n right: 3px;\n bottom: 3px;\n}\n\nadvanced-camera-card-thumbnail-details {\n flex: 1;\n}")}};e([me({attribute:!1})],fD.prototype,"cameraManager",void 0),e([me({attribute:!1})],fD.prototype,"viewItemManager",void 0),e([me({attribute:!1})],fD.prototype,"folderManager",void 0),e([me({attribute:!1})],fD.prototype,"item",void 0),e([me({attribute:!0,type:Boolean})],fD.prototype,"details",void 0),e([me({attribute:!0,type:Boolean})],fD.prototype,"show_favorite_control",void 0),e([me({attribute:!0,type:Boolean})],fD.prototype,"show_timeline_control",void 0),e([me({attribute:!0,type:Boolean})],fD.prototype,"show_download_control",void 0),e([me({attribute:!1})],fD.prototype,"seek",void 0),fD=e([de("advanced-camera-card-thumbnail")],fD);let gD=class extends le{constructor(){super(...arguments),this.fadeThumbnails=!1,this._thumbnails=[]}willUpdate(e){if(e.has("config")){this.config?.size&&this.style.setProperty("--advanced-camera-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._thumbnails=this._renderThumbnails()),e.has("viewManagerEpoch")&&this.style.setProperty("--advanced-camera-card-carousel-thumbnail-opacity",this.fadeThumbnails&&null!==this._getSelectedSlide()?"0.4":"1.0")}_getSelectedSlide(){return this.viewManagerEpoch?.manager.getView()?.queryResults?.getSelectedIndex()??null}_itemClickCallback(e,t){Ud(t);const n=this.viewManagerEpoch?.manager.getView(),i=n?.query,a=n?.queryResults;if(n&&i&&a)if(lh.isMedia(e)){const t=a.clone().selectResultIfFound((t=>t===e)),n=e.getCameraID();sA(this,"thumbnails-carousel:media-select",{media:e}),this.viewManagerEpoch?.manager.setViewByParameters({params:{view:"media",queryResults:t,...n&&{camera:n}},modifiers:[new OO(["timeline","mediaViewer"])]})}else if(LA.isFolderQuery(i)&&lh.isFolder(e)){const t=i.getQuery();if(!t)return;this.viewManagerEpoch?.manager.setViewByParametersWithExistingQuery({params:{query:i.clone().setQuery({folder:t.folder,path:[...t.path??[],{folder:e}]})}})}}_renderThumbnail(e,t,n,i){return q` <advanced-camera-card-thumbnail
class="${ye({embla__slide:!0,"slide-selected":t})}"
.cameraManager=${this.cameraManager}
.hass=${this.hass}
.item=${e}
.viewManagerEpoch=${this.viewManagerEpoch}
.viewItemManager=${this.viewItemManager}
.seek=${i&&lh.isMedia(e)&&e.includesTime(i)?i: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=${t=>n(e,t)}
>
</advanced-camera-card-thumbnail>`}_renderThumbnails(){const e=DO(this.viewManagerEpoch?.manager.getView()),t=[...e?[this._renderThumbnail(e,!1,((e,t)=>LO(0,t,this.viewManagerEpoch)))]:[]],n=this.viewManagerEpoch?.manager.getView(),i=this._getSelectedSlide();for(const e of n?.queryResults?.getResults()??[])t.push(this._renderThumbnail(e,i===t.length,((e,t)=>this._itemClickCallback(e,t)),n?.context?.mediaViewer?.seek));return t}_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._thumbnails.length&&this.config&&e)return q`<advanced-camera-card-carousel
direction=${e}
.selected=${this._getSelectedSlide()??0}
.dragFree=${!0}
>
${this._thumbnails}
</advanced-camera-card-carousel>`}static get styles(){return s(":host {\n --advanced-camera-card-thumbnail-size-max: 300px;\n --advanced-camera-card-thumbnail-details-width: calc(\n var(--advanced-camera-card-thumbnail-size) + 200px\n );\n}\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n background-color: var(--advanced-camera-card-thumbnail-background);\n --advanced-camera-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(--advanced-camera-card-carousel-thumbnail-opacity);\n}\n\n.embla__slide.slide-selected {\n opacity: 1;\n}\n\nadvanced-camera-card-thumbnail {\n width: var(--advanced-camera-card-thumbnail-size);\n height: var(--advanced-camera-card-thumbnail-size);\n max-width: 100%;\n}\n\nadvanced-camera-card-thumbnail[details] {\n width: var(--advanced-camera-card-thumbnail-details-width);\n}")}};e([me({attribute:!1})],gD.prototype,"hass",void 0),e([me({attribute:!1})],gD.prototype,"viewManagerEpoch",void 0),e([me({attribute:!1})],gD.prototype,"cameraManager",void 0),e([me({attribute:!1})],gD.prototype,"viewItemManager",void 0),e([me({attribute:!1})],gD.prototype,"config",void 0),e([me({attribute:!1})],gD.prototype,"fadeThumbnails",void 0),gD=e([de("advanced-camera-card-thumbnail-carousel")],gD);var _D=":host {\n width: 100%;\n height: 100%;\n display: block;\n}";const vD=document.createElement("template");vD.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 yD extends HTMLElement{constructor(){super();const e=this.attachShadow({mode:"open"});e.appendChild(vD.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-disabled","false"),this.focus({preventScroll:!0}),document.addEventListener("keyup",this.handleKeyUp),this.dispatchEvent(new CustomEvent("open",{bubbles:!0}))):(this.setAttribute("tabindex","-1"),this.setAttribute("aria-disabled","true"),document.removeEventListener("keyup",this.handleKeyUp),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))))}handleFreeSpaceDivClick=()=>{this.open=!1}}customElements.define("side-drawer",yD);let bD=class extends le{constructor(){super(...arguments),this.location="left",this.control=!0,this.open=!1,this.empty=!0,this._refDrawer=Pe(),this._refSlot=Pe(),this._resizeObserver=new ResizeObserver((()=>this._hideDrawerIfNecessary())),this._isHoverableDevice=fd()}firstUpdated(e){super.firstUpdated(e);const t=document.createElement("style");t.innerHTML='/************\n * Managing z-indicies and stacking contexts is very challenging on the card,\n * due to the volume of different potentially overlapping surfaces. In\n * particular, care must be taken to not generate new stacking contexts\n * inadvertently which would make "z-index" weaving challenging (e.g. submenu\n * shown for PTZ presets, needs to render "over" the media drawer open/close\n * control).\n *************/\n:host {\n width: unset;\n}\n\n#fs {\n display: none;\n width: 100%;\n inset: 0;\n}\n\n#d,\n#fs {\n height: 100%;\n position: absolute;\n}\n\n#d {\n overflow: visible;\n max-width: 90%;\n z-index: 3;\n}\n\n:host([location=right]) #d {\n left: unset;\n right: 0;\n transform: translateX(100%);\n}\n\n:host([location=right][open]) #d {\n transform: none;\n box-shadow: var(--advanced-camera-card-box-shadow-override, 0px 0px 25px 0px black);\n}\n\n#ifs {\n height: 100%;\n}',this._refDrawer.value?.shadowRoot?.appendChild(t)}_slotChanged(){const e=this._refSlot.value?Ed(this._refSlot.value):[];this._resizeObserver.disconnect();for(const t of e)this._resizeObserver.observe(t);this._hideDrawerIfNecessary()}_hideDrawerIfNecessary(){if(!this._refDrawer.value)return;const e=this._refSlot.value?Ed(this._refSlot.value):null;this.empty=!e||!e.length||e.every((e=>{const t=e.getBoundingClientRect();return!t.width||!t.height}))}render(){return q`
<side-drawer
${Fe(this._refDrawer)}
location="${this.location}"
?open=${this.open}
@mouseleave=${()=>{this.open=!1}}
>
${this.control?q`
<div
class="control-surround"
@click=${e=>{Ud(e),this.open=!this.open}}
>
<advanced-camera-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)}}
>
</advanced-camera-card-icon>
</div>
`:""}
<slot ${Fe(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 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\nadvanced-camera-card-icon.control {\n color: var(--advanced-camera-card-button-color);\n background-color: var(--advanced-camera-card-button-background);\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([location=left]) advanced-camera-card-icon.control {\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n}\n\n:host([location=right]) advanced-camera-card-icon.control {\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n}")}};e([me({attribute:!0,reflect:!0})],bD.prototype,"location",void 0),e([me({attribute:!0,reflect:!0,type:Boolean})],bD.prototype,"control",void 0),e([me({type:Boolean,reflect:!0,attribute:!0})],bD.prototype,"open",void 0),e([me({attribute:!1})],bD.prototype,"icons",void 0),e([me({type:Boolean,reflect:!0,attribute:!0})],bD.prototype,"empty",void 0),bD=e([de("advanced-camera-card-drawer")],bD);let wD=class extends le{constructor(){super(...arguments),this._refDrawerLeft=Pe(),this._refDrawerRight=Pe(),this._boundDrawerHandler=this._drawerHandler.bind(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("advanced-camera-card:drawer:open",this._boundDrawerHandler),this.addEventListener("advanced-camera-card:drawer:close",this._boundDrawerHandler)}disconnectedCallback(){this.removeEventListener("advanced-camera-card:drawer:open",this._boundDrawerHandler),this.removeEventListener("advanced-camera-card:drawer:close",this._boundDrawerHandler),super.disconnectedCallback()}_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>
<advanced-camera-card-drawer
${Fe(this._refDrawerLeft)}
location="left"
.icons=${this.drawerIcons?.left}
>
<slot name="left"></slot>
</advanced-camera-card-drawer>
<advanced-camera-card-drawer
${Fe(this._refDrawerRight)}
location="right"
.icons=${this.drawerIcons?.right}
>
<slot name="right"></slot>
</advanced-camera-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([me({attribute:!1})],wD.prototype,"drawerIcons",void 0),wD=e([de("advanced-camera-card-surround-basic")],wD);let xD=class extends le{constructor(){super(...arguments),this._timelineKeys=null}_hasDrawer(){return!!this.thumbnailConfig&&["left","right"].includes(this.thumbnailConfig.mode)}willUpdate(e){this.timelineConfig?.mode&&"none"!==this.timelineConfig.mode&&import("./timeline-core-3a2deefc.js");const t=this.viewManagerEpoch?.manager.getView();if(e.has("viewManagerEpoch")&&(this.viewManagerEpoch?.manager.hasMajorMediaChange(this.viewManagerEpoch?.oldView)||this.viewManagerEpoch?.oldView?.displayMode!==t?.displayMode)){const e=this._getTimelineKeys();Uu(e,this._timelineKeys)||(this._timelineKeys=e??void 0)}}_getTimelineKeys(){const e=e=>e?.size?{type:"camera",cameraIDs:e}:null,t=this.viewManagerEpoch?.manager.getView();if(!t||!this.cameraManager)return null;if(t.is("live")){const n={anyCapabilities:["clips","snapshots","recordings"]};return t.supportsMultipleDisplayModes()&&t.isGrid()?e(this.cameraManager.getStore().getCameraIDsWithCapability(n)):e(this.cameraManager.getStore().getAllDependentCameras(t.camera,n))}const n=t.query;if(t.isViewerView()){if(LA.isMediaQuery(n))return e(n.getQueryCameraIDs());if(LA.isFolderQuery(n)){const e=n.getQuery()?.folder;return e?(e=>({type:"folder",folder:e}))(e):null}}return null}render(){const e=this.viewManagerEpoch?.manager.getView();if(!this.hass||!e)return;const t=(e,t)=>{this.thumbnailConfig&&this._hasDrawer()&&sA(e.composedPath()[0],"drawer:"+t,{drawer:this.thumbnailConfig.mode})};return q` <advanced-camera-card-surround-basic
@advanced-camera-card:thumbnails-carousel:media-select=${e=>t(e,"close")}
>
${this.thumbnailConfig&&"none"!==this.thumbnailConfig.mode?q` <advanced-camera-card-thumbnail-carousel
slot=${this.thumbnailConfig.mode}
.hass=${this.hass}
.config=${this.thumbnailConfig}
.cameraManager=${this.cameraManager}
.viewItemManager=${this.viewItemManager}
.fadeThumbnails=${e.isViewerView()}
.viewManagerEpoch=${this.viewManagerEpoch}
.selected=${e.queryResults?.getSelectedIndex()??void 0}
>
</advanced-camera-card-thumbnail-carousel>`:""}
${this.timelineConfig&&"none"!==this.timelineConfig.mode?q` <advanced-camera-card-timeline-core
slot=${this.timelineConfig.mode}
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.itemClickAction=${e.isViewerView()||!this.thumbnailConfig||"none"===this.thumbnailConfig?.mode?"play":"select"}
.keys=${this._timelineKeys}
.mini=${!0}
.timelineConfig=${this.timelineConfig}
.thumbnailConfig=${this.thumbnailConfig}
.cameraManager=${this.cameraManager}
.foldersManager=${this.foldersManager}
.conditionStateManager=${this.conditionStateManager}
.viewItemManager=${this.viewItemManager}
.cardWideConfig=${this.cardWideConfig}
>
</advanced-camera-card-timeline-core>`:""}
<slot></slot>
</advanced-camera-card-surround-basic>`}static get styles(){return s(_D)}};e([me({attribute:!1})],xD.prototype,"hass",void 0),e([me({attribute:!1})],xD.prototype,"viewManagerEpoch",void 0),e([me({attribute:!1,hasChanged:pd})],xD.prototype,"thumbnailConfig",void 0),e([me({attribute:!1,hasChanged:pd})],xD.prototype,"timelineConfig",void 0),e([me({attribute:!1})],xD.prototype,"cameraManager",void 0),e([me({attribute:!1})],xD.prototype,"foldersManager",void 0),e([me({attribute:!1})],xD.prototype,"conditionStateManager",void 0),e([me({attribute:!1})],xD.prototype,"viewItemManager",void 0),e([me({attribute:!1})],xD.prototype,"cardWideConfig",void 0),xD=e([de("advanced-camera-card-surround")],xD);
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class MD{constructor(e){this.Y=e}disconnect(){this.Y=void 0}reconnect(e){this.Y=e}deref(){return this.Y}}class kD{constructor(){this.Z=void 0,this.q=void 0}get(){return this.Z}pause(){this.Z??=new Promise((e=>this.q=e))}resume(){this.q?.(),this.Z=this.q=void 0}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const CD=e=>!(e=>null===e||"object"!=typeof e&&"function"!=typeof e)(e)&&"function"==typeof e.then,SD=1073741823;const ED=_e(class extends ze{constructor(){super(...arguments),this._$Cwt=SD,this._$Cbt=[],this._$CK=new MD(this),this._$CX=new kD}render(...e){return e.find((e=>!CD(e)))??W}update(e,t){const n=this._$Cbt;let i=n.length;this._$Cbt=t;const a=this._$CK,r=this._$CX;this.isConnected||this.disconnected();for(let e=0;e<t.length&&!(e>this._$Cwt);e++){const s=t[e];if(!CD(s))return this._$Cwt=e,s;e<i&&s===n[e]||(this._$Cwt=SD,i=0,Promise.resolve(s).then((async e=>{for(;r.get();)await r.get();const t=a.deref();if(void 0!==t){const n=t._$Cbt.indexOf(s);n>-1&&n<t._$Cwt&&(t._$Cwt=n,t.setValue(e))}})))}return W}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}});let AD=class extends le{async _renderDiagnostics(){const e=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:"7.26.0",browser:navigator.userAgent,date:new Date,lang:l_(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,git:{hash:vT,build_date:_T,commit_date:yT},...e&&{ha_version:e.config.version},custom_integrations:{frigate:{...await CT("frigate",e),...a.size&&{devices:Object.fromEntries(a)}},hass_web_proxy:await CT(wT,e)},...n&&{config:n}}})(this.hass,this.deviceRegistryManager,this.rawConfig);return EO({message:u_("error.diagnostics"),icon:"mdi:cogs",context:e})}render(){return q`${ED(this._renderDiagnostics(),EO({message:u_("error.fetching_diagnostics"),dotdotdot:!0,icon:"mdi:cogs"}))}`}static get styles(){return s(_D)}};e([me({attribute:!1})],AD.prototype,"deviceRegistryManager",void 0),e([me({attribute:!1})],AD.prototype,"rawConfig",void 0),AD=e([de("advanced-camera-card-diagnostics")],AD);let TD=class extends le{willUpdate(e){if(e.has("viewManagerEpoch")||e.has("config")){const e=this.viewManagerEpoch?.manager.getView();(e?.is("live")||this._shouldLivePreload())&&import("./index-0154f2b1.js"),e?.isMediaGalleryView()&&!e.is("folders")?import("./media-gallery-c864fbb5.js"):e?.isViewerView()?import("./index-cf387b66.js"):e?.is("image")?import("./image-9ae4596e.js"):e?.is("timeline")?import("./timeline-ed888be3.js"):e?.is("folders")&&import("./folder-gallery-53a6955c.js")}e.has("hide")&&(this.hide?this.setAttribute("hidden",""):this.removeAttribute("hidden"))}_shouldLivePreload(){const e=this.viewManagerEpoch?.manager.getView();return!!this.config?.live.preload&&!e?.is("diagnostics")}render(){if(!this.hass||!this.config||!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.config.live.controls.thumbnails:e?.isViewerView()?this.config.media_viewer.controls.thumbnails:e?.is("timeline")?this.config.timeline.controls.thumbnails:void 0,a=e?.is("live")?this.config.live.controls.timeline:e?.isViewerView()?this.config.media_viewer.controls.timeline:void 0,r=e?this.cameraManager?.getStore().getCameraConfig(e.camera)??null:null;return q` <advanced-camera-card-surround
class="${ye(n)}"
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.thumbnailConfig=${this.hide?void 0:i}
.timelineConfig=${this.hide?void 0:a}
.cameraManager=${this.cameraManager}
.foldersManager=${this.foldersManager}
.conditionStateManager=${this.conditionStateManager}
.viewItemManager=${this.viewItemManager}
.cardWideConfig=${this.cardWideConfig}
>
${!this.hide&&e?.is("image")&&r?q` <advanced-camera-card-image
.imageConfig=${this.config.image}
.viewManagerEpoch=${this.viewManagerEpoch}
.hass=${this.hass}
.cameraConfig=${r}
.cameraManager=${this.cameraManager}
>
</advanced-camera-card-image>`:""}
${this.hide||!e?.isMediaGalleryView()||e.is("folders")?"":q` <advanced-camera-card-media-gallery
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.galleryConfig=${this.config.media_gallery}
.cameraManager=${this.cameraManager}
.viewItemManager=${this.viewItemManager}
.cardWideConfig=${this.cardWideConfig}
>
</advanced-camera-card-media-gallery>`}
${!this.hide&&e?.isViewerView()?q`
<advanced-camera-card-viewer
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.viewerConfig=${this.config.media_viewer}
.resolvedMediaCache=${this.resolvedMediaCache}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</advanced-camera-card-viewer>
`:""}
${!this.hide&&e?.is("timeline")?q` <advanced-camera-card-timeline
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.timelineConfig=${this.config.timeline}
.cameraManager=${this.cameraManager}
.conditionStateManager=${this.conditionStateManager}
.foldersManager=${this.foldersManager}
.viewItemManager=${this.viewItemManager}
.cardWideConfig=${this.cardWideConfig}
>
</advanced-camera-card-timeline>`:""}
${!this.hide&&e?.is("diagnostics")?q` <advanced-camera-card-diagnostics
.hass=${this.hass}
.rawConfig=${this.rawConfig}
.deviceRegistryManager=${this.deviceRegistryManager}
>
</advanced-camera-card-diagnostics>`:""}
${!this.hide&&e?.is("folders")?q` <advanced-camera-card-folder-gallery
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.viewItemManager=${this.viewItemManager}
.galleryConfig=${this.config.media_gallery}
.foldersManager=${this.foldersManager}
></advanced-camera-card-folder-gallery>`:""}
${this._shouldLivePreload()||!this.hide&&e?.is("live")?q`
<advanced-camera-card-live
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.liveConfig=${this.config.live}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
.microphoneState=${this.microphoneState}
.triggeredCameraIDs=${this.triggeredCameraIDs}
class="${ye(t)}"
>
</advanced-camera-card-live>
`:""}
</advanced-camera-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([me({attribute:!1})],TD.prototype,"hass",void 0),e([me({attribute:!1})],TD.prototype,"viewManagerEpoch",void 0),e([me({attribute:!1})],TD.prototype,"cameraManager",void 0),e([me({attribute:!1})],TD.prototype,"foldersManager",void 0),e([me({attribute:!1})],TD.prototype,"viewItemManager",void 0),e([me({attribute:!1})],TD.prototype,"config",void 0),e([me({attribute:!1})],TD.prototype,"cardWideConfig",void 0),e([me({attribute:!1})],TD.prototype,"rawConfig",void 0),e([me({attribute:!1})],TD.prototype,"resolvedMediaCache",void 0),e([me({attribute:!1})],TD.prototype,"hide",void 0),e([me({attribute:!1})],TD.prototype,"microphoneState",void 0),e([me({attribute:!1})],TD.prototype,"triggeredCameraIDs",void 0),e([me({attribute:!1})],TD.prototype,"deviceRegistryManager",void 0),e([me({attribute:!1})],TD.prototype,"conditionStateManager",void 0),TD=e([de("advanced-camera-card-views")],TD);console.info("%c 📷 Advanced Camera Card %c 7.26.0 ","padding: 3px; color: black; background: pink;","padding: 3px; color: black; background: white;"),window.customCards=window.customCards||[],window.customCards.push({type:"advanced-camera-card",name:u_("common.advanced_camera_card"),description:u_("common.advanced_camera_card_description"),preview:!0,documentationURL:"https://github.com/dermotduffy/advanced-camera-card"});let $D=class extends le{constructor(){super(...arguments),this._controller=new YA(this,(()=>this._refMain.value?.scroll({top:0})),(()=>this._refMenu.value?.toggleMenu()),(()=>this._refEffects.value??null)),this._menuButtonController=new XA,this._refEffects=Pe(),this._refElements=Pe(),this._refMain=Pe(),this._refMenu=Pe(),this._refOverlay=Pe(),this._refViews=Pe()}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)}set isPanel(e){this._controller.getConditionStateManager().setState({panel:e})}get isPanel(){return!!this._controller.getConditionStateManager().getState().panel}static async getConfigElement(){return await YA.getConfigElement()}static getStubConfig(e,t){return YA.getStubConfig(t)}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=r=>{const s="none"!==t&&("outside"===t&&"outerlay"===r&&n===e||"outside"!==t&&"overlay"===r),o="none"!==i&&("outside"===i&&"outerlay"===r&&a===e||"outside"!==i&&"overlay"===r),c="left"===n||"right"===n||"bottom"===n&&"hidden"===t&&"popup"!==i||"top"===n&&"popup"===i;return q`
${s&&c?this._renderMenu(n):""}
${o?this._renderStatusBar(a):""}
${s&&!c?this._renderMenu(n):""}
`};return q`
${"overlay"===e?q`<advanced-camera-card-overlay
>${r("overlay")}</advanced-camera-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`
<advanced-camera-card-menu
${Fe(this._refMenu)}
slot=${be(e)}
.hass=${this._hass}
.menuConfig=${this._config.menu}
.buttons=${this._menuButtonController.calculateButtons(this._hass,this._config,this._controller.getCameraManager(),this._controller.getFoldersManager(),{currentMediaLoadedInfo:this._controller.getMediaLoadedInfoManager().get(),fullscreenManager:this._controller.getFullscreenManager(),inExpandedMode:this._controller.getExpandManager().isExpanded(),mediaPlayerController:this._controller.getMediaPlayerManager(),microphoneManager:this._controller.getMicrophoneManager(),showCameraUIButton:this._controller.getCameraURLManager().hasCameraURL(),view:t,viewManager:this._controller.getViewManager()})}
.entityRegistryManager=${this._controller.getEntityRegistryManager()}
></advanced-camera-card-menu>
`}_renderStatusBar(e){if(this._config)return q`
<advanced-camera-card-status-bar
slot=${be(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}
></advanced-camera-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="outside"===this._config?.menu.style||"outside"===this._config?.status_bar.style,t={main:!0,"curve-top":!e||"top"!==this._config?.menu.position&&"top"!==this._config?.status_bar.position,"curve-bottom":!e||"bottom"!==this._config?.menu.position&&"bottom"!==this._config?.status_bar.position},n=this._controller.getActionsManager().getMergedActions(),i=this._controller.getCameraManager(),a=!1!==this._config?.performance?.features.card_loading_indicator&&!this._controller.getMessageManager().hasMessage();return this._renderInDialogIfNecessary(q` <advanced-camera-card-effects
${Fe(this._refEffects)}
></advanced-camera-card-effects>
<ha-card
id="ha-card"
.actionHandler=${Kd({hasHold:Vd(n.hold_action),hasDoubleClick:Vd(n.double_tap_action)})}
style="${He(this._controller.getStyleManager().getAspectRatioStyle())}"
@advanced-camera-card:message=${e=>this._controller.getMessageManager().setMessageIfHigherPriority(e.detail)}
@advanced-camera-card:media:loaded=${e=>this._controller.getMediaLoadedInfoManager().set(e.detail)}
@advanced-camera-card:media:unloaded=${()=>this._controller.getMediaLoadedInfoManager().clear()}
@advanced-camera-card:media:volumechange=${()=>this.requestUpdate()}
@advanced-camera-card:media:play=${()=>this.requestUpdate()}
@advanced-camera-card:media:pause=${()=>this.requestUpdate()}
@advanced-camera-card:focus=${()=>this.focus()}
>
${a?q`<advanced-camera-card-loading
.loaded=${this._controller.getInitializationManager().wasEverInitialized()}
.effectsControllerAPI=${!1!==this._config?.performance?.features.card_loading_effects?this._controller.getEffectsControllerAPI():void 0}
></advanced-camera-card-loading>`:""}
${this._renderMenuStatusContainer("top")}
${this._renderMenuStatusContainer("overlay")}
<div ${Fe(this._refMain)} class="${ye(t)}">
<advanced-camera-card-views
${Fe(this._refViews)}
.hass=${this._hass}
.viewManagerEpoch=${this._controller.getViewManager().getEpoch()}
.cameraManager=${i}
.foldersManager=${this._controller.getFoldersManager()}
.viewItemManager=${this._controller.getViewItemManager()}
.resolvedMediaCache=${this._controller.getResolvedMediaCache()}
.config=${this._controller.getConfigManager().getConfig()}
.cardWideConfig=${this._controller.getConfigManager().getCardWideConfig()}
.rawConfig=${this._controller.getConfigManager().getRawConfig()}
.configManager=${this._controller.getConfigManager()}
.hide=${!!this._controller.getMessageManager().hasMessage()}
.microphoneState=${this._controller.getMicrophoneManager().getState()}
.conditionStateManager=${this._controller.getConditionStateManager()}
.triggeredCameraIDs=${this._config?.view.triggers.show_trigger_status?this._controller.getTriggersManager().getTriggeredCameraIDs():void 0}
.deviceRegistryManager=${this._controller.getDeviceRegistryManager()}
></advanced-camera-card-views>
${this._controller.getMessageManager().hasMessage()?EO(this._controller.getMessageManager().getMessage()):""}
</div>
${this._renderMenuStatusContainer("bottom")}
${this._config?.elements?q` <advanced-camera-card-elements
${Fe(this._refElements)}
.hass=${this._hass}
.elements=${this._config?.elements}
.conditionStateManager=${this._controller.getConditionStateManager()}
@advanced-camera-card:menu:add=${e=>{this._menuButtonController.addDynamicMenuButton(e.detail),this.requestUpdate()}}
@advanced-camera-card:menu:remove=${e=>{this._menuButtonController.removeDynamicMenuButton(e.detail),this.requestUpdate()}}
@advanced-camera-card:status-bar:add=${e=>{this._controller.getStatusBarItemManager().addDynamicStatusBarItem(e.detail)}}
@advanced-camera-card:status-bar:remove=${e=>{this._controller.getStatusBarItemManager().removeDynamicStatusBarItem(e.detail)}}
@advanced-camera-card:condition-state-manager:get=${e=>{e.conditionStateManager=this._controller.getConditionStateManager()}}
>
</advanced-camera-card-elements>`:""}
</ha-card>`)}static get styles(){return s(':host([themes~=dark]) {\n --card-background-color: #1c1c1c;\n --primary-background-color: #111111;\n --secondary-background-color: #282828;\n --primary-text-color: #e1e1e1;\n --divider-color: rgba(225, 225, 225, 0.12);\n --app-header-background-color: #101e24;\n --app-header-text-color: #e1e1e1;\n}\n\n:host([themes~=light]) {\n --card-background-color: #ffffff;\n --primary-background-color: #fafafa;\n --secondary-background-color: #e5e5e5;\n --primary-text-color: #212121;\n --divider-color: rgba(0, 0, 0, 0.12);\n --app-header-text-color: #ffffff;\n --app-header-background-color: #03a9f4;\n}\n\n:host([themes~=traditional]) {\n /*********\n * General\n *********/\n --advanced-camera-card-control-background: black;\n /******\n * Menu\n ******/\n --advanced-camera-card-menu-button-active-color: var(--primary-color, white);\n --advanced-camera-card-menu-button-background: rgba(0, 0, 0, 0.6);\n --advanced-camera-card-menu-position-left-alignment-top-background: linear-gradient(180deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-left-alignment-bottom-background: linear-gradient(0deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-right-alignment-top-background: linear-gradient(180deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-right-alignment-bottom-background: linear-gradient(0deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-top-alignment-left-background: linear-gradient(90deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-top-alignment-right-background: linear-gradient(270deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-bottom-alignment-left-background: linear-gradient(90deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-bottom-alignment-right-background: linear-gradient(270deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-menu-position-top-alignment-left-style-outside-background: var(\n --secondary-background-color\n );\n --advanced-camera-card-menu-position-top-alignment-right-style-outside-background: var(\n --secondary-background-color\n );\n --advanced-camera-card-menu-position-bottom-alignment-left-style-outside-background: var(\n --secondary-background-color\n );\n --advanced-camera-card-menu-position-bottom-alignment-right-style-outside-background: var(\n --secondary-background-color\n );\n /************\n * Status bar\n ************/\n --advanced-camera-card-status-bar-color: white;\n --advanced-camera-card-status-bar-position-top-background: linear-gradient(90deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-status-bar-position-bottom-background: linear-gradient(90deg, var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), var(--advanced-camera-card-menu-background), color-mix(in oklab, var(--advanced-camera-card-menu-background), transparent 100%));\n --advanced-camera-card-status-bar-position-top-style-outside-background: var(\n --secondary-background-color\n );\n --advanced-camera-card-status-bar-position-bottom-style-outside-background: var(\n --secondary-background-color\n );\n --advanced-camera-card-status-bar-position-top-style-outside-color: var(\n --secondary-text-color\n );\n --advanced-camera-card-status-bar-position-bottom-style-outside-color: var(\n --secondary-text-color\n );\n}\n\n:host {\n /*********\n * General\n *********/\n --advanced-camera-card-exterior: var(--secondary-background-color, black);\n --advanced-camera-card-background: var(--card-background-color, white);\n --advanced-camera-card-foreground-primary: var(--primary-color, black);\n --advanced-camera-card-active-color: var(--accent-color, orange);\n --advanced-camera-card-warning-color: var(--error-color, red);\n --advanced-camera-card-text-color: var(--primary-text-color);\n --advanced-camera-card-divider-color: var(--divider-color);\n --advanced-camera-card-border-radius-final: var(\n --advanced-camera-card-border-radius-override,\n var(--advanced-camera-card-border-radius, var(--ha-card-border-radius, 4px))\n );\n --advanced-camera-card-control-background: var(--app-header-background-color);\n --advanced-camera-card-control-background-opacity: 60%;\n --advanced-camera-card-control-background-transparent: color-mix(\n in oklab,\n var(--advanced-camera-card-control-background),\n transparent var(--advanced-camera-card-control-background-opacity)\n );\n --advanced-camera-card-control-foreground: var(--app-header-text-color);\n /*********\n * Buttons\n *********/\n --advanced-camera-card-button-color: var(--advanced-camera-card-control-foreground);\n --advanced-camera-card-button-background: var(\n --advanced-camera-card-control-background-transparent\n );\n --advanced-camera-card-button-border-radius: 50%;\n /******\n * Menu\n ******/\n --advanced-camera-card-menu-button-active-color: var(\n --advanced-camera-card-active-color\n );\n --advanced-camera-card-menu-button-inactive-color: var(\n --advanced-camera-card-button-color\n );\n --advanced-camera-card-menu-button-critical-color: var(\n --error-color,\n var(--advanced-camera-card-warning-color)\n );\n --advanced-camera-card-menu-button-background: color-mix(\n in oklab,\n var(--advanced-camera-card-menu-button-inactive-color),\n transparent var(--advanced-camera-card-control-background-opacity)\n );\n --advanced-camera-card-menu-background: var(\n --advanced-camera-card-control-background-transparent\n );\n --advanced-camera-card-menu-style-outside-background: var(\n --advanced-camera-card-control-background\n );\n --advanced-camera-card-menu-override-background: unset;\n --advanced-camera-card-menu-override-button-inactive-color: unset;\n --advanced-camera-card-menu-override-button-background: unset;\n /************\n * Status bar\n ************/\n --advanced-camera-card-status-bar-override-background: unset;\n --advanced-camera-card-status-bar-override-color: unset;\n --advanced-camera-card-status-bar-color: var(\n --advanced-camera-card-control-foreground\n );\n --advanced-camera-card-status-bar-background: var(\n --advanced-camera-card-control-background-transparent\n );\n --advanced-camera-card-status-bar-style-outside-background: var(\n --advanced-camera-card-control-background\n );\n /************\n * Thumbnails\n ************/\n --advanced-camera-card-thumbnail-icon-color: var(\n --advanced-camera-card-foreground-primary\n );\n --advanced-camera-card-thumbnail-border-color: var(\n --advanced-camera-card-foreground-primary\n );\n --advanced-camera-card-thumbnail-background: var(--advanced-camera-card-background);\n --advanced-camera-card-thumbnail-icon-favorite-color: color-mix(\n in oklab,\n gold,\n transparent 25%\n );\n --advanced-camera-card-thumbnail-text-color: var(--advanced-camera-card-text-color);\n /**********\n * Timeline\n **********/\n --advanced-camera-card-timeline-text-color: var(--advanced-camera-card-text-color);\n --advanced-camera-card-timeline-item-color: var(\n --advanced-camera-card-foreground-primary\n );\n --advanced-camera-card-timeline-tool-color: var(\n --advanced-camera-card-foreground-primary\n );\n --advanced-camera-card-timeline-background: var(--advanced-camera-card-background);\n --advanced-camera-card-timeline-background-item-color: color-mix(\n in oklab,\n var(--advanced-camera-card-timeline-item-color),\n transparent 90%\n );\n --advanced-camera-card-timeline-divider-color: var(\n --advanced-camera-card-divider-color\n );\n --advanced-camera-card-timeline-target-bar-color: var(\n --advanced-camera-card-active-color\n );\n /*******************\n * Loading Indicator\n *******************/\n --advanced-camera-card-loading-background-color: var(\n --advanced-camera-card-control-background-transparent\n );\n --advanced-camera-card-loading-foreground-color: var(\n --advanced-camera-card-control-foreground\n );\n /*********\n * Message\n *********/\n --advanced-camera-card-message-color: var(--advanced-camera-card-text-color);\n --advanced-camera-card-message-background: var(--advanced-camera-card-background);\n --advanced-camera-card-message-overlay-background: var(\n --advanced-camera-card-control-background-transparent\n );\n --advanced-camera-card-message-overlay-color: var(\n --advanced-camera-card-control-foreground\n );\n /*********\n * Trigger\n *********/\n --advanced-camera-card-trigger-border-color: var(--advanced-camera-card-warning-color);\n --advanced-camera-card-trigger-border-color-base: unset;\n /*****\n * Grid\n ******/\n --advanced-camera-card-grid-selected-border-color: var(\n --advanced-camera-card-foreground-primary\n );\n /****\n * PTZ\n *****/\n --advanced-camera-card-ptz-color: var(--advanced-camera-card-control-foreground);\n --advanced-camera-card-ptz-background: var(--advanced-camera-card-control-background);\n --advanced-camera-card-ptz-color-active: color-mix(\n in oklab,\n var(--advanced-camera-card-ptz-color),\n transparent 20%\n );\n --advanced-camera-card-ptz-background-active: color-mix(\n in oklab,\n var(--advanced-camera-card-ptz-background),\n transparent 20%\n );\n --advanced-camera-card-ptz-color-inactive: color-mix(\n in oklab,\n var(--advanced-camera-card-ptz-color),\n transparent var(--advanced-camera-card-control-background-opacity)\n );\n --advanced-camera-card-ptz-background-inactive: color-mix(\n in oklab,\n var(--advanced-camera-card-ptz-background),\n transparent var(--advanced-camera-card-control-background-opacity)\n );\n}\n\n/************\n * Managing z-indicies and stacking contexts is very challenging on the card,\n * due to the volume of different potentially overlapping surfaces. In\n * particular, care must be taken to not generate new stacking contexts\n * inadvertently which would make "z-index" weaving challenging (e.g. submenu\n * shown for PTZ presets, needs to render "over" the media drawer open/close\n * control).\n *************/\n:host {\n display: block;\n position: relative;\n background-color: var(--advanced-camera-card-background);\n border-radius: var(--advanced-camera-card-border-radius-final);\n overflow: auto;\n height: var(--advanced-camera-card-height);\n min-height: 100px;\n pointer-events: all;\n --advanced-camera-card-expand-max-height: calc((100vh - (2 * 56px)) * 0.85);\n --advanced-camera-card-expand-max-width: 85vw;\n --advanced-camera-card-expand-width: none;\n --advanced-camera-card-expand-height: none;\n --advanced-camera-card-expand-aspect-ratio: unset;\n --advanced-camera-card-height: auto;\n}\n\n:host(:not(:hover):not([expanded])) {\n z-index: auto;\n isolation: isolate;\n}\n\nadvanced-camera-card-loading {\n position: absolute;\n inset: 0;\n z-index: 6;\n}\n\n:host([dimmable]:not([interaction])) {\n filter: brightness(75%);\n}\n\n:host([panel]:not([casted])) {\n height: calc(100vh - var(--kiosk-header-height, 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 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\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 background-color: transparent;\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) advanced-camera-card-menu {\n border-radius: 0px;\n}\n\n:host(:-webkit-full-screen) div.main,\n:host(:-webkit-full-screen) advanced-camera-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(--advanced-camera-card-expand-max-height);\n --dialog-max-width: var(--advanced-camera-card-expand-max-width);\n --dialog-width: var(--advanced-camera-card-expand-width);\n --dialog-height: var(--advanced-camera-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(--advanced-camera-card-expand-aspect-ratio);\n border-radius: 0px;\n background: transparent;\n}\n\n/*******************\n * Menu hover styles\n *******************/\nadvanced-camera-card-menu {\n z-index: 4;\n}\n\nadvanced-camera-card-menu[data-style*=hover] {\n transition: opacity 0.5s ease;\n opacity: 0;\n}\n\nadvanced-camera-card-menu[data-style*=hover]:hover,\nha-card:hover > advanced-camera-card-overlay > advanced-camera-card-menu[data-style=hover-card] {\n opacity: 1;\n}\n\n/*************************\n * Status bar hover styles\n *************************/\nadvanced-camera-card-status-bar {\n z-index: 2;\n}\n\nadvanced-camera-card-status-bar[data-style*=hover] {\n transition: opacity 0.5s ease;\n opacity: 0;\n}\n\nadvanced-camera-card-status-bar[data-style*=hover]:hover,\nha-card:hover > advanced-camera-card-overlay > advanced-camera-card-status-bar[data-style=hover-card] {\n opacity: 1;\n}')}getCardSize(){return 6}};$D=e([de("advanced-camera-card")],$D);let ID=class extends $D{};ID=e([de("frigate-card")],ID);export{_C as $,cm as A,lm as B,Xp as C,um as D,dm as E,Vp as F,Hp as G,Up as H,qp as I,Wp as J,Zp as K,Kp as L,Qp as M,Yp as N,Eg as O,fg as P,xi as Q,Gv as R,Mi as S,ig as T,Xf as U,Jf as V,eg as W,ng as X,ki as Y,Yv as Z,e as _,le as a,hf as a$,yC as a0,ud as a1,Ip as a2,mM as a3,EO as a4,bh as a5,d_ as a6,wh as a7,tt as a8,fM as a9,Ff as aA,$f as aB,Lf as aC,Df as aD,If as aE,Of as aF,af as aG,pf as aH,rf as aI,sf as aJ,_f as aK,vf as aL,bf as aM,wf as aN,yf as aO,mf as aP,ff as aQ,gf as aR,Cf as aS,Af as aT,Tf as aU,xf as aV,Mf as aW,Ef as aX,kf as aY,Sf as aZ,uf as a_,Vg as aa,Np as ab,Rp as ac,Fp as ad,Bp as ae,Gp as af,im as ag,pg as ah,hg as ai,dg as aj,mg as ak,kg as al,Mg as am,Sg as an,QS as ao,Cg as ap,Rf as aq,jf as ar,Uf as as,zf as at,Pf as au,Jm as av,ef as aw,tf as ax,nf as ay,Nf as az,fe as b,Pg as b$,df as b0,cf as b1,lf as b2,of as b3,Bf as b4,Hf as b5,Vf as b6,vm as b7,mm as b8,gm as b9,zm as bA,qm as bB,Km as bC,Qm as bD,Vm as bE,Hm as bF,Zm as bG,Um as bH,Wm as bI,Kf as bJ,Yf as bK,Wf as bL,Zf as bM,Qf as bN,tg as bO,rg as bP,sg as bQ,cg as bR,lg as bS,og as bT,ag as bU,$g as bV,Tg as bW,Ig as bX,zg as bY,jg as bZ,Dg as b_,_m as ba,fm as bb,pm as bc,bm as bd,wm as be,xm as bf,Mm as bg,Tm as bh,Gm as bi,$m as bj,Om as bk,Im as bl,km as bm,Em as bn,Am as bo,Cm as bp,Sm as bq,Lm as br,Ym as bs,Dm as bt,jm as bu,Bm as bv,Pm as bw,Nm as bx,Fm as by,Rm as bz,pM as c,mp as c$,Ug as c0,Rg as c1,Bg as c2,Fg as c3,Hg as c4,hM as c5,uM as c6,zp as c7,jp as c8,Lp as c9,Vh as cA,Uh as cB,Xh as cC,Jh as cD,np as cE,tp as cF,wp as cG,bp as cH,xp as cI,Mp as cJ,Eh as cK,Ah as cL,Th as cM,$h as cN,Ih as cO,ip as cP,sp as cQ,op as cR,cp as cS,lp as cT,up as cU,dp as cV,hp as cW,ap as cX,rp as cY,Ch as cZ,Sh as c_,Dp as ca,Op as cb,Mh as cc,ep as cd,Gh as ce,Nh as cf,Fh as cg,xh as ch,kh as ci,Dh as cj,Lh as ck,jh as cl,Oh as cm,Yh as cn,Wh as co,Zh as cp,Kh as cq,Qh as cr,yp as cs,vp as ct,zh as cu,Ph as cv,Rh as cw,Hh as cx,qh as cy,Bh as cz,gM as d,ja as d$,fp as d0,pp as d1,_p as d2,gp as d3,Ng as d4,pE as d5,lA as d6,Pe as d7,uA as d8,Fe as d9,pd as dA,VA as dB,qd as dC,Pu as dD,hD as dE,uD as dF,Bd as dG,$T as dH,Rd as dI,Kd as dJ,Vd as dK,sA as dL,qg as dM,_e as dN,ve as dO,W as dP,kd as dQ,Ad as dR,DO as dS,LO as dT,Ii as dU,qi as dV,c as dW,D_ as dX,rd as dY,Ir as dZ,Qu as d_,vh as da,Qv as db,zL as dc,Ud as dd,bv as de,be as df,_D as dg,vC as dh,LA as di,md as dj,$A as dk,IA as dl,WA as dm,cA as dn,dA as dp,hA as dq,pA as dr,lh as ds,iv as dt,DE as du,jE as dv,kT as dw,CA as dx,cD as dy,sh as dz,ye as e,qv as e$,_d as e0,Or as e1,ed as e2,oy as e3,ge as e4,Ae as e5,Ce as e6,ke as e7,Te as e8,Ee as e9,z_ as eA,vd as eB,bd as eC,j_ as eD,b_ as eE,xd as eF,OE as eG,x_ as eH,w_ as eI,M_ as eJ,Fd as eK,zE as eL,MA as eM,p_ as eN,L_ as eO,Yd as eP,Ed as eQ,xe as eR,Z as eS,LT as eT,oA as eU,Vv as eV,Hv as eW,Uv as eX,Id as eY,Wv as eZ,Gu as e_,Ld as ea,Qd as eb,C_ as ec,S_ as ed,__ as ee,ji as ef,OA as eg,T_ as eh,fd as ei,Zv as ej,gd as ek,UA as el,DA as em,Cd as en,Yi as eo,A_ as ep,ad as eq,bi as er,wd as es,m_ as et,sd as eu,R_ as ev,O_ as ew,td as ex,rh as ey,oh as ez,fE as f,o as f0,Od as f1,ED as f2,iy as f3,oD as f4,ay as f5,OM as g,dM as h,Uu as i,GA as j,ld as k,u_ as l,nm as m,me as n,em as o,qS as p,Jp as q,s as r,Md as s,de as t,tm as u,am as v,sm as w,q as x,rm as y,om as z};