extra-map-card 1.7.0 β 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extra-map-card-bundle.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%cπ EXTRA-MAP-CARD πΊοΈ%cv1.7.0","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: git+https://github.com/ngocjohn/extra-map-card.git"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(e){return"strategy"in e}const r=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),n=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),o=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function a(e){return"strategy"in e}function s(e){return"strategy"in e}const l=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:{type:"entity",...e},c=e=>e.sendMessagePromise({type:"lovelace/resources"}),u=(e,t)=>e.callWS({type:"lovelace/resources/create",...t}),h=(e,t,i)=>e.callWS({type:"lovelace/resources/update",resource_id:t,...i}),p=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),d=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},f=(e,t,i)=>e.subscribeMessage((e=>t(e)),{type:"render_template",...i}),m=/{%|{{/,g=e=>m.test(e),y=e=>{if(!e)return!1;if("string"==typeof e)return g(e);if("object"==typeof e){return(Array.isArray(e)?e:Object.values(e)).some((e=>e&&y(e)))}return!1},_=e=>e.substring(0,e.indexOf(".")),v=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class b{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const x=(e,t)=>!e.states[t]||v.includes(_(t)),w=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>x(e,t)))};return 0!==r.length?e.callWS({...n,entity_ids:r}):e.callWS(n)},C=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>x(e,t)))},l=new b(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},T=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new b(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)};var A,S,M,E,P;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.quote_decimal="quote_decimal",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={})),function(e){e.local="local",e.server="server"}(M||(M={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(E||(E={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(P||(P={}));const I=async(e,t,i,r,n)=>(await e.callWS({type:"frontend/get_translations",language:t,category:i,integration:r,config_flow:n})).resources,k=async(e,t)=>(await e.callWS({type:"frontend/get_translations",language:t})).resources,z=e=>_(e.entity_id);var L="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",D="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",F="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",R="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",B=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function O(e,t){return e===t||!(!B(e)||!B(t))}function j(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!O(e[i],t[i]))return!1;return!0}function $(e,t){void 0===t&&(t=j);var i=null;function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(i&&i.lastThis===this&&t(r,i.lastArgs))return i.lastResult;var o=e.apply(this,r);return i={lastResult:o,lastArgs:r,lastThis:this},o}return r.clear=function(){i=null},r}var N="1.7.0";const V=["today","yesterday"],U=["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT","BASIC","BASIC.DARK","BASIC.LIGHT","BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL","DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT","HYBRID","OPENSTREETMAP","OUTDOOR","SATELLITE","STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL","TONER","TONER.BACKGROUND","TONER.LINES","TONER.LITE","TOPO","TOPO.PASTEL","TOPO.SHINY","TOPO.TOPOGRAPHIQUE","VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE","WINTER"],q=N,Z=0,G=14,H=["auto","light","dark"],W=["auto_fit","fit_zones","use_more_info"],K=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:G,selector:{number:{mode:"box",min:0}}},...W.map((e=>({name:e,label:e.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "),default:!1,selector:{boolean:{}}})))],X=[{title:"Custom Hours to Show",type:"expandable",icon:"mdi:history",flatten:!0,schema:[{name:"hours_to_show",label:"Hours to Show",default:0,required:!1,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",required:!1,helper:"Time period to show, from now backwards (e.g., today = since midnight, yesterday = last 24 hours)",selector:{select:{mode:"dropdown",options:V.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show_template",label:"Hours to Show Template",required:!1,helper:"Jinja2 template that defines the number of hours to show",selector:{template:{}}}]}],Y=e=>({name:e,label:`${e.charAt(0).toUpperCase()+e.slice(1)} Style`,selector:{select:{mode:"dropdown",options:[...U.map((e=>({value:e,label:e})))]}}}),J=[{title:"Custom Styles",type:"expandable",icon:"mdi:compare",schema:[{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:H.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{type:"grid",name:"custom_styles",schema:[Y("light"),Y("dark")]}]}],Q=$((e=>[{type:"expandable",iconPath:F,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[...K]},...X,...J]}])),ee=$((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),te=$(((e,t=!1)=>[...t?[]:ee(),...Q(e)])),ie=globalThis,re=ie.ShadowRoot&&(void 0===ie.ShadyCSS||ie.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ne=Symbol(),oe=new WeakMap;let ae=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ne)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(re&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=oe.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&oe.set(t,e))}return e}toString(){return this.cssText}};const se=e=>new ae("string"==typeof e?e:e+"",void 0,ne),le=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new ae(i,e,ne)},ce=(e,t)=>{if(re)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=ie.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},ue=re?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return se(t)})(e):e
|
|
1
|
+
function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%cπ EXTRA-MAP-CARD πΊοΈ%cv1.7.1","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: git+https://github.com/ngocjohn/extra-map-card.git"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(e){return"strategy"in e}const r=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),n=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),o=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function a(e){return"strategy"in e}function s(e){return"strategy"in e}const l=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:{type:"entity",...e},c=e=>e.sendMessagePromise({type:"lovelace/resources"}),u=(e,t)=>e.callWS({type:"lovelace/resources/create",...t}),h=(e,t,i)=>e.callWS({type:"lovelace/resources/update",resource_id:t,...i}),p=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),d=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},f=(e,t,i)=>e.subscribeMessage((e=>t(e)),{type:"render_template",...i}),m=/{%|{{/,g=e=>m.test(e),y=e=>{if(!e)return!1;if("string"==typeof e)return g(e);if("object"==typeof e){return(Array.isArray(e)?e:Object.values(e)).some((e=>e&&y(e)))}return!1},_=e=>e.substring(0,e.indexOf(".")),v=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class b{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const x=(e,t)=>!e.states[t]||v.includes(_(t)),w=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>x(e,t)))};return 0!==r.length?e.callWS({...n,entity_ids:r}):e.callWS(n)},C=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>x(e,t)))},l=new b(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},T=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new b(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)};var A,S,M,E,P;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.quote_decimal="quote_decimal",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={})),function(e){e.local="local",e.server="server"}(M||(M={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(E||(E={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(P||(P={}));const I=async(e,t,i,r,n)=>(await e.callWS({type:"frontend/get_translations",language:t,category:i,integration:r,config_flow:n})).resources,k=async(e,t)=>(await e.callWS({type:"frontend/get_translations",language:t})).resources,z=e=>_(e.entity_id);var L="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",D="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",F="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",R="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",B=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function O(e,t){return e===t||!(!B(e)||!B(t))}function j(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!O(e[i],t[i]))return!1;return!0}function $(e,t){void 0===t&&(t=j);var i=null;function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(i&&i.lastThis===this&&t(r,i.lastArgs))return i.lastResult;var o=e.apply(this,r);return i={lastResult:o,lastArgs:r,lastThis:this},o}return r.clear=function(){i=null},r}var N="1.7.1";const V=["today","yesterday"],U=["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT","BASIC","BASIC.DARK","BASIC.LIGHT","BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL","DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT","HYBRID","OPENSTREETMAP","OUTDOOR","SATELLITE","STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL","TONER","TONER.BACKGROUND","TONER.LINES","TONER.LITE","TOPO","TOPO.PASTEL","TOPO.SHINY","TOPO.TOPOGRAPHIQUE","VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE","WINTER"],q=N,Z=0,G=14,H=["auto","light","dark"],W=["auto_fit","fit_zones","use_more_info"],K=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:G,selector:{number:{mode:"box",min:0}}},...W.map((e=>({name:e,label:e.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "),default:!1,selector:{boolean:{}}})))],X=[{title:"Custom Hours to Show",type:"expandable",icon:"mdi:history",flatten:!0,schema:[{name:"hours_to_show",label:"Hours to Show",default:0,required:!1,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",required:!1,helper:"Time period to show, from now backwards (e.g., today = since midnight, yesterday = last 24 hours)",selector:{select:{mode:"dropdown",options:V.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show_template",label:"Hours to Show Template",required:!1,helper:"Jinja2 template that defines the number of hours to show",selector:{template:{}}}]}],Y=e=>({name:e,label:`${e.charAt(0).toUpperCase()+e.slice(1)} Style`,selector:{select:{mode:"dropdown",options:[...U.map((e=>({value:e,label:e})))]}}}),J=[{title:"Custom Styles",type:"expandable",icon:"mdi:compare",schema:[{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:H.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{type:"grid",name:"custom_styles",schema:[Y("light"),Y("dark")]}]}],Q=$((e=>[{type:"expandable",iconPath:F,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[...K]},...X,...J]}])),ee=$((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),te=$(((e,t=!1)=>[...t?[]:ee(),...Q(e)])),ie=globalThis,re=ie.ShadowRoot&&(void 0===ie.ShadyCSS||ie.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ne=Symbol(),oe=new WeakMap;let ae=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ne)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(re&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=oe.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&oe.set(t,e))}return e}toString(){return this.cssText}};const se=e=>new ae("string"==typeof e?e:e+"",void 0,ne),le=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new ae(i,e,ne)},ce=(e,t)=>{if(re)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=ie.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},ue=re?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return se(t)})(e):e
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -552,7 +552,7 @@ const ft={attribute:!0,type:String,converter:we,reflect:!1,hasChanged:Ce},mt=(e=
|
|
|
552
552
|
></emc-map>
|
|
553
553
|
</div>
|
|
554
554
|
</ha-card>
|
|
555
|
-
`}shouldUpdate(e){var t;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||(!!e.has("_templateResults")||(!!e.has("_hoursToShow")||((null===(t=this._config)||void 0===t?void 0:t.entities)?Dt(this,e):It(this,e))))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=Pt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this._trySubscribeTemplates(),this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory(),this._tryDisconnect()}async _trySubscribeTemplates(){var e;(null===(e=this._config)||void 0===e?void 0:e.hours_to_show_template)&&Vf.forEach((e=>{this._subscribeTemplateKey(e)}))}async _subscribeTemplateKey(e){var t,i,r;if(this.hass&&y(null===(t=this._config)||void 0===t?void 0:t[e]))try{const t=f(this.hass.connection,(t=>{this._templateResults={...this._templateResults,[e]:t}}),{template:null!==(i=this._config[e])&&void 0!==i?i:"",variables:{config:this._config,user:this.hass.user.name},strict:!0});this._unsubRenderTemplates.set(e,t),await t}catch(t){console.warn("Error while rendering template",t);const i={result:null!==(r=this._config[e])&&void 0!==r?r:"",listeners:{all:!1,domains:[],entities:[],time:!1}};this._templateResults={...this._templateResults,[e]:i},this._unsubRenderTemplates.delete(e)}}async _tryDisconnect(){Vf.forEach((e=>{this._tryDisconnectKey(e)}))}async _tryDisconnectKey(e){const t=this._unsubRenderTemplates.get(e);if(t)try{(await t)(),this._unsubRenderTemplates.delete(e)}catch(e){if("not_found"!==e.code&&"template_error"!==e.code)throw e}}_getValue(e){var t;const i=this._config;if("hours_to_show"===e){let e=(null==i?void 0:i.hours_to_show)||0;if(void 0!==(null==i?void 0:i.history_period)){const t=new Date,r=new Date(t);r.setDate(t.getDate()-1),e="today"===i.history_period?t.getHours():r.getHours()+24}else if(null===(t=this._templateResults.hours_to_show_template)||void 0===t?void 0:t.result){const t=
|
|
555
|
+
`}shouldUpdate(e){var t;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||(!!e.has("_templateResults")||(!!e.has("_hoursToShow")||((null===(t=this._config)||void 0===t?void 0:t.entities)?Dt(this,e):It(this,e))))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=Pt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this._trySubscribeTemplates(),this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory(),this._tryDisconnect()}async _trySubscribeTemplates(){var e;(null===(e=this._config)||void 0===e?void 0:e.hours_to_show_template)&&Vf.forEach((e=>{this._subscribeTemplateKey(e)}))}async _subscribeTemplateKey(e){var t,i,r;if(this.hass&&y(null===(t=this._config)||void 0===t?void 0:t[e]))try{const t=f(this.hass.connection,(t=>{this._templateResults={...this._templateResults,[e]:t}}),{template:null!==(i=this._config[e])&&void 0!==i?i:"",variables:{config:this._config,user:this.hass.user.name},strict:!0});this._unsubRenderTemplates.set(e,t),await t}catch(t){console.warn("Error while rendering template",t);const i={result:null!==(r=this._config[e])&&void 0!==r?r:"",listeners:{all:!1,domains:[],entities:[],time:!1}};this._templateResults={...this._templateResults,[e]:i},this._unsubRenderTemplates.delete(e)}}async _tryDisconnect(){Vf.forEach((e=>{this._tryDisconnectKey(e)}))}async _tryDisconnectKey(e){const t=this._unsubRenderTemplates.get(e);if(t)try{(await t)(),this._unsubRenderTemplates.delete(e)}catch(e){if("not_found"!==e.code&&"template_error"!==e.code)throw e}}_getValue(e){var t;const i=this._config;if("hours_to_show"===e){let e=(null==i?void 0:i.hours_to_show)||0;if(void 0!==(null==i?void 0:i.history_period)){const t=new Date,r=new Date(t);r.setDate(t.getDate()-1),e="today"===i.history_period?t.getHours():r.getHours()+24}else if(null===(t=this._templateResults.hours_to_show_template)||void 0===t?void 0:t.result){const t=this._templateResults.hours_to_show_template.result.replace(/[^0-9.-]/g,""),i=Number(t);isNaN(i)||(e=i)}return e}}_subscribeHistory(){var e,i,r;!t(this.hass,"history")||this._subscribed||null==(null===(e=this._config)||void 0===e?void 0:e.history_period)&&null==(null===(i=this._config)||void 0===i?void 0:i.hours_to_show)&&null==(null===(r=this._config)||void 0===r?void 0:r.hours_to_show_template)||(this._subscribed=C(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),this._hoursToShow,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;super.updated(e),(null===(t=this._configEntities)||void 0===t?void 0:t.length)?(!this._subscribed||e.has("_config")||e.has("_hoursToShow"))&&(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Rt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=xt(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:e.color?e.color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name,icon:e.icon})))]}}Uf.styles=le`
|
|
556
556
|
ha-card {
|
|
557
557
|
overflow: hidden;
|
|
558
558
|
width: 100%;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(e){return"strategy"in e}const r=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),n=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),o=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function a(e){return"strategy"in e}function s(e){return"strategy"in e}const l=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:{type:"entity",...e},c=e=>e.sendMessagePromise({type:"lovelace/resources"}),u=(e,t)=>e.callWS({type:"lovelace/resources/create",...t}),h=(e,t,i)=>e.callWS({type:"lovelace/resources/update",resource_id:t,...i}),p=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),d=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},f=(e,t,i)=>e.subscribeMessage((e=>t(e)),{type:"render_template",...i}),m=/{%|{{/,g=e=>m.test(e),y=e=>{if(!e)return!1;if("string"==typeof e)return g(e);if("object"==typeof e){return(Array.isArray(e)?e:Object.values(e)).some((e=>e&&y(e)))}return!1},_=e=>e.substring(0,e.indexOf(".")),v=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class b{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const x=(e,t)=>!e.states[t]||v.includes(_(t)),w=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>x(e,t)))};return 0!==r.length?e.callWS({...n,entity_ids:r}):e.callWS(n)},C=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>x(e,t)))},l=new b(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},T=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new b(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)};var A,S,M,E,P;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.quote_decimal="quote_decimal",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={})),function(e){e.local="local",e.server="server"}(M||(M={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(E||(E={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(P||(P={}));const I=async(e,t,i,r,n)=>(await e.callWS({type:"frontend/get_translations",language:t,category:i,integration:r,config_flow:n})).resources,k=async(e,t)=>(await e.callWS({type:"frontend/get_translations",language:t})).resources,z=e=>_(e.entity_id);var L="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",D="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",F="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",R="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",B=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function O(e,t){return e===t||!(!B(e)||!B(t))}function j(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!O(e[i],t[i]))return!1;return!0}function $(e,t){void 0===t&&(t=j);var i=null;function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(i&&i.lastThis===this&&t(r,i.lastArgs))return i.lastResult;var o=e.apply(this,r);return i={lastResult:o,lastArgs:r,lastThis:this},o}return r.clear=function(){i=null},r}var N="1.7.
|
|
1
|
+
function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(e){return"strategy"in e}const r=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),n=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),o=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function a(e){return"strategy"in e}function s(e){return"strategy"in e}const l=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:{type:"entity",...e},c=e=>e.sendMessagePromise({type:"lovelace/resources"}),u=(e,t)=>e.callWS({type:"lovelace/resources/create",...t}),h=(e,t,i)=>e.callWS({type:"lovelace/resources/update",resource_id:t,...i}),p=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),d=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},f=(e,t,i)=>e.subscribeMessage((e=>t(e)),{type:"render_template",...i}),m=/{%|{{/,g=e=>m.test(e),y=e=>{if(!e)return!1;if("string"==typeof e)return g(e);if("object"==typeof e){return(Array.isArray(e)?e:Object.values(e)).some((e=>e&&y(e)))}return!1},_=e=>e.substring(0,e.indexOf(".")),v=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class b{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const x=(e,t)=>!e.states[t]||v.includes(_(t)),w=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>x(e,t)))};return 0!==r.length?e.callWS({...n,entity_ids:r}):e.callWS(n)},C=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>x(e,t)))},l=new b(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},T=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new b(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)};var A,S,M,E,P;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.quote_decimal="quote_decimal",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={})),function(e){e.local="local",e.server="server"}(M||(M={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(E||(E={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(P||(P={}));const I=async(e,t,i,r,n)=>(await e.callWS({type:"frontend/get_translations",language:t,category:i,integration:r,config_flow:n})).resources,k=async(e,t)=>(await e.callWS({type:"frontend/get_translations",language:t})).resources,z=e=>_(e.entity_id);var L="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",D="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",F="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",R="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",B=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function O(e,t){return e===t||!(!B(e)||!B(t))}function j(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!O(e[i],t[i]))return!1;return!0}function $(e,t){void 0===t&&(t=j);var i=null;function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(i&&i.lastThis===this&&t(r,i.lastArgs))return i.lastResult;var o=e.apply(this,r);return i={lastResult:o,lastArgs:r,lastThis:this},o}return r.clear=function(){i=null},r}var N="1.7.1";const V=["today","yesterday"],U=["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT","BASIC","BASIC.DARK","BASIC.LIGHT","BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL","DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT","HYBRID","OPENSTREETMAP","OUTDOOR","SATELLITE","STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL","TONER","TONER.BACKGROUND","TONER.LINES","TONER.LITE","TOPO","TOPO.PASTEL","TOPO.SHINY","TOPO.TOPOGRAPHIQUE","VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE","WINTER"],q=N,Z=0,G=14,H=["auto","light","dark"],W=["auto_fit","fit_zones","use_more_info"],K=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:G,selector:{number:{mode:"box",min:0}}},...W.map((e=>({name:e,label:e.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "),default:!1,selector:{boolean:{}}})))],X=[{title:"Custom Hours to Show",type:"expandable",icon:"mdi:history",flatten:!0,schema:[{name:"hours_to_show",label:"Hours to Show",default:0,required:!1,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",required:!1,helper:"Time period to show, from now backwards (e.g., today = since midnight, yesterday = last 24 hours)",selector:{select:{mode:"dropdown",options:V.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show_template",label:"Hours to Show Template",required:!1,helper:"Jinja2 template that defines the number of hours to show",selector:{template:{}}}]}],Y=e=>({name:e,label:`${e.charAt(0).toUpperCase()+e.slice(1)} Style`,selector:{select:{mode:"dropdown",options:[...U.map((e=>({value:e,label:e})))]}}}),J=[{title:"Custom Styles",type:"expandable",icon:"mdi:compare",schema:[{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:H.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{type:"grid",name:"custom_styles",schema:[Y("light"),Y("dark")]}]}],Q=$((e=>[{type:"expandable",iconPath:F,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[...K]},...X,...J]}])),ee=$((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),te=$(((e,t=!1)=>[...t?[]:ee(),...Q(e)])),ie=globalThis,re=ie.ShadowRoot&&(void 0===ie.ShadyCSS||ie.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ne=Symbol(),oe=new WeakMap;let ae=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ne)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(re&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=oe.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&oe.set(t,e))}return e}toString(){return this.cssText}};const se=e=>new ae("string"==typeof e?e:e+"",void 0,ne),le=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new ae(i,e,ne)},ce=(e,t)=>{if(re)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=ie.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},ue=re?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return se(t)})(e):e
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -552,7 +552,7 @@ const ft={attribute:!0,type:String,converter:we,reflect:!1,hasChanged:Ce},mt=(e=
|
|
|
552
552
|
></emc-map>
|
|
553
553
|
</div>
|
|
554
554
|
</ha-card>
|
|
555
|
-
`}shouldUpdate(e){var t;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||(!!e.has("_templateResults")||(!!e.has("_hoursToShow")||((null===(t=this._config)||void 0===t?void 0:t.entities)?Dt(this,e):It(this,e))))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=Pt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this._trySubscribeTemplates(),this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory(),this._tryDisconnect()}async _trySubscribeTemplates(){var e;(null===(e=this._config)||void 0===e?void 0:e.hours_to_show_template)&&Vf.forEach((e=>{this._subscribeTemplateKey(e)}))}async _subscribeTemplateKey(e){var t,i,r;if(this.hass&&y(null===(t=this._config)||void 0===t?void 0:t[e]))try{const t=f(this.hass.connection,(t=>{this._templateResults={...this._templateResults,[e]:t}}),{template:null!==(i=this._config[e])&&void 0!==i?i:"",variables:{config:this._config,user:this.hass.user.name},strict:!0});this._unsubRenderTemplates.set(e,t),await t}catch(t){console.warn("Error while rendering template",t);const i={result:null!==(r=this._config[e])&&void 0!==r?r:"",listeners:{all:!1,domains:[],entities:[],time:!1}};this._templateResults={...this._templateResults,[e]:i},this._unsubRenderTemplates.delete(e)}}async _tryDisconnect(){Vf.forEach((e=>{this._tryDisconnectKey(e)}))}async _tryDisconnectKey(e){const t=this._unsubRenderTemplates.get(e);if(t)try{(await t)(),this._unsubRenderTemplates.delete(e)}catch(e){if("not_found"!==e.code&&"template_error"!==e.code)throw e}}_getValue(e){var t;const i=this._config;if("hours_to_show"===e){let e=(null==i?void 0:i.hours_to_show)||0;if(void 0!==(null==i?void 0:i.history_period)){const t=new Date,r=new Date(t);r.setDate(t.getDate()-1),e="today"===i.history_period?t.getHours():r.getHours()+24}else if(null===(t=this._templateResults.hours_to_show_template)||void 0===t?void 0:t.result){const t=
|
|
555
|
+
`}shouldUpdate(e){var t;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||(!!e.has("_templateResults")||(!!e.has("_hoursToShow")||((null===(t=this._config)||void 0===t?void 0:t.entities)?Dt(this,e):It(this,e))))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=Pt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this._trySubscribeTemplates(),this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory(),this._tryDisconnect()}async _trySubscribeTemplates(){var e;(null===(e=this._config)||void 0===e?void 0:e.hours_to_show_template)&&Vf.forEach((e=>{this._subscribeTemplateKey(e)}))}async _subscribeTemplateKey(e){var t,i,r;if(this.hass&&y(null===(t=this._config)||void 0===t?void 0:t[e]))try{const t=f(this.hass.connection,(t=>{this._templateResults={...this._templateResults,[e]:t}}),{template:null!==(i=this._config[e])&&void 0!==i?i:"",variables:{config:this._config,user:this.hass.user.name},strict:!0});this._unsubRenderTemplates.set(e,t),await t}catch(t){console.warn("Error while rendering template",t);const i={result:null!==(r=this._config[e])&&void 0!==r?r:"",listeners:{all:!1,domains:[],entities:[],time:!1}};this._templateResults={...this._templateResults,[e]:i},this._unsubRenderTemplates.delete(e)}}async _tryDisconnect(){Vf.forEach((e=>{this._tryDisconnectKey(e)}))}async _tryDisconnectKey(e){const t=this._unsubRenderTemplates.get(e);if(t)try{(await t)(),this._unsubRenderTemplates.delete(e)}catch(e){if("not_found"!==e.code&&"template_error"!==e.code)throw e}}_getValue(e){var t;const i=this._config;if("hours_to_show"===e){let e=(null==i?void 0:i.hours_to_show)||0;if(void 0!==(null==i?void 0:i.history_period)){const t=new Date,r=new Date(t);r.setDate(t.getDate()-1),e="today"===i.history_period?t.getHours():r.getHours()+24}else if(null===(t=this._templateResults.hours_to_show_template)||void 0===t?void 0:t.result){const t=this._templateResults.hours_to_show_template.result.replace(/[^0-9.-]/g,""),i=Number(t);isNaN(i)||(e=i)}return e}}_subscribeHistory(){var e,i,r;!t(this.hass,"history")||this._subscribed||null==(null===(e=this._config)||void 0===e?void 0:e.history_period)&&null==(null===(i=this._config)||void 0===i?void 0:i.hours_to_show)&&null==(null===(r=this._config)||void 0===r?void 0:r.hours_to_show_template)||(this._subscribed=C(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),this._hoursToShow,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;super.updated(e),(null===(t=this._configEntities)||void 0===t?void 0:t.length)?(!this._subscribed||e.has("_config")||e.has("_hoursToShow"))&&(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Rt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=xt(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:e.color?e.color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name,icon:e.icon})))]}}Uf.styles=le`
|
|
556
556
|
ha-card {
|
|
557
557
|
overflow: hidden;
|
|
558
558
|
width: 100%;
|