diff --git a/docs/_docs/floorplan/floorplan-examples.js b/docs/_docs/floorplan/floorplan-examples.js index a7cc0b3d..a30c592e 100644 --- a/docs/_docs/floorplan/floorplan-examples.js +++ b/docs/_docs/floorplan/floorplan-examples.js @@ -45,7 +45,7 @@ const ie=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */}var se;null===(se=window.HTMLSlotElement)||void 0===se||se.prototype.assignedElements;class ae{constructor(){this.states={}}callWS(e){return console.log(e),Promise.resolve(null)}callService(e,t,i){return Promise.resolve({context:{id:"",parent_id:void 0,user_id:void 0}})}clone(){const e=new ae;return e.callService=this.callService,e.states=JSON.parse(JSON.stringify(this.states)),e}}class oe{}let ce=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/giu;function le(e="",t="ms"){var i=null;return(e=(e+"").replace(/(\d)[,_](\d)/g,"$1$2")).replace(ce,(function(e,t,n){(n=he(n))&&(i=(i||0)+parseFloat(t,10)*n)})),i&&i/(he(t)||1)}function he(e){return le[e]||le[e.toLowerCase().replace(/s$/,"")]}le.nanosecond=le.ns=1e-6,le["µs"]=le["μs"]=le.us=le.microsecond=.001,le.millisecond=le.ms=le[""]=1,le.second=le.sec=le.s=1e3*le.ms,le.minute=le.min=le.m=60*le.s,le.hour=le.hr=le.h=60*le.m,le.day=le.d=24*le.h,le.week=le.wk=le.w=7*le.d,le.month=le.b=30.4375*le.d,le.year=le.yr=le.y=365.25*le.d;const ue=le;class pe{static miredToRGB(e){return this.kelvinToRGB(1e6/e)}static kelvinToRGB(e){const t=e/100;let i,n,r;return t<=66?(i=255,n=t,n=99.4708025861*Math.log(n)-161.1195681661,t<=19?r=0:(r=t-10,r=138.5177312231*Math.log(r)-305.0447927307)):(i=t-60,i=329.698727446*Math.pow(i,-.1332047592),n=t-60,n=288.1221695283*Math.pow(n,-.0755148492),r=255),[Math.min(Math.max(Math.round(i),0),255),Math.min(Math.max(Math.round(n),0),255),Math.min(Math.max(Math.round(r),0),255)]}}var de,fe=i(1),me=i.n(fe);class ge{static timeago(e){let t="second",i=0;const n=("string"==typeof e?new Date(e):e).getTime()-(new Date).getTime(),r=n/this.MILLISECONDS_IN_YEAR;if(Math.abs(r)>=1)t="year",i=r;else{const e=n/this.MILLISECONDS_IN_DAY;if(Math.abs(e)>=1)t="day",i=e;else{const e=n/this.MILLISECONDS_IN_HOUR;if(Math.abs(e)>=1)t="hour",i=e;else{const e=n/this.MILLISECONDS_IN_MINUTE;Math.abs(e)>=1?(t="minute",i=e):(t="second",i=n/this.MILLISECONDS_IN_SECOND)}}}return this.relativeTimeFormat.format(Math.round(i),t)}}ge.strftime=me(),ge.MILLISECONDS_IN_SECOND=1e3,ge.MILLISECONDS_IN_MINUTE=6e4,ge.MILLISECONDS_IN_HOUR=36e5,ge.MILLISECONDS_IN_DAY=864e5,ge.MILLISECONDS_IN_YEAR=31536e6,ge.relativeTimeFormat=new Intl.RelativeTimeFormat(null!==(de=navigator.language)&&void 0!==de?de:"en",{numeric:"auto",style:"long"});var ve=i(449),ye=i.n(ve);function be(e){return(e=>{if("object"==typeof(t=e)&&null!==t&&"message"in t&&"string"==typeof t.message)return e;var t;try{return new Error(JSON.stringify(e))}catch(t){return new Error(String(e))}})(e).message}class xe{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t){var i;this.expression=e.trim();const n=`${this.expression}_${null!==(i=t.entity_id)&&void 0!==i?i:""}`;this.parsedFunction=this.cache[n],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[n]=this.parsedFunction,this.interpreter.import("util",this.util)),this.entityState=t,this.interpreter.import("entity",this.entityState);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}xe.cache={},xe.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),xe.util={color:pe,date:ge};class we{constructor(e,t){this.hassChanged=t,this.simulationProcessors=[],this.hass=new ae,this.hass.callService=this.callService.bind(this);for(const t of e.simulations){const e=new Se(t,this.hass,this.onEntityStatesChanged.bind(this));this.simulationProcessors.push(e)}}onEntityStatesChanged(e){for(const t of e)this.hass.states[t.entity_id]=t;this.hassChanged(this.hass.clone())}callService(e,t,i){switch(console.log("HassSimulator.callService()",e,t,i),e){case"homeassistant":case"light":case"fan":"toggle"===t&&this.homeAssistantToggle(i);break;case"media_player":switch(t){case"volume_up":this.homeAssistantVolumeUp(i);break;case"volume_down":this.homeAssistantVolumeDown(i)}}return Promise.resolve({context:{id:"",parent_id:void 0,user_id:void 0}})}homeAssistantToggle(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];switch(t){case"switch":case"light":case"fan":case"binary_sensor":case"sensor":case"media_player":i.state="on"===i.state?"off":"on";for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}homeAssistantVolumeUp(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];let n;if("media_player"===t){n=i.attributes.volume_level,i.attributes.volume_level=Math.min(1,n+.1);for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}homeAssistantVolumeDown(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];let n;if("media_player"===t){n=i.attributes.volume_level,i.attributes.volume_level=Math.max(0,n-.1);for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}}class Se{constructor(e,t,i){var n,r;this.simulation=e,this.hass=t,this.onEntityStatesChanged=i,this.currentIndex=0,this.entities=[],this.simulation.entities&&(this.entities=this.entities.concat(this.simulation.entities)),this.simulation.entity&&(this.entities=this.entities.concat(this.simulation.entity)),this.entities.length||console.error("Simulation must contain at least one entity",e),(null===(n=this.simulation.states)||void 0===n?void 0:n.length)||this.simulation.state||console.error("Simulation must contain at least one state",e),this.triggerState(null!==(r=this.simulation.state)&&void 0!==r?r:this.simulation.states[0])}triggerState(e){var t;if(this.simulation.enabled||void 0===this.simulation.enabled)for(const t of this.entities)this.updateEntityState(t,e);if(this.simulation.states){let i;if("string"==typeof this.simulation.states){const e=null!==(t=this.simulation.state)&&void 0!==t?t:{entity_id:this.simulation.entity};i=xe.evaluate(this.simulation.states,e),this.simulation.state=i}else{const t=(this.simulation.states.indexOf(e)+1)%this.simulation.states.length;i=this.simulation.states[t]}if(null==i?void 0:i.duration){const t=e,n="number"==typeof t.duration?1e3*t.duration:ue(t.duration);setTimeout(this.triggerState.bind(this),n,i)}}}updateEntityState(e,t){var i,n,r;const s="string"==typeof e?e:e.entity_id,a=this.hass.states[s];let o;a?(o=Object.assign({},a),o.attributes=Object.assign({},a.attributes)):(o=new oe,o.entity_id=s),"string"==typeof t?o.state="string"==typeof t?t:t.state:"object"==typeof t&&(o.state=t.state,t.attributes&&(o.attributes=Object.assign({},o.attributes,t.attributes))),o.attributes=null!==(i=o.attributes)&&void 0!==i?i:{},o.attributes.friendly_name=null!==(r=null===(n=o.attributes)||void 0===n?void 0:n.friendly_name)&&void 0!==r?r:s,o.last_changed=(new Date).toString(),o.last_updated=(new Date).toString(),this.onEntityStatesChanged([o])}} -/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function _e(e){return null==e}var ke={isNothing:_e,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:_e(e)?[]:[e]},repeat:function(e,t){var i,n="";for(i=0;io&&(t=n-o+(s=" ... ").length),i-n>o&&(i=n+o-(a=" ...").length),{str:s+e.slice(t,i).replace(/\t/g,"→")+a,pos:n-t+s.length}}function Te(e,t){return ke.repeat(" ",t-e.length)+e}var Pe=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,r=[0],s=[],a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var o,c,l="",h=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+h+3);for(o=1;o<=t.linesBefore&&!(a-o<0);o++)c=Ie(e.buffer,r[a-o],s[a-o],e.position-(r[a]-r[a-o]),u),l=ke.repeat(" ",t.indent)+Te((e.line-o+1).toString(),h)+" | "+c.str+"\n"+l;for(c=Ie(e.buffer,r[a],s[a],e.position,u),l+=ke.repeat(" ",t.indent)+Te((e.line+1).toString(),h)+" | "+c.str+"\n",l+=ke.repeat("-",t.indent+h+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(a+o>=s.length);o++)c=Ie(e.buffer,r[a+o],s[a+o],e.position-(r[a]-r[a+o]),u),l+=ke.repeat(" ",t.indent)+Te((e.line+o+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Oe=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ne=["scalar","sequence","mapping"],Me=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===Oe.indexOf(t))throw new Ce('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(i){e[i].forEach((function(e){t[String(e)]=i}))})),t}(t.styleAliases||null),-1===Ne.indexOf(this.kind))throw new Ce('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function Le(e,t){var i=[];return e[t].forEach((function(e){var t=i.length;i.forEach((function(i,n){i.tag===e.tag&&i.kind===e.kind&&i.multi===e.multi&&(t=n)})),i[t]=e})),i}function De(e){return this.extend(e)}De.prototype.extend=function(e){var t=[],i=[];if(e instanceof Me)i.push(e);else if(Array.isArray(e))i=i.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new Ce("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(i=i.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new Ce("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new Ce("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(De.prototype);return n.implicit=(this.implicit||[]).concat(t),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Le(n,"implicit"),n.compiledExplicit=Le(n,"explicit"),n.compiledTypeMap=function(){var e,t,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(e){e.multi?(i.multi[e.kind].push(e),i.multi.fallback.push(e)):i[e.kind][e.tag]=i.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ye=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Ge=/^[-+]?[0-9]+e/,Je=new Me("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!Ye.test(e)||"_"===e[e.length-1])},construct:function(e){var t,i;return i="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:i*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||ke.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ke.isNegativeZero(e))return"-0.0";return i=e.toString(10),Ge.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Xe=Ve.extend({implicit:[Fe,Ue,We,Je]}),Ke=Xe,Qe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ze=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),et=new Me("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==Qe.exec(e)||null!==Ze.exec(e))},construct:function(e){var t,i,n,r,s,a,o,c,l=0,h=null;if(null===(t=Qe.exec(e))&&(t=Ze.exec(e)),null===t)throw new Error("Date resolve error");if(i=+t[1],n=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(i,n,r));if(s=+t[4],a=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(h=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(h=-h)),c=new Date(Date.UTC(i,n,r,s,a,o,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(e){return e.toISOString()}}),tt=new Me("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",nt=new Me("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,n=0,r=e.length,s=it;for(i=0;i64)){if(t<0)return!1;n+=6}return n%8==0},construct:function(e){var t,i,n=e.replace(/[\r\n=]/g,""),r=n.length,s=it,a=0,o=[];for(t=0;t>16&255),o.push(a>>8&255),o.push(255&a)),a=a<<6|s.indexOf(n.charAt(t));return 0==(i=r%4*6)?(o.push(a>>16&255),o.push(a>>8&255),o.push(255&a)):18===i?(o.push(a>>10&255),o.push(a>>2&255)):12===i&&o.push(a>>4&255),new Uint8Array(o)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,i,n="",r=0,s=e.length,a=it;for(t=0;t>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]),r=(r<<8)+e[t];return 0==(i=s%3)?(n+=a[r>>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]):2===i?(n+=a[r>>10&63],n+=a[r>>4&63],n+=a[r<<2&63],n+=a[64]):1===i&&(n+=a[r>>2&63],n+=a[r<<4&63],n+=a[64],n+=a[64]),n}}),rt=Object.prototype.hasOwnProperty,st=Object.prototype.toString,at=new Me("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,n,r,s,a=[],o=e;for(t=0,i=o.length;t>10),56320+(e-65536&1023))}for(var Dt=new Array(256),$t=new Array(256),Rt=0;Rt<256;Rt++)Dt[Rt]=Mt(Rt)?1:0,$t[Rt]=Mt(Rt);function jt(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ut,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Bt(e,t){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=Pe(i),new Ce(t,i)}function Vt(e,t){throw Bt(e,t)}function Ft(e,t){e.onWarning&&e.onWarning.call(null,Bt(e,t))}var Ut={YAML:function(e,t,i){var n,r,s;null!==e.version&&Vt(e,"duplication of %YAML directive"),1!==i.length&&Vt(e,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Vt(e,"ill-formed argument of the YAML directive"),r=parseInt(n[1],10),s=parseInt(n[2],10),1!==r&&Vt(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&Ft(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var n,r;2!==i.length&&Vt(e,"TAG directive accepts exactly two arguments"),n=i[0],r=i[1],_t.test(n)||Vt(e,"ill-formed tag handle (first argument) of the TAG directive"),pt.call(e.tagMap,n)&&Vt(e,'there is a previously declared suffix for "'+n+'" tag handle'),kt.test(r)||Vt(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){Vt(e,"tag prefix is malformed: "+r)}e.tagMap[n]=r}};function Ht(e,t,i,n){var r,s,a,o;if(t1&&(e.result+=ke.repeat("\n",t-1))}function Xt(e,t){var i,n,r=e.tag,s=e.anchor,a=[],o=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),n=e.input.charCodeAt(e.position);0!==n&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,Vt(e,"tab characters must not be used in indentation")),45===n)&&It(e.input.charCodeAt(e.position+1));)if(o=!0,e.position++,Yt(e,!0,-1)&&e.lineIndent<=t)a.push(null),n=e.input.charCodeAt(e.position);else if(i=e.line,Zt(e,t,mt,!1,!0),a.push(e.result),Yt(e,!0,-1),n=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>t)&&0!==n)Vt(e,"bad indentation of a sequence entry");else if(e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt)&&(v&&(a=e.line,o=e.lineStart,c=e.position),Zt(e,t,gt,!0,r)&&(v?m=e.result:g=e.result),v||(zt(e,p,d,f,m,g,a,o,c),f=m=g=null),Yt(e,!0,-1),l=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&0!==l)Vt(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===r?Vt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Vt(e,"repeat of an indentation width identifier"):(l=t+r-1,c=!0)}if(Ct(s)){do{s=e.input.charCodeAt(++e.position)}while(Ct(s));if(35===s)do{s=e.input.charCodeAt(++e.position)}while(!At(s)&&0!==s)}for(;0!==s;){for(Wt(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!c||e.lineIndentl&&(l=e.lineIndent),At(s))h++;else{if(e.lineIndent0){for(r=a,s=0;r>0;r--)(a=Pt(o=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+a:Vt(e,"expected hexadecimal character");e.result+=Lt(s),e.position++}else Vt(e,"unknown escape sequence");i=n=e.position}else At(o)?(Ht(e,i,n,!0),Jt(e,Yt(e,!1,t)),i=n=e.position):e.position===e.lineStart&&Gt(e)?Vt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Vt(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?g=!0:function(e){var t,i,n;if(42!==(n=e.input.charCodeAt(e.position)))return!1;for(n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!It(n)&&!Tt(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Vt(e,"name of an alias node must contain at least one character"),i=e.input.slice(t,e.position),pt.call(e.anchorMap,i)||Vt(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],Yt(e,!0,-1),!0}(e)?(g=!0,null===e.tag&&null===e.anchor||Vt(e,"alias node should not have any properties")):function(e,t,i){var n,r,s,a,o,c,l,h,u=e.kind,p=e.result;if(It(h=e.input.charCodeAt(e.position))||Tt(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n)))return!1;for(e.kind="scalar",e.result="",r=s=e.position,a=!1;0!==h;){if(58===h){if(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n))break}else if(35===h){if(It(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Gt(e)||i&&Tt(h))break;if(At(h)){if(o=e.line,c=e.lineStart,l=e.lineIndent,Yt(e,!1,-1),e.lineIndent>=t){a=!0,h=e.input.charCodeAt(e.position);continue}e.position=s,e.line=o,e.lineStart=c,e.lineIndent=l;break}}a&&(Ht(e,r,s,!1),Jt(e,e.line-o),r=s=e.position,a=!1),Ct(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Ht(e,r,s,!1),!!e.result||(e.kind=u,e.result=p,!1)}(e,p,dt===i)&&(g=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===f&&(g=o&&Xt(e,d))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&Vt(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c"),null!==e.result&&u.kind!==e.kind&&Vt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+u.kind+'", not "'+e.kind+'"'),u.resolve(e.result,e.tag)?(e.result=u.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):Vt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function ei(e){var t,i,n,r,s=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Yt(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);for(n=[],(i=e.input.slice(t,e.position)).length<1&&Vt(e,"directive name must not be less than one character in length");0!==r;){for(;Ct(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!At(r));break}if(At(r))break;for(t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);n.push(e.input.slice(t,e.position))}0!==r&&Wt(e),pt.call(Ut,i)?Ut[i](e,i,n):Ft(e,'unknown document directive "'+i+'"')}Yt(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Yt(e,!0,-1)):a&&Vt(e,"directives end mark is expected"),Zt(e,e.lineIndent-1,gt,!1,!0),Yt(e,!0,-1),e.checkLineBreaks&&wt.test(e.input.slice(s,e.position))&&Ft(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Gt(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Yt(e,!0,-1)):e.position=55296&&n<=56319&&t+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Hi(e){return/^\n* /.test(e)}var qi=1,zi=2,Wi=3,Yi=4,Gi=5;function Ji(e,t,i,n,r){e.dump=function(){if(0===t.length)return e.quotingType===Li?'""':"''";if(!e.noCompatMode&&(-1!==Oi.indexOf(t)||Ni.test(t)))return e.quotingType===Li?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,i),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),o=n||e.flowLevel>-1&&i>=e.flowLevel;switch(function(e,t,i,n,r,s,a,o){var c,l=0,h=null,u=!1,p=!1,d=-1!==n,f=-1,m=function(e){return Bi(e)&&e!==si&&!ji(e)&&e!==yi&&e!==Si&&e!==bi&&e!==vi&&e!==ki&&e!==Ei&&e!==Ci&&e!==Ti&&e!==pi&&e!==fi&&e!==gi&&e!==hi&&e!==Ii&&e!==xi&&e!==wi&&e!==mi&&e!==ui&&e!==di&&e!==_i&&e!==Ai}(Ui(e,0))&&function(e){return!ji(e)&&e!==bi}(Ui(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!Bi(l=Ui(e,c)))return Gi;m=m&&Fi(l,h,o),h=l}else{for(c=0;c=65536?c+=2:c++){if((l=Ui(e,c))===oi)u=!0,d&&(p=p||c-f-1>n&&" "!==e[f+1],f=c);else if(!Bi(l))return Gi;m=m&&Fi(l,h,o),h=l}p=p||d&&c-f-1>n&&" "!==e[f+1]}return u||p?i>9&&Hi(e)?Gi:a?s===Li?Gi:zi:p?Yi:Wi:!m||a||r(e)?s===Li?Gi:zi:qi}(t,o,e.indent,a,(function(t){return function(e,t){var i,n;for(i=0,n=e.implicitTypes.length;i"+Xi(t,e.indent)+Ki($i(function(e,t){for(var i,n,r,s=/(\n+)([^\n]*)/g,a=(r=-1!==(r=e.indexOf("\n"))?r:e.length,s.lastIndex=r,Qi(e.slice(0,r),t)),o="\n"===e[0]||" "===e[0];n=s.exec(e);){var c=n[1],l=n[2];i=" "===l[0],a+=c+(o||i||""===l?"":"\n")+Qi(l,t),o=i}return a}(t,a),s));case Gi:return'"'+function(e){for(var t,i="",n=0,r=0;r=65536?r+=2:r++)n=Ui(e,r),!(t=Pi[n])&&Bi(n)?(i+=e[r],n>=65536&&(i+=e[r+1])):i+=t||Mi(n);return i}(t)+'"';default:throw new Ce("impossible error: invalid scalar style")}}()}function Xi(e,t){var i=Hi(e)?String(t):"",n="\n"===e[e.length-1];return i+(!n||"\n"!==e[e.length-2]&&"\n"!==e?n?"":"-":"+")+"\n"}function Ki(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Qi(e,t){if(""===e||" "===e[0])return e;for(var i,n,r=/ [^ ]/g,s=0,a=0,o=0,c="";i=r.exec(e);)(o=i.index)-s>t&&(n=a>s?a:o,c+="\n"+e.slice(s,n),s=n+1),a=o;return c+="\n",e.length-s>t&&a>s?c+=e.slice(s,a)+"\n"+e.slice(a+1):c+=e.slice(s),c.slice(1)}function Zi(e,t,i,n){var r,s,a,o="",c=e.tag;for(r=0,s=i.length;r tag resolver accepts not "'+c+'" style');n=o.represent[c](t,c)}e.dump=n}return!0}return!1}function tn(e,t,i,n,r,s,a){e.tag=null,e.dump=i,en(e,i,!1)||en(e,i,!0);var o,c=ni.call(e.dump),l=n;n&&(n=e.flowLevel<0||e.flowLevel>t);var h,u,p="[object Object]"===c||"[object Array]"===c;if(p&&(u=-1!==(h=e.duplicates.indexOf(i))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(r=!1),u&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(p&&u&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),"[object Object]"===c)n&&0!==Object.keys(e.dump).length?(function(e,t,i,n){var r,s,a,o,c,l,h="",u=e.tag,p=Object.keys(i);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new Ce("sortKeys must be a boolean or a function");for(r=0,s=p.length;r1024)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=Ri(e,t)),tn(e,t+1,o,!0,c)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+=":":l+=": ",h+=l+=e.dump));e.tag=u,e.dump=h||"{}"}(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a,o,c="",l=e.tag,h=Object.keys(i);for(n=0,r=h.length;n1024&&(o+="? "),o+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),tn(e,t,a,!1,!1)&&(c+=o+=e.dump));e.tag=l,e.dump="{"+c+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+h+" "+e.dump));else if("[object Array]"===c)n&&0!==e.dump.length?(e.noArrayIndent&&!a&&t>0?Zi(e,t-1,e.dump,r):Zi(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a="",o=e.tag;for(n=0,r=i.length;n",e.dump=o+" "+e.dump)}return!0}function nn(e,t){var i,n,r=[],s=[];for(rn(e,r,s),i=0,n=s.length;ie.trim())).filter((e=>e.length));for(let t=0;te.trim()));e.style.setProperty(n[0],n[1])}}static setText(e,t,i){e instanceof SVGTextElement||(e=e.querySelector("text")||e);const n=t.replace(/\\n/g,"\n").split("\n");if(n.length>1){const t=e.querySelector("tspan"),i=null==t?void 0:t.getAttribute("x"),n=null==t?void 0:t.getAttribute("y");i&&!e.getAttribute("x")&&e.setAttribute("x",i),n&&!e.getAttribute("y")&&e.setAttribute("y",n)}const r=e.querySelector("tspan")||!1;e.textContent="";const s=e.getAttribute("x")||"0",a=i||"1em";n.forEach(((t,i)=>{const o=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(o.textContent=t,n.length>1){if(o.setAttribute("x",s),o.setAttribute("dy",i>=1?a:"0"),r){const e=r.getAttribute("style");e&&o.setAttribute("style",e)}}else 1==n.length&&0==i&&r&&["x","y","style"].forEach((e=>{const t=null==r?void 0:r.getAttribute(e);null!=t&&o.setAttribute(e,t)}));e.appendChild(o)}))}static waitForChildNodes(e,t,i){return new Promise(((n,r)=>{const s=setTimeout((()=>r("Timeout waiting for child element(s) to load")),i);new MutationObserver((e=>{for(const t of e)if("childList"===t.type&&t.addedNodes.length)return clearTimeout(s),n()})).observe(e,{childList:!0,subtree:!0}),t()}))}static formatDate(e){return e?"string"==typeof e?new Date(e).toLocaleString():e.toLocaleString():""}static parseYaml(e){return an.load(e)}static fetchText(e,t,i,n){return on(this,void 0,void 0,(function*(){i&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type)return yield e.text();throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static fetchImage(e,t,i,n){return on(this,void 0,void 0,(function*(){t&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",headers:new Headers({"Content-Type":"text/plain; charset=x-user-defined"}),mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type){const t=yield e.arrayBuffer();return`data:image/jpeg;base64,${cn.arrayBufferToBase64(t)}`}throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static singleToArray(e){return null==e?[]:Array.isArray(e)?e:[e]}static getArray(e){if(null==e)return[];if(Array.isArray(e))return e;{const t=e;return Object.values(t)}}static getSet(e){if(Array.isArray(e))return new Set(e);{const t=e;return new Set(Object.values(t))}}static arrayBufferToBase64(e){let t="";[].slice.call(new Uint8Array(e)).forEach((e=>t+=String.fromCharCode(e)));let i=window.btoa(t);for(;i.length%4>0;)i+="=";return i}static cacheBuster(e){return`${e}${e.includes("?")?"&":"?"}_=${(new Date).getTime()}`}static equal(e,t){if(e===t)return!0;const i=Array.isArray(e),n=Array.isArray(t);let r=0;if(i&&n){if(e.length!=t.length)return!1;for(r=0;rMath.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage[e]=`${t()}${t()}_${t()}${t()}`}return localStorage[e]}}class ln{static closestElement(e,t){return function t(i){if(!i||i===document||i===window)return null;i.assignedSlot&&(i=i.assignedSlot);return i.closest(e)||t(i.getRootNode().host)}(t)}}const hn=(e,t,i,n)=>{n=n||{},i=null==i?{}:i;const r=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,e.dispatchEvent(r),r},un=(e,t,i=!1)=>{i?history.replaceState(null,"",t):history.pushState(null,"",t),hn(window,"location-changed",{replace:i})};class pn{constructor(e,t,i,n){this.entityId=e,this.svgElement=t,this.originalSvgElement=i,this.originalBBox=n}}class dn{constructor(e){this.rule=e,this.svgElementInfos={}}}class fn{constructor(e,t,i,n,r,s){this.instance=e,this.entityId=t,this.elementId=i,this.svgElementInfo=n,this.ruleInfo=r,this.actions=s}}const mn={},gn={};gn.click=gn.mousedown=gn.mouseup=gn.mousemove="MouseEvents";let vn=1;function yn(e){return e._dtId||(e._dtId=vn++)}function bn(e){const t=e.indexOf(".");return t>0?{e:e.substring(0,e.indexOf(".")),ns:e.substring(t+1,e.length)}:{e}}function xn(e,t,i,n){const r=bn(i).e;if(!e._dtId)return!1;const s=mn[yn(e)],a=function(e,t,i,n){return i=bn(i),(mn[yn(e)]||[]).filter((e=>e&&(!i.e||e.e===i.e)&&(!i.ns||e.ns===i.ns)&&(!n||e.callback===n)&&(!t||e.selector===t)))}(e,t,i,n);a.forEach((t=>{e.removeEventListener?e.removeEventListener(r,t.delegator||t.callback):e.detachEvent&&e.detachEvent("on"+r,t.delegator||t.callback),s.splice(s.indexOf(t),1)}))}function wn(e,t,i,n,r,s){const a=bn(i).e,o=bn(i).ns;e.addEventListener?e.addEventListener(a,r||n,s):e.attachEvent&&e.attachEvent("on"+a,r||n);const c=yn(e);(mn[c]||(mn[c]=[])).push({delegator:r,callback:n,e:a,ns:o,selector:t})}const Sn={on(e,t,i,n=null){wn(e,null,t,i,null,n)},off(e,t,i=null){xn(e,null,t,i)},once(e,t,i){const n=e=>(Sn.off(e.currentTarget,e.type,n),i(e));this.on(e,t,n)},delegate(e,t,i,n,r=null){wn(e,t,i,n,(function(i){const r=e.querySelectorAll(t);let s=!1;for(let e=0;e{i=!1,t=setTimeout((()=>{i=!0,e.dispatchEvent(new Event("longClick"))}),400)},r=n=>{clearTimeout(t),i||e.dispatchEvent(new Event("short"+n.type[0].toUpperCase()+n.type.slice(1)))},s=e=>{i&&(e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation())};kn.on(e,"mousedown",n.bind(this)),kn.on(e,"tapstart",n.bind(this)),kn.on(e,"touchstart",n.bind(this),{passive:!0}),kn.on(e,"click",r.bind(this)),kn.on(e,"mouseup",r.bind(this)),kn.on(e,"tapend",r.bind(this)),kn.on(e,"touchend",r.bind(this)),kn.on(e,"tap",s.bind(this)),kn.on(e,"touch",s.bind(this)),kn.on(e,"mouseup",s.bind(this)),kn.on(e,"tapend",s.bind(this)),kn.on(e,"touchend",s.bind(this)),kn.on(e,"click",(e=>{e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation()}).bind(this))}}const An=_n,Cn=new Set;class In{static observe(e){if(Cn.has(e))return;Cn.add(e);let t,i=0;An.on(e,"click",(()=>{i++,t=setTimeout((()=>{1===i&&(i=0,e.dispatchEvent(new Event("singleClick")))}),400),2===i&&(clearTimeout(t),i=0,e.dispatchEvent(new Event("doubleClick")))}).bind(this))}}class Tn{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t,i,n,r,s,a){this.expression=e.trim();const o=`${this.expression}_${null!=r?r:""}`;this.parsedFunction=this.cache[o],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[o]=this.parsedFunction,this.interpreter.import("config",i),this.interpreter.import("util",this.util)),this.entityState=n?t.states[n]:void 0,this.interpreter.import("functions",a),this.interpreter.import("entity",this.entityState),this.interpreter.import("entities",t.states),this.interpreter.import("states",t.states),this.interpreter.import("hass",t),this.interpreter.import("element",r),this.interpreter.import("elements",s);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}Tn.cache={},Tn.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),Tn.util={color:pe,date:ge};class Pn{constructor(e,t,i){this.element=e,this.logLevel=t,this.consoleLogLevel=i,this.logLevelGroups={error:["error"],warn:["error","warning","warn"],warning:["error","warning","warn"],info:["error","warning","warn","info"],debug:["error","warning","warn","info","debug"]}}log(e,t,i=!1){var n;const r=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,s=this.logLevel&&this.logLevelGroups[this.logLevel.toLowerCase()],a=(null==s?void 0:s.length)&&s.includes(e.toLowerCase());if((i||a)&&this.element){const t=document.createElement("li");cn.addClass(t,e),t.textContent=r,null===(n=this.element.querySelector("ul"))||void 0===n||n.prepend(t),this.element.style.display="block"}this.consoleLog(e,t,i)}consoleLog(e,t,i=!1){const n=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,r=this.consoleLogLevel&&this.logLevelGroups[this.consoleLogLevel.toLowerCase()],s=(null==r?void 0:r.length)&&r.includes(e.toLowerCase());if(i||s)switch(e){case"error":console.error(n);break;case"warn":case"warning":console.warn(n);break;case"info":console.info(n);break;default:console.log(n)}}}var On=function(e,t,i,n){var r,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a},Nn=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{c(n.next(e))}catch(e){s(e)}}function o(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}c((n=n.apply(e,t||[])).next())}))};const Mn=_n;console.info("%cFloorplan for Home Assistant (ha-floorplan)%c\nVersion 1.0.37","color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: rgb(71, 170, 238)");let Ln=class extends ee{constructor(){super(),this.pageInfos={},this.entityInfos={},this.elementInfos={},this.cssRules=[],this.functions={},this.variables={},this.svgElements={},this.isRulesLoaded=!1,window.onerror=this.handleWindowError.bind(this)}render(){return $` +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function _e(e){return null==e}var ke={isNothing:_e,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:_e(e)?[]:[e]},repeat:function(e,t){var i,n="";for(i=0;io&&(t=n-o+(s=" ... ").length),i-n>o&&(i=n+o-(a=" ...").length),{str:s+e.slice(t,i).replace(/\t/g,"→")+a,pos:n-t+s.length}}function Te(e,t){return ke.repeat(" ",t-e.length)+e}var Pe=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,r=[0],s=[],a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var o,c,l="",h=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+h+3);for(o=1;o<=t.linesBefore&&!(a-o<0);o++)c=Ie(e.buffer,r[a-o],s[a-o],e.position-(r[a]-r[a-o]),u),l=ke.repeat(" ",t.indent)+Te((e.line-o+1).toString(),h)+" | "+c.str+"\n"+l;for(c=Ie(e.buffer,r[a],s[a],e.position,u),l+=ke.repeat(" ",t.indent)+Te((e.line+1).toString(),h)+" | "+c.str+"\n",l+=ke.repeat("-",t.indent+h+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(a+o>=s.length);o++)c=Ie(e.buffer,r[a+o],s[a+o],e.position-(r[a]-r[a+o]),u),l+=ke.repeat(" ",t.indent)+Te((e.line+o+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Oe=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ne=["scalar","sequence","mapping"],Me=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===Oe.indexOf(t))throw new Ce('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(i){e[i].forEach((function(e){t[String(e)]=i}))})),t}(t.styleAliases||null),-1===Ne.indexOf(this.kind))throw new Ce('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function Le(e,t){var i=[];return e[t].forEach((function(e){var t=i.length;i.forEach((function(i,n){i.tag===e.tag&&i.kind===e.kind&&i.multi===e.multi&&(t=n)})),i[t]=e})),i}function De(e){return this.extend(e)}De.prototype.extend=function(e){var t=[],i=[];if(e instanceof Me)i.push(e);else if(Array.isArray(e))i=i.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new Ce("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(i=i.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new Ce("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new Ce("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(De.prototype);return n.implicit=(this.implicit||[]).concat(t),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Le(n,"implicit"),n.compiledExplicit=Le(n,"explicit"),n.compiledTypeMap=function(){var e,t,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(e){e.multi?(i.multi[e.kind].push(e),i.multi.fallback.push(e)):i[e.kind][e.tag]=i.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ye=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Ge=/^[-+]?[0-9]+e/,Je=new Me("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!Ye.test(e)||"_"===e[e.length-1])},construct:function(e){var t,i;return i="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:i*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||ke.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ke.isNegativeZero(e))return"-0.0";return i=e.toString(10),Ge.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Xe=Ve.extend({implicit:[Fe,Ue,We,Je]}),Ke=Xe,Qe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ze=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),et=new Me("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==Qe.exec(e)||null!==Ze.exec(e))},construct:function(e){var t,i,n,r,s,a,o,c,l=0,h=null;if(null===(t=Qe.exec(e))&&(t=Ze.exec(e)),null===t)throw new Error("Date resolve error");if(i=+t[1],n=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(i,n,r));if(s=+t[4],a=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(h=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(h=-h)),c=new Date(Date.UTC(i,n,r,s,a,o,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(e){return e.toISOString()}}),tt=new Me("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",nt=new Me("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,n=0,r=e.length,s=it;for(i=0;i64)){if(t<0)return!1;n+=6}return n%8==0},construct:function(e){var t,i,n=e.replace(/[\r\n=]/g,""),r=n.length,s=it,a=0,o=[];for(t=0;t>16&255),o.push(a>>8&255),o.push(255&a)),a=a<<6|s.indexOf(n.charAt(t));return 0==(i=r%4*6)?(o.push(a>>16&255),o.push(a>>8&255),o.push(255&a)):18===i?(o.push(a>>10&255),o.push(a>>2&255)):12===i&&o.push(a>>4&255),new Uint8Array(o)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,i,n="",r=0,s=e.length,a=it;for(t=0;t>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]),r=(r<<8)+e[t];return 0==(i=s%3)?(n+=a[r>>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]):2===i?(n+=a[r>>10&63],n+=a[r>>4&63],n+=a[r<<2&63],n+=a[64]):1===i&&(n+=a[r>>2&63],n+=a[r<<4&63],n+=a[64],n+=a[64]),n}}),rt=Object.prototype.hasOwnProperty,st=Object.prototype.toString,at=new Me("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,n,r,s,a=[],o=e;for(t=0,i=o.length;t>10),56320+(e-65536&1023))}for(var Dt=new Array(256),$t=new Array(256),Rt=0;Rt<256;Rt++)Dt[Rt]=Mt(Rt)?1:0,$t[Rt]=Mt(Rt);function jt(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ut,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Bt(e,t){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=Pe(i),new Ce(t,i)}function Vt(e,t){throw Bt(e,t)}function Ft(e,t){e.onWarning&&e.onWarning.call(null,Bt(e,t))}var Ut={YAML:function(e,t,i){var n,r,s;null!==e.version&&Vt(e,"duplication of %YAML directive"),1!==i.length&&Vt(e,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Vt(e,"ill-formed argument of the YAML directive"),r=parseInt(n[1],10),s=parseInt(n[2],10),1!==r&&Vt(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&Ft(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var n,r;2!==i.length&&Vt(e,"TAG directive accepts exactly two arguments"),n=i[0],r=i[1],_t.test(n)||Vt(e,"ill-formed tag handle (first argument) of the TAG directive"),pt.call(e.tagMap,n)&&Vt(e,'there is a previously declared suffix for "'+n+'" tag handle'),kt.test(r)||Vt(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){Vt(e,"tag prefix is malformed: "+r)}e.tagMap[n]=r}};function Ht(e,t,i,n){var r,s,a,o;if(t1&&(e.result+=ke.repeat("\n",t-1))}function Xt(e,t){var i,n,r=e.tag,s=e.anchor,a=[],o=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),n=e.input.charCodeAt(e.position);0!==n&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,Vt(e,"tab characters must not be used in indentation")),45===n)&&It(e.input.charCodeAt(e.position+1));)if(o=!0,e.position++,Yt(e,!0,-1)&&e.lineIndent<=t)a.push(null),n=e.input.charCodeAt(e.position);else if(i=e.line,Zt(e,t,mt,!1,!0),a.push(e.result),Yt(e,!0,-1),n=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>t)&&0!==n)Vt(e,"bad indentation of a sequence entry");else if(e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt)&&(v&&(a=e.line,o=e.lineStart,c=e.position),Zt(e,t,gt,!0,r)&&(v?m=e.result:g=e.result),v||(zt(e,p,d,f,m,g,a,o,c),f=m=g=null),Yt(e,!0,-1),l=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&0!==l)Vt(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===r?Vt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Vt(e,"repeat of an indentation width identifier"):(l=t+r-1,c=!0)}if(Ct(s)){do{s=e.input.charCodeAt(++e.position)}while(Ct(s));if(35===s)do{s=e.input.charCodeAt(++e.position)}while(!At(s)&&0!==s)}for(;0!==s;){for(Wt(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!c||e.lineIndentl&&(l=e.lineIndent),At(s))h++;else{if(e.lineIndent0){for(r=a,s=0;r>0;r--)(a=Pt(o=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+a:Vt(e,"expected hexadecimal character");e.result+=Lt(s),e.position++}else Vt(e,"unknown escape sequence");i=n=e.position}else At(o)?(Ht(e,i,n,!0),Jt(e,Yt(e,!1,t)),i=n=e.position):e.position===e.lineStart&&Gt(e)?Vt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Vt(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?g=!0:function(e){var t,i,n;if(42!==(n=e.input.charCodeAt(e.position)))return!1;for(n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!It(n)&&!Tt(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Vt(e,"name of an alias node must contain at least one character"),i=e.input.slice(t,e.position),pt.call(e.anchorMap,i)||Vt(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],Yt(e,!0,-1),!0}(e)?(g=!0,null===e.tag&&null===e.anchor||Vt(e,"alias node should not have any properties")):function(e,t,i){var n,r,s,a,o,c,l,h,u=e.kind,p=e.result;if(It(h=e.input.charCodeAt(e.position))||Tt(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n)))return!1;for(e.kind="scalar",e.result="",r=s=e.position,a=!1;0!==h;){if(58===h){if(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n))break}else if(35===h){if(It(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Gt(e)||i&&Tt(h))break;if(At(h)){if(o=e.line,c=e.lineStart,l=e.lineIndent,Yt(e,!1,-1),e.lineIndent>=t){a=!0,h=e.input.charCodeAt(e.position);continue}e.position=s,e.line=o,e.lineStart=c,e.lineIndent=l;break}}a&&(Ht(e,r,s,!1),Jt(e,e.line-o),r=s=e.position,a=!1),Ct(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Ht(e,r,s,!1),!!e.result||(e.kind=u,e.result=p,!1)}(e,p,dt===i)&&(g=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===f&&(g=o&&Xt(e,d))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&Vt(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c"),null!==e.result&&u.kind!==e.kind&&Vt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+u.kind+'", not "'+e.kind+'"'),u.resolve(e.result,e.tag)?(e.result=u.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):Vt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function ei(e){var t,i,n,r,s=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Yt(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);for(n=[],(i=e.input.slice(t,e.position)).length<1&&Vt(e,"directive name must not be less than one character in length");0!==r;){for(;Ct(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!At(r));break}if(At(r))break;for(t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);n.push(e.input.slice(t,e.position))}0!==r&&Wt(e),pt.call(Ut,i)?Ut[i](e,i,n):Ft(e,'unknown document directive "'+i+'"')}Yt(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Yt(e,!0,-1)):a&&Vt(e,"directives end mark is expected"),Zt(e,e.lineIndent-1,gt,!1,!0),Yt(e,!0,-1),e.checkLineBreaks&&wt.test(e.input.slice(s,e.position))&&Ft(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Gt(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Yt(e,!0,-1)):e.position=55296&&n<=56319&&t+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Hi(e){return/^\n* /.test(e)}var qi=1,zi=2,Wi=3,Yi=4,Gi=5;function Ji(e,t,i,n,r){e.dump=function(){if(0===t.length)return e.quotingType===Li?'""':"''";if(!e.noCompatMode&&(-1!==Oi.indexOf(t)||Ni.test(t)))return e.quotingType===Li?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,i),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),o=n||e.flowLevel>-1&&i>=e.flowLevel;switch(function(e,t,i,n,r,s,a,o){var c,l=0,h=null,u=!1,p=!1,d=-1!==n,f=-1,m=function(e){return Bi(e)&&e!==si&&!ji(e)&&e!==yi&&e!==Si&&e!==bi&&e!==vi&&e!==ki&&e!==Ei&&e!==Ci&&e!==Ti&&e!==pi&&e!==fi&&e!==gi&&e!==hi&&e!==Ii&&e!==xi&&e!==wi&&e!==mi&&e!==ui&&e!==di&&e!==_i&&e!==Ai}(Ui(e,0))&&function(e){return!ji(e)&&e!==bi}(Ui(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!Bi(l=Ui(e,c)))return Gi;m=m&&Fi(l,h,o),h=l}else{for(c=0;c=65536?c+=2:c++){if((l=Ui(e,c))===oi)u=!0,d&&(p=p||c-f-1>n&&" "!==e[f+1],f=c);else if(!Bi(l))return Gi;m=m&&Fi(l,h,o),h=l}p=p||d&&c-f-1>n&&" "!==e[f+1]}return u||p?i>9&&Hi(e)?Gi:a?s===Li?Gi:zi:p?Yi:Wi:!m||a||r(e)?s===Li?Gi:zi:qi}(t,o,e.indent,a,(function(t){return function(e,t){var i,n;for(i=0,n=e.implicitTypes.length;i"+Xi(t,e.indent)+Ki($i(function(e,t){for(var i,n,r,s=/(\n+)([^\n]*)/g,a=(r=-1!==(r=e.indexOf("\n"))?r:e.length,s.lastIndex=r,Qi(e.slice(0,r),t)),o="\n"===e[0]||" "===e[0];n=s.exec(e);){var c=n[1],l=n[2];i=" "===l[0],a+=c+(o||i||""===l?"":"\n")+Qi(l,t),o=i}return a}(t,a),s));case Gi:return'"'+function(e){for(var t,i="",n=0,r=0;r=65536?r+=2:r++)n=Ui(e,r),!(t=Pi[n])&&Bi(n)?(i+=e[r],n>=65536&&(i+=e[r+1])):i+=t||Mi(n);return i}(t)+'"';default:throw new Ce("impossible error: invalid scalar style")}}()}function Xi(e,t){var i=Hi(e)?String(t):"",n="\n"===e[e.length-1];return i+(!n||"\n"!==e[e.length-2]&&"\n"!==e?n?"":"-":"+")+"\n"}function Ki(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Qi(e,t){if(""===e||" "===e[0])return e;for(var i,n,r=/ [^ ]/g,s=0,a=0,o=0,c="";i=r.exec(e);)(o=i.index)-s>t&&(n=a>s?a:o,c+="\n"+e.slice(s,n),s=n+1),a=o;return c+="\n",e.length-s>t&&a>s?c+=e.slice(s,a)+"\n"+e.slice(a+1):c+=e.slice(s),c.slice(1)}function Zi(e,t,i,n){var r,s,a,o="",c=e.tag;for(r=0,s=i.length;r tag resolver accepts not "'+c+'" style');n=o.represent[c](t,c)}e.dump=n}return!0}return!1}function tn(e,t,i,n,r,s,a){e.tag=null,e.dump=i,en(e,i,!1)||en(e,i,!0);var o,c=ni.call(e.dump),l=n;n&&(n=e.flowLevel<0||e.flowLevel>t);var h,u,p="[object Object]"===c||"[object Array]"===c;if(p&&(u=-1!==(h=e.duplicates.indexOf(i))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(r=!1),u&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(p&&u&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),"[object Object]"===c)n&&0!==Object.keys(e.dump).length?(function(e,t,i,n){var r,s,a,o,c,l,h="",u=e.tag,p=Object.keys(i);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new Ce("sortKeys must be a boolean or a function");for(r=0,s=p.length;r1024)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=Ri(e,t)),tn(e,t+1,o,!0,c)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+=":":l+=": ",h+=l+=e.dump));e.tag=u,e.dump=h||"{}"}(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a,o,c="",l=e.tag,h=Object.keys(i);for(n=0,r=h.length;n1024&&(o+="? "),o+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),tn(e,t,a,!1,!1)&&(c+=o+=e.dump));e.tag=l,e.dump="{"+c+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+h+" "+e.dump));else if("[object Array]"===c)n&&0!==e.dump.length?(e.noArrayIndent&&!a&&t>0?Zi(e,t-1,e.dump,r):Zi(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a="",o=e.tag;for(n=0,r=i.length;n",e.dump=o+" "+e.dump)}return!0}function nn(e,t){var i,n,r=[],s=[];for(rn(e,r,s),i=0,n=s.length;ie.trim())).filter((e=>e.length));for(let t=0;te.trim()));e.style.setProperty(n[0],n[1])}}static setText(e,t,i){e instanceof SVGTextElement||(e=e.querySelector("text")||e);const n=t.replace(/\\n/g,"\n").split("\n"),r=n.length>1,s=e.querySelector("tspan");if(r){const t=null==s?void 0:s.getAttribute("x"),r=null==s?void 0:s.getAttribute("y");t&&!e.getAttribute("x")&&e.setAttribute("x",t),r&&!e.getAttribute("y")&&e.setAttribute("y",r);const a=e.querySelector("tspan")||!1;e.textContent="",e.dataset.ha_floorplan_notice="The text_set function splitted your text into multiple tspans. Only the style of the first tspan is preserved. The style from the original tspan is reused on every tspan. The x and y are calculated on basis of the first tspan or text-element.";const o=e.getAttribute("x")||"0",c=i||"1em";n.forEach(((t,i)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(n.textContent=t,n.setAttribute("x",o),n.setAttribute("dy",i>=1?c:"0"),a){const e=a.getAttribute("style");e&&n.setAttribute("style",e)}e.appendChild(n)}))}else(s||e).textContent=t}static waitForChildNodes(e,t,i){return new Promise(((n,r)=>{const s=setTimeout((()=>r("Timeout waiting for child element(s) to load")),i);new MutationObserver((e=>{for(const t of e)if("childList"===t.type&&t.addedNodes.length)return clearTimeout(s),n()})).observe(e,{childList:!0,subtree:!0}),t()}))}static formatDate(e){return e?"string"==typeof e?new Date(e).toLocaleString():e.toLocaleString():""}static parseYaml(e){return an.load(e)}static fetchText(e,t,i,n){return on(this,void 0,void 0,(function*(){i&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type)return yield e.text();throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static fetchImage(e,t,i,n){return on(this,void 0,void 0,(function*(){t&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",headers:new Headers({"Content-Type":"text/plain; charset=x-user-defined"}),mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type){const t=yield e.arrayBuffer();return`data:image/jpeg;base64,${cn.arrayBufferToBase64(t)}`}throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static singleToArray(e){return null==e?[]:Array.isArray(e)?e:[e]}static getArray(e){if(null==e)return[];if(Array.isArray(e))return e;{const t=e;return Object.values(t)}}static getSet(e){if(Array.isArray(e))return new Set(e);{const t=e;return new Set(Object.values(t))}}static arrayBufferToBase64(e){let t="";[].slice.call(new Uint8Array(e)).forEach((e=>t+=String.fromCharCode(e)));let i=window.btoa(t);for(;i.length%4>0;)i+="=";return i}static cacheBuster(e){return`${e}${e.includes("?")?"&":"?"}_=${(new Date).getTime()}`}static equal(e,t){if(e===t)return!0;const i=Array.isArray(e),n=Array.isArray(t);let r=0;if(i&&n){if(e.length!=t.length)return!1;for(r=0;rMath.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage[e]=`${t()}${t()}_${t()}${t()}`}return localStorage[e]}}class ln{static closestElement(e,t){return function t(i){if(!i||i===document||i===window)return null;i.assignedSlot&&(i=i.assignedSlot);return i.closest(e)||t(i.getRootNode().host)}(t)}}const hn=(e,t,i,n)=>{n=n||{},i=null==i?{}:i;const r=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,e.dispatchEvent(r),r},un=(e,t,i=!1)=>{i?history.replaceState(null,"",t):history.pushState(null,"",t),hn(window,"location-changed",{replace:i})};class pn{constructor(e,t,i,n){this.entityId=e,this.svgElement=t,this.originalSvgElement=i,this.originalBBox=n}}class dn{constructor(e){this.rule=e,this.svgElementInfos={}}}class fn{constructor(e,t,i,n,r,s){this.instance=e,this.entityId=t,this.elementId=i,this.svgElementInfo=n,this.ruleInfo=r,this.actions=s}}const mn={},gn={};gn.click=gn.mousedown=gn.mouseup=gn.mousemove="MouseEvents";let vn=1;function yn(e){return e._dtId||(e._dtId=vn++)}function bn(e){const t=e.indexOf(".");return t>0?{e:e.substring(0,e.indexOf(".")),ns:e.substring(t+1,e.length)}:{e}}function xn(e,t,i,n){const r=bn(i).e;if(!e._dtId)return!1;const s=mn[yn(e)],a=function(e,t,i,n){return i=bn(i),(mn[yn(e)]||[]).filter((e=>e&&(!i.e||e.e===i.e)&&(!i.ns||e.ns===i.ns)&&(!n||e.callback===n)&&(!t||e.selector===t)))}(e,t,i,n);a.forEach((t=>{e.removeEventListener?e.removeEventListener(r,t.delegator||t.callback):e.detachEvent&&e.detachEvent("on"+r,t.delegator||t.callback),s.splice(s.indexOf(t),1)}))}function wn(e,t,i,n,r,s){const a=bn(i).e,o=bn(i).ns;e.addEventListener?e.addEventListener(a,r||n,s):e.attachEvent&&e.attachEvent("on"+a,r||n);const c=yn(e);(mn[c]||(mn[c]=[])).push({delegator:r,callback:n,e:a,ns:o,selector:t})}const Sn={on(e,t,i,n=null){wn(e,null,t,i,null,n)},off(e,t,i=null){xn(e,null,t,i)},once(e,t,i){const n=e=>(Sn.off(e.currentTarget,e.type,n),i(e));this.on(e,t,n)},delegate(e,t,i,n,r=null){wn(e,t,i,n,(function(i){const r=e.querySelectorAll(t);let s=!1;for(let e=0;e{i=!1,t=setTimeout((()=>{i=!0,e.dispatchEvent(new Event("longClick"))}),400)},r=n=>{clearTimeout(t),i||e.dispatchEvent(new Event("short"+n.type[0].toUpperCase()+n.type.slice(1)))},s=e=>{i&&(e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation())};kn.on(e,"mousedown",n.bind(this)),kn.on(e,"tapstart",n.bind(this)),kn.on(e,"touchstart",n.bind(this),{passive:!0}),kn.on(e,"click",r.bind(this)),kn.on(e,"mouseup",r.bind(this)),kn.on(e,"tapend",r.bind(this)),kn.on(e,"touchend",r.bind(this)),kn.on(e,"tap",s.bind(this)),kn.on(e,"touch",s.bind(this)),kn.on(e,"mouseup",s.bind(this)),kn.on(e,"tapend",s.bind(this)),kn.on(e,"touchend",s.bind(this)),kn.on(e,"click",(e=>{e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation()}).bind(this))}}const An=_n,Cn=new Set;class In{static observe(e){if(Cn.has(e))return;Cn.add(e);let t,i=0;An.on(e,"click",(()=>{i++,t=setTimeout((()=>{1===i&&(i=0,e.dispatchEvent(new Event("singleClick")))}),400),2===i&&(clearTimeout(t),i=0,e.dispatchEvent(new Event("doubleClick")))}).bind(this))}}class Tn{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t,i,n,r,s,a){this.expression=e.trim();const o=`${this.expression}_${null!=r?r:""}`;this.parsedFunction=this.cache[o],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[o]=this.parsedFunction,this.interpreter.import("config",i),this.interpreter.import("util",this.util)),this.entityState=n?t.states[n]:void 0,this.interpreter.import("functions",a),this.interpreter.import("entity",this.entityState),this.interpreter.import("entities",t.states),this.interpreter.import("states",t.states),this.interpreter.import("hass",t),this.interpreter.import("element",r),this.interpreter.import("elements",s);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}Tn.cache={},Tn.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),Tn.util={color:pe,date:ge};class Pn{constructor(e,t,i){this.element=e,this.logLevel=t,this.consoleLogLevel=i,this.logLevelGroups={error:["error"],warn:["error","warning","warn"],warning:["error","warning","warn"],info:["error","warning","warn","info"],debug:["error","warning","warn","info","debug"]}}log(e,t,i=!1){var n;const r=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,s=this.logLevel&&this.logLevelGroups[this.logLevel.toLowerCase()],a=(null==s?void 0:s.length)&&s.includes(e.toLowerCase());if((i||a)&&this.element){const t=document.createElement("li");cn.addClass(t,e),t.textContent=r,null===(n=this.element.querySelector("ul"))||void 0===n||n.prepend(t),this.element.style.display="block"}this.consoleLog(e,t,i)}consoleLog(e,t,i=!1){const n=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,r=this.consoleLogLevel&&this.logLevelGroups[this.consoleLogLevel.toLowerCase()],s=(null==r?void 0:r.length)&&r.includes(e.toLowerCase());if(i||s)switch(e){case"error":console.error(n);break;case"warn":case"warning":console.warn(n);break;case"info":console.info(n);break;default:console.log(n)}}}var On=function(e,t,i,n){var r,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a},Nn=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{c(n.next(e))}catch(e){s(e)}}function o(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}c((n=n.apply(e,t||[])).next())}))};const Mn=_n;console.info("%cFloorplan for Home Assistant (ha-floorplan)%c\nVersion 1.0.37","color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: rgb(71, 170, 238)");let Ln=class extends ee{constructor(){super(),this.pageInfos={},this.entityInfos={},this.elementInfos={},this.cssRules=[],this.functions={},this.variables={},this.svgElements={},this.isRulesLoaded=!1,window.onerror=this.handleWindowError.bind(this)}render(){return $`