iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.37 kB
JavaScript
;(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[90791],{60543:function(e,t,r){r.a(e,async function(e,a){try{r.r(t),r.d(t,{HaQrCode:function(){return u}});r(18111),r(61701),r(62953);var o=r(40445),s=r(5124),i=r(67576),n=r(81298),c=r(38962),h=r(79468),d=e([c]);c=(d.then?(await d)():d)[0];let l,p,v,g=e=>e;class u extends s.WF{willUpdate(e){super.willUpdate(e),(e.has("data")||e.has("scale")||e.has("width")||e.has("margin")||e.has("maskPattern")||e.has("errorCorrectionLevel"))&&this._error&&(this._error=void 0)}updated(e){const t=this._canvas;if(t&&this.data&&(e.has("data")||e.has("scale")||e.has("width")||e.has("margin")||e.has("maskPattern")||e.has("errorCorrectionLevel")||e.has("centerImage"))){const e=getComputedStyle(this),r=e.getPropertyValue("--rgb-primary-text-color"),a=e.getPropertyValue("--rgb-card-background-color"),o=(0,h.v2)(r.split(",").map(e=>parseInt(e,10))),s=(0,h.v2)(a.split(",").map(e=>parseInt(e,10)));if(n.toCanvas(t,this.data,{errorCorrectionLevel:this.errorCorrectionLevel||(this.centerImage?"Q":"M"),width:this.width,scale:this.scale,margin:this.margin,maskPattern:this.maskPattern,color:{light:s,dark:o}}).catch(e=>{this._error=e.message}),this.centerImage){const e=this._canvas.getContext("2d"),r=new Image;r.src=this.centerImage,r.onload=()=>{null==e||e.drawImage(r,.375*t.width,.375*t.height,t.width/4,t.height/4)}}}}render(){return this.data?this._error?(0,s.qy)(l||(l=g`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):(0,s.qy)(p||(p=g`<canvas></canvas>`)):s.s6}constructor(...e){super(...e),this.errorCorrectionLevel="medium",this.width=4,this.scale=4,this.margin=4}}u.styles=(0,s.AH)(v||(v=g`:host{display:block}`)),(0,o.Cg)([(0,i.MZ)()],u.prototype,"data",void 0),(0,o.Cg)([(0,i.MZ)({attribute:"error-correction-level"})],u.prototype,"errorCorrectionLevel",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],u.prototype,"width",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],u.prototype,"scale",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],u.prototype,"margin",void 0),(0,o.Cg)([(0,i.MZ)({attribute:!1})],u.prototype,"maskPattern",void 0),(0,o.Cg)([(0,i.MZ)({attribute:"center-image"})],u.prototype,"centerImage",void 0),(0,o.Cg)([(0,i.wk)()],u.prototype,"_error",void 0),(0,o.Cg)([(0,i.P)("canvas")],u.prototype,"_canvas",void 0),u=(0,o.Cg)([(0,i.EM)("ha-qr-code")],u),a()}catch(l){a(l)}})},35313:function(e,t,r){r.a(e,async function(e,a){try{r.r(t),r.d(t,{HaSelectorQRCode:function(){return p}});var o=r(40445),s=r(5124),i=r(67576),n=r(60543),c=e([n]);n=(c.then?(await c)():c)[0];let h,d,l=e=>e;class p extends s.WF{render(){var e,t,r,a;return(0,s.qy)(h||(h=l`<ha-qr-code .data="${0}" .scale="${0}" .errorCorrectionLevel="${0}" .centerImage="${0}"></ha-qr-code>`),null===(e=this.selector.qr_code)||void 0===e?void 0:e.data,null===(t=this.selector.qr_code)||void 0===t?void 0:t.scale,null===(r=this.selector.qr_code)||void 0===r?void 0:r.error_correction_level,null===(a=this.selector.qr_code)||void 0===a?void 0:a.center_image)}}p.styles=(0,s.AH)(d||(d=l`ha-qr-code{text-align:center}`)),(0,o.Cg)([(0,i.MZ)({attribute:!1})],p.prototype,"selector",void 0),p=(0,o.Cg)([(0,i.EM)("ha-selector-qr_code")],p),a()}catch(h){a(h)}})},35370:function(e,t,r){var a=r(26198);e.exports=function(e,t,r){for(var o=0,s=arguments.length>2?r:a(t),i=new e(s);s>o;)i[o]=t[o++];return i}}}]);