/*! For license information please see 78008198a16eeb2d0876.chunk.js.LICENSE */
(window.webpackJsonp=window.webpackJsonp||[]).push([[24],{216:function(e,t,a){"use strict";a(63),a(62),a(230),a(202);var i=a(0),o=a(4),r=(a(237),a(127),a(29)),n=a(13),s=a(14);customElements.define("ha-entity-picker",class extends(Object(s.a)(Object(n.a)(o.a))){static get template(){return i["a"]`
    <style>
      paper-input > paper-icon-button {
        width: 24px;
        height: 24px;
        padding: 2px;
        color: var(--secondary-text-color);
      }
      [hidden] {
        display: none;
      }
    </style>
    <vaadin-combo-box-light
      items="[[_states]]"
      item-value-path="entity_id"
      item-label-path="entity_id"
      value="{{value}}"
      opened="{{opened}}"
      allow-custom-value="[[allowCustomEntity]]"
      on-change='_fireChanged'
    >
      <paper-input autofocus="[[autofocus]]" label="[[_computeLabel(label, localize)]]" class="input" value="[[value]]" disabled="[[disabled]]">
        <paper-icon-button slot="suffix" class="clear-button" icon="hass:close" no-ripple="" hidden$="[[!value]]">Clear</paper-icon-button>
        <paper-icon-button slot="suffix" class="toggle-button" icon="[[_computeToggleIcon(opened)]]" hidden="[[!_states.length]]">Toggle</paper-icon-button>
      </paper-input>
      <template>
        <style>
          paper-icon-item {
            margin: -10px;
          }
        </style>
        <paper-icon-item>
          <state-badge state-obj="[[item]]" slot="item-icon"></state-badge>
          <paper-item-body two-line="">
            <div>[[_computeStateName(item)]]</div>
            <div secondary="">[[item.entity_id]]</div>
          </paper-item-body>
        </paper-icon-item>
      </template>
    </vaadin-combo-box-light>
`}static get properties(){return{allowCustomEntity:{type:Boolean,value:!1},hass:{type:Object,observer:"_hassChanged"},_hass:Object,_states:{type:Array,computed:"_computeStates(_hass, domainFilter, entityFilter)"},autofocus:Boolean,label:{type:String},value:{type:String,notify:!0},opened:{type:Boolean,value:!1,observer:"_openedChanged"},domainFilter:{type:String,value:null},entityFilter:{type:Function,value:null},disabled:Boolean}}_computeLabel(e,t){return void 0===e?t("ui.components.entity.entity-picker.entity"):e}_computeStates(e,t,a){if(!e)return[];let i=Object.keys(e.states);t&&(i=i.filter(e=>e.substr(0,e.indexOf("."))===t));let o=i.sort().map(t=>e.states[t]);return a&&(o=o.filter(a)),o}_computeStateName(e){return Object(r.a)(e)}_openedChanged(e){e||(this._hass=this.hass)}_hassChanged(e){this.opened||(this._hass=e)}_computeToggleIcon(e){return e?"hass:menu-up":"hass:menu-down"}_fireChanged(e){e.stopPropagation(),this.fire("change")}})},273:function(e,t,a){"use strict";a(2);var i=/\.splices$/,o=/\.length$/,r=/\.?#?([0-9]+)$/;const n={properties:{data:{type:Object,notify:!0,value:function(){return this.zeroValue}},sequentialTransactions:{type:Boolean,value:!1},log:{type:Boolean,value:!1}},observers:["__dataChanged(data.*)"],created:function(){this.__initialized=!1,this.__syncingToMemory=!1,this.__initializingStoredValue=null,this.__transactionQueueAdvances=Promise.resolve()},ready:function(){this._initializeStoredValue()},get isNew(){return!0},get transactionsComplete(){return this.__transactionQueueAdvances},get zeroValue(){},saveValue:function(e){return Promise.resolve()},reset:function(){},destroy:function(){return this.data=this.zeroValue,this.saveValue()},initializeStoredValue:function(){return this.isNew?Promise.resolve():this._getStoredValue("data").then(function(e){if(this._log("Got stored value!",e,this.data),null==e)return this._setStoredValue("data",this.data||this.zeroValue);this.syncToMemory(function(){this.set("data",e)})}.bind(this))},getStoredValue:function(e){return Promise.resolve()},setStoredValue:function(e,t){return Promise.resolve(t)},memoryPathToStoragePath:function(e){return e},storagePathToMemoryPath:function(e){return e},syncToMemory:function(e){this.__syncingToMemory||(this._group("Sync to memory."),this.__syncingToMemory=!0,e.call(this),this.__syncingToMemory=!1,this._groupEnd("Sync to memory."))},valueIsEmpty:function(e){return Array.isArray(e)?0===e.length:Object.prototype.isPrototypeOf(e)?0===Object.keys(e).length:null==e},_getStoredValue:function(e){return this.getStoredValue(this.memoryPathToStoragePath(e))},_setStoredValue:function(e,t){return this.setStoredValue(this.memoryPathToStoragePath(e),t)},_enqueueTransaction:function(e){if(this.sequentialTransactions)e=e.bind(this);else{var t=e.call(this);e=function(){return t}}return this.__transactionQueueAdvances=this.__transactionQueueAdvances.then(e).catch(function(e){this._error("Error performing queued transaction.",e)}.bind(this))},_log:function(){this.log&&console.log.apply(console,arguments)},_error:function(){this.log&&console.error.apply(console,arguments)},_group:function(){this.log&&console.group.apply(console,arguments)},_groupEnd:function(){this.log&&console.groupEnd.apply(console,arguments)},_initializeStoredValue:function(){if(!this.__initializingStoredValue){this._group("Initializing stored value.");var e=this.__initializingStoredValue=this.initializeStoredValue().then(function(){this.__initialized=!0,this.__initializingStoredValue=null,this._groupEnd("Initializing stored value.")}.bind(this)).catch(function(e){this.__initializingStoredValue=null,this._groupEnd("Initializing stored value.")}.bind(this));return this._enqueueTransaction(function(){return e})}},__dataChanged:function(e){if(!this.isNew&&!this.__syncingToMemory&&this.__initialized&&!this.__pathCanBeIgnored(e.path)){var t=this.__normalizeMemoryPath(e.path),a=e.value,i=a&&a.indexSplices;this._enqueueTransaction(function(){return this._log("Setting",t+":",i||a),i&&this.__pathIsSplices(t)&&(t=this.__parentPath(t),a=this.get(t)),this._setStoredValue(t,a)})}},__normalizeMemoryPath:function(e){for(var t=e.split("."),a=[],i=[],o=[],r=0;r<t.length;++r)i.push(t[r]),/^#/.test(t[r])?o.push(this.get(a).indexOf(this.get(i))):o.push(t[r]),a.push(t[r]);return o.join(".")},__parentPath:function(e){var t=e.split(".");return t.slice(0,t.length-1).join(".")},__pathCanBeIgnored:function(e){return o.test(e)&&Array.isArray(this.get(this.__parentPath(e)))},__pathIsSplices:function(e){return i.test(e)&&Array.isArray(this.get(this.__parentPath(e)))},__pathRefersToArray:function(e){return(i.test(e)||o.test(e))&&Array.isArray(this.get(this.__parentPath(e)))},__pathTailToIndex:function(e){var t=e.split(".").pop();return window.parseInt(t.replace(r,"$1"),10)}};var s=a(3);Object(s.a)({is:"app-localstorage-document",behaviors:[n],properties:{key:{type:String,notify:!0},sessionOnly:{type:Boolean,value:!1},storage:{type:Object,computed:"__computeStorage(sessionOnly)"}},observers:["__storageSourceChanged(storage, key)"],attached:function(){this.listen(window,"storage","__onStorage"),this.listen(window.top,"app-local-storage-changed","__onAppLocalStorageChanged")},detached:function(){this.unlisten(window,"storage","__onStorage"),this.unlisten(window.top,"app-local-storage-changed","__onAppLocalStorageChanged")},get isNew(){return!this.key},saveValue:function(e){try{this.__setStorageValue(e,this.data)}catch(e){return Promise.reject(e)}return this.key=e,Promise.resolve()},reset:function(){this.key=null,this.data=this.zeroValue},destroy:function(){try{this.storage.removeItem(this.key),this.reset()}catch(e){return Promise.reject(e)}return Promise.resolve()},getStoredValue:function(e){var t;if(null!=this.key)try{t=null!=(t=this.__parseValueFromStorage())?this.get(e,{data:t}):void 0}catch(e){return Promise.reject(e)}return Promise.resolve(t)},setStoredValue:function(e,t){if(null!=this.key){try{this.__setStorageValue(this.key,this.data)}catch(e){return Promise.reject(e)}this.fire("app-local-storage-changed",this,{node:window.top})}return Promise.resolve(t)},__computeStorage:function(e){return e?window.sessionStorage:window.localStorage},__storageSourceChanged:function(e,t){this._initializeStoredValue()},__onStorage:function(e){e.key===this.key&&e.storageArea===this.storage&&this.syncToMemory(function(){this.set("data",this.__parseValueFromStorage())})},__onAppLocalStorageChanged:function(e){e.detail!==this&&e.detail.key===this.key&&e.detail.storage===this.storage&&this.syncToMemory(function(){this.set("data",e.detail.data)})},__parseValueFromStorage:function(){try{return JSON.parse(this.storage.getItem(this.key))}catch(e){console.error("Failed to parse value from storage for",this.key)}},__setStorageValue:function(e,t){void 0===t&&(t=null),this.storage.setItem(e,JSON.stringify(t))}})},274:function(e,t,a){"use strict";var i=a(0),o=a(4),r=(a(63),a(62),a(120),a(237),a(14));customElements.define("ha-combo-box",class extends(Object(r.a)(o.a)){static get template(){return i["a"]`
    <style>
      paper-input > paper-icon-button {
        width: 24px;
        height: 24px;
        padding: 2px;
        color: var(--secondary-text-color);
      }
      [hidden] {
        display: none;
      }
    </style>
    <vaadin-combo-box-light
      items="[[_items]]"
      item-value-path="[[itemValuePath]]"
      item-label-path="[[itemLabelPath]]"
      value="{{value}}"
      opened="{{opened}}"
      allow-custom-value="[[allowCustomValue]]"
      on-change='_fireChanged'
    >
      <paper-input autofocus="[[autofocus]]" label="[[label]]" class="input" value="[[value]]">
        <paper-icon-button slot="suffix" class="clear-button" icon="hass:close" hidden$="[[!value]]">Clear</paper-icon-button>
        <paper-icon-button slot="suffix" class="toggle-button" icon="[[_computeToggleIcon(opened)]]" hidden$="[[!items.length]]">Toggle</paper-icon-button>
      </paper-input>
      <template>
        <style>
            paper-item {
              margin: -5px -10px;
            }
        </style>
        <paper-item>[[_computeItemLabel(item, itemLabelPath)]]</paper-item>
      </template>
    </vaadin-combo-box-light>
`}static get properties(){return{allowCustomValue:Boolean,items:{type:Object,observer:"_itemsChanged"},_items:Object,itemLabelPath:String,itemValuePath:String,autofocus:Boolean,label:String,opened:{type:Boolean,value:!1,observer:"_openedChanged"},value:{type:String,notify:!0}}}_openedChanged(e){e||(this._items=this.items)}_itemsChanged(e){this.opened||(this._items=e)}_computeToggleIcon(e){return e?"hass:menu-up":"hass:menu-down"}_computeItemLabel(e,t){return t?e[t]:e}_fireChanged(e){e.stopPropagation(),this.fire("change")}});var n=a(13);customElements.define("ha-service-picker",class extends(Object(n.a)(o.a)){static get template(){return i["a"]`
    <ha-combo-box label="[[localize('ui.components.service-picker.service')]]" items="[[_services]]" value="{{value}}" allow-custom-value=""></ha-combo-box>
`}static get properties(){return{hass:{type:Object,observer:"_hassChanged"},_services:Array,value:{type:String,notify:!0}}}_hassChanged(e,t){if(!e)return void(this._services=[]);if(t&&e.services===t.services)return;const a=[];Object.keys(e.services).sort().forEach(t=>{const i=Object.keys(e.services[t]).sort();for(let e=0;e<i.length;e++)a.push(`${t}.${i[e]}`)}),this._services=a}})},626:function(e,t,a){"use strict";a.r(t),a(158),a(157),a(123),a(55),a(209);var i=a(0),o=a(4);a(216),a(135),a(274),a(121),a(273);const r={};customElements.define("ha-panel-dev-service",class extends o.a{static get template(){return i["a"]`
  <style include='ha-style'>
    :host {
      -ms-user-select: initial;
      -webkit-user-select: initial;
      -moz-user-select: initial;
    }

    .content {
      padding: 16px;
    }

    .ha-form {
      margin-right: 16px;
      max-width: 400px;
    }

    .description {
      margin-top: 24px;
      white-space: pre-wrap;
    }

    .header {
      @apply --paper-font-title;
    }

    .attributes th {
      text-align: left;
    }

    .attributes tr {
      vertical-align: top;
    }

    .attributes tr:nth-child(odd) {
      background-color: var(--table-row-background-color,#eee)
    }

    .attributes tr:nth-child(even) {
      background-color: var(--table-row-alternative-background-color,#eee)
    }

    .attributes td:nth-child(3) {
      white-space: pre-wrap;
      word-break: break-word;
    }

    pre {
      margin: 0;
    }

    h1 {
      white-space: normal;
    }

    td {
      padding: 4px;
    }

    .error {
      color: var(--google-red-500);
    }
  </style>

  <app-header-layout has-scrolling-region>
    <app-header slot="header" fixed>
      <app-toolbar>
        <ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button>
        <div main-title>Services</div>
      </app-toolbar>
    </app-header>

    <app-localstorage-document
      key='panel-dev-service-state-domain-service'
      data='{{domainService}}'>
    </app-localstorage-document>
    <app-localstorage-document
      key='[[_computeServicedataKey(domainService)]]'
      data='{{serviceData}}'>
    </app-localstorage-document>

    <div class='content'>
      <p>
        The service dev tool allows you to call any available service in Home Assistant.
      </p>

      <div class='ha-form'>
        <ha-service-picker
          hass='[[hass]]'
          value='{{domainService}}'
        ></ha-service-picker>
        <template is='dom-if' if='[[_computeHasEntity(_attributes)]]'>
          <ha-entity-picker
            hass='[[hass]]'
            value='[[_computeEntityValue(parsedJSON)]]'
            on-change='_entityPicked'
            disabled='[[!validJSON]]'
            domain-filter='[[_computeEntityDomainFilter(_domain)]]'
            allow-custom-entity
          ></ha-entity-picker>
        </template>
        <paper-textarea
          always-float-label
          label='Service Data (JSON, optional)'
          value='{{serviceData}}'
        ></paper-textarea>
        <paper-button
          on-click='_callService'
          raised
          disabled='[[!validJSON]]'
        >Call Service</paper-button>
        <template is='dom-if' if='[[!validJSON]]'>
            <span class='error'>Invalid JSON</span>
        </template>
      </div>

      <template is='dom-if' if='[[!domainService]]'>
        <h1>Select a service to see the description</h1>
      </template>

      <template is='dom-if' if='[[domainService]]'>
        <template is='dom-if' if='[[!_description]]'>
          <h1>No description is available</h1>
        </template>
        <template is='dom-if' if='[[_description]]'>
          <h3>[[_description]]</h3>

          <table class='attributes'>
            <tr>
              <th>Parameter</th>
              <th>Description</th>
              <th>Example</th>
            </tr>
            <template is='dom-if' if='[[!_attributes.length]]'>
              <tr><td colspan='3'>This service takes no parameters.</td></tr>
            </template>
            <template is='dom-repeat' items='[[_attributes]]' as='attribute'>
              <tr>
                <td><pre>[[attribute.key]]</pre></td>
                <td>[[attribute.description]]</td>
                <td>[[attribute.example]]</td>
              </tr>
            </template>
          </table>
        </template>
      </template>
    </div>

  </app-header-layout>
    `}static get properties(){return{hass:{type:Object},narrow:{type:Boolean,value:!1},showMenu:{type:Boolean,value:!1},domainService:{type:String,observer:"_domainServiceChanged"},_domain:{type:String,computed:"_computeDomain(domainService)"},_service:{type:String,computed:"_computeService(domainService)"},serviceData:{type:String,value:""},parsedJSON:{type:Object,computed:"_computeParsedServiceData(serviceData)"},validJSON:{type:Boolean,computed:"_computeValidJSON(parsedJSON)"},_attributes:{type:Array,computed:"_computeAttributesArray(hass, _domain, _service)"},_description:{type:String,computed:"_computeDescription(hass, _domain, _service)"}}}_domainServiceChanged(){this.serviceData=""}_computeAttributesArray(e,t,a){const i=e.services;if(!(t in i))return[];if(!(a in i[t]))return[];const o=i[t][a].fields;return Object.keys(o).map(function(e){return Object.assign({key:e},o[e])})}_computeDescription(e,t,a){const i=e.services;if(t in i&&a in i[t])return i[t][a].description}_computeServicedataKey(e){return`panel-dev-service-state-servicedata.${e}`}_computeDomain(e){return e.split(".",1)[0]}_computeService(e){return e.split(".",2)[1]||null}_computeParsedServiceData(e){try{return e?JSON.parse(e):{}}catch(e){return r}}_computeValidJSON(e){return e!==r}_computeHasEntity(e){return e.some(e=>"entity_id"===e.key)}_computeEntityValue(e){return e===r?"":e.entity_id}_computeEntityDomainFilter(e){return"homeassistant"===e?null:e}_callService(){this.parsedJSON===r&&alert(`Error parsing JSON: ${this.serviceData}`),this.hass.callService(this._domain,this._service,this.parsedJSON)}_entityPicked(e){this.serviceData=JSON.stringify(Object.assign({},this.parsedJSON,{entity_id:e.target.value}),null,2)}})}}]);
//# sourceMappingURL=78008198a16eeb2d0876.chunk.js.map