node-red-contrib-uibuilder
Version:
Easily create data-driven web UI's for Node-RED using any (or no) front-end library.
1 lines • 112 kB
JavaScript
var Ot=Object.create;var de=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var qe=r=>{throw TypeError(r)};var $t=(r,e,t)=>e in r?de(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var He=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Tt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Lt=(r,e)=>{for(var t in e)de(r,t,{get:e[t],enumerable:!0})},Ut=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of At(e))!Rt.call(r,s)&&s!==t&&de(r,s,{get:()=>e[s],enumerable:!(i=xt(e,s))||i.enumerable});return r};var Oe=(r,e,t)=>(t=r!=null?Ot(Nt(r)):{},Ut(e||!r||!r.__esModule?de(t,"default",{value:r,enumerable:!0}):t,r));var h=(r,e,t)=>$t(r,typeof e!="symbol"?e+"":e,t),Fe=(r,e,t)=>e.has(r)||qe("Cannot "+t);var f=(r,e,t)=>(Fe(r,e,"read from private field"),t?t.call(r):e.get(r)),k=(r,e,t)=>e.has(r)?qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),S=(r,e,t,i)=>(Fe(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var fe=(r,e,t,i)=>({set _(s){S(r,e,s,t)},get _(){return f(r,e,i)}});var Ve=Tt((oi,je)=>{var a,It=(a=class{constructor(e,t,i){h(this,"version","7.0.4-src");h(this,"sanitiseExtraTags",["uib-var"]);h(this,"sanitiseExtraAttribs",["variable","report","undefined"]);h(this,"ui_md_plugins");if(e)a.win=e;else throw new Error("Ui:constructor. Current environment does not include `window`, UI functions cannot be used.");a.doc=a.win.document,t?a.log=t:a.log=function(){return function(){}},i?this.syntaxHighlight=i:this.syntaxHighlight=function(){},a.win.markdownit&&(a.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(s,n){if(n&&window.hljs&&window.hljs.getLanguage(n))try{return'<pre class="">\n <code class="hljs border">'.concat(window.hljs.highlight(s,{language:n,ignoreIllegals:!0}).value,"</code></pre>")}finally{}return'<pre class="hljs border"><code>'.concat(a.md.utils.escapeHtml(s).trim(),"</code></pre>")}},a.md=a.win.markdownit(a.mdOpts))}_markDownIt(){if(a.win.markdownit&&(!this.ui_md_plugins&&a.win.uibuilder&&a.win.uibuilder.ui_md_plugins&&(this.ui_md_plugins=a.win.uibuilder.ui_md_plugins),a.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(e,t){if(window.hljs)if(t&&window.hljs.getLanguage(t))try{return'<pre><code class="hljs border language-'.concat(t,'" data-language="').concat(t,'" title="Source language: \'').concat(t,"'\">").concat(window.hljs.highlight(e,{language:t,ignoreIllegals:!0}).value,"</code></pre>")}finally{}else try{let i=window.hljs.highlightAuto(e);return'<pre><code class="hljs border language-'.concat(i.language,'" data-language="').concat(i.language,'" title="Source language estimated by HighlightJS: \'').concat(i.language,"'\">").concat(i.value,"</code></pre>")}finally{}return'<pre><code class="border">'.concat(a.md.utils.escapeHtml(e).trim(),"</code></pre>")}},a.md=a.win.markdownit(a.mdOpts),this.ui_md_plugins)){if(!Array.isArray(this.ui_md_plugins)){a.log("error","Ui:_markDownIt:plugins","Could not load plugins, ui_md_plugins is not an array")();return}this.ui_md_plugins.forEach(e=>{if(typeof e=="string")a.md.use(a.win[e]);else{let t=Object.keys(e)[0];a.md.use(a.win[t],e[t])}})}}_showNotification(e){e.topic&&!e.title&&(e.title=e.topic),e.title||(e.title="uibuilder notification"),e.payload&&!e.body&&(e.body=e.payload),e.body||(e.body=" No message given.");try{let t=new Notification(e.title,e);return new Promise((i,s)=>{t.addEventListener("close",n=>{n.currentTarget.userAction="close",i(n)}),t.addEventListener("click",n=>{n.currentTarget.userAction="click",i(n)}),t.addEventListener("error",n=>{n.currentTarget.userAction="error",s(n)})})}catch{return Promise.reject(new Error("Browser refused to create a Notification"))}}_uiAdd(e,t){a.log("trace","Ui:_uiManager:add","Starting _uiAdd")(),e.components.forEach((i,s)=>{a.log("trace","Ui:_uiAdd:components-forEach:".concat(s),"Component to add: ",i)();let n;switch(i.type){case"html":{i.ns="html",n=a.doc.createElement("div");break}case"svg":{i.ns="svg",n=a.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{i.ns="dom",n=a.doc.createElement(i.type);break}}!i.slot&&e.payload&&(i.slot=e.payload),this._uiComposeComponent(n,i);let o;i.parentEl?o=i.parentEl:e.parentEl?o=e.parentEl:i.parent?o=a.doc.querySelector(i.parent):e.parent&&(o=a.doc.querySelector(e.parent)),o||(a.log("info","Ui:_uiAdd","No parent found, adding to body")(),o=a.doc.querySelector("body")),i.position&&i.position==="first"?o.insertBefore(n,o.firstChild):i.position&&Number.isInteger(Number(i.position))?o.insertBefore(n,o.children[i.position]):o.appendChild(n),i.components&&this._uiExtendEl(n,i.components,i.ns)})}_uiComposeComponent(e,t){t.attributes&&Object.keys(t.attributes).forEach(i=>{i==="class"&&Array.isArray(t.attributes[i])&&t.attributes[i].join(" "),a.log("trace","_uiComposeComponent:attributes-forEach","Attribute: '".concat(i,"', value: '").concat(t.attributes[i],"'"))(),i==="value"&&(e.value=t.attributes[i]),i.startsWith("xlink:")?e.setAttributeNS("http://www.w3.org/1999/xlink",i,t.attributes[i]):e.setAttribute(i,t.attributes[i])}),t.id&&e.setAttribute("id",t.id),t.type==="svg"&&(e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://www.w3.org/2000/svg"),e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink")),t.events&&Object.keys(t.events).forEach(i=>{i.toLowerCase==="onclick"&&(i="click");try{e.addEventListener(i,s=>{new Function("evt","".concat(t.events[i],"(evt)"))(s)})}catch(s){a.log("error","Ui:_uiComposeComponent","Add event '".concat(i,"' for element '").concat(t.type,"': Cannot add event handler. ").concat(s.message))()}}),t.properties&&Object.keys(t.properties).forEach(i=>{e[i]=t.properties[i],["value","checked"].includes(i)&&(e.dispatchEvent(new Event("input")),e.dispatchEvent(new Event("change")))}),t.slot&&this.replaceSlot(e,t.slot),t.slotMarkdown&&this.replaceSlotMarkdown(e,t)}_uiExtendEl(e,t,i=""){t.forEach((s,n)=>{a.log("trace","Ui:_uiExtendEl:components-forEach:".concat(n),s)();let o;s.ns=i,s.ns==="html"?(o=e,this.replaceSlot(e,s.slot)):s.ns==="svg"?(o=a.doc.createElementNS("http://www.w3.org/2000/svg",s.type),this._uiComposeComponent(o,s),e.appendChild(o)):(o=a.doc.createElement(s.type==="html"?"div":s.type),this._uiComposeComponent(o,s),e.appendChild(o)),s.components&&this._uiExtendEl(o,s.components,s.ns)})}_uiLoad(e){e.components&&(Array.isArray(e.components)||(e.components=[e.components]),e.components.forEach(async t=>{Promise.resolve().then(()=>Oe(He(t)))})),e.srcScripts&&(Array.isArray(e.srcScripts)||(e.srcScripts=[e.srcScripts]),e.srcScripts.forEach(t=>{this.loadScriptSrc(t)})),e.txtScripts&&(Array.isArray(e.txtScripts)||(e.txtScripts=[e.txtScripts]),this.loadScriptTxt(e.txtScripts.join("\n"))),e.srcStyles&&(Array.isArray(e.srcStyles)||(e.srcStyles=[e.srcStyles]),e.srcStyles.forEach(t=>{this.loadStyleSrc(t)})),e.txtStyles&&(Array.isArray(e.txtStyles)||(e.txtStyles=[e.txtStyles]),this.loadStyleTxt(e.txtStyles.join("\n")))}_uiManager(e){e._ui&&(Array.isArray(e._ui)||(e._ui=[e._ui]),e._ui.forEach((t,i)=>{if(t.mode&&!t.method&&(t.method=t.mode),!t.method){a.log("error","Ui:_uiManager","No method defined for msg._ui[".concat(i,"]. Ignoring. "),t)();return}switch(t.payload=e.payload,t.topic=e.topic,t.method){case"add":{this._uiAdd(t,!1);break}case"remove":{this._uiRemove(t,!1);break}case"removeAll":{this._uiRemove(t,!0);break}case"replace":{this._uiReplace(t);break}case"update":{this._uiUpdate(t);break}case"load":{this._uiLoad(t);break}case"reload":{this._uiReload();break}case"notify":{this.showDialog("notify",t,e);break}case"alert":{this.showDialog("alert",t,e);break}default:{a.log("error","Ui:_uiManager","Invalid msg._ui[".concat(i,"].method (").concat(t.method,"). Ignoring"))();break}}}))}_uiReload(){a.log("trace","Ui:uiManager:reload","reloading")(),location.reload()}_uiRemove(e,t=!1){e.components.forEach(i=>{let s;t!==!0?s=[a.doc.querySelector(i)]:s=a.doc.querySelectorAll(i),s.forEach(n=>{try{n.remove()}catch(o){a.log("trace","Ui:_uiRemove","Could not remove. ".concat(o.message))()}})})}_uiReplace(e){a.log("trace","Ui:_uiReplace","Starting")(),e.components.forEach((t,i)=>{a.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Component to replace: ",t)();let s;if(t.id?s=a.doc.getElementById(t.id):t.selector||t.select?s=a.doc.querySelector(t.selector):t.name?s=a.doc.querySelector('[name="'.concat(t.name,'"]')):t.type&&(s=a.doc.querySelector(t.type)),a.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Element to replace: ",s)(),s==null){a.log("trace","Ui:_uiReplace:components-forEach:".concat(i,":noReplace"),"Cannot find the DOM element. Adding instead.",t)(),this._uiAdd({components:[t]},!1);return}let n;switch(t.type){case"html":{t.ns="html",n=a.doc.createElement("div");break}case"svg":{t.ns="svg",n=a.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{t.ns="dom",n=a.doc.createElement(t.type);break}}this._uiComposeComponent(n,t),s.replaceWith(n),t.components&&this._uiExtendEl(n,t.components,t.ns)})}_uiUpdate(e){a.log("trace","UI:_uiUpdate:update","Starting _uiUpdate",e)(),e.components||(e.components=[Object.assign({},e)]),e.components.forEach((t,i)=>{a.log("trace","_uiUpdate:components-forEach","Start loop #".concat(i),t)();let s;if(t.parentEl?s=t.parentEl:t.id?s=a.doc.querySelectorAll("#".concat(t.id)):t.selector||t.select?s=a.doc.querySelectorAll(t.selector):t.name?s=a.doc.querySelectorAll('[name="'.concat(t.name,'"]')):t.type&&(s=a.doc.querySelectorAll(t.type)),s===void 0||s.length<1){a.log("warn","Ui:_uiManager:update","Cannot find the DOM element. Ignoring.",t)();return}a.log("trace","_uiUpdate:components-forEach","Element(s) to update. Count: ".concat(s.length),s)(),!t.slot&&t.payload&&(t.slot=t.payload),s.forEach((n,o)=>{if(a.log("trace","_uiUpdate:components-forEach","Updating element #".concat(o),n)(),this._uiComposeComponent(n,t),t.components){a.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component"),t,n)();let l={_ui:[]};t.components.forEach((u,d)=>{let b=u.method||t.method||e.method;u.method&&delete u.method,Array.isArray(u)||(u=[u]),a.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component #").concat(d),u)(),l._ui.push({method:b,parentEl:n,components:u})}),a.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component new manager"),l)(),this._uiManager(l)}})})}$(e,t){let i=a.doc.querySelector(e);if(!i)return a.log(1,"Uib:$","No element found for CSS selector ".concat(e))(),null;if(i.nodeName==="TEMPLATE"&&(i=i.content.firstElementChild,!i))return a.log(0,"Uib:$","Template selected for CSS selector ".concat(e," but it is empty"))(),null;t||(t="el");let s;try{switch(t.toLowerCase()){case"text":{s=i.innerText;break}case"html":{s=i.innerHTML;break}case"attr":case"attributes":{s={};for(let n of i.attributes)s[n.name]=n.value;break}default:{s=i;break}}}catch(n){s=i,a.log(1,"Uib:$",'Could not process output type "'.concat(t,'" for CSS selector ').concat(e,", returned the DOM element. ").concat(n.message),n)()}return s}$$(e){return Array.from(a.doc.querySelectorAll(e))}addClass(e,t){Array.isArray(e)||(e=[e]),t&&t.classList.add(...e)}applyTemplate(e,t,i){i||(i={onceOnly:!1});let s=a.doc.getElementById(e),n=a.doc.getElementById(t);if(s&&n){let o;try{i.onceOnly!==!0?o=a.doc.importNode(s.content,!0):o=a.doc.adoptNode(s.content)}catch{a.log("error","Ui:applyTemplate","Source must be a <template>. id='".concat(e,"'"))();return}if(o){if(i.attributes){let l=o.firstElementChild;Object.keys(i.attributes).forEach(u=>{l.setAttribute(u,i.attributes[u])})}n.appendChild(o)}}else s||a.log("error","Ui:applyTemplate","Source not found: id='".concat(e,"'"))(),n||a.log("error","Ui:applyTemplate","Target not found: id='".concat(t,"'"))()}buildHtmlTable(e){let t;if(!Array.isArray(e)&&(typeof e=="object"&&(t=Object.keys(e),e=Object.values(e)),!Array.isArray(e))){let u=a.doc.createElement("p");return u.textContent="Input data is not an array or an object, cannot create a table.",u}let i=a.doc.createElement("table"),s=a.doc.createElement("thead"),n=a.doc.createElement("tr"),o=Object.keys(e[0]);o.forEach(u=>{let d=a.doc.createElement("th");d.textContent=u,n.appendChild(d)}),s.appendChild(n),i.appendChild(s);let l=a.doc.createElement("tbody");return e.forEach((u,d)=>{let b=a.doc.createElement("tr");t&&(b.id="r-".concat(t[d])),o.forEach(C=>{let v=a.doc.createElement("td");v.innerHTML=this.sanitiseHTML(u[C]),b.appendChild(v)}),l.appendChild(b)}),i.appendChild(l),i}convertMarkdown(e){if(!e)return"";if(!a.win.markdownit)return e;a.md||this._markDownIt();try{return a.md.render(e.trim())}catch(t){return a.log(0,"uibuilder:convertMarkdown","Could not render Markdown. ".concat(t.message),t)(),'<p class="border error">Could not render Markdown<p>'}}async include(e,t){if(!fetch)return a.log(0,"Ui:include","Current environment does not include `fetch`, skipping.")(),"Current environment does not include `fetch`, skipping.";if(!e)return a.log(0,"Ui:include","url parameter must be provided, skipping.")(),"url parameter must be provided, skipping.";if(!t||!t.id)return a.log(0,"Ui:include","uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.")(),"uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.";let i;try{i=await fetch(e)}catch(d){return a.log(0,"Ui:include","Fetch of file '".concat(e,"' failed. "),d.message)(),d.message}if(!i.ok)return a.log(0,"Ui:include","Fetch of file '".concat(e,"' failed. Status='").concat(i.statusText,"'"))(),i.statusText;let s=await i.headers.get("content-type"),n=null;s&&(s.includes("text/html")?n="html":s.includes("application/json")?n="json":s.includes("multipart/form-data")?n="form":s.includes("image/")?n="image":s.includes("video/")?n="video":s.includes("application/pdf")?n="pdf":s.includes("text/plain")&&(n="text"));let o="",l="Include successful",u;switch(n){case"html":{u=await i.text(),o=u;break}case"json":{u=await i.json(),o='<pre class="syntax-highlight">',o+=this.syntaxHighlight(u),o+="</pre>";break}case"form":{u=await i.formData(),o='<pre class="syntax-highlight">',o+=this.syntaxHighlight(u),o+="</pre>";break}case"image":{u=await i.blob(),o='<img src="'.concat(URL.createObjectURL(u),'">'),a.win.DOMPurify&&(l="Include successful. BUT DOMPurify loaded which may block its use.",a.log("warn","Ui:include:image",l)());break}case"video":{u=await i.blob(),o='<video controls autoplay><source src="'.concat(URL.createObjectURL(u),'"></video>'),a.win.DOMPurify&&(l="Include successful. BUT DOMPurify loaded which may block its use.",a.log("warn","Ui:include:video",l)());break}case"pdf":case"text":default:{u=await i.blob(),o='<iframe style="resize:both;width:inherit;height:inherit;" src="'.concat(URL.createObjectURL(u),'">'),a.win.DOMPurify&&(l="Include successful. BUT DOMPurify loaded which may block its use.",a.log("warn","Ui:include:".concat(n),l)());break}}return t.type="div",t.slot=o,t.parent||(t.parent="body"),t.attributes||(t.attributes={class:"included"}),this._uiReplace({components:[t]}),a.log("trace","Ui:include:".concat(n),l)(),l}loadScriptSrc(e){let t=a.doc.createElement("script");t.src=e,t.async=!1,a.doc.head.appendChild(t)}loadScriptTxt(e){let t=a.doc.createElement("script");t.async=!1,t.textContent=e,a.doc.head.appendChild(t)}loadStyleSrc(e){let t=a.doc.createElement("link");t.href=e,t.rel="stylesheet",t.type="text/css",a.doc.head.appendChild(t)}loadStyleTxt(e){let t=a.doc.createElement("style");t.textContent=e,a.doc.head.appendChild(t)}loadui(e){if(!fetch){a.log(0,"Ui:loadui","Current environment does not include `fetch`, skipping.")();return}if(!e){a.log(0,"Ui:loadui","url parameter must be provided, skipping.")();return}fetch(e).then(t=>{if(t.ok===!1)throw new Error("Could not load '".concat(e,"'. Status ").concat(t.status,", Error: ").concat(t.statusText));a.log("trace","Ui:loadui:then1","Loaded '".concat(e,"'. Status ").concat(t.status,", ").concat(t.statusText))();let i=t.headers.get("content-type");if(!i||!i.includes("application/json"))throw new TypeError("Fetch '".concat(e,"' did not return JSON, ignoring"));return t.json()}).then(t=>t!==void 0?(a.log("trace","Ui:loadui:then2","Parsed JSON successfully obtained")(),this._uiManager({_ui:t}),!0):!1).catch(t=>{a.log("warn","Ui:loadui:catch","Error. ",t)()})}moveElement(e){let{sourceSelector:t,targetSelector:i,moveType:s,position:n}=e;if(!document.querySelector(t)){a.log(0,"Ui:moveElement","Source element not found")();return}if(!document.querySelector(i)){a.log(0,"Ui:moveElement","Target element not found")();return}}nodeGet(e,t){let i={id:e.id===""?void 0:e.id,name:e.name,children:e.childNodes.length,type:e.nodeName,attributes:void 0,isUserInput:!!e.validity,userInput:e.validity?{value:e.value,validity:void 0,willValidate:e.willValidate,valueAsDate:e.valueAsDate,valueAsNumber:e.valueAsNumber,type:e.type}:void 0};if(["UL","OL"].includes(e.nodeName)){let s=a.doc.querySelectorAll("".concat(t," li"));s&&(i.list={entries:s.length})}if(e.nodeName==="DL"){let s=a.doc.querySelectorAll("".concat(t," dt"));s&&(i.list={entries:s.length})}if(e.nodeName==="TABLE"){let s=a.doc.querySelectorAll("".concat(t," > tbody > tr")),n=a.doc.querySelectorAll("".concat(t," > thead > tr")),o=a.doc.querySelectorAll("".concat(t," > tbody > tr:last-child > *"));(s||n||o)&&(i.table={headRows:n?n.length:0,bodyRows:s?s.length:0,columns:o?o.length:0})}if(e.nodeName!=="#text"&&e.attributes&&e.attributes.length>0){i.attributes={};for(let s of e.attributes)s.name!=="id"&&(i.attributes[s.name]=e.attributes[s.name].value),s.name==="class"&&(i.classes=Array.from(e.classList))}e.nodeName==="#text"&&(i.text=e.textContent),e.validity&&(i.userInput.validity={});for(let s in e.validity)i.userInput.validity[s]=e.validity[s];return i}async notification(e){if(typeof e=="string"&&(e={body:e}),typeof Notification>"u")return Promise.reject(new Error("Notifications not available in this browser"));let t=Notification.permission;return t==="denied"?Promise.reject(new Error("Notifications not permitted by user")):t==="granted"?this._showNotification(e):(t=await Notification.requestPermission(),t==="granted"?this._showNotification(e):Promise.reject(new Error("Notifications not permitted by user")))}removeClass(e,t){if(!e){t.removeAttribute("class");return}Array.isArray(e)||(e=[e]),t&&t.classList.remove(...e)}replaceSlot(e,t){if(!e)return;t||(t=""),t=this.sanitiseHTML(t);let i=a.doc.createRange().createContextualFragment(t),s=a.doc.createRange();s.selectNodeContents(e),s.deleteContents(),e.append(i)}replaceSlotMarkdown(e,t){e&&t.slotMarkdown&&(t.slotMarkdown=this.convertMarkdown(t.slotMarkdown),t.slotMarkdown=this.sanitiseHTML(t.slotMarkdown),e.innerHTML=t.slotMarkdown)}sanitiseHTML(e){return a.win.DOMPurify?a.win.DOMPurify.sanitize(e,{ADD_TAGS:this.sanitiseExtraTags,ADD_ATTR:this.sanitiseExtraAttribs}):e}showDialog(e,t,i){let s="";if(i.payload&&typeof i.payload=="string"&&(s+="<div>".concat(i.payload,"</div>")),t.content&&(s+="<div>".concat(t.content,"</div>")),s===""){a.log(1,"Ui:showDialog","Toast content is blank. Not shown.")();return}!t.title&&i.topic&&(t.title=i.topic),t.title&&(s='<p class="toast-head">'.concat(t.title,"</p><p>").concat(s,"</p>")),t.noAutohide&&(t.noAutoHide=t.noAutohide),t.noAutoHide&&(t.autohide=!t.noAutoHide),t.autoHideDelay?(t.autohide||(t.autohide=!0),t.delay=t.autoHideDelay):t.autoHideDelay=1e4,Object.prototype.hasOwnProperty.call(t,"autohide")||(t.autohide=!0),e==="alert"&&(t.modal=!0,t.autohide=!1,s='<svg viewBox="0 0 192.146 192.146" style="width:30;background-color:transparent;"><path d="M108.186 144.372c0 7.054-4.729 12.32-12.037 12.32h-.254c-7.054 0-11.92-5.266-11.92-12.32 0-7.298 5.012-12.31 12.174-12.31s11.91 4.992 12.037 12.31zM88.44 125.301h15.447l2.951-61.298H85.46l2.98 61.298zm101.932 51.733c-2.237 3.664-6.214 5.921-10.493 5.921H12.282c-4.426 0-8.51-2.384-10.698-6.233a12.34 12.34 0 0 1 .147-12.349l84.111-149.22c2.208-3.722 6.204-5.96 10.522-5.96h.332c4.445.107 8.441 2.618 10.513 6.546l83.515 149.229c1.993 3.8 1.905 8.363-.352 12.066zm-10.493-6.4L96.354 21.454l-84.062 149.18h167.587z" /></svg> '.concat(s));let n=a.doc.getElementById("toaster");n===null&&(n=a.doc.createElement("div"),n.id="toaster",n.title="Click to clear all notifcations",n.setAttribute("class","toaster"),n.setAttribute("role","dialog"),n.setAttribute("arial-label","Toast message"),n.onclick=function(){n.remove()},a.doc.body.insertAdjacentElement("afterbegin",n));let o=a.doc.createElement("div");o.title="Click to clear this notifcation",o.setAttribute("class","toast ".concat(t.variant?t.variant:""," ").concat(e)),o.innerHTML=s,o.setAttribute("role","alertdialog"),t.modal&&o.setAttribute("aria-modal",t.modal),o.onclick=function(l){l.stopPropagation(),o.remove(),n.childElementCount<1&&n.remove()},n.insertAdjacentElement(t.appendToast===!0?"beforeend":"afterbegin",o),t.autohide===!0&&setInterval(()=>{o.remove(),n.childElementCount<1&&n.remove()},t.autoHideDelay)}ui(e){let t={};e._ui?t=e:t._ui=e,this._uiManager(t)}uiGet(e,t=null){let i=a.doc.querySelectorAll(e),s=[];return i.forEach(n=>{if(t){t==="classes"&&(t="class");let o=n.getAttribute(t);if(o==null)try{o=n[t]}catch{}if(o==null)t.toLowerCase()==="value"?s.push(n.innerText):s.push("Property '".concat(t,"' not found"));else{let l={},u=o.constructor.name.toLowerCase();if(u==="namednodemap")for(let d of o)l[d.name]=o[d.name].value;else if(!u.includes("map"))l[t]=o;else{let d={};for(let b in o)d[b]=o[b]}l.class&&(l.classes=Array.from(n.classList)),s.push(l)}}else s.push(this.nodeGet(n,e))}),s}uiEnhanceElement(e,t){this._uiComposeComponent(e,t)}},h(a,"win"),h(a,"doc"),h(a,"log"),h(a,"mdOpts"),h(a,"md"),a);je.exports=It});var _t=Oe(Ve());var O=Object.create(null);O.open="0";O.close="1";O.ping="2";O.pong="3";O.message="4";O.upgrade="5";O.noop="6";var K=Object.create(null);Object.keys(O).forEach(r=>{K[O[r]]=r});var Y={type:"error",data:"parser error"};var Je=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ge=typeof ArrayBuffer=="function",Ke=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,X=({type:r,data:e},t,i)=>Je&&e instanceof Blob?t?i(e):We(e,i):Ge&&(e instanceof ArrayBuffer||Ke(e))?t?i(e):We(new Blob([e]),i):i(O[r]+(e||"")),We=(r,e)=>{let t=new FileReader;return t.onload=function(){let i=t.result.split(",")[1];e("b"+(i||""))},t.readAsDataURL(r)};function ze(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var xe;function Ye(r,e){if(Je&&r.data instanceof Blob)return r.data.arrayBuffer().then(ze).then(e);if(Ge&&(r.data instanceof ArrayBuffer||Ke(r.data)))return e(ze(r.data));X(r,!1,t=>{xe||(xe=new TextEncoder),e(xe.encode(t))})}var Xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<Xe.length;r++)Q[Xe.charCodeAt(r)]=r;var Qe=r=>{let e=r.length*.75,t=r.length,i,s=0,n,o,l,u;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let d=new ArrayBuffer(e),b=new Uint8Array(d);for(i=0;i<t;i+=4)n=Q[r.charCodeAt(i)],o=Q[r.charCodeAt(i+1)],l=Q[r.charCodeAt(i+2)],u=Q[r.charCodeAt(i+3)],b[s++]=n<<2|o>>4,b[s++]=(o&15)<<4|l>>2,b[s++]=(l&3)<<6|u&63;return d};var Mt=typeof ArrayBuffer=="function",Z=(r,e)=>{if(typeof r!="string")return{type:"message",data:Ze(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Dt(r.substring(1),e)}:K[t]?r.length>1?{type:K[t],data:r.substring(1)}:{type:K[t]}:Y},Dt=(r,e)=>{if(Mt){let t=Qe(r);return Ze(t,e)}else return{base64:!0,data:r}},Ze=(r,e)=>{switch(e){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}};var et="",tt=(r,e)=>{let t=r.length,i=new Array(t),s=0;r.forEach((n,o)=>{X(n,!1,l=>{i[o]=l,++s===t&&e(i.join(et))})})},it=(r,e)=>{let t=r.split(et),i=[];for(let s=0;s<t.length;s++){let n=Z(t[s],e);if(i.push(n),n.type==="error")break}return i};function st(){return new TransformStream({transform(r,e){Ye(r,t=>{let i=t.length,s;if(i<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,i);else if(i<65536){s=new Uint8Array(3);let n=new DataView(s.buffer);n.setUint8(0,126),n.setUint16(1,i)}else{s=new Uint8Array(9);let n=new DataView(s.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(i))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Ae;function pe(r){return r.reduce((e,t)=>e+t.length,0)}function me(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),i=0;for(let s=0;s<e;s++)t[s]=r[0][i++],i===r[0].length&&(r.shift(),i=0);return r.length&&i<r[0].length&&(r[0]=r[0].slice(i)),t}function rt(r,e){Ae||(Ae=new TextDecoder);let t=[],i=0,s=-1,n=!1;return new TransformStream({transform(o,l){for(t.push(o);;){if(i===0){if(pe(t)<1)break;let u=me(t,1);n=(u[0]&128)===128,s=u[0]&127,s<126?i=3:s===126?i=1:i=2}else if(i===1){if(pe(t)<2)break;let u=me(t,2);s=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),i=3}else if(i===2){if(pe(t)<8)break;let u=me(t,8),d=new DataView(u.buffer,u.byteOffset,u.length),b=d.getUint32(0);if(b>Math.pow(2,21)-1){l.enqueue(Y);break}s=b*Math.pow(2,32)+d.getUint32(4),i=3}else{if(pe(t)<s)break;let u=me(t,s);l.enqueue(Z(n?u:Ae.decode(u),e)),i=0}if(s===0||s>r){l.enqueue(Y);break}}}})}var Ne=4;function g(r){if(r)return Bt(r)}function Bt(r){for(var e in g.prototype)r[e]=g.prototype[e];return r}g.prototype.on=g.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};g.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};g.prototype.off=g.prototype.removeListener=g.prototype.removeAllListeners=g.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var i,s=0;s<t.length;s++)if(i=t[s],i===e||i.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};g.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,s=t.length;i<s;++i)t[i].apply(this,e)}return this};g.prototype.emitReserved=g.prototype.emit;g.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};g.prototype.hasListeners=function(r){return!!this.listeners(r).length};var y=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function be(r,...e){return e.reduce((t,i)=>(r.hasOwnProperty(i)&&(t[i]=r[i]),t),{})}var Pt=y.setTimeout,qt=y.clearTimeout;function N(r,e){e.useNativeTimers?(r.setTimeoutFn=Pt.bind(y),r.clearTimeoutFn=qt.bind(y)):(r.setTimeoutFn=y.setTimeout.bind(y),r.clearTimeoutFn=y.clearTimeout.bind(y))}var Ht=1.33;function nt(r){return typeof r=="string"?Ft(r):Math.ceil((r.byteLength||r.size)*Ht)}function Ft(r){let e=0,t=0;for(let i=0,s=r.length;i<s;i++)e=r.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}function ot(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function at(r){let e={},t=r.split("&");for(let i=0,s=t.length;i<s;i++){let n=t[i].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var ge=class extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}},R=class extends g{constructor(e){super(),this.writable=!1,N(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,i){return super.emitReserved("error",new ge(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Z(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=ot(e);return t.length?"?"+t:""}};var ut="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Re=64,jt={},ct=0,ye=0,lt;function ht(r){let e="";do e=ut[r%Re]+e,r=Math.floor(r/Re);while(r>0);return e}function we(){let r=ht(+new Date);return r!==lt?(ct=0,lt=r):r+"."+ht(ct++)}for(;ye<Re;ye++)jt[ut[ye]]=ye;var dt=!1;try{dt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var ft=dt;function $e(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||ft))return new XMLHttpRequest}catch{}if(!e)try{return new y[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Vt(){}var Wt=function(){return new $e({xdomain:!1}).responseType!=null}(),ve=class extends R{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){let i=location.protocol==="https:",s=location.port;s||(s=i?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Wt&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let i=0;this.polling&&(i++,this.once("pollComplete",function(){--i||t()})),this.writable||(i++,this.once("drain",function(){--i||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};it(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,tt(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=we()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new $(this.uri(),e)}doWrite(e,t){let i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}},$=class r extends g{constructor(e,t){super(),N(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;let t=be(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let i=this.xhr=new $e(t);try{i.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&i.setRequestHeader(s,this.opts.extraHeaders[s])}}catch{}if(this.method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(i.timeout=this.opts.requestTimeout),i.onreadystatechange=()=>{var s;i.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.parseCookies(i)),i.readyState===4&&(i.status===200||i.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof i.status=="number"?i.status:0)},0))},i.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},0);return}typeof document<"u"&&(this.index=r.requestsCount++,r.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Vt,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};$.requestsCount=0;$.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",pt);else if(typeof addEventListener=="function"){let r="onpagehide"in y?"pagehide":"unload";addEventListener(r,pt,!1)}}function pt(){for(let r in $.requests)$.requests.hasOwnProperty(r)&&$.requests[r].abort()}var U=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ee=y.WebSocket||y.MozWebSocket,ke=!0,mt="arraybuffer";var bt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ee=class extends R{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,i=bt?{}:be(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=ke&&!bt?t?new ee(e,t):new ee(e):new ee(e,t,i)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],s=t===e.length-1;X(i,this.supportsBinary,n=>{let o={};ke||(i.options&&(o.compress=i.options.compress),this.opts.perMessageDeflate&&(typeof n=="string"?Buffer.byteLength(n):n.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{ke?this.ws.send(n):this.ws.send(n,o)}catch{}s&&U(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=we()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ee}};var Ce=class extends R{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=rt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),s=st();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();let n=()=>{i.read().then(({done:l,value:u})=>{l||(this.onPacket(u),n())}).catch(l=>{})};n();let o={type:"open"};this.query.sid&&(o.data='{"sid":"'.concat(this.query.sid,'"}')),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],s=t===e.length-1;this.writer.write(i).then(()=>{s&&U(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Te={websocket:Ee,webtransport:Ce,polling:ve};var zt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Jt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function q(r){if(r.length>2e3)throw"URI too long";let e=r,t=r.indexOf("["),i=r.indexOf("]");t!=-1&&i!=-1&&(r=r.substring(0,t)+r.substring(t,i).replace(/:/g,";")+r.substring(i,r.length));let s=zt.exec(r||""),n={},o=14;for(;o--;)n[Jt[o]]=s[o]||"";return t!=-1&&i!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=Gt(n,n.path),n.queryKey=Kt(n,n.query),n}function Gt(r,e){let t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function Kt(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,s,n){s&&(t[s]=n)}),t}var I=class r extends g{constructor(e,t={}){super(),this.binaryType=mt,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=q(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=q(t.host).host),N(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=at(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=Ne,t.transport=e,this.id&&(t.sid=this.id);let i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Te[e](i)}open(){let e;if(this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),i=!1;r.priorWebsocketSuccess=!1;let s=()=>{i||(t.send([{type:"ping",data:"probe"}]),t.once("packet",C=>{if(!i)if(C.type==="pong"&&C.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;r.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(b(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function n(){i||(i=!0,b(),t.close(),t=null)}let o=C=>{let v=new Error("probe error: "+C);v.transport=t.name,n(),this.emitReserved("upgradeError",v)};function l(){o("transport closed")}function u(){o("socket closed")}function d(C){t&&C.name!==t.name&&n()}let b=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",l),this.off("close",u),this.off("upgrading",d)};t.once("open",s),t.once("error",o),t.once("close",l),this.once("close",u),this.once("upgrading",d),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onOpen(){if(this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){let s=this.writeBuffer[i].data;if(s&&(t+=nt(s)),i>0&&t>this.maxPayload)return this.writeBuffer.slice(0,i);t+=2}return this.writeBuffer}write(e,t,i){return this.sendPacket("message",e,t,i),this}send(e,t,i){return this.sendPacket("message",e,t,i),this}sendPacket(e,t,i,s){if(typeof t=="function"&&(s=t,t=void 0),typeof i=="function"&&(s=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let n={type:e,data:t,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}onError(e){r.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],i=0,s=e.length;for(;i<s;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}};I.protocol=Ne;var ms=I.protocol;function gt(r,e="",t){let i=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),i=q(r)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let n=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(t&&t.port===i.port?"":":"+i.port),i}var Be={};Lt(Be,{Decoder:()=>Me,Encoder:()=>Ie,PacketType:()=>p,protocol:()=>Et});var Yt=typeof ArrayBuffer=="function",Xt=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,yt=Object.prototype.toString,Qt=typeof Blob=="function"||typeof Blob<"u"&&yt.call(Blob)==="[object BlobConstructor]",Zt=typeof File=="function"||typeof File<"u"&&yt.call(File)==="[object FileConstructor]";function ie(r){return Yt&&(r instanceof ArrayBuffer||Xt(r))||Qt&&r instanceof Blob||Zt&&r instanceof File}function te(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,i=r.length;t<i;t++)if(te(r[t]))return!0;return!1}if(ie(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return te(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&te(r[t]))return!0;return!1}function wt(r){let e=[],t=r.data,i=r;return i.data=Le(t,e),i.attachments=e.length,{packet:i,buffers:e}}function Le(r,e){if(!r)return r;if(ie(r)){let t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){let t=new Array(r.length);for(let i=0;i<r.length;i++)t[i]=Le(r[i],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=Le(r[i],e));return t}return r}function vt(r,e){return r.data=Ue(r.data,e),delete r.attachments,r}function Ue(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=Ue(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=Ue(r[t],e));return r}var ei=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Et=5,p;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(p||(p={}));var Ie=class{constructor(e){this.replacer=e}encode(e){return(e.type===p.EVENT||e.type===p.ACK)&&te(e)?this.encodeAsBinary({type:e.type===p.EVENT?p.BINARY_EVENT:p.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===p.BINARY_EVENT||e.type===p.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=wt(e),i=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(i),s}};function kt(r){return Object.prototype.toString.call(r)==="[object Object]"}var Me=class r extends g{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let i=t.type===p.BINARY_EVENT;i||t.type===p.BINARY_ACK?(t.type=i?p.EVENT:p.ACK,this.reconstructor=new De(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ie(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,i={type:Number(e.charAt(0))};if(p[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===p.BINARY_EVENT||i.type===p.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););i.nsp=e.substring(n,t)}else i.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}i.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(r.isPayloadValid(i.type,n))i.data=n;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case p.CONNECT:return kt(t);case p.DISCONNECT:return t===void 0;case p.CONNECT_ERR