iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 38.2 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[8133],{28417:function(e,t,r){"use strict";r(50808);var n=r(33367),i=r(93592),o=r(87156),a={getTabbableNodes:function(e){var t=[];return this._collectTabbableNodes(e,t)?i.H._sortByTabIndex(t):t},_collectTabbableNodes:function(e,t){if(e.nodeType!==Node.ELEMENT_NODE||!i.H._isVisible(e))return!1;var r,n=e,a=i.H._normalizedTabIndex(n),s=a>0;a>=0&&t.push(n),r="content"===n.localName||"slot"===n.localName?(0,o.vz)(n).getDistributedNodes():(0,o.vz)(n.shadowRoot||n.root||n).children;for(var c=0;c<r.length;c++)s=this._collectTabbableNodes(r[c],t)||s;return s}};function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function f(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var p=customElements.get("paper-dialog"),h={get _focusableNodes(){return a.getTabbableNodes(this)}},m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(r,e);var t=l(r);function r(){return c(this,r),t.apply(this,arguments)}return r}((0,n.P)([h],p));customElements.define("ha-paper-dialog",m)},77760:function(e,t,r){"use strict";r.d(t,{VG:function(){return D},UO:function(){return I}});var n=r(4915),i=r(58831),o=r(27269),a=r(22311),s=r(91741),c=r(49706),u=function(e){var t=[];return Object.keys(e).forEach((function(r){var n=e[r];n.attributes.view&&t.push(n)})),t.sort((function(e,t){return e.entity_id===c.a1?-1:t.entity_id===c.a1?1:e.attributes.order-t.attributes.order})),t},l=function(e,t){var r={};return t.attributes.entity_id.forEach((function(t){var n=e[t];if(n&&(r[n.entity_id]=n,"group"===(0,i.M)(n.entity_id))){var o=function(e,t){var r={};return t.attributes.entity_id.forEach((function(t){var n=e[t];n&&(r[n.entity_id]=n)})),r}(e,n);Object.keys(o).forEach((function(e){var t=o[e];r[e]=t}))}})),r},f=r(85415);function d(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}var p=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){var n=r(t,(function(t){n(),e(t)}))})));case 1:case"end":return e.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){d(o,n,i,a,s,"next",e)}function s(e){d(o,n,i,a,s,"throw",e)}a(void 0)}))});return function(e,r){return t.apply(this,arguments)}}(),h=r(57066),m=r(57292),y=r(74186),v=r(5986),b=r(41499),g=r(14748);function w(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}function _(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){w(o,n,i,a,s,"next",e)}function s(e){w(o,n,i,a,s,"throw",e)}a(void 0)}))}}function k(e){return function(e){if(Array.isArray(e))return P(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||O(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(c){i=!0,o=c}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}(e,t)||O(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=O(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function O(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var S=["binary_sensor","mailbox","person","sensor","sun","timer"],x=new Set(["automation","configurator","device_tracker","geo_location","persistent_notification","zone"]),j=new Set(["mobile_app"]),A=!1,D=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],a=[],c=t.title?"".concat(t.title," "):void 0,u=C(e);try{for(u.s();!(r=u.n()).done;){var l=E(r.value,2),f=l[0],d=l[1],p=(0,i.M)(f);if("alarm_control_panel"===p){var h={type:"alarm-panel",entity:f};o.push(h)}else if("camera"===p){var m={type:"picture-entity",entity:f};o.push(m)}else if("climate"===p){var y={type:"thermostat",entity:f};o.push(y)}else if("humidifier"===p){var v={type:"humidifier",entity:f};o.push(v)}else if("light"===p&&n){var g={type:"light",entity:f};o.push(g)}else if("media_player"===p){var w={type:"media-control",entity:f};o.push(w)}else if("plant"===p){var _={type:"plant-status",entity:f};o.push(_)}else if("weather"===p){var k={type:"weather-forecast",entity:f,show_forecast:!1};o.push(k)}else if("sensor"===p&&(null==d?void 0:d.attributes.device_class)===b.A);else{var O=void 0,P=c&&d&&(O=(0,s.C)(d)).startsWith(c)?{entity:f,name:O.substr(c.length)}:f;a.push(P)}}}catch(S){u.e(S)}finally{u.f()}return a.length>0&&o.unshift(Object.assign({type:"entities",entities:a},t)),o},T=function(e,t,r,n,o,c){var u=function(e){var t=[],r={};return Object.keys(e).forEach((function(n){var o=e[n];"group"===(0,i.M)(n)?t.push(o):r[n]=o})),t.forEach((function(e){return e.attributes.entity_id.forEach((function(e){delete r[e]}))})),{groups:t,ungrouped:r}}(o);u.groups.sort((function(e,t){return c[e.entity_id]-c[t.entity_id]}));var l={},d={};Object.keys(u.ungrouped).forEach((function(e){var t=u.ungrouped[e],r=(0,a.N)(t),n=S.includes(r)?l:d;r in n||(n[r]=[]),n[r].push(t.entity_id)}));var p=[];S.forEach((function(e){e in l&&(p=p.concat(l[e]))}));var h=[];u.groups.forEach((function(e){h=h.concat(D(e.attributes.entity_id.map((function(e){return[e,o[e]]})),{title:(0,s.C)(e),show_header_toggle:"hidden"!==e.attributes.control}))})),Object.keys(d).sort().forEach((function(t){h=h.concat(D(d[t].sort((function(e,t){return(0,f.q)((0,s.C)(o[e]),(0,s.C)(o[t]))})).map((function(e){return[e,o[e]]})),{title:(0,v.Lh)(e,t)}))}));var m={path:t,title:r,badges:(0,g.Q)(p),cards:h};return n&&(m.icon=n),m},z=function(e,t,r,n,i){var o,s=function(e,t){var r={},n=new Set(t.filter((function(e){return j.has(e.platform)})).map((function(e){return e.entity_id})));return Object.keys(e).forEach((function(t){var i=e[t];x.has((0,a.N)(i))||n.has(i.entity_id)||(r[t]=e[t])})),r}(n,r),c={};Object.keys(s).forEach((function(e){var t=s[e];t.attributes.order&&(c[e]=t.attributes.order)}));var u=function(e,t,r,n){var i,o=Object.assign({},n),a=[],s=C(e);try{var c=function(){var e,n=i.value,s=[],c=new Set(t.filter((function(e){return e.area_id===n.area_id})).map((function(e){return e.id}))),u=C(r);try{for(u.s();!(e=u.n()).done;){var l=e.value;c.has(l.device_id)&&l.entity_id in o&&(s.push(o[l.entity_id]),delete o[l.entity_id])}}catch(f){u.e(f)}finally{u.f()}s.length>0&&a.push([n,s])};for(s.s();!(i=s.n()).done;)c()}catch(u){s.e(u)}finally{s.f()}return{areasWithEntities:a,otherEntities:o}}(e,t,r,s),l=T(i,"default_view","Home",undefined,u.otherEntities,c),f=[];return u.areasWithEntities.forEach((function(e){var t=E(e,2),r=t[0],n=t[1];f.push.apply(f,k(D(n.map((function(e){return[e.entity_id,e]})),{title:r.name})))})),(o=l.cards).unshift.apply(o,f),l},R=function(){var e=_(regeneratorRuntime.mark((function e(t,r,n,i,a,c){var f,d,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.safe_mode){e.next=2;break}return e.abrupt("return",{title:t.location_name,views:[{cards:[{type:"safe-mode"}]}]});case 2:return f=u(a),d=f.map((function(e){var t=l(a,e),r={};return Object.keys(t).forEach((function(e,t){r[e]=t})),T(c,(0,o.p)(e.entity_id),(0,s.C)(e),e.attributes.icon,t,r)})),p=t.location_name,0!==f.length&&"group.default_view"===f[0].entity_id||(d.unshift(z(r,n,i,a,c)),t.components.includes("geo_location")&&d[0]&&d[0].cards&&d[0].cards.push({type:"map",geo_location_sources:["all"]}),d.length>1&&"Home"===p&&(p="ioBroker")),1===d.length&&0===d[0].cards.length&&d[0].cards.push({type:"empty-state"}),e.abrupt("return",{title:p,views:d});case 8:case"end":return e.stop()}}),e)})));return function(t,r,n,i,o,a){return e.apply(this,arguments)}}(),I=function(){var e=_(regeneratorRuntime.mark((function e(t,r){var i,o,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.config.state!==n.UE){e.next=2;break}return e.abrupt("return",{title:t.config.location_name,views:[{cards:[{type:"starting"}]}]});case 2:if(!t.config.safe_mode){e.next=4;break}return e.abrupt("return",{title:t.config.location_name,views:[{cards:[{type:"safe-mode"}]}]});case 4:return A||(A=!0,(0,h.sG)(t.connection,(function(){})),(0,m.q4)(t.connection,(function(){})),(0,y.LM)(t.connection,(function(){}))),e.next=7,Promise.all([p(t.connection,h.sG),p(t.connection,m.q4),p(t.connection,y.LM)]);case 7:return i=e.sent,o=E(i,3),a=o[0],s=o[1],c=o[2],e.abrupt("return",R(t.config,a,s,c,t.states,r||t.localize));case 13:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},65430:function(e,t,r){"use strict";r(25856);var n=r(87744),i=r(46628),o=r(7778),a=r(15652);function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=_(e);if(t){var i=_(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?f(e):t}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(){d=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var i=t.placement;if(t.kind===n&&("static"===i||"prototype"===i)){var o="static"===i?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!m(e))return r.push(e);var t=this.decorateElement(e,i);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var o=this.decorateConstructor(r,t);return n.push.apply(n,o.finishers),o.finishers=n,o},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var u=c.extras;if(u){for(var l=0;l<u.length;l++)this.addElementPlacement(u[l],t);r.push.apply(r,u)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=b(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+n+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:n,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:v(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=v(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function p(e){var t,r=b(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function h(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function m(e){return e.decorators&&e.decorators.length}function y(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function v(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function b(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===s(t)?t:String(t)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function w(e,t,r){return(w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=function(e,t,r,n){var i=d();if(n)for(var o=0;o<n.length;o++)i=n[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),r),s=i.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},n=0;n<e.length;n++){var i,o=e[n];if("method"===o.kind&&(i=t.find(r)))if(y(o.descriptor)||y(i.descriptor)){if(m(o)||m(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(m(o)){if(m(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}h(o,i)}else t.push(o)}return t}(a.d.map(p)),e);return i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}(null,(function(e,t){var r=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(n,t);var r=u(n);function n(){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),t=r.call(this),e(f(t)),t.addEventListener("ll-rebuild",(function(){t._cleanup(),t.config&&t._createCard(t.config)})),t}return n}(t);return{F:r,d:[{kind:"field",decorators:[(0,a.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,a.Cb)()],key:"config",value:void 0},{kind:"field",key:"_element",value:void 0},{kind:"get",key:"_error",value:function(){var e;return"HUI-ERROR-CARD"===(null===(e=this._element)||void 0===e?void 0:e.tagName)}},{kind:"method",key:"update",value:function(e){if(w(_(r.prototype),"update",this).call(this,e),e.has("config")){var t=e.get("config");if(!this.config)return void this._cleanup();if(!this.config.type)return void this._createCard((0,o.N2)("No card type found",this.config));if(!this._element)return void this._createCard(this.config);if(!this._error&&t&&this.config.type===t.type)try{this._element.setConfig(this.config)}catch(a){this._createCard((0,o.N2)(a.message,this.config))}else this._createCard(this.config)}if(e.has("hass")){var i=e.get("hass");i&&i.language===this.hass.language||(this.style.direction=(0,n.HE)(this.hass)?"rtl":"ltr"),this._element&&(this._element.hass=this.hass)}}},{kind:"method",key:"_createCard",value:function(e){this._cleanup(),this._element=(0,i.Z6)(e),this.hass&&(this._element.hass=this.hass),this.appendChild(this._element)}},{kind:"method",key:"_cleanup",value:function(){this._element&&(this.removeChild(this._element),this._element=void 0)}}]}}),a.f4);customElements.define("hui-card-preview",k)},9444:function(e,t,r){"use strict";r.r(t),r.d(t,{HuiDialogSuggestCard:function(){return N}});r(22626);var n=r(60461),i=r.n(n),o=r(15652),a=(r(28417),r(18900),r(11654)),s=r(98573),c=r(77760),u=r(54324),l=(r(65430),r(97504));function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}function p(){var e=_(["\n @media all and (max-width: 450px), all and (max-height: 500px) {\n /* overrule the ha-style-dialog max-height on small screens */\n ha-paper-dialog {\n max-height: 100%;\n height: 100%;\n }\n }\n @media all and (min-width: 850px) {\n ha-paper-dialog {\n width: 845px;\n }\n }\n ha-paper-dialog {\n max-width: 845px;\n --dialog-z-index: 5;\n }\n .hidden {\n display: none;\n }\n .element-preview {\n position: relative;\n }\n hui-card-preview {\n padding-top: 8px;\n margin: 4px auto;\n max-width: 390px;\n display: block;\n width: 100%;\n }\n .editor {\n padding-top: 16px;\n }\n "]);return p=function(){return e},e}function h(){var e=_(['\n <ha-circular-progress\n active\n title="Saving"\n size="small"\n ></ha-circular-progress>\n ']);return h=function(){return e},e}function m(){var e=_(['\n <mwc-button @click="','"\n >','</mwc-button\n >\n <mwc-button ?disabled="','" @click="','">\n ',"\n </mwc-button>\n "]);return m=function(){return e},e}function y(){var e=_(['\n <div class="editor">\n <ha-yaml-editor\n .defaultValue=',"\n ></ha-yaml-editor>\n </div>\n "]);return y=function(){return e},e}function v(){var e=_(["\n <hui-card-preview\n .hass=",'\n .config="','"\n ></hui-card-preview>\n ']);return v=function(){return e},e}function b(){var e=_(['\n <div class="element-preview">\n ',"\n </div>\n "]);return b=function(){return e},e}function g(){var e=_(["\n <ha-paper-dialog with-backdrop opened>\n <h2>\n ","\n </h2>\n <paper-dialog-scrollable>\n ","\n ",'\n </paper-dialog-scrollable>\n <div class="paper-dialog-buttons">\n <mwc-button @click="','">\n ',"\n </mwc-button>\n ","\n </div>\n </ha-paper-dialog>\n "]);return g=function(){return e},e}function w(){var e=_([""]);return w=function(){return e},e}function _(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=S(e);if(t){var i=S(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return O(this,r)}}function O(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(){x=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var i=t.placement;if(t.kind===n&&("static"===i||"prototype"===i)){var o="static"===i?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!D(e))return r.push(e);var t=this.decorateElement(e,i);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var o=this.decorateConstructor(r,t);return n.push.apply(n,o.finishers),o.finishers=n,o},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var u=c.extras;if(u){for(var l=0;l<u.length;l++)this.addElementPlacement(u[l],t);r.push.apply(r,u)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=R(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+n+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:n,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:z(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=z(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function j(e){var t,r=R(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function A(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function D(e){return e.decorators&&e.decorators.length}function T(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function z(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function R(e){var t=function(e,t){if("object"!==f(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===f(t)?t:String(t)}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var N=function(e,t,r,n){var i=x();if(n)for(var o=0;o<n.length;o++)i=n[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),r),s=i.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},n=0;n<e.length;n++){var i,o=e[n];if("method"===o.kind&&(i=t.find(r)))if(T(o.descriptor)||T(i.descriptor)){if(D(o)||D(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(D(o)){if(D(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}A(o,i)}else t.push(o)}return t}(a.d.map(j)),e);return i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,o.Mo)("hui-dialog-suggest-card")],(function(e,t){var r,n;return{F:function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&E(e,t)}(n,t);var r=C(n);function n(){var t;k(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=r.call.apply(r,[this].concat(o)),e(P(t)),t}return n}(t),d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_cardConfig",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_saving",value:function(){return!1}},{kind:"field",decorators:[(0,o.IO)("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"method",key:"showDialog",value:function(e){var t=this;this._params=e,this._cardConfig=e.cardConfig||(0,c.VG)(e.entities.map((function(e){return[e,t.hass.states[e]]})),{},!0),Object.isFrozen(this._cardConfig)||(this._cardConfig=i()(this._cardConfig)),this._yamlEditor&&this._yamlEditor.setValue(this._cardConfig)}},{kind:"method",key:"render",value:function(){var e=this;return this._params?(0,o.dy)(g(),this.hass.localize("ui.panel.lovelace.editor.suggest_card.header"),this._cardConfig?(0,o.dy)(b(),this._cardConfig.map((function(t){return(0,o.dy)(v(),e.hass,t)}))):"",this._params.yaml&&this._cardConfig?(0,o.dy)(y(),this._cardConfig):"",this._close,this._params.yaml?this.hass.localize("ui.common.close"):this.hass.localize("ui.common.cancel"),this._params.yaml?"":(0,o.dy)(m(),this._pickCard,this.hass.localize("ui.panel.lovelace.editor.suggest_card.create_own"),this._saving,this._save,this._saving?(0,o.dy)(h()):this.hass.localize("ui.panel.lovelace.editor.suggest_card.add"))):(0,o.dy)(w())}},{kind:"get",static:!0,key:"styles",value:function(){return[a.yu,(0,o.iv)(p())]}},{kind:"method",key:"_close",value:function(){this._params=void 0,this._cardConfig=void 0}},{kind:"method",key:"_pickCard",value:function(){var e,t,r;(null===(e=this._params)||void 0===e?void 0:e.lovelaceConfig)&&(null===(t=this._params)||void 0===t?void 0:t.path)&&(null===(r=this._params)||void 0===r?void 0:r.saveConfig)&&((0,l.F)(this,{lovelaceConfig:this._params.lovelaceConfig,saveConfig:this._params.saveConfig,path:this._params.path,entities:this._params.entities}),this._close())}},{kind:"method",key:"_save",value:(r=regeneratorRuntime.mark((function e(){var t,r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null===(t=this._params)||void 0===t?void 0:t.lovelaceConfig)&&(null===(r=this._params)||void 0===r?void 0:r.path)&&(null===(n=this._params)||void 0===n?void 0:n.saveConfig)&&this._cardConfig){e.next=2;break}return e.abrupt("return");case 2:return this._saving=!0,e.next=5,this._params.saveConfig((0,u.BN)(this._params.lovelaceConfig,this._params.path,this._cardConfig));case 5:this._saving=!1,(0,s.f)(this,this.hass),this._close();case 8:case"end":return e.stop()}}),e,this)})),n=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function a(e){d(o,n,i,a,s,"next",e)}function s(e){d(o,n,i,a,s,"throw",e)}a(void 0)}))},function(){return n.apply(this,arguments)})}]}}),o.oi)},97504:function(e,t,r){"use strict";r.d(t,{F:function(){return o}});var n=r(47181),i=function(){return Promise.all([r.e(6372),r.e(5755),r.e(9494),r.e(5324),r.e(1480),r.e(4821),r.e(7164),r.e(2899),r.e(2979),r.e(5804),r.e(8170)]).then(r.bind(r,52408))},o=function(e,t){(0,n.B)(e,"show-dialog",{dialogTag:"hui-dialog-create-card",dialogImport:i,dialogParams:t})}},14748:function(e,t,r){"use strict";function n(e){return e.map((function(e){return"string"==typeof e?{entity:e}:e}))}r.d(t,{Q:function(){return n}})},98573:function(e,t,r){"use strict";r.d(t,{f:function(){return i}});var n=r(81796),i=function(e,t){return(0,n.C)(e,{message:t.localize("ui.common.successfully_saved")})}}}]);
//# sourceMappingURL=chunk.49cfd6a631565be12a58.js.map