usda-hass-config/custom_components/hacs/hacs_frontend_experimental/c.d32a5f4a.js

2 lines
14 KiB
JavaScript
Raw Normal View History

2024-10-01 14:06:39 +00:00
import{K as t,f as e,e as i,t as s,j as r,y as n}from"./main-85e087f9.js";import{c as o}from"./c.117d0056.js";class l{constructor(e=!0){t(this,"_storage",{}),t(this,"_listeners",{}),e&&window.addEventListener("storage",(t=>{t.key&&this.hasKey(t.key)&&(this._storage[t.key]=t.newValue?JSON.parse(t.newValue):t.newValue,this._listeners[t.key]&&this._listeners[t.key].forEach((e=>e(t.oldValue?JSON.parse(t.oldValue):t.oldValue,this._storage[t.key]))))}))}addFromStorage(t){if(!this._storage[t]){const e=window.localStorage.getItem(t);e&&(this._storage[t]=JSON.parse(e))}}subscribeChanges(t,e){return this._listeners[t]?this._listeners[t].push(e):this._listeners[t]=[e],()=>{this.unsubscribeChanges(t,e)}}unsubscribeChanges(t,e){if(!(t in this._listeners))return;const i=this._listeners[t].indexOf(e);-1!==i&&this._listeners[t].splice(i,1)}hasKey(t){return t in this._storage}getValue(t){return this._storage[t]}setValue(t,e){this._storage[t]=e;try{void 0===e?window.localStorage.removeItem(t):window.localStorage.setItem(t,JSON.stringify(e))}catch(t){}}}const h=new l,a=(t,e,i=!0,s)=>r=>{const n=i?h:new l(!1),o=String(r.key);t=t||String(r.key);const a=r.initializer?r.initializer():void 0;n.addFromStorage(t);const c=()=>n.hasKey(t)?n.getValue(t):a;return{kind:"method",placement:"prototype",key:r.key,descriptor:{set(i){((i,s)=>{let o;e&&(o=c()),n.setValue(t,s),e&&i.requestUpdate(r.key,o)})(this,i)},get:()=>c(),enumerable:!0,configurable:!0},finisher(l){if(e&&i){const e=l.prototype.connectedCallback,i=l.prototype.disconnectedCallback;l.prototype.connectedCallback=function(){var i;e.call(this),this[`__unbsubLocalStorage${o}`]=(i=this,n.subscribeChanges(t,(t=>{i.requestUpdate(r.key,t)})))},l.prototype.disconnectedCallback=function(){i.call(this),this[`__unbsubLocalStorage${o}`]()}}e&&l.createProperty(r.key,{noAccessor:!0,...s})}}};let c,u;async function _(){return u||async function(){if(c)return(await c).default;c=window.ResizeObserver;try{new c((function(){}))}catch(t){c=import("./c.033798e3.js"),c=(await c).default}return u=c}()}const d=Symbol("virtualizerRef"),m="virtualizer-sizer";class p extends Event{constructor(t){super(p.eventName,{bubbles:!0}),this.first=t.first,this.last=t.last}}p.eventName="rangeChanged";class y extends Event{constructor(t){super(y.eventName,{bubbles:!0}),this.first=t.first,this.last=t.last}}y.eventName="visibilityChanged";class f{constructor(t){if(this._benchmarkStart=null,this._layout=null,this._clippingAncestors=[],this._scrollSize=null,this._scrollError=null,this._childrenPos=null,this._childMeasurements=null,this._toBeMeasured=new Map,this._rangeChanged=!0,this._itemsChanged=!0,this._visibilityChanged=!0,this._isScroller=!1,this._sizer=null,this._hostElementRO=null,this._childrenRO=null,this._mutationObserver=null,this._mutationPromise=null,this._mutationPromiseResolver=null,this._mutationsObserved=!1,this._scrollEventListeners=[],this._scrollEventListenerOptions={passive:!0},this._loadListener=this._childLoaded.bind(this),this._scrollToIndex=null,this._items=[],this._first=-1,this._last=-1,this._firstVisible=-1,this._lastVisible=-1,this._scheduled=new WeakSet,this._measureCallback=null,this._measureChildOverride=null,!t)throw new Error("Virtualizer constructor requires a configuration object");if(!t.hostElement)throw new Error('Virtualizer configuration requires the "hostElement" property');this._init(t)}set items(t){Array.isArray(t)&&t!==this._items&&(this._itemsChanged=!0,this._items=t,this._schedule(this._updateLayout))}_init(t){this._isScroller=!!t.scroller,this._initHostElement(t),this._initLayout(t)}async _initObservers(){this._mutationObserver=new MutationObserver(this._observeMutations.bind(this));const t=await _();this._hostElementRO=new t((()=>this._hostElementSizeChanged())),this._childrenRO=new t(this._childrenSizeChanged.bind(this))}async _initLayout(t){t.layout?this.layout=t.layout:this.layout=(await import("./c.f3491693.js")).FlowLayout}_initHostElement(t){const e=this._hostElement=t.hostElement;this._applyVirtualizerStyles(),e[d]=this}async connected(){await this._initObservers();const t=this._i