'use strict';Array.prototype.first=function(){return this.length>0?this[0]:null};Array.prototype.last=function(){return this.length>0?this[this.length-1]:null};Array.prototype.toHtml=function(e=void 0){const t=HTMLElement.new("thead"),n=t.appendNew("tr");n.appendNew("th").setText("#"),n.appendNew("th").setText("Value");const p=HTMLElement.new("tbody");this.forEach((function(e,t){let n=p.appendNew("tr");n.appendNew("th").setText(t),n.appendNew("td",{class:typeof e}).setText(JSON.stringify(e))}));const a=HTMLElement.new("table",e);return a.appendChild(t),a.appendChild(p),a};HTMLElement.prototype.addClass=function(t){return this.classList.add(t),this};HTMLElement.prototype.removeClass=function(e){return this.classList.remove(e),this};HTMLElement.prototype.toggleClass=function(t){return this.classList.toggle(t),this};HTMLElement.prototype.hasClass=function(s){return this.classList.contains(s)};JSON.load=async function(t,n){return fetch(t,n).then((t=>{if(!t.ok)throw new Error(`HTTP ${rp.status}: ${rp.statusText} – “${url}”.`);return t.json()}))};HTMLElement.new=function(e,n=void 0,t=void 0){var r=null;try{if(r=document.createElement(e),n)for(let e in n)r.setAttribute(e,n[e]);t&&("string"==typeof t||t instanceof String?r.textContent=t.toString():t instanceof HTMLElement?r.appendChild(t):Array.isArray(t)&&t.forEach(e=>{e instanceof HTMLElement&&r.appendChild(e)}))}catch(e){$p&&$p.console&&$p.console.error(e.toString()),console.error(e)}finally{return r}};HTMLElement.prototype.getAttr=function(t){let e=this.getAttribute(t);return e||""};HTMLElement.prototype.setAttr=function(t,e){return this.setAttribute(t,e),this};HTMLElement.prototype.appendText=function(e){return this.append(document.createTextNode(e)),this};HTMLElement.prototype.prependText=function(e){return this.prepend(document.createTextNode(e)),this};HTMLElement.prototype.getText=function(){return this.textContent};HTMLElement.prototype.setText=function(t){return this.textContent=t.toString(),this};HTMLElement.prototype.appendNew=function(e,o=void 0,n=void 0){var r=null;try{r=HTMLElement.new(e,o,n),this.appendChild(r)}catch(e){$p&&$p.console&&$p.console.error(e.toString()),console.error(e)}return r};HTMLElement.prototype.prependNew=function(e,n=void 0,r=void 0){var t=null;try{t=HTMLElement.new(e,n,r),this.prepend(t)}catch(t){console.error(t)}return t};HTMLElement.prototype.setHtml=function(e){let t=(new DOMParser).parseFromString("
"+e+"
","application/xml");return this.innerHTML=t.documentElement.innerHTML,this};HTMLElement.prototype.getHtml=function(t=null){return this.innerHTML};HTMLElement.prototype.empty=function(){for(;this.firstChild;)this.removeChild(this.lastChild);return this;};HTMLElement.prototype.load=async function(t,e){return fetch(t,e).then(t=>{if(!t.ok)throw new Error("HTTP Status "+t.status+" – "+t.statusText);return t.text().then(t=>(this.innerHTML=t,t))})};HTMLElement.prototype.on=function(t,e){return this.addEventListener(t,e),this};HTMLElement.prototype.once=function(e,t){return this.addEventListener(e,t,{once:!0}),this};HTMLElement.prototype.off=function(e,t){return this.removeEventListener(e,t),this};HTMLElement.prototype.onBlur=function(t){return this.addEventListener("blur",t),this};HTMLElement.prototype.onClick=function(t){return this.addEventListener("click",t),this};HTMLElement.prototype.onFocus=function(t){return this.addEventListener("focus",t),this};HTMLFormElement.prototype.onSubmit=function(t){return this.addEventListener("submit",t),this};document.onReady=function(n){return document.addEventListener('DOMContentLoaded',n),document};Number.prototype.toBytesString=function(i=2,t="en-US",r=void 0){let e=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB","???"];var n=Math.floor(this);if(r&&r[n])return r[n];for(var o=0;n>980&&o{const c=t[n];let o=null;if("object"==typeof c&&(i&&c._init?o=c._init:!i&&c.init&&(o=c.init),"function"==typeof o)){o.bind(c)(t)}}))}};document.addEventListener("DOMContentLoaded",$p._init);$p.gui={_init:function(i){$p._callInit(this,!0),i._callInit(this),this.init&&this.init(this)}};$p.gui.tabs={_init:function(){document.querySelectorAll("*[role=tablist]").forEach($p.gui.tabs.add)},add:function(t){t.querySelectorAll("*[role=tab]").forEach((t=>t.onClick($p.gui.tabs._onTabClick)))},_onTabClick:function(t){const e="aria-selected",i="aria-controls",l="true";t.preventDefault();let r=this.getAttribute(e);if(r&&r==l)return;var u=null;let n=this.getAncestors((t=>"tablist"==(t.getAttribute?t.getAttribute("role"):null))).first();if(n){n.querySelectorAll("*[role=tab]").forEach((t=>{let i=t.getAttribute(e);i&&i==l&&(u=t)}))}if(this.setAttribute(e,l),u){u.setAttribute(e,"false");let t=u.getAttribute(i),l=document.getElementById(t);l&&(l.hidden=!0)}let o=this.getAttribute(i),a=document.getElementById(o);a&&(a.hidden=!1)}};$p.gui.overlay={_init:function(){let e=HTMLElement.new("div",{id:"overlay",style:"z-index:9; display:none;",tabindex:"-1"}).onClick($p.gui.overlay.hide);$p.gui.overlay._element=e,document.body.appendChild(e)},_element:null,_callbacks:[],show:function(e,l,n=null){let i=$p.gui.overlay._element;i&&(void 0!==l&&(i.style.zIndex=parseInt(l)),i.style.backgroundColor=n||"transparent",void 0!==e&&"function"==typeof e&&$p.gui.overlay._callbacks.push(e),i.style.display=null)},hide:function(){for(;$p.gui.overlay._callbacks.length>0;){$p.gui.overlay._callbacks.pop()()}$p.gui.overlay._element.style.display="none"}};$p.url={_init:function(i){$p._callInit(this,!0),i._callInit(this),this.init&&this.init(this)}};$p.url.fragment={_init:function(){window.addEventListener("hashchange",$p.url.fragment._onHashChange)},get:function(){return location.hash.substr(1)},set:function(n){location.hash=n},onChange:function(n){$p.url.fragment._cbs.push(n)},_cbs:[],_onHashChange:function(n){$p.url.fragment._cbs.forEach((a=>{a(n)}))}};$p.dyn={_init:function(n){$p._callInit(this,!0)},init:function(n){$p._callInit(this),this.parse(document)},parse:function(n){const t=n.getElementsByTagName("script"),o=Array.prototype.filter.call(t,(n=>n.hasAttribute("type")&&"application/json"==n.getAttribute("type")));for(var e=0;et.id==n));return t>=0?$p.dyn.action._store[t].cb:null}}};$p.console={_init:function(o){$p._callInit(this,!0)},_targetStack:[],setTarget:function(o){o&&($p.console._targetStack=[o.appendNew("ul",{class:"console"})])},_log:function(o,t){let e="";e=t.toHtml?t.toHtml():"object"==typeof t?JSON.stringify(t):t;let n=null;if($p.console._targetStack.length>0&&(n=$p.console._targetStack[$p.console._targetStack.length-1]),n){const t=n.appendNew("li",{class:o});"object"==typeof e?t.appendChild(e):t.setText(e)}else switch(o){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}},log:function(o){$p.console._log("log",o)},info:function(o){$p.console._log("info",o)},warn:function(o){$p.console._log("warn",o)},error:function(o){$p.console._log("error",o)},group:function(o="",t=!0){if(trg=null,$p.console._targetStack.length>0&&(trg=$p.console._targetStack[$p.console._targetStack.length-1]),trg){const e=trg.appendNew("details");t&&e.setAttribute("open",""),e.appendNew("summary").setText(o);const n=e.appendNew("ul",{class:"sub"});trg.appendChild(e),$p.console._targetStack.push(n)}else console.group(o)},groupEnd:function(){$p.console._targetStack.length>1?$p.console._targetStack.pop():console.groupEnd()},assert:function(o,...t){$p.console._log("assert_"+(o?"pass":"fail"),t.join(" "))}};