From efd62f65c971a5d0904a157f04fcc079d79fd894 Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Mon, 26 Aug 2019 05:59:12 +0000 Subject: [PATCH] fix taps triggering twice iOS13 --- dist/deep-press.js | 2 +- package.json | 4 +++- src/deep-press.js | 24 +++++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/dist/deep-press.js b/dist/deep-press.js index 2344824..4963ae5 100644 --- a/dist/deep-press.js +++ b/dist/deep-press.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r,o=n(2),i=(r=n(1))&&r.__esModule?r:{default:r};customElements.whenDefined("card-tools").then(()=>{let e=customElements.get("card-tools");var t=Object.assign({},{enable_unsupported:!1},e.lovelace.config.deep_press);if("ontouchforcechange"in document==!1&&0==t.enable_unsupported)return;const n=function(e){var t=document.querySelector("body > home-assistant").shadowRoot.querySelector("ha-more-info-dialog");t&&(e?(t.noCancelOnOutsideClick=!1,t.style.pointerEvents="all"):(t.noCancelOnOutsideClick=!0,t.style.pointerEvents="none"))};["touchend","mouseup"].forEach(e=>{document.addEventListener(e,()=>{!function(){try{document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view").style.webkitFilter="blur(0px)"}catch(e){if(!(e instanceof TypeError))throw e}}(),setTimeout(function(){n(!0)},100)},{passive:!0})});const r=customElements.get("ha-card"),s=function(e){return e.config?e.config:e._config?e._config:e.host?s(e.host):e.parentElement?s(e.parentElement):e.parentNode?s(e.parentNode):null};var a=r.prototype.update;r.prototype.update=function(e){a.apply(this,e);const t=s(this);t&&t.deep_press&&function(e,t){e.querySelector(":scope >#deep-press-cover")||(e.cover=document.createElement("div"),e.cover.setAttribute("id","deep-press-cover"),e.cover.onclick=function(e){this.hold&&e.stopPropagation()},e.cover.onmouseup=function(e){this.hold&&e.stopPropagation()},e.cover.ontouchend=function(e){this.hold&&e.stopPropagation()},e.cover.onmousedown=function(e){e.stopPropagation()},e.cover.ontouchstart=function(e){e.stopPropagation()},e.cover.setAttribute("style","position:absolute; top:0; left:0; width:100%; height: 100%;"),e.appendChild(e.cover),i.default.set(e.cover,{start:function(e){this.hold=!1,this.deep_press=!1,this.view=document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view")},change:function(e,t){e>.2&&(this.view.style.webkitFilter="blur("+i.default.map(e,.2,.5,0,10)+"px)",this.hold=!0)},startDeepPress:function(r){this.deep_press||(this.deep_press=!0,(0,o.handleClick)(this,e.hass,t,!0,!1),n(!1))},end:function(){this.view.style.webkitFilter="blur(0px)"}}))}(this,t)}})},function(e,t,n){var r,o,i;o=[],void 0===(i="function"==typeof(r=function(){"use strict";function e(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n=.5?this._startDeepPress(t):this._endDeepPress()}},{key:"runPolyfill",value:function(e){this.increment=0===h.get("polyfillSpeedUp",this.options)?1:10/h.get("polyfillSpeedUp",this.options),this.decrement=0===h.get("polyfillSpeedDown",this.options)?1:10/h.get("polyfillSpeedDown",this.options),this.setPressed(!0),this.runClosure("start",e),!1===this.runningPolyfill&&this.loopPolyfillForce(0,e)}},{key:"loopPolyfillForce",value:function(e,t){!1===this.nativeSupport&&(this.isPressed()?(this.runningPolyfill=!0,e=e+this.increment>1?1:e+this.increment,this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10)):((e=e-this.decrement<0?0:e-this.decrement)<.5&&this.isDeepPressed()&&(this.setDeepPressed(!1),this.runClosure("endDeepPress")),0===e?(this.runningPolyfill=!1,this.setPressed(!0),this._endPress()):(this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10))))}}]),e}(),u=function(r){function i(t,r,o){return n(this,i),e(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,r,o))}return t(i,r),o(i,[{key:"bindEvents",value:function(){this.add("webkitmouseforcewillbegin",this._startPress.bind(this)),this.add("mousedown",this.support.bind(this)),this.add("webkitmouseforcechanged",this.change.bind(this)),this.add("webkitmouseforcedown",this._startDeepPress.bind(this)),this.add("webkitmouseforceup",this._endDeepPress.bind(this)),this.add("mouseleave",this._endPress.bind(this)),this.add("mouseup",this._endPress.bind(this))}},{key:"support",value:function(e){!1===this.isPressed()&&this.fail(e,this.runKey)}},{key:"change",value:function(e){this.isPressed()&&e.webkitForce>0&&this._changePress(this.normalizeForce(e.webkitForce),e)}},{key:"normalizeForce",value:function(e){return this.reachOne(p(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.995?1:e}}]),i}(a),c=function(r){function i(t,r,o){return n(this,i),e(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,r,o))}return t(i,r),o(i,[{key:"bindEvents",value:function(){b?(this.add("touchforcechange",this.start.bind(this)),this.add("touchstart",this.support.bind(this,0)),this.add("touchend",this._endPress.bind(this))):(this.add("touchstart",this.startLegacy.bind(this)),this.add("touchend",this._endPress.bind(this)))}},{key:"start",value:function(e){e.touches.length>0&&(this._startPress(e),this.touch=this.selectTouch(e),this.touch&&this._changePress(this.touch.force,e))}},{key:"support",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.runKey;!1===this.isPressed()&&(e<=6?(e++,setTimeout(this.support.bind(this,e,t,n),10)):this.fail(t,n))}},{key:"startLegacy",value:function(e){this.initialForce=e.touches[0].force,this.supportLegacy(0,e,this.runKey,this.initialForce)}},{key:"supportLegacy",value:function(e,t,n,r){r!==this.initialForce?(this._startPress(t),this.loopForce(t)):e<=6?(e++,setTimeout(this.supportLegacy.bind(this,e,t,n,r),10)):this.fail(t,n)}},{key:"loopForce",value:function(e){this.isPressed()&&(this.touch=this.selectTouch(e),setTimeout(this.loopForce.bind(this,e),10),this._changePress(this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t1?this.fail(e,this.runKey):(this._startPress(e),this._changePress(e.pressure,e)))}},{key:"change",value:function(e){this.isPressed()&&e.pressure>0&&.5!==e.pressure&&(this._changePress(e.pressure,e),this.deepPress(e.pressure,e))}}]),i}(a),h={polyfill:!0,polyfillSpeedUp:1e3,polyfillSpeedDown:0,preventSelect:!0,only:null,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},d=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof e||e instanceof String)for(var r=document.querySelectorAll(e),o=0;o3?0:(e-e%10!=10)*e%10]}};var m={D:function(e){return e.getDate()},DD:function(e){return l(e.getDate())},Do:function(e,t){return t.DoFn(e.getDate())},d:function(e){return e.getDay()},dd:function(e){return l(e.getDay())},ddd:function(e,t){return t.dayNamesShort[e.getDay()]},dddd:function(e,t){return t.dayNames[e.getDay()]},M:function(e){return e.getMonth()+1},MM:function(e){return l(e.getMonth()+1)},MMM:function(e,t){return t.monthNamesShort[e.getMonth()]},MMMM:function(e,t){return t.monthNames[e.getMonth()]},YY:function(e){return l(String(e.getFullYear()),4).substr(2)},YYYY:function(e){return l(e.getFullYear(),4)},h:function(e){return e.getHours()%12||12},hh:function(e){return l(e.getHours()%12||12)},H:function(e){return e.getHours()},HH:function(e){return l(e.getHours())},m:function(e){return e.getMinutes()},mm:function(e){return l(e.getMinutes())},s:function(e){return e.getSeconds()},ss:function(e){return l(e.getSeconds())},S:function(e){return Math.round(e.getMilliseconds()/100)},SS:function(e){return l(Math.round(e.getMilliseconds()/10),2)},SSS:function(e){return l(e.getMilliseconds(),3)},a:function(e,t){return e.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(e,t){return e.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+l(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)}},y={D:["\\d\\d?",function(e,t){e.day=t}],Do:["\\d\\d?"+i,function(e,t){e.day=parseInt(t,10)}],M:["\\d\\d?",function(e,t){e.month=t-1}],YY:["\\d\\d?",function(e,t){var n=+(""+(new Date).getFullYear()).substr(0,2);e.year=""+(t>68?n-1:n)+t}],h:["\\d\\d?",function(e,t){e.hour=t}],m:["\\d\\d?",function(e,t){e.minute=t}],s:["\\d\\d?",function(e,t){e.second=t}],YYYY:["\\d{4}",function(e,t){e.year=t}],S:["\\d",function(e,t){e.millisecond=100*t}],SS:["\\d{2}",function(e,t){e.millisecond=10*t}],SSS:["\\d{3}",function(e,t){e.millisecond=t}],d:["\\d\\d?",a],ddd:[i,a],MMM:[i,c("monthNamesShort")],MMMM:[i,c("monthNames")],a:[i,function(e,t,n){var r=t.toLowerCase();r===n.amPm[0]?e.isPm=!1:r===n.amPm[1]&&(e.isPm=!0)}],ZZ:["[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z",function(e,t){var n,r=(t+"").match(/([+-]|\d\d)/gi);r&&(n=60*r[1]+parseInt(r[2],10),e.timezoneOffset="+"===r[0]?n:-n)}]};y.dd=y.d,y.dddd=y.ddd,y.DD=y.D,y.mm=y.m,y.hh=y.H=y.HH=y.h,y.MM=y.M,y.ss=y.s,y.A=y.a,r.masks={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},r.format=function(e,t,n){var i=n||r.i18n;if("number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date in fecha.format");t=r.masks[t]||t||r.masks.default;var a=[];return(t=(t=t.replace(s,function(e,t){return a.push(t),"@@@"})).replace(o,function(t){return t in m?m[t](e,i):t.slice(1,t.length-1)})).replace(/@@@/g,function(){return a.shift()})},r.parse=function(e,t,n){var i=n||r.i18n;if("string"!=typeof t)throw new Error("Invalid format in fecha.parse");if(t=r.masks[t]||t,e.length>1e3)return null;var a={},u=[],c=[];t=t.replace(s,function(e,t){return c.push(t),"@@@"});var l,h=(l=t,l.replace(/[|\\{()[^$+*?.-]/g,"\\$&")).replace(o,function(e){if(y[e]){var t=y[e];return u.push(t[1]),"("+t[0]+")"}return e});h=h.replace(/@@@/g,function(){return c.shift()});var d=e.match(new RegExp(h,"i"));if(!d)return null;for(var f=1;f=0?"past":"future";o=Math.abs(o);for(var s=0;s0?t+":"+D(n)+":"+D(r):n>0?n+":"+D(r):r>0?""+r:null}function M(e){var t=g(e.attributes.remaining);if("active"===e.state){var n=(new Date).getTime(),r=new Date(e.last_changed).getTime();t=Math.max(t-(n-r)/1e3,0)}return t}var T=function(e,t,n,r){void 0===r&&(r=!1),e._themes||(e._themes={});var o=t.default_theme;("default"===n||n&&t.themes[n])&&(o=n);var i=Object.assign({},e._themes);if("default"!==o){var s=t.themes[o];Object.keys(s).forEach(function(t){var n="--"+t;e._themes[n]="",i[n]=s[t]})}if(e.updateStyles?e.updateStyles(i):window.ShadyCSS&&window.ShadyCSS.styleSubtree(e,i),r){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var u=i["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",u)}}};function O(e){return e.substr(0,e.indexOf("."))}function C(e){return e.substr(e.indexOf(".")+1)}function Y(e){var t=e.language||"en";return e.translationMetadata.translations[t]&&e.translationMetadata.translations[t].isRTL||!1}function x(e){return Y(e)?"rtl":"ltr"}function F(e){return O(e.entity_id)}function L(e,t,n){var r,o=F(t);if("binary_sensor"===o)t.attributes.device_class&&(r=e("state."+o+"."+t.attributes.device_class+"."+t.state)),r||(r=e("state."+o+".default."+t.state));else if(t.attributes.unit_of_measurement&&!["unknown","unavailable"].includes(t.state))r=t.state+" "+t.attributes.unit_of_measurement;else if("input_datetime"===o){var i;if(t.attributes.has_time)if(t.attributes.has_date)i=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),r=w(i,n);else{var s=new Date;i=new Date(s.getFullYear(),s.getMonth(),s.getDay(),t.attributes.hour,t.attributes.minute),r=_(i,n)}else i=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),r=b(i,n)}else r="zwave"===o?["initializing","dead"].includes(t.state)?e("state.zwave.query_stage."+t.state,"query_stage",t.attributes.query_stage):e("state.zwave.default."+t.state):e("state."+o+"."+t.state);return r||(r=e("state.default."+t.state)||e("component."+o+".state."+t.state)||t.state),r}var R="hass:bookmark",N="lovelace",A=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],H=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],I=["input_number","input_select","input_text","scene","weblink"],j=["camera","configurator","history_graph","scene"],q=["closed","locked","off"],U=new Set(["fan","input_boolean","light","switch","group","automation"]),z="°C",K="°F",Z="group.default_view",W=function(e,t,n,r){r=r||{},n=null==n?{}:n;var o=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return o.detail=n,e.dispatchEvent(o),o},V=function(e){var t=function(e,t){return n("hui-error-card",{type:"error",error:e,config:t})},n=function(e,n){var r=window.document.createElement(e);try{r.setConfig(n)}catch(r){return console.error(e,r),t(r.message,n)}return r};if(!e||"object"!=typeof e||!e.type||!e.type.startsWith("custom:"))return t("No type configured",e);var r=e.type.substr("custom:".length);if(customElements.get(r))return n(r,e);var o=t("Custom element doesn't exist: "+e.type+".",e);o.style.display="None";var i=setTimeout(function(){o.style.display=""},2e3);return customElements.whenDefined(e.type).then(function(){clearTimeout(i),W(o,"ll-rebuild",{},o)}),o},B={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function J(e,t){if(e in B)return B[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),R}}var G=function(e,t){W(e,"haptic",t)},X=function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),W(window,"location-changed",{replace:n})},$=function(e,t,n){void 0===n&&(n=!0);var r,o=O(t),i="group"===o?"homeassistant":o;switch(o){case"lock":r=n?"unlock":"lock";break;case"cover":r=n?"open_cover":"close_cover";break;default:r=n?"turn_on":"turn_off"}return e.callService(i,r,{entity_id:t})},Q=function(e,t){var n=q.includes(e.states[t].state);return $(e,t,n)},ee=function(e,t,n,r,o){var i;switch(o&&n.dbltap_action?i=n.dbltap_action:r&&n.hold_action?i=n.hold_action:!r&&n.tap_action&&(i=n.tap_action),i||(i={action:"more-info"}),i.action){case"more-info":(n.entity||n.camera_image)&&(W(e,"hass-more-info",{entityId:i.entity?i.entity:n.entity?n.entity:n.camera_image}),i.haptic&&G(e,i.haptic));break;case"navigate":i.navigation_path&&(X(0,i.navigation_path),i.haptic&&G(e,i.haptic));break;case"url":i.url&&window.open(i.url),i.haptic&&G(e,i.haptic);break;case"toggle":n.entity&&(Q(t,n.entity),i.haptic&&G(e,i.haptic));break;case"call-service":if(!i.service)return;var s=i.service.split(".",2),a=s[0],u=s[1],c=Object.assign({},i.service_data);"entity"===c.entity_id&&(c.entity_id=n.entity),t.callService(a,u,c),i.haptic&&G(e,i.haptic)}};function te(e,t,n){if(t.has("config")||n)return!0;if(e.config.entity){var r=t.get("hass");return!r||r.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}const ne=new WeakMap;String(Math.random()).slice(2);try{const e={get capture(){return!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");var re="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,oe=function(e){function t(){e.call(this),this.holdTime=500,this.ripple=document.createElement("paper-ripple"),this.timer=void 0,this.held=!1,this.cooldownStart=!1,this.cooldownEnd=!1,this.nbClicks=0}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.connectedCallback=function(){var e=this;Object.assign(this.style,{borderRadius:"50%",position:"absolute",width:re?"100px":"50px",height:re?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none"}),this.appendChild(this.ripple),this.ripple.style.color="#03a9f4",this.ripple.style.color="var(--primary-color)",["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(function(t){document.addEventListener(t,function(){clearTimeout(e.timer),e.stopAnimation(),e.timer=void 0},{passive:!0})})},t.prototype.bind=function(e){var t=this;if(!e.longPress){e.longPress=!0,e.addEventListener("contextmenu",function(e){var t=e||window.event;return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0,t.returnValue=!1,!1});var n=function(n){var r,o;t.cooldownStart||(t.held=!1,n.touches?(r=n.touches[0].pageX,o=n.touches[0].pageY):(r=n.pageX,o=n.pageY),t.timer=window.setTimeout(function(){t.startAnimation(r,o),t.held=!0,e.repeat&&!e.isRepeating&&(e.isRepeating=!0,t.repeatTimeout=setInterval(function(){e.dispatchEvent(new Event("ha-hold"))},e.repeat))},t.holdTime),t.cooldownStart=!0,window.setTimeout(function(){return t.cooldownStart=!1},100))},r=function(n){t.cooldownEnd||["touchend","touchcancel"].includes(n.type)&&void 0===t.timer?e.isRepeating&&t.repeatTimeout&&(clearInterval(t.repeatTimeout),e.isRepeating=!1):(clearTimeout(t.timer),e.isRepeating&&t.repeatTimeout&&clearInterval(t.repeatTimeout),e.isRepeating=!1,t.stopAnimation(),t.timer=void 0,t.held?e.repeat||e.dispatchEvent(new Event("ha-hold")):e.hasDblClick?0===t.nbClicks?(t.nbClicks+=1,t.dblClickTimeout=window.setTimeout(function(){1===t.nbClicks&&(t.nbClicks=0,e.dispatchEvent(new Event("ha-click")))},250)):(t.nbClicks=0,clearTimeout(t.dblClickTimeout),e.dispatchEvent(new Event("ha-dblclick"))):e.dispatchEvent(new Event("ha-click")),t.cooldownEnd=!0,window.setTimeout(function(){return t.cooldownEnd=!1},100))};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",r),e.addEventListener("touchcancel",r),e.addEventListener("mousedown",n,{passive:!0}),e.addEventListener("click",r)}},t.prototype.startAnimation=function(e,t){Object.assign(this.style,{left:e+"px",top:t+"px",display:null}),this.ripple.holdDown=!0,this.ripple.simulatedRipple()},t.prototype.stopAnimation=function(){this.ripple.holdDown=!1,this.style.display="none"},t}(HTMLElement);customElements.get("long-press-custom-card-helpers")||customElements.define("long-press-custom-card-helpers",oe);var ie=function(e){var t=function(){var e=document.body;if(e.querySelector("long-press-custom-card-helpers"))return e.querySelector("long-press-custom-card-helpers");var t=document.createElement("long-press-custom-card-helpers");return e.appendChild(t),t}();t&&t.bind(e)},se=(e=>(...e)=>{const t=function(){return function(e){ie(e.committer.element)}}(...e);return ne.set(t,!0),t})(),ae=function(e,t,n){void 0===n&&(n=!0);var r={};t.forEach(function(t){if(q.includes(e.states[t].state)===n){var o=O(t),i=["cover","lock"].includes(o)?o:"homeassistant";i in r||(r[i]=[]),r[i].push(t)}}),Object.keys(r).forEach(function(t){var o;switch(t){case"lock":o=n?"unlock":"lock";break;case"cover":o=n?"open_cover":"close_cover";break;default:o=n?"turn_on":"turn_off"}e.callService(t,o,{entity_id:r[t]})})},ue=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}}]); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r,i=n(3),s=(r=n(1))&&r.__esModule?r:{default:r},o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,n):{};r.get||r.set?Object.defineProperty(t,n,r):t[n]=e[n]}return t.default=e,t}(n(2));customElements.whenDefined("card-tools").then(()=>{let e=customElements.get("card-tools");var t=Object.assign({},{enable_unsupported:!1},e.lovelace.config.deep_press);if("ontouchforcechange"in document==!1&&0==t.enable_unsupported)return;const n=o.getParser(window.navigator.userAgent),r=n.satisfies({mobile:{safari:">=13"}}),a=new RegExp("^13\\..*","gm"),u="iOS"===n.getOSName()&&!!n.getOSVersion().match(a),c=function(e){var t=document.querySelector("body > home-assistant").shadowRoot.querySelector("ha-more-info-dialog");t&&(e?(t.noCancelOnOutsideClick=!1,t.style.pointerEvents="all"):(t.noCancelOnOutsideClick=!0,t.style.pointerEvents="none"))};["touchend","mouseup"].forEach(e=>{document.addEventListener(e,()=>{!function(){try{document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view").style.webkitFilter="blur(0px)"}catch(e){if(!(e instanceof TypeError))throw e}}(),setTimeout(function(){c(!0)},100)},{passive:!0})});const d=customElements.get("ha-card"),l=function(e){return e.config?e.config:e._config?e._config:e.host?l(e.host):e.parentElement?l(e.parentElement):e.parentNode?l(e.parentNode):null};var f=d.prototype.update;d.prototype.update=function(e){f.apply(this,e);const t=l(this);t&&t.deep_press&&function(e,t){e.querySelector(":scope >#deep-press-cover")||(e.cover=document.createElement("div"),e.cover.setAttribute("id","deep-press-cover"),e.cover.onmouseup=function(e){this.hold&&e.stopPropagation()},e.cover.ontouchend=function(e){this.hold&&e.stopPropagation()},e.cover.ontouchstart=function(e){e.stopPropagation()},r||u||(e.cover.onmousedown=function(e){e.stopPropagation()},e.cover.onclick=function(e){this.hold&&e.stopPropagation()}),e.cover.setAttribute("style","position:absolute; top:0; left:0; width:100%; height: 100%;"),e.appendChild(e.cover),s.default.set(e.cover,{start:function(e){this.hold=!1,this.deep_press=!1,this.view=document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view")},change:function(e,t){e>.2&&(this.view.style.webkitFilter="blur("+s.default.map(e,.2,.5,0,10)+"px)",this.hold=!0)},startDeepPress:function(n){this.deep_press||(this.deep_press=!0,(0,i.handleClick)(this,e.hass,t,!0,!1),c(!1))},end:function(){this.view.style.webkitFilter="blur(0px)"}}))}(this,t)}})},function(e,t,n){var r,i,s;i=[],void 0===(s="function"==typeof(r=function(){"use strict";function e(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;n=.5?this._startDeepPress(t):this._endDeepPress()}},{key:"runPolyfill",value:function(e){this.increment=0===l.get("polyfillSpeedUp",this.options)?1:10/l.get("polyfillSpeedUp",this.options),this.decrement=0===l.get("polyfillSpeedDown",this.options)?1:10/l.get("polyfillSpeedDown",this.options),this.setPressed(!0),this.runClosure("start",e),!1===this.runningPolyfill&&this.loopPolyfillForce(0,e)}},{key:"loopPolyfillForce",value:function(e,t){!1===this.nativeSupport&&(this.isPressed()?(this.runningPolyfill=!0,e=e+this.increment>1?1:e+this.increment,this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10)):((e=e-this.decrement<0?0:e-this.decrement)<.5&&this.isDeepPressed()&&(this.setDeepPressed(!1),this.runClosure("endDeepPress")),0===e?(this.runningPolyfill=!1,this.setPressed(!0),this._endPress()):(this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10))))}}]),e}(),u=function(r){function s(t,r,i){return n(this,s),e(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t,r,i))}return t(s,r),i(s,[{key:"bindEvents",value:function(){this.add("webkitmouseforcewillbegin",this._startPress.bind(this)),this.add("mousedown",this.support.bind(this)),this.add("webkitmouseforcechanged",this.change.bind(this)),this.add("webkitmouseforcedown",this._startDeepPress.bind(this)),this.add("webkitmouseforceup",this._endDeepPress.bind(this)),this.add("mouseleave",this._endPress.bind(this)),this.add("mouseup",this._endPress.bind(this))}},{key:"support",value:function(e){!1===this.isPressed()&&this.fail(e,this.runKey)}},{key:"change",value:function(e){this.isPressed()&&e.webkitForce>0&&this._changePress(this.normalizeForce(e.webkitForce),e)}},{key:"normalizeForce",value:function(e){return this.reachOne(p(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.995?1:e}}]),s}(a),c=function(r){function s(t,r,i){return n(this,s),e(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t,r,i))}return t(s,r),i(s,[{key:"bindEvents",value:function(){y?(this.add("touchforcechange",this.start.bind(this)),this.add("touchstart",this.support.bind(this,0)),this.add("touchend",this._endPress.bind(this))):(this.add("touchstart",this.startLegacy.bind(this)),this.add("touchend",this._endPress.bind(this)))}},{key:"start",value:function(e){e.touches.length>0&&(this._startPress(e),this.touch=this.selectTouch(e),this.touch&&this._changePress(this.touch.force,e))}},{key:"support",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.runKey;!1===this.isPressed()&&(e<=6?(e++,setTimeout(this.support.bind(this,e,t,n),10)):this.fail(t,n))}},{key:"startLegacy",value:function(e){this.initialForce=e.touches[0].force,this.supportLegacy(0,e,this.runKey,this.initialForce)}},{key:"supportLegacy",value:function(e,t,n,r){r!==this.initialForce?(this._startPress(t),this.loopForce(t)):e<=6?(e++,setTimeout(this.supportLegacy.bind(this,e,t,n,r),10)):this.fail(t,n)}},{key:"loopForce",value:function(e){this.isPressed()&&(this.touch=this.selectTouch(e),setTimeout(this.loopForce.bind(this,e),10),this._changePress(this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t1?this.fail(e,this.runKey):(this._startPress(e),this._changePress(e.pressure,e)))}},{key:"change",value:function(e){this.isPressed()&&e.pressure>0&&.5!==e.pressure&&(this._changePress(e.pressure,e),this.deepPress(e.pressure,e))}}]),s}(a),l={polyfill:!0,polyfillSpeedUp:1e3,polyfillSpeedDown:0,preventSelect:!0,only:null,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},f=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof e||e instanceof String)for(var r=document.querySelectorAll(e),i=0;i0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,r){void 0===r&&(r=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(n),o=Math.max(i,s),a=0,u=e.map([t,n],function(t){var n=o-e.getVersionPrecision(t),r=t+new Array(n+1).join(".0");return e.map(r.split("."),function(e){return new Array(20-e.length).join("0")+e}).reverse()});for(r&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(u[0][o]>u[1][o])return 1;if(u[0][o]===u[1][o]){if(o===a)return 0;o-=1}else if(u[0][o]0){var o=Object.keys(n),a=o.find(function(e){return t.isOS(e)});if(a){var u=this.satisfies(n[a]);if(void 0!==u)return u}var c=o.find(function(e){return t.isPlatform(e)});if(c){var d=this.satisfies(n[c]);if(void 0!==d)return d}}if(s>0){var l=Object.keys(i).find(function(e){return t.isBrowser(e,!0)});if(void 0!==l)return this.compareVersion(i[l])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n},t.compareVersion=function(e){var t=[0],n=e,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(a.default.compareVersions(i,n,r))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e){return this.isBrowser(e)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some(function(e){return t.is(e)})},e}();t.default=c,e.exports=t.default},92:function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(/(?:opr|opios)[\s\/](\S+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=i.default.getFirstMatch(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=i.default.getFirstMatch(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=i.default.getFirstMatch(/(?:swing)[\s\/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=i.default.getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=i.default.getFirstMatch(/(?:micromessenger)[\s\/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=i.default.getFirstMatch(/(?:qupzilla)[\s\/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s\/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=i.default.getFirstMatch(/(?:chromium)[\s\/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=i.default.getFirstMatch(s,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows/i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=i.default.getWindowsVersionName(t);return{name:s.OS_MAP.Windows,version:t,versionName:n}}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=i.default.getMacOSVersionName(t),r={name:s.OS_MAP.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=i.default.getFirstMatch(/android[\s\/-](\d+(\.\d+)*)/i,e),n=i.default.getAndroidVersionName(t),r={name:s.OS_MAP.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:s.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[\/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},n=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},n=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},n=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},n=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=o,e.exports=t.default}})},function(e,t,n){"use strict";n.r(t);var r={},i=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,s="[^\\s]+",o=/\[([^]*?)\]/gm,a=function(){};function u(e,t){for(var n=[],r=0,i=e.length;r3?0:(e-e%10!=10)*e%10]}};var m={D:function(e){return e.getDate()},DD:function(e){return d(e.getDate())},Do:function(e,t){return t.DoFn(e.getDate())},d:function(e){return e.getDay()},dd:function(e){return d(e.getDay())},ddd:function(e,t){return t.dayNamesShort[e.getDay()]},dddd:function(e,t){return t.dayNames[e.getDay()]},M:function(e){return e.getMonth()+1},MM:function(e){return d(e.getMonth()+1)},MMM:function(e,t){return t.monthNamesShort[e.getMonth()]},MMMM:function(e,t){return t.monthNames[e.getMonth()]},YY:function(e){return d(String(e.getFullYear()),4).substr(2)},YYYY:function(e){return d(e.getFullYear(),4)},h:function(e){return e.getHours()%12||12},hh:function(e){return d(e.getHours()%12||12)},H:function(e){return e.getHours()},HH:function(e){return d(e.getHours())},m:function(e){return e.getMinutes()},mm:function(e){return d(e.getMinutes())},s:function(e){return e.getSeconds()},ss:function(e){return d(e.getSeconds())},S:function(e){return Math.round(e.getMilliseconds()/100)},SS:function(e){return d(Math.round(e.getMilliseconds()/10),2)},SSS:function(e){return d(e.getMilliseconds(),3)},a:function(e,t){return e.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(e,t){return e.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+d(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)}},v={D:["\\d\\d?",function(e,t){e.day=t}],Do:["\\d\\d?"+s,function(e,t){e.day=parseInt(t,10)}],M:["\\d\\d?",function(e,t){e.month=t-1}],YY:["\\d\\d?",function(e,t){var n=+(""+(new Date).getFullYear()).substr(0,2);e.year=""+(t>68?n-1:n)+t}],h:["\\d\\d?",function(e,t){e.hour=t}],m:["\\d\\d?",function(e,t){e.minute=t}],s:["\\d\\d?",function(e,t){e.second=t}],YYYY:["\\d{4}",function(e,t){e.year=t}],S:["\\d",function(e,t){e.millisecond=100*t}],SS:["\\d{2}",function(e,t){e.millisecond=10*t}],SSS:["\\d{3}",function(e,t){e.millisecond=t}],d:["\\d\\d?",a],ddd:[s,a],MMM:[s,c("monthNamesShort")],MMMM:[s,c("monthNames")],a:[s,function(e,t,n){var r=t.toLowerCase();r===n.amPm[0]?e.isPm=!1:r===n.amPm[1]&&(e.isPm=!0)}],ZZ:["[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z",function(e,t){var n,r=(t+"").match(/([+-]|\d\d)/gi);r&&(n=60*r[1]+parseInt(r[2],10),e.timezoneOffset="+"===r[0]?n:-n)}]};v.dd=v.d,v.dddd=v.ddd,v.DD=v.D,v.mm=v.m,v.hh=v.H=v.HH=v.h,v.MM=v.M,v.ss=v.s,v.A=v.a,r.masks={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},r.format=function(e,t,n){var s=n||r.i18n;if("number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date in fecha.format");t=r.masks[t]||t||r.masks.default;var a=[];return(t=(t=t.replace(o,function(e,t){return a.push(t),"@@@"})).replace(i,function(t){return t in m?m[t](e,s):t.slice(1,t.length-1)})).replace(/@@@/g,function(){return a.shift()})},r.parse=function(e,t,n){var s=n||r.i18n;if("string"!=typeof t)throw new Error("Invalid format in fecha.parse");if(t=r.masks[t]||t,e.length>1e3)return null;var a={},u=[],c=[];t=t.replace(o,function(e,t){return c.push(t),"@@@"});var d,l=(d=t,d.replace(/[|\\{()[^$+*?.-]/g,"\\$&")).replace(i,function(e){if(v[e]){var t=v[e];return u.push(t[1]),"("+t[0]+")"}return e});l=l.replace(/@@@/g,function(){return c.shift()});var f=e.match(new RegExp(l,"i"));if(!f)return null;for(var h=1;h=0?"past":"future";i=Math.abs(i);for(var o=0;o0?t+":"+k(n)+":"+k(r):n>0?n+":"+k(r):r>0?""+r:null}function A(e){var t=b(e.attributes.remaining);if("active"===e.state){var n=(new Date).getTime(),r=new Date(e.last_changed).getTime();t=Math.max(t-(n-r)/1e3,0)}return t}var E=function(e,t,n,r){void 0===r&&(r=!1),e._themes||(e._themes={});var i=t.default_theme;("default"===n||n&&t.themes[n])&&(i=n);var s=Object.assign({},e._themes);if("default"!==i){var o=t.themes[i];Object.keys(o).forEach(function(t){var n="--"+t;e._themes[n]="",s[n]=o[t]})}if(e.updateStyles?e.updateStyles(s):window.ShadyCSS&&window.ShadyCSS.styleSubtree(e,s),r){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var u=s["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",u)}}};function F(e){return e.substr(0,e.indexOf("."))}function T(e){return e.substr(e.indexOf(".")+1)}function R(e){var t=e.language||"en";return e.translationMetadata.translations[t]&&e.translationMetadata.translations[t].isRTL||!1}function D(e){return R(e)?"rtl":"ltr"}function N(e){return F(e.entity_id)}function x(e,t,n){var r,i=N(t);if("binary_sensor"===i)t.attributes.device_class&&(r=e("state."+i+"."+t.attributes.device_class+"."+t.state)),r||(r=e("state."+i+".default."+t.state));else if(t.attributes.unit_of_measurement&&!["unknown","unavailable"].includes(t.state))r=t.state+" "+t.attributes.unit_of_measurement;else if("input_datetime"===i){var s;if(t.attributes.has_time)if(t.attributes.has_date)s=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),r=w(s,n);else{var o=new Date;s=new Date(o.getFullYear(),o.getMonth(),o.getDay(),t.attributes.hour,t.attributes.minute),r=_(s,n)}else s=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),r=y(s,n)}else r="zwave"===i?["initializing","dead"].includes(t.state)?e("state.zwave.query_stage."+t.state,"query_stage",t.attributes.query_stage):e("state.zwave.default."+t.state):e("state."+i+"."+t.state);return r||(r=e("state.default."+t.state)||e("component."+i+".state."+t.state)||t.state),r}var B="hass:bookmark",L="lovelace",C=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],j=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],I=["input_number","input_select","input_text","scene","weblink"],Y=["camera","configurator","history_graph","scene"],z=["closed","locked","off"],H=new Set(["fan","input_boolean","light","switch","group","automation"]),W="°C",V="°F",q="group.default_view",U=function(e,t,n,r){r=r||{},n=null==n?{}:n;var i=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return i.detail=n,e.dispatchEvent(i),i},G=function(e){var t=function(e,t){return n("hui-error-card",{type:"error",error:e,config:t})},n=function(e,n){var r=window.document.createElement(e);try{r.setConfig(n)}catch(r){return console.error(e,r),t(r.message,n)}return r};if(!e||"object"!=typeof e||!e.type||!e.type.startsWith("custom:"))return t("No type configured",e);var r=e.type.substr("custom:".length);if(customElements.get(r))return n(r,e);var i=t("Custom element doesn't exist: "+e.type+".",e);i.style.display="None";var s=setTimeout(function(){i.style.display=""},2e3);return customElements.whenDefined(e.type).then(function(){clearTimeout(s),U(i,"ll-rebuild",{},i)}),i},K={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Z(e,t){if(e in K)return K[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),B}}var J=function(e,t){U(e,"haptic",t)},X=function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),U(window,"location-changed",{replace:n})},Q=function(e,t,n){void 0===n&&(n=!0);var r,i=F(t),s="group"===i?"homeassistant":i;switch(i){case"lock":r=n?"unlock":"lock";break;case"cover":r=n?"open_cover":"close_cover";break;default:r=n?"turn_on":"turn_off"}return e.callService(s,r,{entity_id:t})},$=function(e,t){var n=z.includes(e.states[t].state);return Q(e,t,n)},ee=function(e,t,n,r,i){var s;switch(i&&n.dbltap_action?s=n.dbltap_action:r&&n.hold_action?s=n.hold_action:!r&&n.tap_action&&(s=n.tap_action),s||(s={action:"more-info"}),s.action){case"more-info":(n.entity||n.camera_image)&&(U(e,"hass-more-info",{entityId:s.entity?s.entity:n.entity?n.entity:n.camera_image}),s.haptic&&J(e,s.haptic));break;case"navigate":s.navigation_path&&(X(0,s.navigation_path),s.haptic&&J(e,s.haptic));break;case"url":s.url&&window.open(s.url),s.haptic&&J(e,s.haptic);break;case"toggle":n.entity&&($(t,n.entity),s.haptic&&J(e,s.haptic));break;case"call-service":if(!s.service)return;var o=s.service.split(".",2),a=o[0],u=o[1],c=Object.assign({},s.service_data);"entity"===c.entity_id&&(c.entity_id=n.entity),t.callService(a,u,c),s.haptic&&J(e,s.haptic)}};function te(e,t,n){if(t.has("config")||n)return!0;if(e.config.entity){var r=t.get("hass");return!r||r.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}const ne=new WeakMap;String(Math.random()).slice(2);try{const e={get capture(){return!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");var re="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,ie=function(e){function t(){e.call(this),this.holdTime=500,this.ripple=document.createElement("paper-ripple"),this.timer=void 0,this.held=!1,this.cooldownStart=!1,this.cooldownEnd=!1,this.nbClicks=0}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.connectedCallback=function(){var e=this;Object.assign(this.style,{borderRadius:"50%",position:"absolute",width:re?"100px":"50px",height:re?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none"}),this.appendChild(this.ripple),this.ripple.style.color="#03a9f4",this.ripple.style.color="var(--primary-color)",["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(function(t){document.addEventListener(t,function(){clearTimeout(e.timer),e.stopAnimation(),e.timer=void 0},{passive:!0})})},t.prototype.bind=function(e){var t=this;if(!e.longPress){e.longPress=!0,e.addEventListener("contextmenu",function(e){var t=e||window.event;return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0,t.returnValue=!1,!1});var n=function(n){var r,i;t.cooldownStart||(t.held=!1,n.touches?(r=n.touches[0].pageX,i=n.touches[0].pageY):(r=n.pageX,i=n.pageY),t.timer=window.setTimeout(function(){t.startAnimation(r,i),t.held=!0,e.repeat&&!e.isRepeating&&(e.isRepeating=!0,t.repeatTimeout=setInterval(function(){e.dispatchEvent(new Event("ha-hold"))},e.repeat))},t.holdTime),t.cooldownStart=!0,window.setTimeout(function(){return t.cooldownStart=!1},100))},r=function(n){t.cooldownEnd||["touchend","touchcancel"].includes(n.type)&&void 0===t.timer?e.isRepeating&&t.repeatTimeout&&(clearInterval(t.repeatTimeout),e.isRepeating=!1):(clearTimeout(t.timer),e.isRepeating&&t.repeatTimeout&&clearInterval(t.repeatTimeout),e.isRepeating=!1,t.stopAnimation(),t.timer=void 0,t.held?e.repeat||e.dispatchEvent(new Event("ha-hold")):e.hasDblClick?0===t.nbClicks?(t.nbClicks+=1,t.dblClickTimeout=window.setTimeout(function(){1===t.nbClicks&&(t.nbClicks=0,e.dispatchEvent(new Event("ha-click")))},250)):(t.nbClicks=0,clearTimeout(t.dblClickTimeout),e.dispatchEvent(new Event("ha-dblclick"))):e.dispatchEvent(new Event("ha-click")),t.cooldownEnd=!0,window.setTimeout(function(){return t.cooldownEnd=!1},100))};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",r),e.addEventListener("touchcancel",r),e.addEventListener("mousedown",n,{passive:!0}),e.addEventListener("click",r)}},t.prototype.startAnimation=function(e,t){Object.assign(this.style,{left:e+"px",top:t+"px",display:null}),this.ripple.holdDown=!0,this.ripple.simulatedRipple()},t.prototype.stopAnimation=function(){this.ripple.holdDown=!1,this.style.display="none"},t}(HTMLElement);customElements.get("long-press-custom-card-helpers")||customElements.define("long-press-custom-card-helpers",ie);var se=function(e){var t=function(){var e=document.body;if(e.querySelector("long-press-custom-card-helpers"))return e.querySelector("long-press-custom-card-helpers");var t=document.createElement("long-press-custom-card-helpers");return e.appendChild(t),t}();t&&t.bind(e)},oe=(e=>(...e)=>{const t=function(){return function(e){se(e.committer.element)}}(...e);return ne.set(t,!0),t})(),ae=function(e,t,n){void 0===n&&(n=!0);var r={};t.forEach(function(t){if(z.includes(e.states[t].state)===n){var i=F(t),s=["cover","lock"].includes(i)?i:"homeassistant";s in r||(r[s]=[]),r[s].push(t)}}),Object.keys(r).forEach(function(t){var i;switch(t){case"lock":i=n?"unlock":"lock";break;case"cover":i=n?"open_cover":"close_cover";break;default:i=n?"turn_on":"turn_off"}e.callService(t,i,{entity_id:r[t]})})},ue=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}}]); \ No newline at end of file diff --git a/package.json b/package.json index 89e1bcf..849bea5 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ }, "dependencies": { "custom-card-helpers": "^1.2.2", - "pressure": "^2.1.2" + "pressure": "^2.1.2", + "forceify": "latest", + "bowser": "^2.5.2" } } diff --git a/src/deep-press.js b/src/deep-press.js index 1fcd3f3..9c7dc89 100644 --- a/src/deep-press.js +++ b/src/deep-press.js @@ -3,6 +3,7 @@ import { } from 'custom-card-helpers'; import Pressure from 'pressure'; +import * as Bowser from 'bowser'; customElements.whenDefined('card-tools').then(() => { let cardTools = customElements.get('card-tools'); @@ -17,6 +18,16 @@ customElements.whenDefined('card-tools').then(() => { return; // disable if device doesnt support force-touch } + // https://community.home-assistant.io/t/lovelace-button-card/65981/1933 + const br = Bowser.getParser(window.navigator.userAgent); + const isCrazyBrowser = br.satisfies({ + mobile: { + safari: '>=13', + }, + }); + const ios13 = new RegExp('^13\\..*', 'gm'); + const isCrazyBrowser2 = br.getOSName() === 'iOS' && (br.getOSVersion().match(ios13) ? true : false); + const setModalBehaviour = function(enable_clicks) { var modal = document.querySelector("body > home-assistant").shadowRoot.querySelector("ha-more-info-dialog"); if (modal) { @@ -84,11 +95,14 @@ customElements.whenDefined('card-tools').then(() => { // Create a cover which captures the deep press root.cover = document.createElement("div"); root.cover.setAttribute("id", "deep-press-cover"); - root.cover.onclick = function(event) { if (this.hold) { event.stopPropagation(); } }; // Catch click method so we can stop propagation - root.cover.onmouseup = function(event) { if (this.hold) { event.stopPropagation(); } }; // Catch click method so we can stop propagation - root.cover.ontouchend = function(event) { if (this.hold) { event.stopPropagation(); } }; // Catch click method so we can stop propagation - root.cover.onmousedown = function(event) { event.stopPropagation(); }; // Catch click method so we can stop propagation - root.cover.ontouchstart = function(event) { event.stopPropagation(); }; // Catch click method so we can stop propagation + root.cover.onmouseup = function(event) { if (this.hold) { event.stopPropagation(); } }; + root.cover.ontouchend = function(event) { if (this.hold) { event.stopPropagation(); } }; + root.cover.ontouchstart = function(event) { event.stopPropagation(); }; + if (!isCrazyBrowser && !isCrazyBrowser2) { + root.cover.onmousedown = function(event) { event.stopPropagation(); }; + root.cover.onclick = function(event) { if (this.hold) { event.stopPropagation(); } }; + } + root.cover.setAttribute( "style", "position:absolute; top:0; left:0; width:100%; height: 100%;"