Home-AssistantConfig/config/www/community/frigate-hass-card/gallery-15a600d2.js

185 lines
110 KiB
JavaScript
Raw Normal View History

2024-12-17 17:05:10 +00:00
import{d3 as e,d4 as t,d5 as r,l as i,d6 as o,d7 as n,d8 as a,d9 as s,i as l,da as c,db as d,k as h,dc as g,dd as u,de as m,df as p,_ as f,n as v,cW as b,cR as y,dg as w,x as $,cV as x,r as k,a as _,t as C,e as T,b as E,dh as O,di as S,cI as M,dj as z,dk as L,cU as D,dl as A,c$ as F}from"./card-769e2b91.js";import{e as I}from"./endOfDay-696ac7f4.js";import{p as W}from"./parse-7dfc1897.js";import{F as R}from"./date-picker-8102261e.js";function N(t){const r=e(t),i=r.getMonth();return r.setFullYear(r.getFullYear(),i+1,0),r.setHours(23,59,59,999),r}function H(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),i=e.getDate(),o=new Date(0);return o.setFullYear(t,r,i-1),o.setHours(23,59,59,999),o}function V(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),i=e.getDate(),o=new Date(0);return o.setFullYear(t,r,i-1),o.setHours(0,0,0,0),o}var j,B,q;
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function P(e){return class extends e{createRenderRoot(){const e=this.constructor,{registry:t,elementDefinitions:i,shadowRootOptions:o}=e;i&&!t&&(e.registry=new CustomElementRegistry,Object.entries(i).forEach((([t,r])=>e.registry.define(t,r))));const n=this.renderOptions.creationScope=this.attachShadow({...o,customElements:e.registry});return r(n,this.constructor.elementStyles),n}}}!function(e){e.Favorite="favorite",e.NotFavorite="not-favorite"}(j||(j={})),function(e){e.Today="today",e.Yesterday="yesterday",e.PastWeek="past-week",e.PastMonth="past-month",e.Custom="custom"}(B||(B={})),function(e){e.Clips="clips",e.Snapshots="snapshots",e.Recordings="recordings"}(q||(q={}));class U{constructor(e){this._cameraOptions=[],this._whenOptions=[],this._metaDataWhenOptions=[],this._whatOptions=[],this._whereOptions=[],this._tagsOptions=[],this._defaults=null,this._viewManager=null,this._host=e,this._favoriteOptions=[{value:j.Favorite,label:i("media_filter.favorite")},{value:j.NotFavorite,label:i("media_filter.not_favorite")}],this._mediaTypeOptions=[{value:q.Clips,label:i("media_filter.media_types.clips")},{value:q.Snapshots,label:i("media_filter.media_types.snapshots")},{value:q.Recordings,label:i("media_filter.media_types.recordings")}],this._staticWhenOptions=[{value:B.Today,label:i("media_filter.whens.today")},{value:B.Yesterday,label:i("media_filter.whens.yesterday")},{value:B.PastWeek,label:i("media_filter.whens.past_week")},{value:B.PastMonth,label:i("media_filter.whens.past_month")},{value:B.Custom,label:i("media_filter.whens.custom")}],this._computeWhenOptions()}getMediaTypeOptions(){return this._mediaTypeOptions}getCameraOptions(){return this._cameraOptions}getWhenOptions(){return this._whenOptions}getWhatOptions(){return this._whatOptions}getWhereOptions(){return this._whereOptions}getTagsOptions(){return this._tagsOptions}getFavoriteOptions(){return this._favoriteOptions}getDefaults(){return this._defaults}setViewManager(e){this._viewManager=e}async valueChangeHandler(e,t,r,i){const s=e=>e&&Array.isArray(e)&&e.length&&!e.includes("")?new Set([...e]):null,l=s(r.camera)??this._getAllCameraIDs(e);if(!l.size||!r.mediaType)return;const c=this._getWhen(r.when),d=r.favorite?r.favorite===j.Favorite:null,h=t.performance?.features.media_chunk_size;if(r.mediaType===q.Clips||r.mediaType===q.Snapshots){const e=s(r.where),t=s(r.what),i=s(r.tags),a=new o([{type:n.Event,cameraIDs:l,...i&&{tags:i},...t&&{what:t},...e&&{where:e},...null!==d&&{favorite:d},...c&&{...c.start&&{start:c.start},...c.end&&{end:c.end}},...h&&{limit:h},...r.mediaType===q.Clips&&{hasClip:!0},...r.mediaType===q.Snapshots&&{hasSnapshot:!0}}]);this._viewManager?.setViewByParametersWithExistingQuery({params:{query:a,...1===l.size&&{camera:[...l][0]},view:r.mediaType===q.Clips?"clips":"snapshots"}})}else{const e=new a([{type:n.Recording,cameraIDs:l,...h&&{limit:h},...c&&{...c.start&&{start:c.start},...c.end&&{end:c.end}},...null!==d&&{favorite:d}}]);this._viewManager?.setViewByParametersWithExistingQuery({params:{query:e,...1===l.size&&{camera:[...l][0]},view:"recordings"}})}this._host.requestUpdate()}_getAllCameraIDs(e){return e.getStore().getCameraIDsWithCapability({anyCapabilities:["clips","snapshots","recordings"]})}computeInitialDefaultsFromView(e){const t=this._viewManager?.getView(),r=t?.query?.getQueries(),i=this._getAllCameraIDs(e);if(!t||!r||!i.size)return;let o,n,a,d,h,g;1!==s(r.map((e=>e.cameraIDs)),l).length||l(r[0].cameraIDs,i)||(n=[...r[0].cameraIDs]);
/* istanbul ignore else: the else path cannot be reached -- @preserve */
if(1===s(r.map((e=>e.favorite)),l).length&&void 0!==r[0].favorite&&(h=r[0].favorite?j.Favorite:j.NotFavorite),c.areEventQueries(t.query)){const e=t.query.getQueries();
/* istanbul ignore if: the if path cannot be reached -- @preserve */if(!e)return;const r=s(e.map((e=>e.hasClip)),l),i=s(e.map((e=>e.hasSnapshot)),l);1===r.length&&1===i.length&&(o=r[0]?q.Clips:i[0]?q.Snapshots:void 0);1===s(e.map((e=>e.what)),l).length&&e[0].what?.size&&(a=[...e[0].what]);1===s(e.map((e=>e.where)),l).length&&e[0].where?.size&&(d=[...e[0].where]);1===s(e.map((e=>e.tags)),l).length&&e[0].tags?.size&&(g=[...e[0].tags])}else c.areRecordingQueries(t.query)&&(o=q.Recordings);this._defaults={...o&&{mediaType:o},...n&&{cameraIDs:n},...a&&{what:a},...d&&{where:d},...void 0!==h&&{favorite:h},...g&&{tags:g}}}computeCameraOptions(e){this._cameraOptions=[...this._getAllCameraIDs(e)].map((t=>({value:t,label:e.getCameraMetadata(t)?.title??t})))}async computeMetadataOptions(e){let t=null;try{t=await e.getMediaMetadata()}catch(e){d(e)}if(t){if(t.what&&(this._whatOptions=[...t.what].sort().map((e=>({value:e,label:h(e)})))),t.where&&(this._whereOptions=[...t.where].sort().map((e=>({value:e,label:h(e)})))),t.tags&&(this._tagsOptions=[...t.tags].sort().map((e=>({value:e,label:h(e)})))),t.days){const e=new Set;[...t.days].forEach((t=>{e.add(t.substring(0,7))}));const r=[];e.forEach((e=>{r.push(W(e,"yyyy-MM",new Date))})),this._metaDataWhenOptions=g(r,(e=>e.getTime()),"desc").map((e=>({label:u(e,"MMMM yyyy"),value:this._dateRangeToString({start:e,end:N(e)})}))),this._computeWhenOptions()}this._host.requestUpdate()}}getControlsToShow(e){const t=this._viewManager?.getView(),r=c.areEventQueries(t?.query),i=c.areRecordingQueries(t?.query),o=e.getAggregateCameraCapabilities();return{events:r,recordings:i,favorites:r?o?.has("favorite-events"):!!i&&o?.has("favorite-recordings")}}_computeWhenOptions(){this._whenOptions=[...this._staticWhenOptions,...this._metaDataWhenOptions]}_dateRangeToString(e){return`${m(e.start)},${m(e.end)}`}_stringToDateRange(e){const t=e.split(",");return{start:W(t[0],"yyyy-MM-dd",new Date),end:I(W(t[1],"yyyy-MM-dd",new Date))}}_getWhen(e){if(e.from||e.to)return{...e.from&&{start:e.from},...e.to&&{end:e.to}};if(!e.selected||Array.isArray(e.selected))return null;const r=new Date;switch(e.selected){case B.Custom:return null;case B.Today:return{start:t(Date.now()),end:I(Date.now())};case B.Yesterday:return{start:V(),end:H()};case B.PastWeek:return{start:t(p(r,{days:7})),end:I(r)};case B.PastMonth:return{start:t(p(r,{months:1})),end:I(r)};default:return this._stringToDateRange(e.selected)}}}const K=!0,Y=!0,Q=!0,G=!1,X=!1;let Z,J,ee,te=!1,re=!1,ie=!1,oe=!1,ne=null,ae=!1;const se="http://www.w3.org/1999/xlink",le={},ce=e=>"object"===(e=typeof e)||"function"===e;const de=(e,t,...r)=>{let i=null,o=null,n=null,a=!1,s=!1;const l=[],c=t=>{for(let r=0;r<t.length;r++)i=t[r],Array.isArray(i)?c(i):null!=i&&"boolean"!=typeof i&&((a="function"!=typeof e&&!ce(i))&&(i=String(i)),a&&s?l[l.length-1].$text$+=i:l.push(a?he(null,i):i),s=a)};if(c(r),t){t.key&&(o=t.key),t.name&&(n=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,l,ue);const d=he(e,null);return d.$attrs$=t,l.length>0&&(d.$children$=l),d.$key$=o,d.$name$=n,d},he=(e,t)=>{const r={$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null,$key$:null,$name$:null};return r},ge={},ue={forEach:(e,t)=>e.map(me).forEach(t),map:(e,t)=>e.map(me).map(t).map(pe)},me=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),pe=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),de(e.vtag,t,...e.vchildren||[])}const t=he(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},fe=(e,t,r)=>{const i=e;return{emit:e=>ve(i,t,{bubbles:!!(4&r),composed:!!(2&r),cancelable:!!(1&r),detail:e})}},ve=(e,t,r)=>{const i=ht.ce(t,r);return e.dispatchEvent(i),i},be=new WeakMap,ye=e=>{const t=e.$cmpMeta$,r=e.$hostElement$,i=t.$flags$,o=(t.$tagName$,()=>{}),n=((e,t,r,i)=>{var o;let n=we(t,r);const a=at.get(n);if(e=11===e.n
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
function kt(e){const t=e?e.assignedNodes({flatten:!0}):[];let r="";return[...t].map((e=>{e.nodeType===Node.TEXT_NODE&&(r+=e.textContent)})),r}function _t(e,t){return t?null!==e.querySelector(`[slot="${t}"]`):[...e.childNodes].some((e=>{if(e.nodeType===e.TEXT_NODE&&""!==e.textContent.trim())return!0;if(e.nodeType===e.ELEMENT_NODE){if(!e.hasAttribute("slot"))return!0}return!1}))}
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/const Ct=(e,t=[])=>{const r={};return t.forEach((t=>{if(e.hasAttribute(t)){null!==e.getAttribute(t)&&(r[t]=e.getAttribute(t)),e.removeAttribute(t)}})),r},Tt=Ge(class extends dt{constructor(){super(),this.__registerHost(),this.__attachShadow()}render(){return de("span",{class:"spinner","aria-busy":"true","aria-live":"polite"})}static get style(){return":host{--track-color:var(--gr-color-light-shade);--indicator-color:var(--gr-color-primary);--stroke-width:2px;display:inline-flex;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}.spinner{display:inline-block;width:1em;height:1em;border-radius:50%;border:solid var(--stroke-width) var(--track-color);border-top-color:var(--indicator-color);border-right-color:var(--indicator-color);animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}"}},[1,"gr-spinner"]);function Et(){if("undefined"==typeof customElements)return;["gr-spinner"].forEach((e=>{if("gr-spinner"===e)customElements.get(e)||customElements.define(e,Tt)}))}Et();
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
const Ot=Ge(class extends dt{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.grFocus=fe(this,"gr-focus",7),this.grBlur=fe(this,"gr-blur",7),this.inheritedAttributes={},this.handleClick=e=>{if("button"!==this.type){const t=this.el.closest("form");if(t){e.preventDefault();const r=document.createElement("button");r.type=this.type,r.style.display="none",t.appendChild(r),r.click(),r.remove()}}},this.onFocus=()=>{this.grFocus.emit()},this.onBlur=()=>{this.grBlur.emit()},this.variant="default",this.disabled=!1,this.loading=!1,this.size="medium",this.caret=!1,this.pill=!1,this.expand=void 0,this.circle=!1,this.href=void 0,this.target=void 0,this.rel=void 0,this.type="button"}componentWillLoad(){this.inheritedAttributes=Ct(this.el,["aria-label","tabindex","title"])}async setFocus(e){this.button.focus(e)}async removeFocus(){this.button.blur()}render(){const{rel:e,target:t,href:r,variant:i,size:o,expand:n,type:a,inheritedAttributes:s,disabled:l}=this,c=void 0===r?"button":"a",d="button"===c?{type:a}:{href:r,rel:e,target:t};return de(ge,{onClick:this.handleClick,"aria-disabled":l?"true":null,class:{[`button-${i}`]:!0,[`button-${o}`]:!0,[`button-${n}`]:void 0!==n,"button-caret":this.caret,"button-circle":this.circle,"button-pill":this.pill,"button-disabled":l,"button-loading":this.loading}},de(c,Object.assign({ref:e=>this.button=e},d,{class:"button-native",disabled:l,onFocus:this.onFocus,onBlur:this.onBlur},s),de("span",{class:"button-inner"},de("slot",{name:"icon-only"}),de("slot",{name:"start"}),de("slot",null),de("slot",{name:"end"}),this.caret&&de("span",{class:"caret"},de("svg",{role:"img","aria-hidden":"true",viewBox:"0 0 512 512"},de("title",null,"Chevron Down"),de("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"M112 184l144 144 144-144"})))),this.loading&&de("gr-spinner",null)))}get el(){return this}static get style(){return".gr-scroll-lock{overflow:hidden !important}:host{display:inline-block;width:auto;font-family:var(--gr-font-family);font-weight:var(--gr-font-weight-medium);font-size:var(--gr-form-element-font-size-medium);font-kerning:none;user-select:none;vertical-align:top;vertical-align:-webkit-baseline-middle;pointer-events:auto;--height:var(--gr-form-element-height-medium);--border-radius:var(--gr-form-element-border-radius-medium);--border-width:1px;--border-style:solid;--background:transparent;--background-hover:transparent;--background-focus:transparent;--color:var(--gr-color-dark-tint);--color-hover:var(--gr-color-dark-tint);--color-focus:var(--gr-color-dark-tint);--border-color:var(--gr-color-light-shade);--border-color-hover:var(--gr-color-medium);--border-color-focus:var(--gr-color-primary);--padding-top:0;--padding-start:var(--gr-spacing-medium);--padding-end:var(--gr-spacing-medium);--padding-bottom:0;--focus-ring:0 0 0 var(--gr-focus-ring-width) rgb(var(--gr-color-primary-rgb), 0.33);--shadow:none;--transition:background-color 150ms linear, opacity 150ms linear, border 150ms linear, color 150ms linear}:host(.button-disabled){pointer-events:none;opacity:0.5}:host(.button-primary){--border-color:var(--gr-color-primary);--background:var(--gr-color-primary);--color:var(--gr-color-primary-contrast);--border-color-hover:var(--gr-color-primary-shade);--background-hover:var(--gr-color-primary-shade);--color-hover:var(--gr-color-primary-contrast);--border-color-focus:var(--gr-color-primary);--background-focus:var(--gr-color-primary-shade);--color-focus:var(--gr-color-primary-contrast);--focus-ring:0 0 0 var(--gr-focus-ring-width) rgb(var(--gr-color-primary-rgb), 0.33)}:host(.button-secondary){--border-color:var(--gr-color-light-shade);--background:transparent;--color:var(--gr-color-primary);--border-color-hover:var(--gr-color-primary);--background-hover:transparent;--color-hover:var(--gr-color-primary);--border-color-focus:var(--gr-color-primary);--background-focus:transparent;--color-focus:var(--gr-color-primary);--focus-ring:0 0 0 var(--gr-focus-ring-width) rgb(var(--gr-color-primary-rgb), 0.33)}:host(.button-danger){--bor
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
function(e,t){return{top:Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top),left:Math.round(e.getBoundingClientRect().left-t.getBoundingClientRect().left)}}(e,t),n=o.top+t.scrollTop,a=o.left+t.scrollLeft,s=t.scrollLeft,l=t.scrollLeft+t.offsetWidth,c=t.scrollTop,d=t.scrollTop+t.offsetHeight;"horizontal"!==r&&"both"!==r||(a<s?t.scrollTo({left:a,behavior:i}):a+e.clientWidth>l&&t.scrollTo({left:a-t.offsetWidth+e.clientWidth,behavior:i})),"vertical"!==r&&"both"!==r||(n<c?t.scrollTo({top:n,behavior:i}):n+e.clientHeight>d&&t.scrollTo({top:n-t.offsetHeight+e.clientHeight,behavior:i}))}
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/function zt(e){return e.tabIndex>-1}function Lt(e){if(zt(e))return e;if(e.shadowRoot){const t=[...e.shadowRoot.children].find(zt);if(t)return t}return e.children?[...e.children].map(Lt)[0]:null}St();var Dt="top",At="bottom",Ft="right",It="left",Wt="auto",Rt=[Dt,At,Ft,It],Nt="start",Ht="end",Vt="clippingParents",jt="viewport",Bt="popper",qt="reference",Pt=Rt.reduce((function(e,t){return e.concat([t+"-"+Nt,t+"-"+Ht])}),[]),Ut=[].concat(Rt,[Wt]).reduce((function(e,t){return e.concat([t,t+"-"+Nt,t+"-"+Ht])}),[]),Kt=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Yt(e){return e?(e.nodeName||"").toLowerCase():null}function Qt(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Gt(e){return e instanceof Qt(e).Element||e instanceof Element}function Xt(e){return e instanceof Qt(e).HTMLElement||e instanceof HTMLElement}function Zt(e){return"undefined"!=typeof ShadowRoot&&(e instanceof Qt(e).ShadowRoot||e instanceof ShadowRoot)}const Jt={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var r=t.styles[e]||{},i=t.attributes[e]||{},o=t.elements[e];Xt(o)&&Yt(o)&&(Object.assign(o.style,r),Object.keys(i).forEach((function(e){var t=i[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],o=t.attributes[e]||{},n=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:r[e]).reduce((function(e,t){return e[t]="",e}),{});Xt(i)&&Yt(i)&&(Object.assign(i.style,n),Object.keys(o).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};function er(e){return e.split("-")[0]}var tr=Math.max,rr=Math.min,ir=Math.round;function or(e,t){void 0===t&&(t=!1);var r=e.getBoundingClientRect(),i=1,o=1;if(Xt(e)&&t){var n=e.offsetHeight,a=e.offsetWidth;a>0&&(i=ir(r.width)/a||1),n>0&&(o=ir(r.height)/n||1)}return{width:r.width/i,height:r.height/o,top:r.top/o,right:r.right/i,bottom:r.bottom/o,left:r.left/i,x:r.left/i,y:r.top/o}}function nr(e){var t=or(e),r=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:i}}function ar(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Zt(r)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function sr(e){return Qt(e).getComputedStyle(e)}function lr(e){return["table","td","th"].indexOf(Yt(e))>=0}function cr(e){return((Gt(e)?e.ownerDocument:e.document)||window.document).documentElement}function dr(e){return"html"===Yt(e)?e:e.assignedSlot||e.parentNode||(Zt(e)?e.host:null)||cr(e)}function hr(e){return Xt(e)&&"fixed"!==sr(e).position?e.offsetParent:null}function gr(e){for(var t=Qt(e),r=hr(e);r&&lr(r)&&"static"===sr(r).position;)r=hr(r);return r&&("html"===Yt(r)||"body"===Yt(r)&&"static"===sr(r).position)?t:r||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&Xt(e)&&"fixed"===sr(e).position)return null;var r=dr(e);for(Zt(r)&&(r=r.host);Xt(r)&&["html","body"].indexOf(Yt(r))<0;){var i=sr(r);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return r;r=r.parentNode}return null}(e)||t}function ur(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function mr(e,t,r){return tr(e,rr(t,r))}function pr(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function fr(e,t){return t.reduce((function(t,r){return t[r]=e,t}),{})}const vr={name:"arrow",enabled:!0,phase:"main",fn:function(e){v
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
const Zr=Ge(class extends dt{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.grSelect=fe(this,"gr-select",7),this.typeToSelectString=""}connectedCallback(){this.handleClick=this.handleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}async typeToSelect(e){clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=setTimeout((()=>this.typeToSelectString=""),750),this.typeToSelectString+=e.toLowerCase();const t=this.getItems();for(const e of t){if(kt(e.shadowRoot.querySelector("slot:not([name])")).toLowerCase().trim().substring(0,this.typeToSelectString.length)===this.typeToSelectString){e.setFocus();break}}}getItems(){return[...this.menu.querySelector("slot").assignedElements({flatten:!0})].filter((e=>"gr-menu-item"===e.tagName.toLowerCase()&&!e.disabled))}getActiveItem(){return this.getItems().find((e=>e===document.activeElement))}setActiveItem(e){e.setFocus()}handleClick(e){const t=e.target.closest("gr-menu-item");t&&!t.disabled&&this.grSelect.emit({item:t})}handleKeyDown(e){if("Enter"===e.key){const t=this.getActiveItem();e.preventDefault(),t&&this.grSelect.emit({item:t})}if(" "===e.key&&e.preventDefault(),["ArrowDown","ArrowUp","Home","End"].includes(e.key)){const t=this.getItems(),r=this.getActiveItem();let i=t.indexOf(r);if(t.length)return e.preventDefault(),"ArrowDown"===e.key?i++:"ArrowUp"===e.key?i--:"Home"===e.key?i=0:"End"===e.key&&(i=t.length-1),i<0&&(i=0),i>t.length-1&&(i=t.length-1),void this.setActiveItem(t[i])}this.typeToSelect(e.key)}render(){return de("div",{ref:e=>this.menu=e,class:"menu",role:"menu",onClick:this.handleClick,onKeyDown:this.handleKeyDown},de("slot",null))}static get style(){return".gr-scroll-lock{overflow:hidden !important}:host{--padding-top:var(--gr-spacing-x-small);--padding-bottom:var(--gr-spacing-x-small);display:block;padding-top:var(--padding-top);padding-left:0;padding-right:0;padding-bottom:var(--padding-bottom);box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host:focus{outline:none}"}},[1,"gr-menu",{typeToSelect:[64]}]);function Jr(){if("undefined"==typeof customElements)return;["gr-menu"].forEach((e=>{if("gr-menu"===e)customElements.get(e)||customElements.define(e,Zr)}))}Jr();
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
const ei=Ge(class extends dt{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.grClear=fe(this,"gr-clear",7),this.type="primary",this.size="medium",this.pill=!1,this.clearable=!1,this.truncate=!1,this.title=""}connectedCallback(){this.handleClearClick=this.handleClearClick.bind(this)}handleClearClick(){this.grClear.emit()}render(){return de(ge,{class:{[`tag-${this.type}`]:!0,[`tag-${this.size}`]:!0,"tag-pill":this.pill,"tag-clearable":this.clearable}},de("span",{class:"tag"},de("span",{class:{"tag-truncate":this.truncate},title:this.title},de("slot",null)),this.clearable&&de("gr-button",{variant:"plain",size:this.size,class:"tag-clear","aria-label":"clear",onClick:this.handleClearClick},de("svg",{slot:"icon-only",role:"img","aria-hidden":"true",viewBox:"0 0 512 512"},de("title",null,"Close"),de("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M368 368L144 144M368 144L144 368"})))))}static get style(){return":host{--height:calc(var(--gr-form-element-height-medium) * 0.8);--line-height:calc(var(--gr-form-element-height-medium) - 1px * 2);--border-radius:var(--gr-form-element-border-radius-medium);--border-width:1px;--border-style:solid;--padding-top:0;--padding-start:var(--gr-spacing-small);--padding-end:var(--gr-spacing-small);--padding-bottom:0;--font-size:var(--gr-form-element-font-size-medium);--background-color:rgba(var(--gr-color-primary-rgb), 0.05);--border-color:rgba(var(--gr-color-primary-rgb), 0.2);--color:var(--gr-color-primary-shade);--clear-color:var(--gr-color-primary);--clear-color-hover:var(--gr-color-primary-shade);--clear-margin-left:var(--gr-spacing-xx-small);--clear-margin-right:calc(-1 * var(--gr-spacing-xxx-small));display:inline-block;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host(.tag-success){--background-color:rgba(var(--gr-color-success-rgb), 0.05);--border-color:rgba(var(--gr-color-success-rgb), 0.2);--color:var(--gr-color-success-shade);--clear-color:var(--gr-color-success);--clear-color-hover:var(--gr-color-success-shade)}:host(.tag-info){--background-color:rgba(var(--gr-color-medium-rgb), 0.05);--border-color:rgba(var(--gr-color-medium-rgb), 0.2);--color:var(--gr-color-medium-shade);--clear-color:var(--gr-color-medium);--clear-color-hover:var(--gr-color-medium-shade)}:host(.tag-warning){--background-color:rgba(var(--gr-color-warning-rgb), 0.05);--border-color:rgba(var(--gr-color-warning-rgb), 0.2);--color:var(--gr-color-warning-shade);--clear-color:var(--gr-color-warning);--clear-color-hover:var(--gr-color-warning-shade)}:host(.tag-danger){--background-color:rgba(var(--gr-color-danger-rgb), 0.05);--border-color:rgba(var(--gr-color-danger-rgb), 0.2);--color:var(--gr-color-danger-shade);--clear-color:var(--gr-color-danger);--clear-color-hover:var(--gr-color-danger-shade)}:host(.tag-small){--font-size:var(--gr-form-element-font-size-small);--height:calc(var(--gr-form-element-height-small) * 0.8);--line-height:calc(var(--gr-form-element-height-small) - 1px * 2);--border-radius:var(--gr-form-element-border-radius-small);--padding-start:var(--gr-spacing-x-small);--padding-end:var(--gr-spacing-x-small);--clear-margin-left:var(--gr-spacing-xx-small);--clear-margin-right:calc(-1 * var(--gr-spacing-xxx-small))}:host(.tag-large){--font-size:var(--gr-form-element-font-size-large);--height:calc(var(--gr-form-element-height-large) * 0.8);--line-height:calc(var(--gr-form-element-height-large) - 1px * 2);--border-radius:var(--gr-form-element-border-radius-large);--padding:0 var(--gr-spacing-medium);--clear-margin-left:var(--gr-spacing-xx-small);--clear-margin-right:calc(-1 * var(--gr-spacing-x-small))}.tag{display:flex;align-items:center;border-style:var(--border-style);border-width:var(--border-width);border-radius:var(--border-radius);white-space:nowrap;user-select:none;cursor:default;font-family:var(--gr-font-family);font-size:var(--font-size);font-weight:var(--gr-font-weight-normal);height:var(--height);line-height:var(--line-height);padding-top:var(--padding-top);padding-left:var
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/
const ri="undefined"!=typeof HTMLElement?HTMLElement:class{};let ii=0;const oi=Ge(class extends dt{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.grChange=fe(this,"gr-change",7),this.grFocus=fe(this,"gr-focus",7),this.grBlur=fe(this,"gr-blur",7),this.inputId="select-"+ ++ii,this.labelId=`select-label-${ii}`,this.helpTextId=`select-help-text-${ii}`,this.invalidTextId=`select-invalid-text-${ii}`,this.inheritedAttributes={},this.handleBlur=()=>{this.isOpen||(this.hasFocus=!1,this.grBlur.emit())},this.handleFocus=()=>{this.hasFocus||(this.hasFocus=!0,this.grFocus.emit())},this.hasFocus=!1,this.hasHelpTextSlot=!1,this.hasInvalidTextSlot=!1,this.hasLabelSlot=!1,this.isOpen=!1,this.items=[],this.displayLabel="",this.displayTags=[],this.multiple=!1,this.maxTagsVisible=3,this.disabled=!1,this.name="",this.placeholder="",this.size="medium",this.hoist=!1,this.value="",this.pill=!1,this.label="",this.requiredIndicator=!1,this.helpText="",this.invalidText="",this.invalid=!1,this.clearable=!1}handleDisabledChange(){this.disabled&&this.isOpen&&this.dropdown.hide()}handleLabelChange(){this.handleSlotChange()}handleMultipleChange(){const e=this.getValueAsArray();this.value=this.multiple?e:e[0]||"",this.syncItemsFromValue()}handleValueChange(){this.syncItemsFromValue(),this.grChange.emit()}connectedCallback(){this.handleClearClick=this.handleClearClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleLabelClick=this.handleLabelClick.bind(this),this.handleMenuHide=this.handleMenuHide.bind(this),this.handleMenuShow=this.handleMenuShow.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleSlotChange=this.handleSlotChange.bind(this),this.handleTagInteraction=this.handleTagInteraction.bind(this),this.el.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}componentWillLoad(){this.handleSlotChange(),this.inheritedAttributes=Ct(this.el,["aria-label"])}componentDidLoad(){this.resizeObserver=new ResizeObserver((()=>this.resizeMenu())),this.reportDuplicateItemValues(),requestAnimationFrame((()=>this.syncItemsFromValue()))}disconnectedCallback(){this.el.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}async setFocus(){this.hasFocus=!0,this.grFocus.emit(),this.dropdown.focusOnTrigger()}getItemLabel(e){return kt(e.shadowRoot.querySelector("slot:not([name])"))}getItems(){return[...this.el.querySelectorAll("gr-menu-item")]}getValueAsArray(){return Array.isArray(this.value)?this.value:[this.value]}handleClearClick(e){e.stopPropagation(),this.value=this.multiple?[]:"",this.syncItemsFromValue()}handleKeyDown(e){const t=e.target,r=this.getItems(),i=r[0],o=r[r.length-1];if("gr-tag"!==t.tagName.toLowerCase())if("Tab"!==e.key){if(["ArrowDown","ArrowUp"].includes(e.key)){if(e.preventDefault(),this.isOpen||this.dropdown.show(),"ArrowDown"===e.key&&i)return void i.setFocus();if("ArrowUp"===e.key&&o)return void o.setFocus()}this.isOpen||1!==e.key.length||(e.stopPropagation(),e.preventDefault(),this.dropdown.show(),this.menu.typeToSelect(e.key))}else this.isOpen&&this.dropdown.hide()}handleLabelClick(){this.box.focus()}handleMenuSelect(e){const t=e.detail.item;this.multiple?this.value=this.value.includes(t.value)?this.value.filter((e=>e!==t.value)):[...this.value,t.value]:this.value=t.value,this.syncItemsFromValue()}handleMenuShow(e){this.disabled?e.preventDefault():(this.resizeMenu(),this.resizeObserver.observe(this.el),this.isOpen=!0)}handleMenuHide(){this.resizeObserver.unobserve(this.el),this.isOpen=!1,this.box.focus()}handleSlotChange(){this.hasHelpTextSlot=_t(this.el,"help-text"),this.hasInvalidTextSlot=_t(this.el,"invalid-text"),this.hasLabelSlot=_t(this.el,"label"),this.syncItemsFromValue(),this.reportDuplicateItemValues()}handleTagInteraction(e){e.composedPath().find((e=>{if(e instanceof ri)return e.classList.contains("tag-clear")}))&&e.stopPropagation()}reportDuplicateItemValues(){const e=this.getItems().map((e=>e.value)).filter(((e,t,r)=>r.indexOf(e)!==t));if(e.length)throw new Error('Duplicate value found on <gr-menu-item> in <gr-select>: "'+e.join('", "')
/*!
* (C) PAQT.com B.V. https://paqt.com - MIT License
*/!function(){if("undefined"==typeof customElements)return;["gr-menu-item"].forEach((e=>{if("gr-menu-item"===e)customElements.get(e)||customElements.define(e,si)}))}();const li={"gr-select":ai,"gr-menu-item":si};class ci extends(P(_)){constructor(){super(...arguments),this.value=null,this.multiple=!1,this.clearable=!1,this._refSelect=y()}reset(){this.value=null}_valueChangedHandler(e){const t=this._refSelect.value?.value;if(void 0!==t&&!l(this.value,t)){const e=null===this.value;this.value=t,e||w(this,"select:change",t)}}willUpdate(e){e.has("initialValue")&&this.initialValue&&!this.value&&(this.value=this.initialValue)}render(){return $` <gr-select
${x(this._refSelect)}
label=${this.label??""}
placeholder=${this.placeholder??""}
size="small"
?multiple=${this.multiple}
?clearable=${this.clearable}
.value=${this.value??[]}
@gr-change=${this._valueChangedHandler.bind(this)}
>
${this.options?.map((e=>$`<gr-menu-item value="${e.value??""}"
>${e.label}</gr-menu-item
>`))}
</gr-select>`}static get styles(){return k(':root, :host {\n --gr-color-primary: #1079b2;\n --gr-color-primary-rgb: 16, 121, 178;\n --gr-color-primary-contrast: #ffffff;\n --gr-color-primary-contrast-rgb: 255, 255, 255;\n --gr-color-primary-shade: #0d6696;\n --gr-color-primary-tint: #1499e1;\n --gr-color-secondary: #051f2c;\n --gr-color-secondary-rgb: 5, 31, 44;\n --gr-color-secondary-contrast: #ffffff;\n --gr-color-secondary-contrast-rgb: 255, 255, 255;\n --gr-color-secondary-shade: #000000;\n --gr-color-secondary-tint: #0a415c;\n --gr-color-tertiary: #0c4a6e;\n --gr-color-tertiary-rgb: 12, 74, 110;\n --gr-color-tertiary-contrast: #ffffff;\n --gr-color-tertiary-contrast-rgb: 255, 255, 255;\n --gr-color-tertiary-shade: #083249;\n --gr-color-tertiary-tint: #106393;\n --gr-color-success: #0fbe78;\n --gr-color-success-rgb: 15, 190, 120;\n --gr-color-success-contrast: #000000;\n --gr-color-success-contrast-rgb: 0, 0, 0;\n --gr-color-success-shade: #057f4e;\n --gr-color-success-tint: #12e28f;\n --gr-color-warning: #fbbc4e;\n --gr-color-warning-rgb: 251, 188, 78;\n --gr-color-warning-contrast: #051f2c;\n --gr-color-warning-contrast-rgb: 5, 31, 44;\n --gr-color-warning-shade: #9e6400;\n --gr-color-warning-tint: #fdd187;\n --gr-color-danger: #e60017;\n --gr-color-danger-rgb: 230, 0, 23;\n --gr-color-danger-contrast: #ffffff;\n --gr-color-danger-contrast-rgb: 255, 255, 255;\n --gr-color-danger-shade: #cc0014;\n --gr-color-danger-tint: #ff1f35;\n --gr-color-light: #f4f5f8;\n --gr-color-light-rgb: 244, 245, 248;\n --gr-color-light-contrast: #051f2c;\n --gr-color-light-contrast-rgb: 5, 31, 44;\n --gr-color-light-shade: #d7d8da;\n --gr-color-light-tint: #f9fafb;\n --gr-color-medium: #5e6c78;\n --gr-color-medium-rgb: 94, 108, 120;\n --gr-color-medium-contrast: #ffffff;\n --gr-color-medium-contrast-rgb: 255, 255, 255;\n --gr-color-medium-shade: #48535b;\n --gr-color-medium-tint: #81909c;\n --gr-color-dark: #02131b;\n --gr-color-dark-rgb: 2, 19, 27;\n --gr-color-dark-contrast: #ffffff;\n --gr-color-dark-contrast-rgb: 255, 255, 255;\n --gr-color-dark-shade: #000000;\n --gr-color-dark-tint: #222428;\n --gr-color-white: #ffffff;\n --gr-color-black: #000000;\n --gr-border-radius-small: 0.125rem;\n --gr-border-radius-medium: 0.25rem;\n --gr-border-radius-large: 0.5rem;\n --gr-border-radius-x-large: 1rem;\n --gr-border-width-small: 0.063rem;\n --gr-border-width-medium: 0.125rem;\n --gr-border-width-large: 0.188rem;\n --gr-shadow-x-small: 0 1px 0 #0d131e0d;\n --gr-shadow-small: 0 1px 2px #0d131e1a;\n --gr-shadow-medium: 0 2px 4px #0d131e1a;\n --gr-shadow-large: 0 2px 8px #0d131e1a;\n --gr-shadow-x-large: 0 4px 16px #0d131e1a;\n --gr-spacing-xxx-small: 0.125rem;\n --gr-spacing-xx-small: 0.25rem;\n --gr-spacing-x-small: 0.5rem;\n --gr-spacing-small: 0.75rem;\n --gr-spacing-medium: 1rem;\n --gr-spacing-large: 1.25rem;\n --gr-spacing-x-large: 1.75rem;\n --gr-spacing-xx-large: 2.25rem;\n --gr-spacing-xxx-large: 3rem;\n --gr-spacing-xxxx-large: 4.5rem;\n --gr-font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,\n sans-serif;\n --gr-letter-spacing-dense: -0.015em;\n --gr-letter-spacing-normal: normal;\n --gr-letter-spacing-loose: 0.075em;\n --gr-line-height-dense: 1.4;\n --gr-line-height-normal: 1.8;\n --gr-line-height-loose: 2.2;\n --gr-font-size-xx-small: 0.625rem;\n --gr-font-size-x-small: 0.75rem;\n --gr-font-size-small: 0.875rem;\n --gr-font-size-medium: 1rem;\n --gr-font-size-large: 1.25rem;\n --gr-font-size-x-large: 1.5rem;\n --gr-font-size-xx-large: 2.25rem;\n --gr-font-size-xxx-large: 3rem;\n --gr-font-size-xxxx-large: 4.5rem;\n --gr-font-weight-thin: 100;\n --gr-font-weight-extra-light: 200;\n --gr-font-weight-light: 300;\n --gr-font-weight-normal: 400;\n --gr-font-weight-medium: 500;\n --gr-font-weight-semi-bold: 600;\n --gr-font-weight-bold: 700;\n --gr-font-weight-extra-bold: 800;\n --gr-font-weight-black: 900;\n --gr-form-element-font-size-x-small: var(--gr-font-size-x-small);
${x(this._refMediaType)}
label=${i("media_filter.media_type")}
placeholder=${i("media_filter.select_media_type")}
.options=${this._mediaFilterController.getMediaTypeOptions()}
.initialValue=${o?.mediaType}
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>
<div class="when">
<frigate-card-select
${x(this._refWhen)}
.label=${i("media_filter.when")}
placeholder=${i("media_filter.select_when")}
.options=${this._mediaFilterController.getWhenOptions()}
.initialValue=${o?.when}
clearable
@frigate-card:select:change=${()=>t("selected")}
>
</frigate-card-select>
<frigate-card-date-picker
class="${T({selected:!!this._refWhenFrom.value?.value,hidden:this._refWhen.value?.value!==B.Custom})}"
${x(this._refWhenFrom)}
.icon=${"mdi:calendar-arrow-right"}
@frigate-card:date-picker:change=${()=>t("custom")}
>
</frigate-card-date-picker>
<frigate-card-date-picker
class="${T({selected:!!this._refWhenTo.value?.value,hidden:this._refWhen.value?.value!==B.Custom})}"
${x(this._refWhenTo)}
.icon=${"mdi:calendar-arrow-left"}
@frigate-card:date-picker:change=${()=>t("custom")}
>
</frigate-card-date-picker>
</div>
<frigate-card-select
${x(this._refCamera)}
.label=${i("media_filter.camera")}
placeholder=${i("media_filter.select_camera")}
.options=${this._mediaFilterController.getCameraOptions()}
.initialValue=${o?.cameraIDs}
clearable
multiple
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>
${r.events&&n.length?$` <frigate-card-select
${x(this._refWhat)}
label=${i("media_filter.what")}
placeholder=${i("media_filter.select_what")}
clearable
multiple
.options=${n}
.initialValue=${o?.what}
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>`:""}
${r.events&&a.length?$` <frigate-card-select
${x(this._refTags)}
label=${i("media_filter.tag")}
placeholder=${i("media_filter.select_tag")}
clearable
multiple
.options=${a}
.initialValue=${o?.tags}
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>`:""}
${r.events&&s.length?$` <frigate-card-select
${x(this._refWhere)}
label=${i("media_filter.where")}
placeholder=${i("media_filter.select_where")}
clearable
multiple
.options=${s}
.initialValue=${o?.where}
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>`:""}
${r.favorites?$`
<frigate-card-select
${x(this._refFavorite)}
label=${i("media_filter.favorite")}
placeholder=${i("media_filter.select_favorite")}
.options=${this._mediaFilterController.getFavoriteOptions()}
.initialValue=${o?.favorite}
clearable
@frigate-card:select:change=${()=>e()}
>
</frigate-card-select>
`:""}`}static get styles(){return k(":host {\n display: flex;\n flex-direction: column;\n overflow: auto;\n scrollbar-width: none;\n -ms-overflow-style: none;\n height: 100%;\n width: 300px;\n margin: 5px;\n}\n\n/* Hide scrollbar for Chrome, Safari and Opera */\n:host::-webkit-scrollbar {\n display: none;\n}\n\nfrigate-card-select {\n padding: 5px;\n}\n\ndiv.when {\n display: inline-flex;\n align-items: flex-end;\n}\n\ndiv.when frigate-card-select {\n flex: 1;\n}\n\ndiv.when frigate-card-date-picker {\n padding-bottom: 5px;\n transition: width 0.5s ease-in-out;\n}\n\ndiv.when frigate-card-date-picker {\n color: var(--secondary-color);\n}\n\ndiv.when frigate-card-date-picker.selected {\n color: var(--primary-color);\n}\n\ndiv.when frigate-card-date-picker.hidden {\n width: 0px;\n}")}};di.elementDefinitions={"frigate-card-select":ci,"frigate-card-date-picker":R},f([v({attribute:!1})],di.prototype,"hass",void 0),f([v({attribute:!1})],di.prototype,"cameraManager",void 0),f([v({attribute:!1})],di.prototype,"viewManagerEpoch",void 0),f([v({attribute:!1})],di.prototype,"cardWideConfig",void 0),di=f([C("frigate-card-media-filter")],di);const hi={closed:"mdi:filter-cog-outline",open:"mdi:filter-cog"};let gi=class extends _{render(){const e=this.viewManagerEpoch?.manager.getView();if(this.hass&&e?.isGalleryView()&&this.cameraManager&&this.cardWideConfig)return $`
<frigate-card-surround-basic
.drawerIcons=${{...this.galleryConfig&&"none"!==this.galleryConfig.controls.filter.mode&&{[this.galleryConfig.controls.filter.mode]:hi}}}
>
${this.galleryConfig&&"none"!==this.galleryConfig.controls.filter.mode?$` <frigate-card-media-filter
.hass=${this.hass}
.cameraManager=${this.cameraManager}
.viewManagerEpoch=${this.viewManagerEpoch}
.cardWideConfig=${this.cardWideConfig}
slot=${this.galleryConfig.controls.filter.mode}
>
</frigate-card-media-filter>`:""}
<frigate-card-gallery-core
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.galleryConfig=${this.galleryConfig}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</frigate-card-gallery-core>
</frigate-card-surround-basic>
`}static get styles(){return k(":host {\n width: 100%;\n height: 100%;\n display: block;\n}\n\nfrigate-card-surround-basic {\n max-height: 110dvh;\n}")}};f([v({attribute:!1})],gi.prototype,"hass",void 0),f([v({attribute:!1})],gi.prototype,"viewManagerEpoch",void 0),f([v({attribute:!1})],gi.prototype,"galleryConfig",void 0),f([v({attribute:!1})],gi.prototype,"cameraManager",void 0),f([v({attribute:!1})],gi.prototype,"cardWideConfig",void 0),gi=f([C("frigate-card-gallery")],gi);let ui=class extends _{constructor(){super(),this._refLoaderBottom=y(),this._refSelected=y(),this._showLoaderBottom=!0,this._showLoaderTop=!1,this._boundWheelHandler=this._wheelHandler.bind(this),this._boundTouchStartHandler=this._touchStartHandler.bind(this),this._boundTouchEndHandler=this._touchEndHandler.bind(this),this._throttleExtendGalleryLater=O(this._extendGallery.bind(this),500,{leading:!0,trailing:!1}),this._touchScrollYPosition=null,this._resizeObserver=new ResizeObserver(this._resizeHandler.bind(this)),this._intersectionObserver=new IntersectionObserver(this._intersectionHandler.bind(this))}_touchStartHandler(e){1===e.touches.length?this._touchScrollYPosition=e.touches[0].screenY:this._touchScrollYPosition=null}async _touchEndHandler(e){!this.scrollTop&&1===e.changedTouches.length&&this._touchScrollYPosition&&e.changedTouches[0].screenY>this._touchScrollYPosition&&await this._extendLater(),this._touchScrollYPosition=null}async _wheelHandler(e){!this.scrollTop&&e.deltaY<0&&await this._extendLater()}async _extendLater(){const e=new Date;this._showLoaderTop=!0,await this._throttleExtendGalleryLater("later",!1);const t=(new Date).getTime()-e.getTime();t<500&&await S(.5-t/1e3),this._showLoaderTop=!1}connectedCallback(){super.connectedCallback(),this._resizeObserver.observe(this),this.addEventListener("wheel",this._boundWheelHandler,{passive:!0}),this.addEventListener("touchstart",this._boundTouchStartHandler,{passive:!0}),this.addEventListener("touchend",this._boundTouchEndHandler),this.requestUpdate()}disconnectedCallback(){this.removeEventListener("wheel",this._boundWheelHandler),this.removeEventListener("touchstart",this._boundTouchStartHandler),this.removeEventListener("touchend",this._boundTouchEndHandler),this._resizeObserver.disconnect(),this._intersectionObserver.disconnect(),super.disconnectedCallback()}_setColumnCount(){const e=this.galleryConfig?.controls.thumbnails.size??M.media_gallery.controls.thumbnails.size,t=this.galleryConfig?.controls.thumbnails.show_details?Math.max(1,Math.floor(this.clientWidth/z)):Math.max(1,Math.ceil(this.clientWidth/e));this.style.setProperty("--frigate-card-gallery-columns",String(t))}_resizeHandler(){this._setColumnCount()}async _intersectionHandler(e){e.every((e=>!e.isIntersecting))||(this._showLoaderBottom=!1,await this._extendGallery("earlier"))}async _extendGallery(e,t=!0){const r=this.viewManagerEpoch?.manager.getView();if(!this.cameraManager||!this.hass||!r)return;const i=r.query,n=i?.getQueries()??null,s=r.queryResults?.getResults();if(!i||!n||!s)return;let l;try{l=await this.cameraManager.extendMediaQueries(n,s,e,{useCache:t})}catch(e){return void d(e)}if(l){const e=c.areEventQueries(i)?new o(l.queries):c.areRecordingQueries(i)?new a(l.queries):null;e&&this.viewManagerEpoch?.manager.setViewByParameters({baseView:r,params:{query:e,queryResults:new L({results:l.results}).selectResultIfFound((e=>e===r.queryResults?.getSelectedResult()))}})}}willUpdate(e){if(e.has("galleryConfig")&&(this.galleryConfig?.controls.thumbnails.show_details?this.setAttribute("details",""):this.removeAttribute("details"),this._setColumnCount(),this.galleryConfig?.controls.thumbnails.size&&this.style.setProperty("--frigate-card-thumbnail-size",`${this.galleryConfig.controls.thumbnails.size}px`)),e.has("viewManagerEpoch")){this._showLoaderBottom=!0;const e=this.viewManagerEpoch?.manager.getView(),t=this.viewManagerEpoch?.oldView;this._media&&t?.queryResults?.getResults()===e?.queryResults?.getResults()||(this._media=[...e?.queryResults?.getResults()??[]].reverse())}}render(){if(!this._media||!this.hass)return $``
${this._showLoaderTop?$`${A({cardWideConfig:this.cardWideConfig,classes:{top:!0},size:"small"})}`:""}
${this._media.map(((r,i)=>$`<frigate-card-thumbnail
${r===t?x(this._refSelected):""}
class=${T({selected:r===t})}
.hass=${this.hass}
.cameraManager=${this.cameraManager}
.media=${r}
.viewManagerEpoch=${this.viewManagerEpoch}
?details=${!!this.galleryConfig?.controls.thumbnails.show_details}
?show_favorite_control=${!!this.galleryConfig?.controls.thumbnails.show_favorite_control}
?show_timeline_control=${!!this.galleryConfig?.controls.thumbnails.show_timeline_control}
?show_download_control=${!!this.galleryConfig?.controls.thumbnails.show_download_control}
@click=${t=>{this._media&&this.viewManagerEpoch?.manager.setViewByParameters({params:{view:"media",queryResults:e.queryResults?.clone().selectIndex(this._media.length-i-1)}}),F(t)}}
>
</frigate-card-thumbnail>`))}
${this._showLoaderBottom?$`${A({cardWideConfig:this.cardWideConfig,componentRef:this._refLoaderBottom})}`:""}
</div>`}updated(e){this._refLoaderBottom.value&&(this._intersectionObserver.disconnect(),this._intersectionObserver.observe(this._refLoaderBottom.value)),this.updateComplete.then((()=>{e.has("viewManagerEpoch")&&!e.get("viewManagerEpoch")&&this._refSelected.value&&this._refSelected.value.scrollIntoView({block:"center"})}))}static get styles(){return k(":host {\n width: 100%;\n height: 100%;\n display: block;\n overflow: auto;\n -ms-overflow-style: none;\n scrollbar-width: none;\n --frigate-card-gallery-gap: 3px;\n --frigate-card-gallery-columns: 4;\n}\n\n.grid {\n display: grid;\n grid-template-columns: repeat(var(--frigate-card-gallery-columns), minmax(0, 1fr));\n grid-auto-rows: min-content;\n gap: var(--frigate-card-gallery-gap);\n}\n\n:host::-webkit-scrollbar {\n display: none;\n}\n\nfrigate-card-thumbnail {\n height: 100%;\n max-height: var(--frigate-card-thumbnail-size);\n}\n\nfrigate-card-thumbnail:not([details]) {\n width: 100%;\n}\n\nfrigate-card-thumbnail.selected {\n border: 4px solid var(--accent-color);\n border-radius: calc(var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px)) + 4px);\n}\n\nfrigate-card-progress-indicator.top {\n grid-column: 1/-1;\n}")}};f([v({attribute:!1})],ui.prototype,"hass",void 0),f([v({attribute:!1})],ui.prototype,"viewManagerEpoch",void 0),f([v({attribute:!1})],ui.prototype,"galleryConfig",void 0),f([v({attribute:!1})],ui.prototype,"cameraManager",void 0),f([v({attribute:!1})],ui.prototype,"cardWideConfig",void 0),f([E()],ui.prototype,"_showLoaderBottom",void 0),f([E()],ui.prototype,"_showLoaderTop",void 0),ui=f([C("frigate-card-gallery-core")],ui);export{gi as FrigateCardGallery,ui as FrigateCardGalleryCore};