iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 5.26 kB
JavaScript
export const __rspack_esm_id=1960;export const __rspack_esm_ids=[1960];export const __webpack_modules__={16891(e,s,t){t.r(s),t.d(s,{HaSnowflakes:()=>l});t(44114),t(18111),t(61701);var a=t(62826),o=t(5124),n=t(22441),r=t(93758),i=t(54706);class l extends((0,i.E)(o.WF)){hassSubscribe(){return[(0,r.CO)(this.hass.connection,"frontend","winter_mode",e=>{this._enabled=e.enabled})]}_generateSnowflakes(){if(!this._enabled)return void(this._snowflakes=[]);const e=[];for(let s=0;s<this._maxSnowflakes;s++)e.push({id:s,left:100*Math.random(),size:12*Math.random()+8,duration:8*Math.random()+8,delay:8*Math.random(),rotation:720*Math.random()-360});this._snowflakes=e}willUpdate(e){super.willUpdate(e),e.has("_enabled")&&this._generateSnowflakes()}render(){if(!this._enabled)return o.s6;const e=this.hass?.themes.darkMode??!1;return o.qy` <div class="snowflakes ${e?"dark":"light"}" aria-hidden="true"> ${this._snowflakes.map(e=>o.qy` <svg class="snowflake ${this.narrow&&e.id>=30?"hide-narrow":""}" style="left:${e.left}%;width:${e.size}px;height:${e.size}px;animation-duration:${e.duration}s;animation-delay:${e.delay}s;--rotation:${e.rotation}deg" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M7.991 0a.644.644 0 0 1 .283 1.221v2.553l.986-.988a.645.645 0 0 1 .612-.839.644.644 0 1 1-.222 1.247l-1.376 1.38V7.52l1.65-.954.466-1.879a.645.645 0 0 1 .1-1.042.643.643 0 1 1 .445 1.189l-.363 1.356 3.145-1.82a.643.643 0 1 1 .282.49l-2.205 1.277 1.347.361a.643.643 0 1 1-.158.543l-1.88-.505L8.573 8l1.632.945 1.858-.535a.64.64 0 0 1 .95-.434.643.643 0 1 1-.805.98l-1.354.364L14 11.14a.641.641 0 0 1 .914.855.643.643 0 0 1-1.197-.366l-2.205-1.276.36 1.35a.642.642 0 0 1 .419.95.643.643 0 1 1-.967-.816l-.503-1.884L8.273 8.48v1.909l1.39 1.344a.644.644 0 1 1 .208 1.252.644.644 0 0 1-.606-.852l-.991-.994v3.64A.644.644 0 0 1 7.99 16a.644.644 0 0 1-.282-1.221v-2.553l-.986.988a.645.645 0 0 1-.612.839.644.644 0 1 1 .222-1.247l1.376-1.38V8.5l-1.632.945-.467 1.879q.079.068.134.163a.643.643 0 1 1-.68-.31l.364-1.357-3.145 1.82A.643.643 0 1 1 2 11.15l2.205-1.276-1.347-.361a.643.643 0 1 1 .158-.543l1.88.505L7.444 8l-1.65-.954-1.857.534a.64.64 0 0 1-.95.434.643.643 0 1 1 .805-.98l1.354-.364L2 4.85a.641.641 0 0 1-.914-.855.643.643 0 0 1 1.197.366l2.205 1.276-.36-1.35a.642.642 0 0 1-.419-.95.643.643 0 1 1 .967.816l.503 1.884L7.71 7.5V5.611L6.32 4.267a.644.644 0 1 1-.208-1.252.644.644 0 0 1 .607.852l.991.994V1.22A.644.644 0 0 1 7.991 0" fill="currentColor"/> </svg> `)} </div> `}constructor(...e){super(...e),this.narrow=!1,this._enabled=!1,this._snowflakes=[],this._maxSnowflakes=50}}l.styles=o.AH`:host{display:block;position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9999;overflow:hidden}.snowflakes{position:absolute;top:-10%;left:0;width:100%;height:110%;pointer-events:none}.snowflake{position:absolute;top:-10%;opacity:.7;user-select:none;pointer-events:none;animation:fall linear infinite}.light .snowflake{color:#00bcd4}.dark .snowflake{color:#fff}.snowflake.hide-narrow{display:none} fall{0%{transform:translateY(-10vh) translateX(0) rotate(var(--rotation))}25%{transform:translateY(30vh) translateX(10px) rotate(calc(var(--rotation) + 25deg))}50%{transform:translateY(60vh) translateX(-10px) rotate(calc(var(--rotation) + 50deg))}75%{transform:translateY(85vh) translateX(10px) rotate(calc(var(--rotation) + 75deg))}100%{transform:translateY(120vh) translateX(0) rotate(calc(var(--rotation) + 100deg))}} (prefers-reduced-motion:reduce){.snowflake{animation:none;display:none}}`,(0,a.Cg)([(0,n.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],l.prototype,"narrow",void 0),(0,a.Cg)([(0,n.wk)()],l.prototype,"_enabled",void 0),(0,a.Cg)([(0,n.wk)()],l.prototype,"_snowflakes",void 0),l=(0,a.Cg)([(0,n.EM)("ha-snowflakes")],l)},93758(e,s,t){t.d(s,{CO:()=>h,NS:()=>d,f$:()=>n,ok:()=>r});var a=t(35518),o=t(9899);const n=async e=>(await e.callWS({type:"labs/list"})).features,r=(e,s,t,a,o)=>e.callWS({type:"labs/update",domain:s,preview_feature:t,enabled:a,...void 0!==o&&{create_backup:o}}),i=e=>e.sendMessagePromise({type:"labs/list"}).then(e=>e.features),l=(e,s)=>e.subscribeEvents((0,o.s)(()=>i(e).then(e=>s.setState(e,!0)),500,!0),"labs_updated"),d=(e,s)=>(0,a.N)("_labFeatures",i,l,e,s),h=(e,s,t,a)=>e.subscribeMessage(a,{type:"labs/subscribe",domain:s,preview_feature:t})},54706(e,s,t){t.d(s,{E:()=>n});t(74423),t(18111),t(13579);var a=t(62826),o=t(22441);const n=e=>{class s extends e{connectedCallback(){super.connectedCallback(),this._checkSubscribed()}disconnectedCallback(){if(super.disconnectedCallback(),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then(e=>e()):e()}this.__unsubs=void 0}}updated(e){if(super.updated(e),e.has("hass"))this._checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const s of e.keys())if(this.hassSubscribeRequiredHostProps.includes(s))return void this._checkSubscribed()}hassSubscribe(){return[]}_checkSubscribed(){void 0===this.__unsubs&&this.isConnected&&void 0!==this.hass&&!this.hassSubscribeRequiredHostProps?.some(e=>void 0===this[e])&&(this.__unsubs=this.hassSubscribe())}}return(0,a.Cg)([(0,o.MZ)({attribute:!1})],s.prototype,"hass",void 0),s}}};