UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

11 lines 16.5 kB
/*! For license information please see 49224.3cca44cface43fdc.js.LICENSE.txt */ "use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[49224],{67258:function(e,t,a){a.d(t,{d:function(){return i}});const i=e=>{switch(e.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},41060:function(e,t,a){a.a(e,async function(e,t){try{a(18111),a(61701),a(62953);var i=a(40445),r=a(5124),o=a(67576),n=a(6412),s=a(44537),l=a(1087),c=a(67258),d=a(46187),p=a(18350),h=a(26300),u=a(94355),g=e([p,h,u]);[p,h,u]=g.then?(await g)():g;let v,f,b,m,y,w,k,_,$=e=>e;const x="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",M="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z";class C extends r.WF{firstUpdated(e){super.firstUpdated(e),this.autoOpenFileDialog&&this._openFilePicker()}get _name(){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return(this.value instanceof FileList?Array.from(this.value):(0,s.e)(this.value)).map(e=>e.name).join(", ")}render(){const e=this.localize||this.hass.localize;return(0,r.qy)(v||(v=$` ${0} `),this.uploading?(0,r.qy)(f||(f=$`<div class="container"> <div class="uploading"> <span class="header">${0}</span> ${0} </div> <ha-progress-bar .indeterminate="${0}" .value="${0}" loading></ha-progress-bar> </div>`),this.uploadingLabel||(this.value?e("ui.components.file-upload.uploading_name",{name:this._name}):e("ui.components.file-upload.uploading")),this.progress?(0,r.qy)(b||(b=$`<div class="progress"> ${0}${0}% </div>`),this.progress,this.hass&&(0,c.d)(this.hass.locale)):r.s6,!this.progress,this.progress):(0,r.qy)(m||(m=$`<label for="${0}" class="container ${0}" @drop="${0}" @dragenter="${0}" @dragover="${0}" @dragleave="${0}" @dragend="${0}">${0} <input id="input" type="file" class="file" .accept="${0}" .multiple="${0}" @change="${0}"></label>`),this.value?"":"input",(0,n.H)({dragged:this._drag,multiple:this.multiple,value:Boolean(this.value)}),this._handleDrop,this._handleDragStart,this._handleDragStart,this._handleDragEnd,this._handleDragEnd,this.value?"string"==typeof this.value?(0,r.qy)(w||(w=$`<div class="row"> <div class="value" @click="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} </div> <ha-icon-button @click="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||M,this.value,this._clearValue,this.deleteLabel||e("ui.common.delete"),x):(this.value instanceof FileList?Array.from(this.value):(0,s.e)(this.value)).map(t=>(0,r.qy)(k||(k=$`<div class="row"> <div class="value" @click="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} - ${0} </div> <ha-icon-button @click="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||M,t.name,(0,d.A)(t.size),this._clearValue,this.deleteLabel||e("ui.common.delete"),x)):(0,r.qy)(y||(y=$`<ha-button size="small" appearance="filled" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> <span class="secondary">${0}</span> <span class="supports">${0}</span>`),this._openFilePicker,this.icon||M,this.label||e("ui.components.file-upload.label"),this.secondary||e("ui.components.file-upload.secondary"),this.supports),this.accept,this.multiple,this._handleFilePicked))}_openFilePicker(){var e;null===(e=this._input)||void 0===e||e.click()}_handleDrop(e){var t;e.preventDefault(),e.stopPropagation(),null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&(0,l.r)(this,"file-picked",{files:this.multiple||1===e.dataTransfer.files.length?Array.from(e.dataTransfer.files):[e.dataTransfer.files[0]]}),this._drag=!1}_handleDragStart(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}_handleDragEnd(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}_handleFilePicked(e){0!==e.target.files.length&&(this.value=e.target.files,(0,l.r)(this,"file-picked",{files:e.target.files}))}_clearValue(e){e.preventDefault(),this._input.value="",this.value=void 0,(0,l.r)(this,"change"),(0,l.r)(this,"files-cleared")}constructor(...e){super(...e),this.multiple=!1,this.disabled=!1,this.uploading=!1,this.autoOpenFileDialog=!1,this._drag=!1}}C.styles=(0,r.AH)(_||(_=$`:host{display:block;height:240px}:host([disabled]){pointer-events:none;color:var(--disabled-text-color)}.container{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;border:solid 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));border-radius:var(--mdc-shape-small,var(--ha-border-radius-sm));height:100%}.row{display:flex;align-items:center}label.container{border:dashed 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));cursor:pointer}.container .uploading{display:flex;flex-direction:column;width:100%;align-items:flex-start;padding:0 32px;box-sizing:border-box}:host([disabled]) .container{border-color:var(--disabled-color)}label.dragged,label:hover{border-style:solid}label.dragged{border-color:var(--primary-color)}.dragged:before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:var(--primary-color);content:"";opacity:var(--dark-divider-opacity);pointer-events:none;border-radius:var(--mdc-shape-small,4px)}label.value{cursor:default}label.value.multiple{justify-content:unset;overflow:auto}.highlight{color:var(--primary-color)}ha-button{margin-bottom:8px}.supports{color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}:host([disabled]) .secondary{color:var(--disabled-text-color)}input.file{display:none}.value{cursor:pointer}.value ha-svg-icon{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}ha-button{--mdc-button-outline-color:var(--primary-color);--ha-icon-button-size:24px}ha-progress-bar{width:100%;padding:8px 32px;box-sizing:border-box}.header{font-weight:var(--ha-font-weight-medium)}.progress{color:var(--secondary-text-color)}button.link{background:0 0;border:none;padding:0;font-size:var(--ha-font-size-m);color:var(--primary-color);text-decoration:underline;cursor:pointer}`)),(0,i.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"localize",void 0),(0,i.Cg)([(0,o.MZ)()],C.prototype,"accept",void 0),(0,i.Cg)([(0,o.MZ)()],C.prototype,"icon",void 0),(0,i.Cg)([(0,o.MZ)()],C.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],C.prototype,"secondary",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"uploading-label"})],C.prototype,"uploadingLabel",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"delete-label"})],C.prototype,"deleteLabel",void 0),(0,i.Cg)([(0,o.MZ)()],C.prototype,"supports",void 0),(0,i.Cg)([(0,o.MZ)({type:Object})],C.prototype,"value",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],C.prototype,"multiple",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],C.prototype,"disabled",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],C.prototype,"uploading",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],C.prototype,"progress",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],C.prototype,"autoOpenFileDialog",void 0),(0,i.Cg)([(0,o.wk)()],C.prototype,"_drag",void 0),(0,i.Cg)([(0,o.P)("#input")],C.prototype,"_input",void 0),C=(0,i.Cg)([(0,o.EM)("ha-file-upload")],C),t()}catch(v){t(v)}})},25078:function(e,t,a){a.a(e,async function(e,i){try{a.r(t),a.d(t,{HaFileSelector:function(){return v}});a(3362),a(62953);var r=a(40445),o=a(5124),n=a(67576),s=a(1087),l=a(62854),c=a(65063),d=a(41060),p=e([d]);d=(p.then?(await p)():p)[0];let h,u=e=>e;const g="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z";class v extends o.WF{render(){var e,t;return(0,o.qy)(h||(h=u` <ha-file-upload .hass="${0}" .accept="${0}" .icon="${0}" .label="${0}" .required="${0}" .disabled="${0}" .supports="${0}" .uploading="${0}" .value="${0}" @file-picked="${0}" @change="${0}"></ha-file-upload> `),this.hass,null===(e=this.selector.file)||void 0===e?void 0:e.accept,g,this.label,this.required,this.disabled,this.helper,this._busy,this.value?(null===(t=this._filename)||void 0===t?void 0:t.name)||this.hass.localize("ui.components.selectors.file.unknown_file"):void 0,this._uploadFile,this._removeFile)}willUpdate(e){super.willUpdate(e),e.has("value")&&this._filename&&this.value!==this._filename.fileId&&(this._filename=void 0)}async _uploadFile(e){this._busy=!0;const t=e.detail.files[0];try{const e=await(0,l.Q)(this.hass,t);this._filename={fileId:e,name:t.name},(0,s.r)(this,"value-changed",{value:e})}catch(a){(0,c.showAlertDialog)(this,{text:this.hass.localize("ui.components.selectors.file.upload_failed",{reason:a.message||a})})}finally{this._busy=!1}}constructor(...e){super(...e),this.disabled=!1,this.required=!0,this._busy=!1,this._removeFile=async()=>{this._busy=!0;try{await(0,l.n)(this.hass,this.value)}catch(e){}finally{this._busy=!1}this._filename=void 0,(0,s.r)(this,"value-changed",{value:""})}}}(0,r.Cg)([(0,n.MZ)({attribute:!1})],v.prototype,"hass",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],v.prototype,"selector",void 0),(0,r.Cg)([(0,n.MZ)()],v.prototype,"value",void 0),(0,r.Cg)([(0,n.MZ)()],v.prototype,"label",void 0),(0,r.Cg)([(0,n.MZ)()],v.prototype,"helper",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean})],v.prototype,"disabled",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean})],v.prototype,"required",void 0),(0,r.Cg)([(0,n.wk)()],v.prototype,"_filename",void 0),(0,r.Cg)([(0,n.wk)()],v.prototype,"_busy",void 0),v=(0,r.Cg)([(0,n.EM)("ha-selector-file")],v),i()}catch(h){i(h)}})},94355:function(e,t,a){a.a(e,async function(e,t){try{a(62953);var i=a(40445),r=a(88590),o=a(5124),n=a(67576),s=e([r]);r=(s.then?(await s)():s)[0];let l,c=e=>e;class d extends r.A{static get styles(){return[r.A.styles,(0,o.AH)(l||(l=c`:host{--indicator-color:var( --ha-progress-bar-indicator-color, var(--ha-color-on-primary-normal) );--track-color:var( --ha-progress-bar-track-color, var(--ha-color-fill-neutral-normal-hover) );--track-height:var(--ha-progress-bar-track-height, 12px);--wa-transition-slow:var(--ha-animation-duration-slow);position:relative}.progress-bar{border-radius:var(--ha-progress-bar-border-radius,var(--ha-border-radius-pill))}.indicator{background:var(--ha-progress-bar-indicator-background,var(--indicator-color))}:host([indeterminate]) .indicator{animation:wa-progress-indeterminate var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1)}@keyframes slide-highlight{0%{transform:translateX(-200%)}100%{transform:translateX(200%)}}:host([loading]:not([indeterminate])) .progress-bar::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 0%,oklch(from var(--indicator-color) 85% c h) 50%,transparent 100%);opacity:.5;animation:slide-highlight var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1);width:50%}:host::after{--width:var( --ha-progress-bar-indicator-highlight-width, calc(var(--track-height) * 2) );width:var(--width);height:var(--ha-progress-bar-indicator-highlight-height,calc(var(--track-height) * 2));content:"";position:absolute;inset-inline-start:clamp(var(--width)/ 2,var(--percentage,0%),calc(100% - var(--width)/ 2));top:50%;transform:translate(-50%,-50%);background-image:var(--ha-progress-bar-indicator-highlight-image);background-size:contain;background-repeat:no-repeat;background-position:center;pointer-events:none;transition:inset-inline-start var(--wa-transition-slow, 200ms) var(--wa-transition-easing, ease)}:host([indeterminate])::after{display:none}`))]}constructor(...e){super(...e),this.loading=!1}}(0,i.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],d.prototype,"loading",void 0),d=(0,i.Cg)([(0,n.EM)("ha-progress-bar")],d),t()}catch(l){t(l)}})},62854:function(e,t,a){a.d(t,{Q:function(){return i},n:function(){return r}});a(16280),a(3362);const i=async(e,t)=>{const a=new FormData;a.append("file",t);const i=await e.fetchWithAuth("/api/file_upload",{method:"POST",body:a});if(413===i.status)throw new Error(`Uploaded file is too large (${t.name})`);if(200!==i.status)throw new Error("Unknown error");return(await i.json()).file_id},r=async(e,t)=>e.callApi("DELETE","file_upload",{file_id:t})},65063:function(e,t,a){a.d(t,{an:function(){return l},dk:function(){return s},showAlertDialog:function(){return n}});a(3362),a(62953);var i=a(1087);const r=()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(29962),a.e(62574),a.e(960)]).then(a.bind(a,26683)),o=(e,t,a)=>new Promise(o=>{const n=t.cancel,s=t.confirm;(0,i.r)(e,"show-dialog",{dialogTag:"dialog-box",dialogImport:r,dialogParams:Object.assign(Object.assign(Object.assign({},t),a),{},{cancel:()=>{o(!(null==a||!a.prompt)&&null),n&&n()},confirm:e=>{o(null==a||!a.prompt||e),s&&s(e)}})})}),n=(e,t)=>o(e,t),s=(e,t)=>o(e,t,{confirmation:!0}),l=(e,t)=>o(e,t,{prompt:!0})},46187:function(e,t,a){a.d(t,{A:function(){return i}});const i=(e=0,t=2)=>{if(0===e)return"0 Bytes";t=t<0?0:t;const a=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**a).toFixed(t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][a]}`}},35370:function(e,t,a){var i=a(26198);e.exports=function(e,t,a){for(var r=0,o=arguments.length>2?a:i(t),n=new e(o);o>r;)n[r]=t[r++];return n}},88590:function(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:function(){return m}});a(62953);var r=a(5124),o=a(67576),n=a(63672),s=a(95010),l=a(717),c=a(17060),d=a(4168),p=e([c]);c=(p.then?(await p)():p)[0];let v,f,b=e=>e;var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,g=(e,t,a,i)=>{for(var r,o=i>1?void 0:i?u(t,a):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(i?r(t,a,o):r(o))||o);return i&&o&&h(t,a,o),o};let m=class extends l.A{updated(e){e.has("value")&&requestAnimationFrame(()=>{this.style.setProperty("--percentage",`${(0,s.q)(this.value,0,100)}%`)})}render(){return(0,r.qy)(v||(v=b` <div part="base" class="progress-bar" role="progressbar" title="${0}" aria-label="${0}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${0}"> <div part="indicator" class="indicator"> ${0} </div> </div> `),(0,n.J)(this.title),this.label.length>0?this.label:this.localize.term("progress"),this.indeterminate?"0":this.value,this.indeterminate?"":(0,r.qy)(f||(f=b` <slot part="label" class="label"></slot> `)))}constructor(){super(...arguments),this.localize=new c.c(this),this.value=0,this.indeterminate=!1,this.label=""}};m.css=d.A,g([(0,o.MZ)({type:Number,reflect:!0})],m.prototype,"value",2),g([(0,o.MZ)({type:Boolean,reflect:!0})],m.prototype,"indeterminate",2),g([(0,o.MZ)()],m.prototype,"label",2),m=g([(0,o.EM)("wa-progress-bar")],m),i()}catch(v){i(v)}})},4168:function(e,t,a){a.d(t,{A:function(){return r}});let i;var r=(0,a(5124).AH)(i||(i=(e=>e)`:host{--track-height:1rem;--track-color:var(--wa-color-neutral-fill-normal);--indicator-color:var(--wa-color-brand-fill-loud);display:flex}.progress-bar{flex:1 1 auto;display:flex;position:relative;overflow:hidden;height:var(--track-height);border-radius:var(--wa-border-radius-pill);background-color:var(--track-color);color:var(--wa-color-brand-on-loud);font-size:var(--wa-font-size-s)}.indicator{width:var(--percentage);display:flex;align-items:center;justify-content:center;background-color:var(--indicator-color);text-align:center;white-space:nowrap;overflow:hidden;line-height:1;font-weight:var(--wa-font-weight-semibold);transition:all var(--wa-transition-slow, 200ms) var(--wa-transition-easing, ease);user-select:none;-webkit-user-select:none}:host([indeterminate]) .indicator{position:absolute;inset-block:0;inline-size:50%;animation:wa-progress-indeterminate 2.5s infinite cubic-bezier(.37,0,.63,1)}@media (forced-colors:active){.progress-bar{outline:solid 1px SelectedItem;background-color:var(--wa-color-surface-default)}.indicator{outline:solid 1px SelectedItem;background-color:SelectedItem}}@keyframes wa-progress-indeterminate{0%{inset-inline-start:-50%}100%,75%{inset-inline-start:100%}}`))},95010:function(e,t,a){a.d(t,{q:function(){return r},N:function(){return o}});a(54743),a(11745),a(16573),a(78100),a(77936),a(21489),a(48140),a(75044),a(21903),a(91134),a(28845),a(373),a(37467),a(44732),a(79577),a(16632),a(34226),a(9486),a(20456);let i=(e=21)=>{let t="",a=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&a[e]];return t};function r(e,t,a){const i=e=>Object.is(e,-0)?0:e;return i(e<t?t:e>a?a:e)}function o(e=""){return`${e}${i()}`}}}]);