iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.07 kB
JavaScript
export const __rspack_esm_id=15251;export const __rspack_esm_ids=[15251];export const __webpack_modules__={60543(e,t,r){r.a(e,async function(e,a){try{r.r(t),r.d(t,{HaQrCode:()=>l});r(18111),r(61701);var o=r(62826),s=r(5124),i=r(22441),c=r(81298),n=r(38962),h=r(79468),d=e([n]);n=(d.then?(await d)():d)[0];class l 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(c.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=()=>{e?.drawImage(r,.375*t.width,.375*t.height,t.width/4,t.height/4)}}}}render(){return this.data?this._error?s.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:s.qy`<canvas></canvas>`:s.s6}constructor(...e){super(...e),this.errorCorrectionLevel="medium",this.width=4,this.scale=4,this.margin=4}}l.styles=s.AH`:host{display:block}`,(0,o.Cg)([(0,i.MZ)()],l.prototype,"data",void 0),(0,o.Cg)([(0,i.MZ)({attribute:"error-correction-level"})],l.prototype,"errorCorrectionLevel",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],l.prototype,"width",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],l.prototype,"scale",void 0),(0,o.Cg)([(0,i.MZ)({type:Number})],l.prototype,"margin",void 0),(0,o.Cg)([(0,i.MZ)({attribute:!1})],l.prototype,"maskPattern",void 0),(0,o.Cg)([(0,i.MZ)({attribute:"center-image"})],l.prototype,"centerImage",void 0),(0,o.Cg)([(0,i.wk)()],l.prototype,"_error",void 0),(0,o.Cg)([(0,i.P)("canvas")],l.prototype,"_canvas",void 0),l=(0,o.Cg)([(0,i.EM)("ha-qr-code")],l),a()}catch(e){a(e)}})},35313(e,t,r){r.a(e,async function(e,a){try{r.r(t),r.d(t,{HaSelectorQRCode:()=>h});var o=r(62826),s=r(5124),i=r(22441),c=r(60543),n=e([c]);c=(n.then?(await n)():n)[0];class h extends s.WF{render(){return s.qy`<ha-qr-code .data="${this.selector.qr_code?.data}" .scale="${this.selector.qr_code?.scale}" .errorCorrectionLevel="${this.selector.qr_code?.error_correction_level}" .centerImage="${this.selector.qr_code?.center_image}"></ha-qr-code>`}}h.styles=s.AH`ha-qr-code{text-align:center}`,(0,o.Cg)([(0,i.MZ)({attribute:!1})],h.prototype,"selector",void 0),h=(0,o.Cg)([(0,i.EM)("ha-selector-qr_code")],h),a()}catch(e){a(e)}})},35370(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}},89429(e){e.exports=function(){}}};