353 lines
76 KiB
JavaScript
353 lines
76 KiB
JavaScript
|
/*! *****************************************************************************
|
||
|
Copyright (c) Microsoft Corporation.
|
||
|
|
||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||
|
purpose with or without fee is hereby granted.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
|
PERFORMANCE OF THIS SOFTWARE.
|
||
|
***************************************************************************** */
|
||
|
function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r);return s>3&&r&&Object.defineProperty(e,i,r),r
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/}const e="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},n=`{{lit-${String(Math.random()).slice(2)}}}`,o=`\x3c!--${n}--\x3e`,s=new RegExp(`${n}|${o}`);class r{constructor(t,e){this.parts=[],this.element=e;const i=[],o=[],r=document.createTreeWalker(e.content,133,null,!1);let d=0,u=-1,h=0;const{strings:p,values:{length:g}}=t;for(;h<g;){const t=r.nextNode();if(null!==t){if(u++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:i}=e;let n=0;for(let t=0;t<i;t++)a(e[t].name,"$lit$")&&n++;for(;n-- >0;){const e=p[h],i=c.exec(e)[2],n=i.toLowerCase()+"$lit$",o=t.getAttribute(n);t.removeAttribute(n);const r=o.split(s);this.parts.push({type:"attribute",index:u,name:i,strings:r}),h+=r.length-1}}"TEMPLATE"===t.tagName&&(o.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,o=e.split(s),r=o.length-1;for(let e=0;e<r;e++){let i,s=o[e];if(""===s)i=l();else{const t=c.exec(s);null!==t&&a(t[2],"$lit$")&&(s=s.slice(0,t.index)+t[1]+t[2].slice(0,-"$lit$".length)+t[3]),i=document.createTextNode(s)}n.insertBefore(i,t),this.parts.push({type:"node",index:++u})}""===o[r]?(n.insertBefore(l(),t),i.push(t)):t.data=o[r],h+=r}}else if(8===t.nodeType)if(t.data===n){const e=t.parentNode;null!==t.previousSibling&&u!==d||(u++,e.insertBefore(l(),t)),d=u,this.parts.push({type:"node",index:u}),null===t.nextSibling?t.data="":(i.push(t),u--),h++}else{let e=-1;for(;-1!==(e=t.data.indexOf(n,e+1));)this.parts.push({type:"node",index:-1}),h++}}else r.currentNode=o.pop()}for(const t of i)t.parentNode.removeChild(t)}}const a=(t,e)=>{const i=t.length-e.length;return i>=0&&t.slice(i)===e},d=t=>-1!==t.index,l=()=>document.createComment(""),c=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function u(t,e){const{element:{content:i},parts:n}=t,o=document.createTreeWalker(i,133,null,!1);let s=p(n),r=n[s],a=-1,d=0;const l=[];let c=null;for(;o.nextNode();){a++;const t=o.currentNode;for(t.previousSibling===c&&(c=null),e.has(t)&&(l.push(t),null===c&&(c=t)),null!==c&&d++;void 0!==r&&r.index===a;)r.index=null!==c?-1:r.index-d,s=p(n,s),r=n[s]}l.forEach((t=>t.parentNode.removeChild(t)))}const h=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},p=(t,e=-1)=>{for(let i=e+1;i<t.length;i++){const e=t[i];if(d(e))return i}return-1};
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/
|
||
|
const g=new WeakMap,f=t=>"function"==typeof t&&g.has(t),v={},m={};
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/
|
||
|
class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),i=[],n=this.template.parts,o=document.createTreeWalker(t,133,null,!1);let s,r=0,a=0,l=o.nextNode();for(;r<n.length;)if(s=n[r],d(s)){for(;a<s.index;)a++,"TEMPLATE"===l.nodeName&&(i.push(l),o.currentNode=l.content),null===(l=o.nextNode())&&(o.currentNode=i.pop(),l=o.nextNode());if("node"===s.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(l.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,s.name,s.strings,this.options));r++}else this.__parts.push(void 0),r++;return e&&(document.adoptNode(t),customElements.upgrade(t)),t}}
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/const y=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),S=` ${n} `;class b{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let s=0;s<t;s++){const t=this.strings[s],r=t.lastIndexOf("\x3c!--");i=(r>-1||i)&&-1===t.indexOf("--\x3e",r+1);const a=c.exec(t);e+=null===a?t+(i?S:o):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==y&&(e=y.createHTML(e)),t.innerHTML=e,t}}class w extends b{getHTML(){return`<svg>${super.getHTML()}</svg>`}getTemplateElement(){const t=super.getTemplateElement(),e=t.content,i=e.firstChild;return e.removeChild(i),((t,e,i=null,n=null)=>{for(;e!==i;){const i=e.nextSibling;t.insertBefore(e,n),e=i}})(e,i.firstChild),t}}
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/const N=t=>null===t||!("object"==typeof t||"function"==typeof t),E=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class O{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t<i.length-1;t++)this.parts[t]=this._createPart()}_createPart(){return new k(this)}_getValue(){const t=this.strings,e=t.length-1,i=this.parts;if(1===e&&""===t[0]&&""===t[1]){const t=i[0].value;if("symbol"==typeof t)return String(t);if("string"==typeof t||!E(t))return t}let n="";for(let o=0;o<e;o++){n+=t[o];const e=i[o];if(void 0!==e){const t=e.value;if(N(t)||!E(t))n+="string"==typeof t?t:String(t);else for(const e of t)n+="string"==typeof e?e:String(e)}}return n+=t[e],n}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class k{constructor(t){this.value=void 0,this.committer=t}setValue(t){t===v||N(t)&&t===this.value||(this.value=t,f(t)||(this.committer.dirty=!0))}commit(){for(;f(this.value);){const t=this.value;this.value=v,t(this)}this.value!==v&&this.committer.commit()}}class W{constructor(t){this.value=void 0,this.__pendingValue=void 0,this.options=t}appendInto(t){this.startNode=t.appendChild(l()),this.endNode=t.appendChild(l())}insertAfterNode(t){this.startNode=t,this.endNode=t.nextSibling}appendIntoPart(t){t.__insert(this.startNode=l()),t.__insert(this.endNode=l())}insertAfterPart(t){t.__insert(this.startNode=l()),this.endNode=t.endNode,t.endNode=this.startNode}setValue(t){this.__pendingValue=t}commit(){if(null===this.startNode.parentNode)return;for(;f(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=v,t(this)}const t=this.__pendingValue;t!==v&&(N(t)?t!==this.value&&this.__commitText(t):t instanceof b?this.__commitTemplateResult(t):t instanceof Node?this.__commitNode(t):E(t)?this.__commitIterable(t):t===m?(this.value=m,this.clear()):this.__commitText(t))}__insert(t){this.endNode.parentNode.insertBefore(t,this.endNode)}__commitNode(t){this.value!==t&&(this.clear(),this.__insert(t),this.value=t)}__commitText(t){const e=this.startNode.nextSibling,i="string"==typeof(t=null==t?"":t)?t:String(t);e===this.endNode.previousSibling&&3===e.nodeType?e.data=i:this.__commitNode(document.createTextNode(i)),this.value=t}__commitTemplateResult(t){const e=this.options.templateFactory(t);if(this.value instanceof _&&this.value.template===e)this.value.update(t.values);else{const i=new _(e,t.processor,this.options),n=i._clone();i.update(t.values),this.__commitNode(n),this.value=i}}__commitIterable(t){Array.isArray(this.value)||(this.value=[],this.clear());const e=this.value;let i,n=0;for(const o of t)i=e[n],void 0===i&&(i=new W(this.options),e.push(i),0===n?i.appendIntoPart(this):i.insertAfterPart(e[n-1])),i.setValue(o),i.commit(),n++;n<e.length&&(e.length=n,this.clear(i&&i.endNode))}clear(t=this.startNode){i(this.startNode.parentNode,t.nextSibling,this.endNode)}}class x{constructor(t,e,i){if(this.value=void 0,this.__pendingValue=void 0,2!==i.length||""!==i[0]||""!==i[1])throw new Error("Boolean attributes can only contain a single expression");this.element=t,this.name=e,this.strings=i}setValue(t){this.__pendingValue=t}commit(){for(;f(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=v,t(this)}if(this.__pendingValue===v)return;const t=!!this.__pendingValue;this.value!==t&&(t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=t),this.__pendingValue=v}}class C extends O{constructor(t,e,i){super(t,e,i),this.single=2===i.length&&""===i[0]&&""===i[1]}_createPart(){return new P(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class P extends k{}let V=!1;(()=>{try{const t={get capture(){return V=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class j{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}com
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/;function M(t){let e=$.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},$.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const o=t.strings.join(n);return i=e.keyString.get(o),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(o,i)),e.stringsArray.set(t.strings,i),i}const $=new Map,D=new WeakMap;
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/const T=new
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/
|
||
|
class{handleAttributeExpressions(t,e,i,n){const o=e[0];if("."===o){return new C(t,e.slice(1),i).parts}if("@"===o)return[new j(t,e.slice(1),n.eventContext)];if("?"===o)return[new x(t,e.slice(1),i)];return new O(t,e,i).parts}handleTextExpression(t){return new W(t)}};
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const A=(t,...e)=>new b(t,e,"html",T),I=(t,...e)=>new w(t,e,"svg",T)
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/,R=(t,e)=>`${t}--${e}`;let U=!0;void 0===window.ShadyCSS?U=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),U=!1);const Z=t=>e=>{const i=R(e.type,t);let o=$.get(i);void 0===o&&(o={stringsArray:new WeakMap,keyString:new Map},$.set(i,o));let s=o.stringsArray.get(e.strings);if(void 0!==s)return s;const a=e.strings.join(n);if(s=o.keyString.get(a),void 0===s){const i=e.getTemplateElement();U&&window.ShadyCSS.prepareTemplateDom(i,t),s=new r(e,i),o.keyString.set(a,s)}return o.stringsArray.set(e.strings,s),s},H=["html","svg"],Y=new Set,q=(t,e,i)=>{Y.add(t);const n=i?i.element:document.createElement("template"),o=e.querySelectorAll("style"),{length:s}=o;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(n,t);const r=document.createElement("style");for(let t=0;t<s;t++){const e=o[t];e.parentNode.removeChild(e),r.textContent+=e.textContent}(t=>{H.forEach((e=>{const i=$.get(R(e,t));void 0!==i&&i.keyString.forEach((t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach((t=>{i.add(t)})),u(t,i)}))}))})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:o}=t;if(null==i)return void n.appendChild(e);const s=document.createTreeWalker(n,133,null,!1);let r=p(o),a=0,d=-1;for(;s.nextNode();)for(d++,s.currentNode===i&&(a=h(e),i.parentNode.insertBefore(e,i));-1!==r&&o[r].index===d;){if(a>0){for(;-1!==r;)o[r].index+=a,r=p(o,r);return}r=p(o,r)}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const d=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==d)e.insertBefore(d.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),u(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const L={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},F=(t,e)=>e!==t&&(e==e||t==t),J={attribute:!0,type:String,converter:L,reflect:!1,hasChanged:F};class K extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach(((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))})),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach(((t,e)=>this._classProperties.set(e,t)))}}static createProperty(t,e=J){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():`__${t}`,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const o=this[t];this[e]=n,this.requestUpdateInternal(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||J}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=F){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||L,o="function"==typeof n?n:n.fromA
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/
|
||
|
const B=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(t,e),X=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function G(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):X(t,e)}function Q(t){return G({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}
|
||
|
/**
|
||
|
@license
|
||
|
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
|
||
|
This code may only be used under the BSD style license found at
|
||
|
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
||
|
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
||
|
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
||
|
part of the polymer project is also subject to an additional IP rights grant
|
||
|
found at http://polymer.github.io/PATENTS.txt
|
||
|
*/const tt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,et=Symbol();class it{constructor(t,e){if(e!==et)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(tt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const nt=(t,...e)=>{const i=e.reduce(((e,i,n)=>e+(t=>{if(t instanceof it)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[n+1]),t[0]);return new it(i,et)};
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||
|
* This code may only be used under the BSD style license found at
|
||
|
* http://polymer.github.io/LICENSE.txt
|
||
|
* The complete set of authors may be found at
|
||
|
* http://polymer.github.io/AUTHORS.txt
|
||
|
* The complete set of contributors may be found at
|
||
|
* http://polymer.github.io/CONTRIBUTORS.txt
|
||
|
* Code distributed by Google as part of the polymer project is also
|
||
|
* subject to an additional IP rights grant found at
|
||
|
* http://polymer.github.io/PATENTS.txt
|
||
|
*/
|
||
|
(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const ot={};class st extends K{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight(((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t)),i),i=e(t,new Set),n=[];i.forEach((t=>n.unshift(t))),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map((t=>{if(t instanceof CSSStyleSheet&&!tt){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new it(String(e),et)}return t}))}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?tt?this.renderRoot.adoptedStyleSheets=t.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map((t=>t.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ot&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)})))}render(){return ot}}st.finalized=!0,st.render=(t,e,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const o=n.scopeName,s=D.has(e),r=U&&11===e.nodeType&&!!e.host,a=r&&!Y.has(o),d=a?document.createDocumentFragment():e;if(((t,e,n)=>{let o=D.get(e);void 0===o&&(i(e,e.firstChild),D.set(e,o=new W(Object.assign({templateFactory:M},n))),o.appendInto(e)),o.setValue(t),o.commit()})(t,d,Object.assign({templateFactory:Z(o)},n)),a){const t=D.get(d);D.delete(d);const n=t.value instanceof _?t.value.template:void 0;q(o,d,n),i(e,e.firstChild),e.appendChild(d),D.set(e,t)}!s&&r&&window.ShadyCSS.styleElement(e.host)};var rt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,at="[^\\s]+",dt=/\[([^]*?)\]/gm;function lt(t,e){for(var i=[],n=0,o=t.length;n<o;n++)i.push(t[n].substr(0,e));return i}var ct=function(t){return function(e,i){var n=i[t].map((function(t){return t.toLowerCase()})).indexOf(e.toLowerCase());return n>-1?n:null}};function ut(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];for(var n=0,o=e;n<o.length;n++){var s=o[n];for(var r in s)t[r]=s[r]}return t}var ht=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pt=["January","February","March","April","May","June","July","August","September","October","November","December"],gt=lt(pt,3),ft={dayNamesShort:lt(ht,3),dayNames:ht,monthNamesShort:gt,monthNames:pt,amPm:["am","pm"],DoFn:function(t){return t+["th","st","nd","rd"][t%10>3?0:(t-t%10!=10?1:0)*t%10]}},vt=ut({},ft),mt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length<e;)t="0"+t;return t},_t={D:function(t){return String(t.getDate())},DD:function(t){return mt(t.getDate())},Do:function(t,e){return e.DoFn(t.getDate())},d:function(t){return String(t.getDay())},dd:function(t){return mt(t.getDay())},ddd:function(t,e){return e.dayNamesShort[t.getDay()]},dddd:function(t,e){return e.dayNames[t.getDay()]},M:function(t){return String(t.getMonth()+1)},MM:function(t){return mt(t.getMonth()+1)},MMM:function(t,e){return e.monthNamesShort[t.getMonth()]},MMMM:function(t,e){return e.monthNames[t.getMonth()]},YY:function(t){return mt(String(t.getFullYear()),4).substr(2)},YYYY:function(t){return mt(t.getFullYear(),4)},h:function(t){return String(t.getHours()%12||12)},hh:function(t){return mt(t.getHours()%12||12)},H:function(t){return String(t.ge
|
||
|
<div class="card-config">
|
||
|
${this.getEditorInput("editor.name","editor.optional","header.title.value",this._name)}
|
||
|
${this.getEditorDropDown("editor.primary entity description","editor.required","indicator_sensors[0].sensor",this._entity,e)}
|
||
|
${this.getEditorDropDown("editor.secondary entity description","editor.optional","value_sensors[0].sensor",this._secondary_entity,i)}
|
||
|
${this.getEditorDropDown("editor.indicator","editor.optional","indicator_sensors[0].indicator.type",this._compass_indicator,xe)}
|
||
|
${this.getEditorDropDown("editor.language description","editor.optional","language",this._compass_language,we)}
|
||
|
${this.getEditorInput("editor.offset description","editor.optional","compass.north.offset",this._direction_offset)}
|
||
|
${this.getEditorSwitch("directions.north","compass.north.show",this._compass_show_north)}
|
||
|
</div>
|
||
|
`}_valueChanged(t){var e,i,n,o,s,r,a,d,l,c,u,h,p,g,f,v,m,_,y,S,b,w,N,E,O,k;if(!this._config||!this.hass)return;const W=t.target;if(void 0!==W.checked){if(this[`_${W.configValue}`]===W.checked)return}else if(this[`_${W.configValue}`]===W.value)return;if(W.configValue)switch(W.configValue){case"language":this._config=Object.assign(Object.assign({},this._config),{language:W.value}),""===(null===(e=W.value)||void 0===e?void 0:e.trim())&&delete this._config.language;break;case"compass.north.show":const t=Object.assign(Object.assign({},null===(i=this._config.compass)||void 0===i?void 0:i.north),{show:W.checked}),x=Object.assign(Object.assign({},this._config.compass),{north:t});this._config=Object.assign(Object.assign({},this._config),{compass:x}),W.checked||(null===(o=null===(n=this._config.compass)||void 0===n?void 0:n.north)||void 0===o||delete o.show,(null===(s=this._config.compass)||void 0===s?void 0:s.north)&&0===Object.keys(null===(r=this._config.compass)||void 0===r?void 0:r.north).length&&(null===(a=this._config.compass)||void 0===a||delete a.north),this._config.compass&&0===Object.keys(this._config.compass).length&&delete this._config.compass);break;case"header.title.value":const C=Object.assign(Object.assign({},null===(d=this._config.header)||void 0===d?void 0:d.title),{value:W.value}),P=Object.assign(Object.assign({},this._config.header),{title:C});this._config=Object.assign(Object.assign({},this._config),{header:P}),""===(null===(l=W.value)||void 0===l?void 0:l.trim())&&(null===(u=null===(c=this._config.header)||void 0===c?void 0:c.title)||void 0===u||delete u.value,(null===(h=this._config.header)||void 0===h?void 0:h.title)&&0===Object.keys(null===(p=this._config.header)||void 0===p?void 0:p.title).length&&(null===(g=this._config.header)||void 0===g||delete g.title),this._config.header&&0===Object.keys(this._config.header).length&&delete this._config.header);break;case"compass.north.offset":const V=Object.assign(Object.assign({},null===(f=this._config.compass)||void 0===f?void 0:f.north),{offset:Number(W.value)}),j=Object.assign(Object.assign({},this._config.compass),{north:V});this._config=Object.assign(Object.assign({},this._config),{compass:j}),W.value&&Me(W.value)&&0===Number(W.value)&&(null===(m=null===(v=this._config.compass)||void 0===v?void 0:v.north)||void 0===m||delete m.offset,(null===(_=this._config.compass)||void 0===_?void 0:_.north)&&0===Object.keys(null===(y=this._config.compass)||void 0===y?void 0:y.north).length&&(null===(S=this._config.compass)||void 0===S||delete S.north),this._config.compass&&0===Object.keys(this._config.compass).length&&delete this._config.compass);break;case"indicator_sensors[0].sensor":const z=[...this._config.indicator_sensors];z[0]=Object.assign(Object.assign({},this._config.indicator_sensors[0]),{sensor:W.value||""}),this._config=Object.assign(Object.assign({},this._config),{indicator_sensors:z});break;case"value_sensors[0].sensor":const M=this._config.value_sensors?[...this._config.value_sensors]:[];M[0]=Object.assign(Object.assign({},M[0]),{sensor:W.value||""}),this._config=Object.assign(Object.assign({},this._config),{value_sensors:M});break;case"indicator_sensors[0].indicator.type":const $=Object.assign(Object.assign({},null===(b=this._config.indicator_sensors[0])||void 0===b?void 0:b.indicator),{type:W.value}),D=[...this._config.indicator_sensors];D[0]=Object.assign(Object.assign({},this._config.indicator_sensors[0]),{indicator:$}),this._config=Object.assign(Object.assign({},this._config),{indicator_sensors:D}),(null===(N=null===(w=this._config.indicator_sensors[0])||void 0===w?void 0:w.indicator)||void 0===N?void 0:N.type)&&1===xe.indexOf(null===(O=null===(E=this._config.indicator_sensors[0])||void 0===E?void 0:E.indicator)||void 0===O?void 0:O.type)&&1===Object.keys(null===(k=this._config.indicator_sensors[0])||void 0===k?void 0:k.indicator).length&&delete this._config.indicator_sensors[0].indicator;break;default:console.warn("Value changed of unknown config node: "+W.configValue)}kt(this,"config-changed",{config:this._config})}getEditorDropDown(t,e,i,n,o){re
|
||
|
<paper-listbox slot="dropdown-content" .selected=${o.indexOf(n)}>
|
||
|
${o.map((t=>A` <paper-item>${t}</paper-item> `))}
|
||
|
</paper-listbox>
|
||
|
</paper-dropdown-menu>`}getEditorInput(t,e,i,n){return A`<paper-input label="${Ne(t)} (${Ne(e)})" .value=${n} .configValue=${i} @value-changed=${this._valueChanged}></paper-input>`}getEditorSwitch(t,e,i){return A`
|
||
|
<ha-formfield
|
||
|
.label=${`${Ne("editor.toggle")} ${Ne(t)} ${Ne("editor.indicator")} ${Ne(i?"common.off":"common.on")}`}>
|
||
|
<ha-switch
|
||
|
.checked=${!1!==i}
|
||
|
.configValue=${e}
|
||
|
@change=${this._valueChanged}
|
||
|
></ha-switch>
|
||
|
</ha-formfield>
|
||
|
</div>`}_initialize(){void 0!==this.hass&&void 0!==this._config&&void 0!==this._helpers&&(this._initialized=!0)}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}static get styles(){return nt`
|
||
|
.editor-entity-select {
|
||
|
width: 100%;
|
||
|
}
|
||
|
ha-switch {
|
||
|
ha-formfield {
|
||
|
padding-bottom: 8px;
|
||
|
}
|
||
|
`}};t([G({attribute:!1})],De.prototype,"hass",void 0),t([Q()],De.prototype,"_helpers",void 0),t([Q()],De.prototype,"_config",void 0),De=t([B("compass-card-editor")],De);const Te=nt`
|
||
|
:host ::slotted(.card-content:not(:first-child)),
|
||
|
slot:not(:first-child)::slotted(.card-content) {
|
||
|
padding-top: 0px;
|
||
|
margin-top: -8px;
|
||
|
}
|
||
|
:host ::slotted(.card-content) {
|
||
|
padding: 16px;
|
||
|
}
|
||
|
ha-card {
|
||
|
flex-direction: column;
|
||
|
flex: 1;
|
||
|
position: relative;
|
||
|
overflow: hidden;
|
||
|
}
|
||
|
.header {
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
padding: 8px 16px 0px;
|
||
|
}
|
||
|
.header > .name {
|
||
|
line-height: 40px;
|
||
|
font-weight: 500;
|
||
|
font-size: 16px;
|
||
|
white-space: nowrap;
|
||
|
text-overflow: ellipsis;
|
||
|
overflow: hidden;
|
||
|
}
|
||
|
.icon {
|
||
|
margin-top: 8px;
|
||
|
float: right;
|
||
|
}
|
||
|
.compass {
|
||
|
display: block;
|
||
|
width: 100%;
|
||
|
height: 152px;
|
||
|
max-width: 152px;
|
||
|
margin: 10px auto;
|
||
|
}
|
||
|
.content {
|
||
|
height: 162px;
|
||
|
position: relative;
|
||
|
width: 100%;
|
||
|
font-weight: normal;
|
||
|
line-height: 28px;
|
||
|
}
|
||
|
.value-sensors {
|
||
|
text-overflow: ellipsis;
|
||
|
white-space: nowrap;
|
||
|
position: absolute;
|
||
|
text-align: center;
|
||
|
top: 62px;
|
||
|
left: 50%;
|
||
|
transform: translateX(-50%);
|
||
|
}
|
||
|
.indicator-sensors {
|
||
|
line-height: 18px;
|
||
|
font-weight: 500;
|
||
|
font-size: 16px;
|
||
|
white-space: nowrap;
|
||
|
text-overflow: ellipsis;
|
||
|
text-align: center;
|
||
|
overflow: hidden;
|
||
|
position: absolute;
|
||
|
top: 32px;
|
||
|
left: 50%;
|
||
|
transform: translateX(-50%);
|
||
|
}
|
||
|
.value-sensors .measurement {
|
||
|
font-size: 18px;
|
||
|
}
|
||
|
.value-sensors .value {
|
||
|
font-size: 28px;
|
||
|
}
|
||
|
`;var Ae;console.info("%c COMPASS-CARD %c 1.1.0 ","color: white; background: coral; font-weight: 700;","color: coral; background: white; font-weight: 700;"),window.customCards=window.customCards||[],window.customCards.push({type:"compass-card",name:"Compass Card",preview:!0,description:Ne("common.description")});let Ie=Ae=class extends st{constructor(){super(...arguments),this.entities={}}static async getConfigElement(){return document.createElement("compass-card-editor")}static getStubConfig(){return{type:"custom:compass-card",indicator_sensors:[{sensor:"sun.sun",attribute:"azimuth"}]}}setConfig(t){if(!t)throw new Error(Ne("common.invalid_configuration"));if(!t.indicator_sensors||!t.indicator_sensors[0].sensor)throw new Error(Ne("common.missing_direction_entity"));t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this.colors={accent:getComputedStyle(document.documentElement).getPropertyValue("--accent-color").trim(),primary:getComputedStyle(document.documentElement).getPropertyValue("--primary-color").trim(),stateIcon:getComputedStyle(document.documentElement).getPropertyValue("--state-icon-color").trim(),secondaryText:getComputedStyle(document.documentElement).getPropertyValue("--secondary-text-color").trim(),primaryText:getComputedStyle(document.documentElement).getPropertyValue("--primary-text-color").trim()},this._config=Object.assign({},t),this.updateConfig(this._hass,this._config)}getCardSize(){return 5}set hass(t){this._hass=t,this.updateConfig(this._hass,this._config)}shouldUpdate(t){if(t.has("_config"))return!0;if(t.has("_hass")){const e=t.get("_hass");for(const t in this.entities)if(e.states[t].last_updated!==this._hass.states[t].last_updated)return!0}return!1}updateConfig(t,e){var i;if(!t||!e)return;$e(this._config,t.states,ze(this._config.debug,!1)).forEach((t=>{if(this._hass.states[t]){const e=this._hass.states[t];this.entities[e.entity_id]=this._hass.states[t]}})),this.header=function(t,e,i,n){var o,s,r,a,d,l,c,u,h,p,g,f,v,m,_,y,S,b,w,N,E,O,k,W,x,C;const P=(null===(s=null===(o=t.header)||void 0===o?void 0:o.title)||void 0===s?void 0:s.color)||e.secondaryText,V=ze(null===(a=null===(r=t.header)||void 0===r?void 0:r.title)||void 0===a?void 0:a.show,ze(void 0!==(null===(l=null===(d=t.header)||void 0===d?void 0:d.title)||void 0===l?void 0:l.value),!1)),j=(null===(u=null===(c=t.header)||void 0===c?void 0:c.icon)||void 0===u?void 0:u.color)||e.stateIcon,z=ze(null===(p=null===(h=t.header)||void 0===h?void 0:h.icon)||void 0===p?void 0:p.show,ze(null===(f=null===(g=t.header)||void 0===g?void 0:g.icon)||void 0===f?void 0:f.value,!1)||ze(null===(m=null===(v=t.header)||void 0===v?void 0:v.title)||void 0===m?void 0:m.value,!1));return{label:(null===(y=null===(_=t.header)||void 0===_?void 0:_.title)||void 0===y?void 0:y.value)||(null===(S=null==i?void 0:i.attributes)||void 0===S?void 0:S.friendly_name)||(null==i?void 0:i.entity_id),title:{value:(null===(w=null===(b=t.header)||void 0===b?void 0:b.title)||void 0===w?void 0:w.value)||"",color:P,dynamic_style:je(null===(E=null===(N=t.header)||void 0===N?void 0:N.title)||void 0===E?void 0:E.dynamic_style,t,n,P,V),show:V},icon:{value:(null===(k=null===(O=t.header)||void 0===O?void 0:O.icon)||void 0===k?void 0:k.value)||(null===(W=null==i?void 0:i.attributes)||void 0===W?void 0:W.icon)||Ee,color:j,dynamic_style:je(null===(C=null===(x=t.header)||void 0===x?void 0:x.icon)||void 0===C?void 0:C.dynamic_style,t,n,j,z),show:z}}}(this._config,this.colors,this.entities[null===(i=this._config)||void 0===i?void 0:i.indicator_sensors[0].sensor],this.entities),this.compass=function(t,e,i){var n,o,s,r,a,d,l,c,u,h,p,g,f,v;const m=(null===(o=null===(n=t.compass)||void 0===n?void 0:n.circle)||void 0===o?void 0:o.color)||e.primary,_
|
||
|
<ha-card tabindex="0" .label=${`Compass: ${this.header.label}`} class="flex compass-card" @click=${t=>this.handlePopup(t)}>
|
||
|
${this.getVisibility(this.header.title)||this.getVisibility(this.header.icon)?this.renderHeader():""}
|
||
|
<div class="content">
|
||
|
<div class="compass">${this.svgCompass(this.compass.north.offset)}</div>
|
||
|
<div class="indicator-sensors">${this.renderDirections()}</div>
|
||
|
<div class="value-sensors">${this.renderValues()}</div>
|
||
|
</div>
|
||
|
</ha-card>
|
||
|
`:A``}renderHeader(){return A`
|
||
|
<div class="header">
|
||
|
<div class="name" style="color:${this.getColor(this.header.title)};">${this.getVisibility(this.header.title)?this.renderTitle():A`<span> </span>`}</div>
|
||
|
<div class="icon" style="color:${this.getColor(this.header.icon)};">${this.getVisibility(this.header.icon)?this.renderIcon():A`<span> </span>`}</div>
|
||
|
</div>
|
||
|
`}renderTitle(){return A`<span>${this.header.title.value} </span>`}renderIcon(){return A`<ha-icon .icon=${this.header.icon.value}></ha-icon>`}renderDirections(){const t=[];let e=0;return this.indicatorSensors.forEach((i=>{(this.getVisibility(i.state_abbreviation)||this.getVisibility(i.state_value))&&(t.push(A`<div class="sensor-${e}">
|
||
|
<span class="abbr" style="color: ${this.getColor(i.state_abbreviation)};"
|
||
|
>${this.getVisibility(i.state_abbreviation)?this.computeIndicator(i).abbreviation:""}</span
|
||
|
>
|
||
|
<span class="value" style="color: ${this.getColor(i.state_value)};"
|
||
|
>${this.getVisibility(i.state_value)?this.computeIndicator(i).degrees.toFixed(i.decimals):""}</span
|
||
|
>
|
||
|
<span class="measurement" style="color: ${this.getColor(i.state_units)};">${this.getVisibility(i.state_units)?i.units:""}</span>
|
||
|
</div>`),e++)})),t}renderValues(){const t=[];let e=0;return this.valueSensors.forEach((i=>{this.getVisibility(i.state_value)&&(t.push(A`<div class="sensor-${e}">
|
||
|
<span class="value" style="color: ${this.getColor(i.state_value)};">${this.getVisibility(i.state_value)?this.getValue(i).value:""}</span>
|
||
|
<span class="measurement" style="color: ${this.getColor(i.state_units)};">${this.getVisibility(i.state_units)?i.units:""}</span>
|
||
|
</div>`),e++)})),t}getVisibility(t){var e;if(0===t.dynamic_style.bands.length)return t.show;const i=this.getValue(t.dynamic_style);if(Me(i.value)){const n=t.dynamic_style.bands.filter((t=>t.from_value<=Number(i.value)));return ze(null===(e=n[n.length-1])||void 0===e?void 0:e.show,t.show)}return t.show}getColor(t){var e;if(0===t.dynamic_style.bands.length)return t.color;const i=this.getValue(t.dynamic_style);if(Me(i.value)){const n=t.dynamic_style.bands.filter((t=>t.from_value<=Number(i.value)));return(null===(e=n[n.length-1])||void 0===e?void 0:e.color)||t.color}return t.color}svgCompass(t){return I`
|
||
|
<svg viewbox="0 0 152 152" preserveAspectRatio="xMidYMin slice" style="width: 100%; padding-bottom: 92%; height: 1px; overflow: visible">
|
||
|
${this.getVisibility(this.compass.circle)?this.svgCircle():""}
|
||
|
<g class="indicators" transform="rotate(${t},76,76)" stroke-width=".5">
|
||
|
${this.compass.north.show?this.svgIndicatorNorth():""}
|
||
|
${this.svgIndicators()}
|
||
|
</g>
|
||
|
</svg>
|
||
|
`}svgCircle(){return I`<circle class="circle" cx="76" cy="76" r="62" stroke="${this.getColor(this.compass.circle)}" stroke-width="2" fill="white" fill-opacity="0.0" stroke-opacity="1.0" />`}svgIndicators(){const t=[];return this.indicatorSensors.forEach((e=>{this.getVisibility(e.indicator)&&t.push(this.svgSingleIndicator(e))})),t}svgIndicator(t){switch(t.indicator.type){case"arrow_outward":return this.svgIndicatorArrowOutward(t);case"circle":return this.svgIndicatorCircle(t)}return this.svgIndicatorArrowInward(t)}svgSingleIndicator(t){const e=this.svgIndicator(t),{degrees:i}=this.computeIndicator(t);return I`
|
||
|
<g class="indicator" transform="rotate(${i},76,76)">
|
||
|
${e}
|
||
|
</g>
|
||
|
`}svgIndicatorArrowOutward(t){return I`
|
||
|
<g class="arrow-outward">
|
||
|
<path d="M76 0v23l-8 7z" fill="${this.getColor(t.indicator)}" stroke="${this.getColor(t.indicator)}" stroke-width=".5"/>
|
||
|
<path d="M76 0v23l8 7z" fill="${this.getColor(t.indicator)}" stroke="${this.getColor(t.indicator)}" stroke-width="0"/>
|
||
|
<path d="M76 0v23l8 7z" fill="white" opacity="0.5" stroke="white" stroke-width=".5"/>
|
||
|
</g>
|
||
|
`}svgIndicatorArrowInward(t){return I`
|
||
|
<g class="arrow-inward">
|
||
|
<path d="M76 30.664v-23l-8-7z" fill="${this.getColor(t.indicator)}" stroke="${this.getColor(t.indicator)}" stroke-width=".5" />
|
||
|
<path d="M76 30.664v-23l8-7z" fill="${this.getColor(t.indicator)}" stroke="${this.getColor(t.indicator)}" stroke-width="0" />
|
||
|
<path d="M76 30.664v-23l8-7z" fill="white" opacity="0.5" stroke="white" stroke-width=".5" />
|
||
|
</g>
|
||
|
`}svgIndicatorCircle(t){return I`
|
||
|
<g class="circle">
|
||
|
<path d="m76 5.8262a9.1809 9.1809 0 0 0-0.0244 0 9.1809 9.1809 0 0 0-9.1813 9.18 9.1809 9.1809 0 0 0 9.1813 9.1813 9.1809 9.1809 0 0 0 0.0244 0z" fill="${this.getColor(t.indicator)}"/>
|
||
|
<path d="m76 5.8262v18.361a9.1809 9.1809 0 0 0 9.1556-9.1813 9.1809 9.1809 0 0 0-9.1556-9.18z" fill="${this.getColor(t.indicator)}"/>
|
||
|
<path d="m76 5.8262v18.361a9.1809 9.1809 0 0 0 9.1556-9.1813 9.1809 9.1809 0 0 0-9.1556-9.18z" fill="white" opacity="0.5"/>
|
||
|
</g>
|
||
|
`}svgIndicatorNorth(){return I`
|
||
|
<g class="north">
|
||
|
<text x="76" y="10.089" font-family="sans-serif" font-size="13.333" text-anchor="middle" fill="${this.getColor(this.compass.north)}">
|
||
|
<tspan x="76" y="11">${Ne("directions.N","","",this._config.language)}</tspan>
|
||
|
</text>
|
||
|
</g>
|
||
|
`}getSecondaryEntity(t){return A` <span class="value">${t.state}</span> <span class="measurement">${t.attributes.unit_of_measurement}</span>`}getValue(t){var e;if(t.is_attribute){const e=t.sensor.slice(0,t.sensor.lastIndexOf(".")),i=this.entities[e];if(i&&i.attributes){const e=t.sensor.slice(t.sensor.lastIndexOf(".")+1),n=i.attributes[e]||We;return{value:Me(n)?Number(n).toFixed(t.decimals):n,units:t.units}}return{value:We,units:t.units}}const i=(null===(e=this.entities[t.sensor])||void 0===e?void 0:e.state)||We;return{value:Me(i)?Number(i).toFixed(t.decimals):i,units:t.units}}handlePopup(t){t.stopPropagation(),this._config.tap_action&&((t,e,i,n)=>{let o;switch(n.action||"more-info"){case"more-info":o=new Event("hass-more-info",{composed:!0}),o.detail={entityId:n.entity||(null==i?void 0:i.tap_action)},t.dispatchEvent(o);break;case"navigate":if(!n.navigation_path)return;if(n.new_tab||void 0===n.new_tab){window.open(n.navigation_path,"_blank");break}window.history.pushState(null,"",n.navigation_path),o=new Event("location-changed",{composed:!0}),o.detail={replace:!1},window.dispatchEvent(o);break;case"call-service":{if(!n.service)return;const[t,i]=n.service.split(".",2),o=n.service_data?Object.assign({},JSON.parse(n.service_data)):"";e.callService(t,i,o);break}case"url":if(!n.url)return;if(n.new_tab||void 0===n.new_tab){window.open(n.url,"_blank");break}window.location.href=n.url;break;default:;}})(this,this._hass,this._config,this._config.tap_action)}computeIndicator(t){let e=0,i=Ne("common.invalid");const n=this.getValue(t);if(Number.isNaN(Number(n.value))){if(e=Ae.getDegrees(n.value),i=n.value,-1===e){const t=n.value.replace(/\s+/g,"").match(/[+-]?\d+(\.\d)?/);e=(null==t?void 0:t.length)?Ae.positiveDegrees(parseFloat(t[0])):0,i=Ae.getCompassAbbreviation(e,this._config.language)}}else e=Ae.positiveDegrees(parseFloat(n.value)),i=Ae.getCompassAbbreviation(e,this._config.language);return{abbreviation:i,degrees:Math.round(e)}}static get styles(){return Te}static getDegrees(t){return Oe[t]?Oe[t]:-1}static getCompassAbbreviation(t,e){const i=Math.round(Ae.positiveDegrees(t)/22.5);let n="N";return n=ke[i],i>15&&(n=ke[0]),Ne(`directions.${n}`,"","",e)}static positiveDegrees(t){return t<0?t+360*(Math.abs(Math.ceil(t/360))+1):t%360}};t([G({attribute:!1})],Ie.prototype,"_hass",void 0),t([G({attribute:!1})],Ie.prototype,"_config",void 0),t([Q()],Ie.prototype,"colors",void 0),t([Q()],Ie.prototype,"header",void 0),t([Q()],Ie.prototype,"compass",void 0),t([Q()],Ie.prototype,"indicatorSensors",void 0),t([Q()],Ie.prototype,"entities",void 0),t([Q()],Ie.prototype,"valueSensors",void 0),Ie=Ae=t([B("compass-card")],Ie);export{Ie as CompassCard};
|