homebridge-config-ui-x 5.0.0-beta.1 → 5.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/public/{chunk-FPOZAQLC.js → chunk-2ZL77L5V.js} +1 -1
  3. package/public/{chunk-DOLYKWZH.js → chunk-36QI2JZZ.js} +1 -1
  4. package/public/{chunk-S4SOWUAW.js → chunk-54RIF7BL.js} +1 -1
  5. package/public/{chunk-ZEONO5N6.js → chunk-6PFEOQAC.js} +1 -1
  6. package/public/{chunk-422JXES4.js → chunk-AA4ALV5Q.js} +1 -1
  7. package/public/{chunk-FBP5C7VG.js → chunk-C4DMFK2F.js} +1 -1
  8. package/public/{chunk-TS27NWVA.js → chunk-CMASH2I6.js} +1 -1
  9. package/public/{chunk-BQLALGZ5.js → chunk-D63P2BMG.js} +1 -1
  10. package/public/{chunk-C4OONTE3.js → chunk-E6TKCZQK.js} +1 -1
  11. package/public/{chunk-LS7T2AVU.js → chunk-EEAGROCO.js} +1 -1
  12. package/public/{chunk-K6TZNXIW.js → chunk-EXLYVJ3I.js} +1 -1
  13. package/public/{chunk-VROGSJLF.js → chunk-H7H7YVXE.js} +1 -1
  14. package/public/{chunk-3KSUXL3K.js → chunk-LL4U2S7T.js} +1 -1
  15. package/public/{chunk-5UYN5OWH.js → chunk-MMU5EB5I.js} +1 -1
  16. package/public/{chunk-VVILZWTF.js → chunk-MQHO5ODL.js} +1 -1
  17. package/public/{chunk-Z47RP4BH.js → chunk-MQOC5AAT.js} +1 -1
  18. package/public/{chunk-7564WJJL.js → chunk-NJRXPLIM.js} +1 -1
  19. package/public/{chunk-T5QVI4H2.js → chunk-NLHSKWUN.js} +1 -1
  20. package/public/{chunk-DRWF7R4E.js → chunk-PCHM6ESV.js} +1 -1
  21. package/public/{chunk-K3YXRBTH.js → chunk-PREOLVG7.js} +1 -1
  22. package/public/{chunk-RID7V4NP.js → chunk-RYWTZYEC.js} +1 -1
  23. package/public/{chunk-WCQIGCXO.js → chunk-TCMARCBB.js} +1 -1
  24. package/public/{chunk-NZPTOWFC.js → chunk-UBGLUD5C.js} +1 -1
  25. package/public/{chunk-RIWBPQF3.js → chunk-V7NUKNPP.js} +1 -1
  26. package/public/{chunk-7R6JSPNH.js → chunk-W5QNZH4U.js} +1 -1
  27. package/public/{chunk-B6G7GTDI.js → chunk-YXVNS6GA.js} +1 -1
  28. package/public/index.html +1 -1
  29. package/public/{main-VTRWQ63R.js → main-EIMWK4RL.js} +2 -2
@@ -1 +1 @@
1
- import{c as de}from"./chunk-RIWBPQF3.js";import{b as pe}from"./chunk-S4SOWUAW.js";import{W as ue,Z as le,f as Ke,h as S,k as fe,l as X}from"./chunk-IGUSDGD6.js";var m=Object.create(null);m.open="0";m.close="1";m.ping="2";m.pong="3";m.message="4";m.upgrade="5";m.noop="6";var O=Object.create(null);Object.keys(m).forEach(r=>{O[m[r]]=r});var B={type:"error",data:"parser error"};var ge=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",_e=typeof ArrayBuffer=="function",be=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,N=({type:r,data:e},t,s)=>ge&&e instanceof Blob?t?s(e):me(e,s):_e&&(e instanceof ArrayBuffer||be(e))?t?s(e):me(new Blob([e]),s):s(m[r]+(e||"")),me=(r,e)=>{let t=new FileReader;return t.onload=function(){let s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(r)};function ye(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var Q;function we(r,e){if(ge&&r.data instanceof Blob)return r.data.arrayBuffer().then(ye).then(e);if(_e&&(r.data instanceof ArrayBuffer||be(r.data)))return e(ye(r.data));N(r,!1,t=>{Q||(Q=new TextEncoder),e(Q.encode(t))})}var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<ke.length;r++)L[ke.charCodeAt(r)]=r;var Ee=r=>{let e=r.length*.75,t=r.length,s,i=0,n,o,a,h;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let l=new ArrayBuffer(e),d=new Uint8Array(l);for(s=0;s<t;s+=4)n=L[r.charCodeAt(s)],o=L[r.charCodeAt(s+1)],a=L[r.charCodeAt(s+2)],h=L[r.charCodeAt(s+3)],d[i++]=n<<2|o>>4,d[i++]=(o&15)<<4|a>>2,d[i++]=(a&3)<<6|h&63;return l};var Ye=typeof ArrayBuffer=="function",P=(r,e)=>{if(typeof r!="string")return{type:"message",data:ve(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Je(r.substring(1),e)}:O[t]?r.length>1?{type:O[t],data:r.substring(1)}:{type:O[t]}:B},Je=(r,e)=>{if(Ye){let t=Ee(r);return ve(t,e)}else return{base64:!0,data:r}},ve=(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 xe="",Te=(r,e)=>{let t=r.length,s=new Array(t),i=0;r.forEach((n,o)=>{N(n,!1,a=>{s[o]=a,++i===t&&e(s.join(xe))})})},Ae=(r,e)=>{let t=r.split(xe),s=[];for(let i=0;i<t.length;i++){let n=P(t[i],e);if(s.push(n),n.type==="error")break}return s};function Re(){return new TransformStream({transform(r,e){we(r,t=>{let s=t.length,i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);let n=new DataView(i.buffer);n.setUint8(0,126),n.setUint16(1,s)}else{i=new Uint8Array(9);let n=new DataView(i.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(s))}r.data&&typeof r.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}var j;function V(r){return r.reduce((e,t)=>e+t.length,0)}function M(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),s=0;for(let i=0;i<e;i++)t[i]=r[0][s++],s===r[0].length&&(r.shift(),s=0);return r.length&&s<r[0].length&&(r[0]=r[0].slice(s)),t}function Ce(r,e){j||(j=new TextDecoder);let t=[],s=0,i=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(V(t)<1)break;let h=M(t,1);n=(h[0]&128)===128,i=h[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(V(t)<2)break;let h=M(t,2);i=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(V(t)<8)break;let h=M(t,8),l=new DataView(h.buffer,h.byteOffset,h.length),d=l.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(B);break}i=d*Math.pow(2,32)+l.getUint32(4),s=3}else{if(V(t)<i)break;let h=M(t,i);a.enqueue(P(n?h:j.decode(h),e)),s=0}if(i===0||i>r){a.enqueue(B);break}}}})}var G=4;function f(r){if(r)return $e(r)}function $e(r){for(var e in f.prototype)r[e]=f.prototype[e];return r}f.prototype.on=f.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};f.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.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 s,i=0;i<t.length;i++)if(s=t[i],s===e||s.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+r],this};f.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,i=t.length;s<i;++s)t[s].apply(this,e)}return this};f.prototype.emitReserved=f.prototype.emit;f.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};f.prototype.hasListeners=function(r){return!!this.listeners(r).length};var y=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),u=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Se="arraybuffer";function H(r,...e){return e.reduce((t,s)=>(r.hasOwnProperty(s)&&(t[s]=r[s]),t),{})}var ze=u.setTimeout,Xe=u.clearTimeout;function g(r,e){e.useNativeTimers?(r.setTimeoutFn=ze.bind(u),r.clearTimeoutFn=Xe.bind(u)):(r.setTimeoutFn=u.setTimeout.bind(u),r.clearTimeoutFn=u.clearTimeout.bind(u))}var Qe=1.33;function Oe(r){return typeof r=="string"?je(r):Math.ceil((r.byteLength||r.size)*Qe)}function je(r){let e=0,t=0;for(let s=0,i=r.length;s<i;s++)e=r.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function W(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Be(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Ne(r){let e={},t=r.split("&");for(let s=0,i=t.length;s<i;s++){let n=t[s].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var K=class extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}},_=class extends f{constructor(e){super(),this.writable=!1,g(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new K(e,t,s)),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=P(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=Be(e);return t.length?"?"+t:""}};var q=class extends _{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Ae(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,Te(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]=W()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var Le=!1;try{Le=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Pe=Le;function Ge(){}var Z=class extends q{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){let s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(i,n)=>{this.onError("xhr post error",i,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}},Y=(()=>{class r extends f{constructor(t,s,i){super(),this.createRequest=t,g(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;let s=H(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;let i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&i.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var n;i.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(i.getResponseHeader("set-cookie"))),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(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Ge,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}return r.requestsCount=0,r.requests={},r})();if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",qe);else if(typeof addEventListener=="function"){let r="onpagehide"in u?"pagehide":"unload";addEventListener(r,qe,!1)}}function qe(){for(let r in Y.requests)Y.requests.hasOwnProperty(r)&&Y.requests[r].abort()}var Ze=function(){let r=De({xdomain:!1});return r&&r.responseType!==null}(),w=class extends Z{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ze&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Y(De,this.uri(),e)}};function De(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Pe))return new XMLHttpRequest}catch{}if(!e)try{return new u[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Fe=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",te=class extends _{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,s=Fe?{}:H(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(i){return this.emitReserved("error",i)}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 s=e[t],i=t===e.length-1;N(s,this.supportsBinary,n=>{try{this.doWrite(s,n)}catch{}i&&y(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},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]=W()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},ee=u.WebSocket||u.MozWebSocket,k=class extends te{createSocket(e,t,s){return Fe?new ee(e,t,s):t?new ee(e,t):new ee(e)}doWrite(e,t){this.ws.send(t)}};var v=class extends _{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Ce(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),i=Re();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();let n=()=>{s.read().then(({done:a,value:h})=>{a||(this.onPacket(h),n())}).catch(a=>{})};n();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let s=e[t],i=t===e.length-1;this._writer.write(s).then(()=>{i&&y(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var se={websocket:k,webtransport:v,polling:w};var et=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,tt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function x(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),s=r.indexOf("]");t!=-1&&s!=-1&&(r=r.substring(0,t)+r.substring(t,s).replace(/:/g,";")+r.substring(s,r.length));let i=et.exec(r||""),n={},o=14;for(;o--;)n[tt[o]]=i[o]||"";return t!=-1&&s!=-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=st(n,n.path),n.queryKey=rt(n,n.query),n}function st(r,e){let t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function rt(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,n){i&&(t[i]=n)}),t}var re=typeof addEventListener=="function"&&typeof removeEventListener=="function",J=[];re&&addEventListener("offline",()=>{J.forEach(r=>r())},!1);var $=(()=>{class r extends f{constructor(t,s){if(super(),this.binaryType=Se,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){let i=x(t);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=x(s.host).host);g(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{let n=i.prototype.name;this.transports.push(n),this._transportsByName[n]=i}),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},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ne(this.opts.query)),re&&(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"})},J.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let s=Object.assign({},this.opts.query);s.EIO=G,s.transport=t,this.id&&(s.sid=this.id);let i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let s=new Error("server error");s.code=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),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 t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){let n=this.writeBuffer[i].data;if(n&&(s+=Oe(n)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,y(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,i){return this._sendPacket("message",t,s,i),this}send(t,s,i){return this._sendPacket("message",t,s,i),this}_sendPacket(t,s,i,n){if(typeof s=="function"&&(n=s,s=void 0),typeof i=="function"&&(n=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let o={type:t,data:s,options:i};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():t()}):this.upgrading?i():t()),this}_onError(t){if(r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),re&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let i=J.indexOf(this._offlineEventListener);i!==-1&&J.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}return r.protocol=G,r})(),z=class extends ${constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;$.priorWebsocketSuccess=!1;let i=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;$.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let C=new Error("probe error");C.transport=t.name,this.emitReserved("upgradeError",C)}}))};function n(){s||(s=!0,d(),t.close(),t=null)}let o=b=>{let C=new Error("probe error: "+b);C.transport=t.name,n(),this.emitReserved("upgradeError",C)};function a(){o("transport closed")}function h(){o("socket closed")}function l(b){t&&b.name!==t.name&&n()}let d=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",h),this.off("upgrading",l)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",h),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}},T=class extends z{constructor(e,t={}){let s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>se[i]).filter(i=>!!i)),super(e,s)}};var ms=T.protocol;function Ie(r,e="",t){let s=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),s=x(r)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";let n=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(t&&t.port===s.port?"":":"+s.port),s}var he={};Ke(he,{Decoder:()=>ae,Encoder:()=>oe,PacketType:()=>c,protocol:()=>We});var nt=typeof ArrayBuffer=="function",ot=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Ue=Object.prototype.toString,at=typeof Blob=="function"||typeof Blob<"u"&&Ue.call(Blob)==="[object BlobConstructor]",ct=typeof File=="function"||typeof File<"u"&&Ue.call(File)==="[object FileConstructor]";function F(r){return nt&&(r instanceof ArrayBuffer||ot(r))||at&&r instanceof Blob||ct&&r instanceof File}function D(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,s=r.length;t<s;t++)if(D(r[t]))return!0;return!1}if(F(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return D(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&D(r[t]))return!0;return!1}function Ve(r){let e=[],t=r.data,s=r;return s.data=ie(t,e),s.attachments=e.length,{packet:s,buffers:e}}function ie(r,e){if(!r)return r;if(F(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 s=0;s<r.length;s++)t[s]=ie(r[s],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=ie(r[s],e));return t}return r}function Me(r,e){return r.data=ne(r.data,e),delete r.attachments,r}function ne(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]=ne(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=ne(r[t],e));return r}var ht=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],We=5,c=function(r){return 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",r}(c||{}),oe=class{constructor(e){this.replacer=e}encode(e){return(e.type===c.EVENT||e.type===c.ACK)&&D(e)?this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===c.BINARY_EVENT||e.type===c.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=Ve(e),s=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(s),i}};function He(r){return Object.prototype.toString.call(r)==="[object Object]"}var ae=class r extends f{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 s=t.type===c.BINARY_EVENT;s||t.type===c.BINARY_ACK?(t.type=s?c.EVENT:c.ACK,this.reconstructor=new ce(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(F(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,s={type:Number(e.charAt(0))};if(c[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===c.BINARY_EVENT||s.type===c.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");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(n,t)}else s.nsp="/";let i=e.charAt(t+1);if(i!==""&&Number(i)==i){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(r.isPayloadValid(s.type,n))s.data=n;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return He(t);case c.DISCONNECT:return t===void 0;case c.CONNECT_ERROR:return typeof t=="string"||He(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ht.indexOf(t[0])===-1);case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},ce=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Me(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function p(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var ft=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),A=class extends f{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[p(e,"open",this.onopen.bind(this)),p(e,"packet",this.onpacket.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,i,n;if(ft.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let o={type:c.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let d=this.ids++,b=t.pop();this._registerAckCallback(d,b),o.id=d}let a=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,h=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!a||(h?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;let i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(n),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,i)=>{let n=(o,a)=>o?i(o):s(a);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...n)=>s!==this._queue[0]?void 0:(i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...n)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:c.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){let s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case c.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case c.EVENT:case c.BINARY_EVENT:this.onevent(e);break;case c.ACK:case c.BINARY_ACK:this.onack(e);break;case c.DISCONNECT:this.ondisconnect();break;case c.CONNECT_ERROR:this.destroy();let s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,s=!1;return function(...i){s||(s=!0,t.packet({type:c.ACK,id:e,data:i}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:c.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let s of t)s.apply(this,e.data)}}};function E(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}E.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=Math.floor(e*10)&1?r+t:r-t}return Math.min(r,this.max)|0};E.prototype.reset=function(){this.attempts=0};E.prototype.setMin=function(r){this.ms=r};E.prototype.setMax=function(r){this.max=r};E.prototype.setJitter=function(r){this.jitter=r};var R=class extends f{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,g(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new E({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let i=t.parser||he;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new T(this.uri,this.opts);let t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;let i=p(t,"open",function(){s.onopen(),e&&e()}),n=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=p(t,"error",n);if(this._timeout!==!1){let a=this._timeout,h=this.setTimeoutFn(()=>{i(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(p(e,"ping",this.onping.bind(this)),p(e,"data",this.ondata.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this)),p(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){y(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new A(this,e,t),this.nsps[e]=s),s}_destroy(e){let t=Object.keys(this.nsps);for(let s of t)if(this.nsps[s].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var I={};function U(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Ie(r,e.path||"/socket.io"),s=t.source,i=t.id,n=t.path,o=I[i]&&n in I[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,h;return a?h=new R(s,e):(I[i]||(I[i]=new R(s,e)),h=I[i]),t.query&&!e.query&&(e.query=t.queryKey),h.socket(t.path,e)}Object.assign(U,{Manager:R,Socket:A,io:U,connect:U});var or=(()=>{let e=class e{constructor(s){S(this,"$auth");S(this,"namespaceConnectionCache",{});this.$auth=s}connectToNamespace(s){if(this.namespaceConnectionCache[s]){let i=this.namespaceConnectionCache[s];return i.connected=new X,setTimeout(()=>{i.socket.connected&&i.connected.next(void 0)}),i.socket.on("connect",()=>{i.connected.next(void 0)}),i.end=()=>{i.socket.emit("end"),i.socket.removeAllListeners(),i.connected.complete()},this.namespaceConnectionCache[s]}else{let i=this.establishConnectionToNamespace(s);return i.connected=new X,i.socket.on("connect",()=>{i.connected.next(void 0)}),i.end=()=>{i.socket.emit("end"),i.socket.removeAllListeners(),i.connected.complete()},this.namespaceConnectionCache[s]=i,i}}getExistingNamespace(s){return this.namespaceConnectionCache[s]}establishConnectionToNamespace(s){let i=U(`${pe.api.socket}/${s}`,{query:{token:this.$auth.token}});return{socket:i,request:(o,a)=>new fe(h=>{i.emit(o,a,l=>{typeof l=="object"&&l.error?h.error(l):h.next(l),h.complete()})})}}};S(e,"\u0275fac",function(i){return new(i||e)(le(de))}),S(e,"\u0275prov",ue({token:e,factory:e.\u0275fac,providedIn:"root"}));let r=e;return r})();export{or as a};
1
+ import{c as de}from"./chunk-V7NUKNPP.js";import{b as pe}from"./chunk-54RIF7BL.js";import{W as ue,Z as le,f as Ke,h as S,k as fe,l as X}from"./chunk-IGUSDGD6.js";var m=Object.create(null);m.open="0";m.close="1";m.ping="2";m.pong="3";m.message="4";m.upgrade="5";m.noop="6";var O=Object.create(null);Object.keys(m).forEach(r=>{O[m[r]]=r});var B={type:"error",data:"parser error"};var ge=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",_e=typeof ArrayBuffer=="function",be=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,N=({type:r,data:e},t,s)=>ge&&e instanceof Blob?t?s(e):me(e,s):_e&&(e instanceof ArrayBuffer||be(e))?t?s(e):me(new Blob([e]),s):s(m[r]+(e||"")),me=(r,e)=>{let t=new FileReader;return t.onload=function(){let s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(r)};function ye(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var Q;function we(r,e){if(ge&&r.data instanceof Blob)return r.data.arrayBuffer().then(ye).then(e);if(_e&&(r.data instanceof ArrayBuffer||be(r.data)))return e(ye(r.data));N(r,!1,t=>{Q||(Q=new TextEncoder),e(Q.encode(t))})}var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<ke.length;r++)L[ke.charCodeAt(r)]=r;var Ee=r=>{let e=r.length*.75,t=r.length,s,i=0,n,o,a,h;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let l=new ArrayBuffer(e),d=new Uint8Array(l);for(s=0;s<t;s+=4)n=L[r.charCodeAt(s)],o=L[r.charCodeAt(s+1)],a=L[r.charCodeAt(s+2)],h=L[r.charCodeAt(s+3)],d[i++]=n<<2|o>>4,d[i++]=(o&15)<<4|a>>2,d[i++]=(a&3)<<6|h&63;return l};var Ye=typeof ArrayBuffer=="function",P=(r,e)=>{if(typeof r!="string")return{type:"message",data:ve(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Je(r.substring(1),e)}:O[t]?r.length>1?{type:O[t],data:r.substring(1)}:{type:O[t]}:B},Je=(r,e)=>{if(Ye){let t=Ee(r);return ve(t,e)}else return{base64:!0,data:r}},ve=(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 xe="",Te=(r,e)=>{let t=r.length,s=new Array(t),i=0;r.forEach((n,o)=>{N(n,!1,a=>{s[o]=a,++i===t&&e(s.join(xe))})})},Ae=(r,e)=>{let t=r.split(xe),s=[];for(let i=0;i<t.length;i++){let n=P(t[i],e);if(s.push(n),n.type==="error")break}return s};function Re(){return new TransformStream({transform(r,e){we(r,t=>{let s=t.length,i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);let n=new DataView(i.buffer);n.setUint8(0,126),n.setUint16(1,s)}else{i=new Uint8Array(9);let n=new DataView(i.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(s))}r.data&&typeof r.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}var j;function V(r){return r.reduce((e,t)=>e+t.length,0)}function M(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),s=0;for(let i=0;i<e;i++)t[i]=r[0][s++],s===r[0].length&&(r.shift(),s=0);return r.length&&s<r[0].length&&(r[0]=r[0].slice(s)),t}function Ce(r,e){j||(j=new TextDecoder);let t=[],s=0,i=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(V(t)<1)break;let h=M(t,1);n=(h[0]&128)===128,i=h[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(V(t)<2)break;let h=M(t,2);i=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(V(t)<8)break;let h=M(t,8),l=new DataView(h.buffer,h.byteOffset,h.length),d=l.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(B);break}i=d*Math.pow(2,32)+l.getUint32(4),s=3}else{if(V(t)<i)break;let h=M(t,i);a.enqueue(P(n?h:j.decode(h),e)),s=0}if(i===0||i>r){a.enqueue(B);break}}}})}var G=4;function f(r){if(r)return $e(r)}function $e(r){for(var e in f.prototype)r[e]=f.prototype[e];return r}f.prototype.on=f.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};f.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.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 s,i=0;i<t.length;i++)if(s=t[i],s===e||s.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+r],this};f.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,i=t.length;s<i;++s)t[s].apply(this,e)}return this};f.prototype.emitReserved=f.prototype.emit;f.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};f.prototype.hasListeners=function(r){return!!this.listeners(r).length};var y=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),u=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Se="arraybuffer";function H(r,...e){return e.reduce((t,s)=>(r.hasOwnProperty(s)&&(t[s]=r[s]),t),{})}var ze=u.setTimeout,Xe=u.clearTimeout;function g(r,e){e.useNativeTimers?(r.setTimeoutFn=ze.bind(u),r.clearTimeoutFn=Xe.bind(u)):(r.setTimeoutFn=u.setTimeout.bind(u),r.clearTimeoutFn=u.clearTimeout.bind(u))}var Qe=1.33;function Oe(r){return typeof r=="string"?je(r):Math.ceil((r.byteLength||r.size)*Qe)}function je(r){let e=0,t=0;for(let s=0,i=r.length;s<i;s++)e=r.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function W(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Be(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Ne(r){let e={},t=r.split("&");for(let s=0,i=t.length;s<i;s++){let n=t[s].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var K=class extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}},_=class extends f{constructor(e){super(),this.writable=!1,g(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new K(e,t,s)),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=P(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=Be(e);return t.length?"?"+t:""}};var q=class extends _{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Ae(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,Te(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]=W()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var Le=!1;try{Le=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Pe=Le;function Ge(){}var Z=class extends q{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){let s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(i,n)=>{this.onError("xhr post error",i,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}},Y=(()=>{class r extends f{constructor(t,s,i){super(),this.createRequest=t,g(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;let s=H(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;let i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&i.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var n;i.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(i.getResponseHeader("set-cookie"))),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(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Ge,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}return r.requestsCount=0,r.requests={},r})();if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",qe);else if(typeof addEventListener=="function"){let r="onpagehide"in u?"pagehide":"unload";addEventListener(r,qe,!1)}}function qe(){for(let r in Y.requests)Y.requests.hasOwnProperty(r)&&Y.requests[r].abort()}var Ze=function(){let r=De({xdomain:!1});return r&&r.responseType!==null}(),w=class extends Z{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ze&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Y(De,this.uri(),e)}};function De(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Pe))return new XMLHttpRequest}catch{}if(!e)try{return new u[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Fe=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",te=class extends _{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,s=Fe?{}:H(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(i){return this.emitReserved("error",i)}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 s=e[t],i=t===e.length-1;N(s,this.supportsBinary,n=>{try{this.doWrite(s,n)}catch{}i&&y(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},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]=W()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},ee=u.WebSocket||u.MozWebSocket,k=class extends te{createSocket(e,t,s){return Fe?new ee(e,t,s):t?new ee(e,t):new ee(e)}doWrite(e,t){this.ws.send(t)}};var v=class extends _{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Ce(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),i=Re();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();let n=()=>{s.read().then(({done:a,value:h})=>{a||(this.onPacket(h),n())}).catch(a=>{})};n();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let s=e[t],i=t===e.length-1;this._writer.write(s).then(()=>{i&&y(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var se={websocket:k,webtransport:v,polling:w};var et=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,tt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function x(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),s=r.indexOf("]");t!=-1&&s!=-1&&(r=r.substring(0,t)+r.substring(t,s).replace(/:/g,";")+r.substring(s,r.length));let i=et.exec(r||""),n={},o=14;for(;o--;)n[tt[o]]=i[o]||"";return t!=-1&&s!=-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=st(n,n.path),n.queryKey=rt(n,n.query),n}function st(r,e){let t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function rt(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,n){i&&(t[i]=n)}),t}var re=typeof addEventListener=="function"&&typeof removeEventListener=="function",J=[];re&&addEventListener("offline",()=>{J.forEach(r=>r())},!1);var $=(()=>{class r extends f{constructor(t,s){if(super(),this.binaryType=Se,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){let i=x(t);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=x(s.host).host);g(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{let n=i.prototype.name;this.transports.push(n),this._transportsByName[n]=i}),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},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ne(this.opts.query)),re&&(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"})},J.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let s=Object.assign({},this.opts.query);s.EIO=G,s.transport=t,this.id&&(s.sid=this.id);let i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let s=new Error("server error");s.code=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),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 t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){let n=this.writeBuffer[i].data;if(n&&(s+=Oe(n)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,y(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,i){return this._sendPacket("message",t,s,i),this}send(t,s,i){return this._sendPacket("message",t,s,i),this}_sendPacket(t,s,i,n){if(typeof s=="function"&&(n=s,s=void 0),typeof i=="function"&&(n=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let o={type:t,data:s,options:i};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():t()}):this.upgrading?i():t()),this}_onError(t){if(r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),re&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let i=J.indexOf(this._offlineEventListener);i!==-1&&J.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}return r.protocol=G,r})(),z=class extends ${constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;$.priorWebsocketSuccess=!1;let i=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;$.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let C=new Error("probe error");C.transport=t.name,this.emitReserved("upgradeError",C)}}))};function n(){s||(s=!0,d(),t.close(),t=null)}let o=b=>{let C=new Error("probe error: "+b);C.transport=t.name,n(),this.emitReserved("upgradeError",C)};function a(){o("transport closed")}function h(){o("socket closed")}function l(b){t&&b.name!==t.name&&n()}let d=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",h),this.off("upgrading",l)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",h),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}},T=class extends z{constructor(e,t={}){let s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>se[i]).filter(i=>!!i)),super(e,s)}};var ms=T.protocol;function Ie(r,e="",t){let s=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),s=x(r)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";let n=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(t&&t.port===s.port?"":":"+s.port),s}var he={};Ke(he,{Decoder:()=>ae,Encoder:()=>oe,PacketType:()=>c,protocol:()=>We});var nt=typeof ArrayBuffer=="function",ot=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Ue=Object.prototype.toString,at=typeof Blob=="function"||typeof Blob<"u"&&Ue.call(Blob)==="[object BlobConstructor]",ct=typeof File=="function"||typeof File<"u"&&Ue.call(File)==="[object FileConstructor]";function F(r){return nt&&(r instanceof ArrayBuffer||ot(r))||at&&r instanceof Blob||ct&&r instanceof File}function D(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,s=r.length;t<s;t++)if(D(r[t]))return!0;return!1}if(F(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return D(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&D(r[t]))return!0;return!1}function Ve(r){let e=[],t=r.data,s=r;return s.data=ie(t,e),s.attachments=e.length,{packet:s,buffers:e}}function ie(r,e){if(!r)return r;if(F(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 s=0;s<r.length;s++)t[s]=ie(r[s],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=ie(r[s],e));return t}return r}function Me(r,e){return r.data=ne(r.data,e),delete r.attachments,r}function ne(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]=ne(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=ne(r[t],e));return r}var ht=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],We=5,c=function(r){return 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",r}(c||{}),oe=class{constructor(e){this.replacer=e}encode(e){return(e.type===c.EVENT||e.type===c.ACK)&&D(e)?this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===c.BINARY_EVENT||e.type===c.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=Ve(e),s=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(s),i}};function He(r){return Object.prototype.toString.call(r)==="[object Object]"}var ae=class r extends f{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 s=t.type===c.BINARY_EVENT;s||t.type===c.BINARY_ACK?(t.type=s?c.EVENT:c.ACK,this.reconstructor=new ce(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(F(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,s={type:Number(e.charAt(0))};if(c[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===c.BINARY_EVENT||s.type===c.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");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(n,t)}else s.nsp="/";let i=e.charAt(t+1);if(i!==""&&Number(i)==i){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(r.isPayloadValid(s.type,n))s.data=n;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return He(t);case c.DISCONNECT:return t===void 0;case c.CONNECT_ERROR:return typeof t=="string"||He(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ht.indexOf(t[0])===-1);case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},ce=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Me(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function p(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var ft=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),A=class extends f{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[p(e,"open",this.onopen.bind(this)),p(e,"packet",this.onpacket.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,i,n;if(ft.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let o={type:c.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let d=this.ids++,b=t.pop();this._registerAckCallback(d,b),o.id=d}let a=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,h=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!a||(h?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;let i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(n),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,i)=>{let n=(o,a)=>o?i(o):s(a);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...n)=>s!==this._queue[0]?void 0:(i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...n)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:c.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){let s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case c.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case c.EVENT:case c.BINARY_EVENT:this.onevent(e);break;case c.ACK:case c.BINARY_ACK:this.onack(e);break;case c.DISCONNECT:this.ondisconnect();break;case c.CONNECT_ERROR:this.destroy();let s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,s=!1;return function(...i){s||(s=!0,t.packet({type:c.ACK,id:e,data:i}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:c.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let s of t)s.apply(this,e.data)}}};function E(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}E.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=Math.floor(e*10)&1?r+t:r-t}return Math.min(r,this.max)|0};E.prototype.reset=function(){this.attempts=0};E.prototype.setMin=function(r){this.ms=r};E.prototype.setMax=function(r){this.max=r};E.prototype.setJitter=function(r){this.jitter=r};var R=class extends f{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,g(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new E({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let i=t.parser||he;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new T(this.uri,this.opts);let t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;let i=p(t,"open",function(){s.onopen(),e&&e()}),n=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=p(t,"error",n);if(this._timeout!==!1){let a=this._timeout,h=this.setTimeoutFn(()=>{i(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(p(e,"ping",this.onping.bind(this)),p(e,"data",this.ondata.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this)),p(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){y(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new A(this,e,t),this.nsps[e]=s),s}_destroy(e){let t=Object.keys(this.nsps);for(let s of t)if(this.nsps[s].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var I={};function U(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Ie(r,e.path||"/socket.io"),s=t.source,i=t.id,n=t.path,o=I[i]&&n in I[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,h;return a?h=new R(s,e):(I[i]||(I[i]=new R(s,e)),h=I[i]),t.query&&!e.query&&(e.query=t.queryKey),h.socket(t.path,e)}Object.assign(U,{Manager:R,Socket:A,io:U,connect:U});var or=(()=>{let e=class e{constructor(s){S(this,"$auth");S(this,"namespaceConnectionCache",{});this.$auth=s}connectToNamespace(s){if(this.namespaceConnectionCache[s]){let i=this.namespaceConnectionCache[s];return i.connected=new X,setTimeout(()=>{i.socket.connected&&i.connected.next(void 0)}),i.socket.on("connect",()=>{i.connected.next(void 0)}),i.end=()=>{i.socket.emit("end"),i.socket.removeAllListeners(),i.connected.complete()},this.namespaceConnectionCache[s]}else{let i=this.establishConnectionToNamespace(s);return i.connected=new X,i.socket.on("connect",()=>{i.connected.next(void 0)}),i.end=()=>{i.socket.emit("end"),i.socket.removeAllListeners(),i.connected.complete()},this.namespaceConnectionCache[s]=i,i}}getExistingNamespace(s){return this.namespaceConnectionCache[s]}establishConnectionToNamespace(s){let i=U(`${pe.api.socket}/${s}`,{query:{token:this.$auth.token}});return{socket:i,request:(o,a)=>new fe(h=>{i.emit(o,a,l=>{typeof l=="object"&&l.error?h.error(l):h.next(l),h.complete()})})}}};S(e,"\u0275fac",function(i){return new(i||e)(le(de))}),S(e,"\u0275prov",ue({token:e,factory:e.\u0275fac,providedIn:"root"}));let r=e;return r})();export{or as a};
@@ -1 +1 @@
1
- import{a as I}from"./chunk-FPOZAQLC.js";import"./chunk-GNQUXZMN.js";import"./chunk-THFLPY67.js";import"./chunk-7564WJJL.js";import"./chunk-RIWBPQF3.js";import"./chunk-S4SOWUAW.js";import{b as S,c as E}from"./chunk-F22FMU37.js";import{$ as f,$b as M,Ua as l,Va as c,Wa as v,X as m,aa as s,ab as h,fb as w,gb as b,h as t,hb as x,jb as C,kb as T,l as p,va as u,vc as d,wa as y,xa as g,yb as j,zb as z}from"./chunk-IGUSDGD6.js";var Q=["terminaloutput"],B=(()=>{let e=class e{constructor(o){t(this,"$terminal");t(this,"termTarget");t(this,"resizeEvent",new p);this.$terminal=o}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$terminal.startTerminal(this.termTarget,{},this.resizeEvent),this.$terminal.term.focus()}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$terminal.destroyTerminal()}};t(e,"\u0275fac",function(i){return new(i||e)(g(I))}),t(e,"\u0275cmp",f({type:e,selectors:[["ng-component"]],viewQuery:function(i,r){if(i&1&&w(Q,7),i&2){let a;b(a=x())&&(r.termTarget=a.first)}},hostBindings:function(i,r){i&1&&h("resize",function(N){return r.onWindowResize(N)},!1,u)},decls:8,vars:3,consts:[["terminaloutput",""],[1,"row","mb-3"],[1,"col-12"],[1,"primary-text","m-0"],[1,"flex-column","d-flex","align-items-stretch","adjust-for-mobile"],["id","docker-terminal",1,"align-self-end","w-100","h-100","mb-1"]],template:function(i,r){i&1&&(l(0,"div",1)(1,"div",2)(2,"h3",3),C(3),j(4,"translate"),c()()(),l(5,"div",4),v(6,"div",5,0),c()),i&2&&(y(3),T(z(4,1,"menu.linux.label_terminal")))},dependencies:[S],encapsulation:2}));let n=e;return n})();var k=[{path:"",component:B}],H=(()=>{let e=class e{};t(e,"\u0275fac",function(i){return new(i||e)}),t(e,"\u0275mod",s({type:e})),t(e,"\u0275inj",m({imports:[d.forChild(k),d]}));let n=e;return n})();var X=(()=>{let e=class e{};t(e,"\u0275fac",function(i){return new(i||e)}),t(e,"\u0275mod",s({type:e})),t(e,"\u0275inj",m({imports:[M,H,E.forChild()]}));let n=e;return n})();export{X as TerminalModule};
1
+ import{a as I}from"./chunk-2ZL77L5V.js";import"./chunk-GNQUXZMN.js";import"./chunk-THFLPY67.js";import"./chunk-NJRXPLIM.js";import"./chunk-V7NUKNPP.js";import"./chunk-54RIF7BL.js";import{b as S,c as E}from"./chunk-F22FMU37.js";import{$ as f,$b as M,Ua as l,Va as c,Wa as v,X as m,aa as s,ab as h,fb as w,gb as b,h as t,hb as x,jb as C,kb as T,l as p,va as u,vc as d,wa as y,xa as g,yb as j,zb as z}from"./chunk-IGUSDGD6.js";var Q=["terminaloutput"],B=(()=>{let e=class e{constructor(o){t(this,"$terminal");t(this,"termTarget");t(this,"resizeEvent",new p);this.$terminal=o}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$terminal.startTerminal(this.termTarget,{},this.resizeEvent),this.$terminal.term.focus()}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$terminal.destroyTerminal()}};t(e,"\u0275fac",function(i){return new(i||e)(g(I))}),t(e,"\u0275cmp",f({type:e,selectors:[["ng-component"]],viewQuery:function(i,r){if(i&1&&w(Q,7),i&2){let a;b(a=x())&&(r.termTarget=a.first)}},hostBindings:function(i,r){i&1&&h("resize",function(N){return r.onWindowResize(N)},!1,u)},decls:8,vars:3,consts:[["terminaloutput",""],[1,"row","mb-3"],[1,"col-12"],[1,"primary-text","m-0"],[1,"flex-column","d-flex","align-items-stretch","adjust-for-mobile"],["id","docker-terminal",1,"align-self-end","w-100","h-100","mb-1"]],template:function(i,r){i&1&&(l(0,"div",1)(1,"div",2)(2,"h3",3),C(3),j(4,"translate"),c()()(),l(5,"div",4),v(6,"div",5,0),c()),i&2&&(y(3),T(z(4,1,"menu.linux.label_terminal")))},dependencies:[S],encapsulation:2}));let n=e;return n})();var k=[{path:"",component:B}],H=(()=>{let e=class e{};t(e,"\u0275fac",function(i){return new(i||e)}),t(e,"\u0275mod",s({type:e})),t(e,"\u0275inj",m({imports:[d.forChild(k),d]}));let n=e;return n})();var X=(()=>{let e=class e{};t(e,"\u0275fac",function(i){return new(i||e)}),t(e,"\u0275mod",s({type:e})),t(e,"\u0275inj",m({imports:[M,H,E.forChild()]}));let n=e;return n})();export{X as TerminalModule};
@@ -1 +1 @@
1
- import{f as L}from"./chunk-422JXES4.js";import{a as B}from"./chunk-7564WJJL.js";import"./chunk-TS27NWVA.js";import"./chunk-7R6JSPNH.js";import"./chunk-JM7QCDMZ.js";import"./chunk-RIWBPQF3.js";import"./chunk-WCDFKYP6.js";import{c as S,k as T,m as D}from"./chunk-S4SOWUAW.js";import{a as _,b as w,c as M}from"./chunk-F22FMU37.js";import{$ as h,$b as E,Ga as y,La as u,Rb as $,Ua as s,Va as a,Wa as v,X as x,aa as g,bb as I,h as i,jb as l,kb as c,sc as k,vc as j,wa as o,xa as m,yb as f,zb as d}from"./chunk-IGUSDGD6.js";function G(e,t){e&1&&(s(0,"p",11),l(1),f(2,"translate"),a()),e&2&&(o(),c(d(2,1,"restart.please_wait_while_server_restarts")))}function H(e,t){if(e&1&&(s(0,"div",12),l(1),a()),e&2){let C=I();o(),c(C.error)}}function J(e,t){e&1&&(s(0,"div",13)(1,"div",14),v(2,"i",15),a()())}function K(e,t){e&1&&(s(0,"div")(1,"div",16),l(2),f(3,"translate"),a()()),e&2&&(o(2),c(d(3,1,"platform.linux.long_time")))}var N=(()=>{let t=class t{constructor(r,n,p,F,z,A){i(this,"$api");i(this,"$router");i(this,"$settings");i(this,"$toastr");i(this,"$translate");i(this,"$ws");i(this,"checkTimeout");i(this,"checkDelay");i(this,"resp",{});i(this,"timeout",!1);i(this,"error",!1);i(this,"io");this.$api=r,this.$router=n,this.$settings=p,this.$toastr=F,this.$translate=z,this.$ws=A}ngOnInit(){this.io=this.$ws.connectToNamespace("status"),this.io.connected.subscribe(()=>{this.io.socket.emit("monitor-server-status"),this.$settings.getAppSettings().catch()}),this.$api.put("/platform-tools/linux/restart-host",{}).subscribe({next:r=>{this.resp=r,this.checkIfServerUp()},error:r=>{console.error(r),this.error=this.$translate.instant("platform.linux.server_restart_error"),this.$toastr.error(this.$translate.instant("platform.linux.server_restart_error"),this.$translate.instant("toast.title_error"))}})}checkIfServerUp(){this.checkDelay=setTimeout(()=>{this.io.socket.on("homebridge-status",r=>{(r.status==="up"||r.status==="pending")&&(this.$toastr.success(this.$translate.instant("platform.linux.server_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))})},3e4),this.checkTimeout=setTimeout(()=>{this.$toastr.warning(this.$translate.instant("platform.linux.server_taking_long_time"),this.$translate.instant("toast.title_warning"),{timeOut:1e4}),this.timeout=!0},12e4)}ngOnDestroy(){this.io.end(),clearTimeout(this.checkDelay),clearTimeout(this.checkTimeout)}};i(t,"\u0275fac",function(n){return new(n||t)(m(S),m(k),m(D),m(T),m(_),m(B))}),i(t,"\u0275cmp",h({type:t,selectors:[["ng-component"]],decls:15,vars:10,consts:[[1,"d-flex","justify-content-between"],[1,"primary-text","m-0"],[1,"my-4","align-items-center",2,"max-width","1000px","margin","auto"],[1,"w-100","text-center","primary-text","mb-5"],[1,"fas","fa-fw","fa-power-off",2,"font-size","75px"],[1,"text-center"],[1,"primary-text","mb-4"],["class","grey-text",4,"ngIf"],["class","alert alert-error my-4",4,"ngIf"],["class","justify-content-center my-4",4,"ngIf"],[4,"ngIf"],[1,"grey-text"],[1,"alert","alert-error","my-4"],[1,"justify-content-center","my-4"],[1,"restart-progress-box","primary-text"],[1,"fas","fa-fw","fa-spinner","fa-spin"],[1,"alert","alert-warning","my-4"]],template:function(n,p){n&1&&(s(0,"div",0)(1,"h3",1),l(2),f(3,"translate"),a()(),s(4,"div",2)(5,"div",3),v(6,"i",4),a(),s(7,"div",5)(8,"h4",6),l(9),f(10,"translate"),a(),y(11,G,3,3,"p",7)(12,H,2,1,"div",8)(13,J,3,0,"div",9)(14,K,4,3,"div",10),a()()),n&2&&(o(2),c(d(3,6,"menu.restart.title")),o(7),c(d(10,8,"platform.linux.restarting_server")),o(2),u("ngIf",!p.error),o(),u("ngIf",p.error),o(),u("ngIf",!p.error),o(),u("ngIf",p.timeout))},dependencies:[$,w],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;margin-top:15px}"]}));let e=t;return e})();function Q(e,t){e&1&&(s(0,"p",9),l(1),f(2,"translate"),a()),e&2&&(o(),c(d(2,1,"platform.linux.server_will_power_down")))}function V(e,t){if(e&1&&(s(0,"div",10),l(1),a()),e&2){let C=I();o(),c(C.error)}}var R=(()=>{let t=class t{constructor(r,n,p){i(this,"$api");i(this,"$toastr");i(this,"$translate");i(this,"error",!1);this.$api=r,this.$toastr=n,this.$translate=p}ngOnInit(){this.$api.put("/platform-tools/linux/shutdown-host",{}).subscribe({error:r=>{console.error(r),this.error=this.$translate.instant("platform.linux.server_restart_error"),this.$toastr.error(this.$translate.instant("platform.linux.server_restart_error"),this.$translate.instant("toast.title_error"))}})}};i(t,"\u0275fac",function(n){return new(n||t)(m(S),m(T),m(_))}),i(t,"\u0275cmp",h({type:t,selectors:[["ng-component"]],decls:13,vars:8,consts:[[1,"d-flex","justify-content-between"],[1,"primary-text","m-0"],[1,"my-4","align-items-center",2,"max-width","1000px","margin","auto"],[1,"w-100","text-center","primary-text","mb-5"],[1,"fas","fa-fw","fa-power-off",2,"font-size","75px"],[1,"text-center"],[1,"primary-text","mb-4"],["class","grey-text",4,"ngIf"],["class","alert alert-error my-4",4,"ngIf"],[1,"grey-text"],[1,"alert","alert-error","my-4"]],template:function(n,p){n&1&&(s(0,"div",0)(1,"h3",1),l(2),f(3,"translate"),a()(),s(4,"div",2)(5,"div",3),v(6,"i",4),a(),s(7,"div",5)(8,"h4",6),l(9),f(10,"translate"),a(),y(11,Q,3,3,"p",7)(12,V,2,1,"div",8),a()()),n&2&&(o(2),c(d(3,4,"menu.restart.title")),o(7),c(d(10,6,"platform.linux.shutting_down_server")),o(2),u("ngIf",!p.error),o(),u("ngIf",p.error))},dependencies:[$,w],encapsulation:2}));let e=t;return e})();var X=[{path:"",redirectTo:"/",pathMatch:"full"},{path:"restart-server",component:N},{path:"shutdown-server",component:R}],O=(()=>{let t=class t{};i(t,"\u0275fac",function(n){return new(n||t)}),i(t,"\u0275mod",g({type:t})),i(t,"\u0275inj",x({imports:[j.forChild(X),j]}));let e=t;return e})();var gt=(()=>{let t=class t{};i(t,"\u0275fac",function(n){return new(n||t)}),i(t,"\u0275mod",g({type:t})),i(t,"\u0275inj",x({imports:[E,M.forChild(),L,O]}));let e=t;return e})();export{gt as LinuxModule};
1
+ import{f as L}from"./chunk-AA4ALV5Q.js";import{a as B}from"./chunk-NJRXPLIM.js";import"./chunk-CMASH2I6.js";import"./chunk-W5QNZH4U.js";import"./chunk-JM7QCDMZ.js";import"./chunk-V7NUKNPP.js";import"./chunk-WCDFKYP6.js";import{c as S,k as T,m as D}from"./chunk-54RIF7BL.js";import{a as _,b as w,c as M}from"./chunk-F22FMU37.js";import{$ as h,$b as E,Ga as y,La as u,Rb as $,Ua as s,Va as a,Wa as v,X as x,aa as g,bb as I,h as i,jb as l,kb as c,sc as k,vc as j,wa as o,xa as m,yb as f,zb as d}from"./chunk-IGUSDGD6.js";function G(e,t){e&1&&(s(0,"p",11),l(1),f(2,"translate"),a()),e&2&&(o(),c(d(2,1,"restart.please_wait_while_server_restarts")))}function H(e,t){if(e&1&&(s(0,"div",12),l(1),a()),e&2){let C=I();o(),c(C.error)}}function J(e,t){e&1&&(s(0,"div",13)(1,"div",14),v(2,"i",15),a()())}function K(e,t){e&1&&(s(0,"div")(1,"div",16),l(2),f(3,"translate"),a()()),e&2&&(o(2),c(d(3,1,"platform.linux.long_time")))}var N=(()=>{let t=class t{constructor(r,n,p,F,z,A){i(this,"$api");i(this,"$router");i(this,"$settings");i(this,"$toastr");i(this,"$translate");i(this,"$ws");i(this,"checkTimeout");i(this,"checkDelay");i(this,"resp",{});i(this,"timeout",!1);i(this,"error",!1);i(this,"io");this.$api=r,this.$router=n,this.$settings=p,this.$toastr=F,this.$translate=z,this.$ws=A}ngOnInit(){this.io=this.$ws.connectToNamespace("status"),this.io.connected.subscribe(()=>{this.io.socket.emit("monitor-server-status"),this.$settings.getAppSettings().catch()}),this.$api.put("/platform-tools/linux/restart-host",{}).subscribe({next:r=>{this.resp=r,this.checkIfServerUp()},error:r=>{console.error(r),this.error=this.$translate.instant("platform.linux.server_restart_error"),this.$toastr.error(this.$translate.instant("platform.linux.server_restart_error"),this.$translate.instant("toast.title_error"))}})}checkIfServerUp(){this.checkDelay=setTimeout(()=>{this.io.socket.on("homebridge-status",r=>{(r.status==="up"||r.status==="pending")&&(this.$toastr.success(this.$translate.instant("platform.linux.server_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))})},3e4),this.checkTimeout=setTimeout(()=>{this.$toastr.warning(this.$translate.instant("platform.linux.server_taking_long_time"),this.$translate.instant("toast.title_warning"),{timeOut:1e4}),this.timeout=!0},12e4)}ngOnDestroy(){this.io.end(),clearTimeout(this.checkDelay),clearTimeout(this.checkTimeout)}};i(t,"\u0275fac",function(n){return new(n||t)(m(S),m(k),m(D),m(T),m(_),m(B))}),i(t,"\u0275cmp",h({type:t,selectors:[["ng-component"]],decls:15,vars:10,consts:[[1,"d-flex","justify-content-between"],[1,"primary-text","m-0"],[1,"my-4","align-items-center",2,"max-width","1000px","margin","auto"],[1,"w-100","text-center","primary-text","mb-5"],[1,"fas","fa-fw","fa-power-off",2,"font-size","75px"],[1,"text-center"],[1,"primary-text","mb-4"],["class","grey-text",4,"ngIf"],["class","alert alert-error my-4",4,"ngIf"],["class","justify-content-center my-4",4,"ngIf"],[4,"ngIf"],[1,"grey-text"],[1,"alert","alert-error","my-4"],[1,"justify-content-center","my-4"],[1,"restart-progress-box","primary-text"],[1,"fas","fa-fw","fa-spinner","fa-spin"],[1,"alert","alert-warning","my-4"]],template:function(n,p){n&1&&(s(0,"div",0)(1,"h3",1),l(2),f(3,"translate"),a()(),s(4,"div",2)(5,"div",3),v(6,"i",4),a(),s(7,"div",5)(8,"h4",6),l(9),f(10,"translate"),a(),y(11,G,3,3,"p",7)(12,H,2,1,"div",8)(13,J,3,0,"div",9)(14,K,4,3,"div",10),a()()),n&2&&(o(2),c(d(3,6,"menu.restart.title")),o(7),c(d(10,8,"platform.linux.restarting_server")),o(2),u("ngIf",!p.error),o(),u("ngIf",p.error),o(),u("ngIf",!p.error),o(),u("ngIf",p.timeout))},dependencies:[$,w],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;margin-top:15px}"]}));let e=t;return e})();function Q(e,t){e&1&&(s(0,"p",9),l(1),f(2,"translate"),a()),e&2&&(o(),c(d(2,1,"platform.linux.server_will_power_down")))}function V(e,t){if(e&1&&(s(0,"div",10),l(1),a()),e&2){let C=I();o(),c(C.error)}}var R=(()=>{let t=class t{constructor(r,n,p){i(this,"$api");i(this,"$toastr");i(this,"$translate");i(this,"error",!1);this.$api=r,this.$toastr=n,this.$translate=p}ngOnInit(){this.$api.put("/platform-tools/linux/shutdown-host",{}).subscribe({error:r=>{console.error(r),this.error=this.$translate.instant("platform.linux.server_restart_error"),this.$toastr.error(this.$translate.instant("platform.linux.server_restart_error"),this.$translate.instant("toast.title_error"))}})}};i(t,"\u0275fac",function(n){return new(n||t)(m(S),m(T),m(_))}),i(t,"\u0275cmp",h({type:t,selectors:[["ng-component"]],decls:13,vars:8,consts:[[1,"d-flex","justify-content-between"],[1,"primary-text","m-0"],[1,"my-4","align-items-center",2,"max-width","1000px","margin","auto"],[1,"w-100","text-center","primary-text","mb-5"],[1,"fas","fa-fw","fa-power-off",2,"font-size","75px"],[1,"text-center"],[1,"primary-text","mb-4"],["class","grey-text",4,"ngIf"],["class","alert alert-error my-4",4,"ngIf"],[1,"grey-text"],[1,"alert","alert-error","my-4"]],template:function(n,p){n&1&&(s(0,"div",0)(1,"h3",1),l(2),f(3,"translate"),a()(),s(4,"div",2)(5,"div",3),v(6,"i",4),a(),s(7,"div",5)(8,"h4",6),l(9),f(10,"translate"),a(),y(11,Q,3,3,"p",7)(12,V,2,1,"div",8),a()()),n&2&&(o(2),c(d(3,4,"menu.restart.title")),o(7),c(d(10,6,"platform.linux.shutting_down_server")),o(2),u("ngIf",!p.error),o(),u("ngIf",p.error))},dependencies:[$,w],encapsulation:2}));let e=t;return e})();var X=[{path:"",redirectTo:"/",pathMatch:"full"},{path:"restart-server",component:N},{path:"shutdown-server",component:R}],O=(()=>{let t=class t{};i(t,"\u0275fac",function(n){return new(n||t)}),i(t,"\u0275mod",g({type:t})),i(t,"\u0275inj",x({imports:[j.forChild(X),j]}));let e=t;return e})();var gt=(()=>{let t=class t{};i(t,"\u0275fac",function(n){return new(n||t)}),i(t,"\u0275mod",g({type:t})),i(t,"\u0275inj",x({imports:[E,M.forChild(),L,O]}));let e=t;return e})();export{gt as LinuxModule};
@@ -1 +1 @@
1
- import{c as h}from"./chunk-RIWBPQF3.js";import{k as u}from"./chunk-S4SOWUAW.js";import{a as c}from"./chunk-F22FMU37.js";import{W as o,Z as i,h as r,sc as n}from"./chunk-IGUSDGD6.js";var I=(()=>{let t=class t{constructor(s,a,$,f){r(this,"$auth");r(this,"$router");r(this,"$translate");r(this,"$toastr");this.$auth=s,this.$router=a,this.$translate=$,this.$toastr=f}canActivate(){return this.$auth.user&&this.$auth.user.admin?!0:(this.$toastr.error(this.$translate.instant("toast.no_auth"),this.$translate.instant("toast.title_error")),this.$router.navigate(["/"]),!1)}};r(t,"\u0275fac",function(a){return new(a||t)(i(h),i(n),i(c),i(u))}),r(t,"\u0275prov",o({token:t,factory:t.\u0275fac,providedIn:"root"}));let e=t;return e})();export{I as a};
1
+ import{c as h}from"./chunk-V7NUKNPP.js";import{k as u}from"./chunk-54RIF7BL.js";import{a as c}from"./chunk-F22FMU37.js";import{W as o,Z as i,h as r,sc as n}from"./chunk-IGUSDGD6.js";var I=(()=>{let t=class t{constructor(s,a,$,f){r(this,"$auth");r(this,"$router");r(this,"$translate");r(this,"$toastr");this.$auth=s,this.$router=a,this.$translate=$,this.$toastr=f}canActivate(){return this.$auth.user&&this.$auth.user.admin?!0:(this.$toastr.error(this.$translate.instant("toast.no_auth"),this.$translate.instant("toast.title_error")),this.$router.navigate(["/"]),!1)}};r(t,"\u0275fac",function(a){return new(a||t)(i(h),i(n),i(c),i(u))}),r(t,"\u0275prov",o({token:t,factory:t.\u0275fac,providedIn:"root"}));let e=t;return e})();export{I as a};
@@ -1 +1 @@
1
- import{f as Se}from"./chunk-422JXES4.js";import{b as ye}from"./chunk-TS27NWVA.js";import"./chunk-7R6JSPNH.js";import"./chunk-JM7QCDMZ.js";import{c as H}from"./chunk-RIWBPQF3.js";import{G as we,M as N,N as Ce,Q as $e,b as J,c as B,d as w,e as D,f as K,g as M,j as C,m as W,o as X,p as Y,q as Z,w as he,y as ge,z as xe}from"./chunk-WCDFKYP6.js";import{a as Ge,c as I,k as E}from"./chunk-S4SOWUAW.js";import{a as S,b as T,c as ve}from"./chunk-F22FMU37.js";import{$ as k,$b as fe,Ab as ce,Ga as U,Ka as h,La as u,Pb as L,Qb as ue,Rb as G,Ua as s,Va as m,W as le,Wa as c,X as Q,Z as q,Za as V,aa as R,ab as g,bb as $,fb as pe,g as Ae,gb as me,h as o,ha as j,hb as de,i as se,ia as F,jb as d,kb as x,lb as b,qc as be,sc as _e,t as oe,ub as y,vc as ne,wa as t,xa as f,yb as l,zb as p}from"./chunk-IGUSDGD6.js";function qe(n,a){n&1&&(s(0,"p",15)(1,"small"),d(2),l(3,"translate"),m()()),n&2&&(t(2),x(p(3,1,"login.invalid_credentials")))}var Ie=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"formGroup",new M({password:new C("",[w.required])}));o(this,"invalidCredentials",!1);this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}disable2fa(){this.invalidCredentials=!1,this.$api.post("/users/otp/deactivate",this.formGroup.value).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.setup_2fa_disable_success"),this.$translate.instant("toast.title_success"))},error:()=>{this.formGroup.setValue({password:""}),this.invalidCredentials=!0}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],decls:28,vars:24,consts:[[1,"modal-content",2,"min-height","300px"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"form-group"],["type","password","autocomplete","current-password",1,"form-control",3,"formControl","placeholder"],["class","red-text",4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","data-dismiss","modal",1,"btn","btn-danger",3,"click","disabled"],[1,"red-text"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h5",2),d(3),l(4,"translate"),m(),s(5,"button",3),l(6,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(7,"span",4),d(8,"\xD7"),m()()(),s(9,"div",5)(10,"p"),d(11),l(12,"translate"),m(),s(13,"div",6),c(14,"input",7),l(15,"translate"),m(),U(16,qe,4,3,"p",8),m(),s(17,"div",9)(18,"div",10)(19,"button",11),l(20,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(21),l(22,"translate"),m()(),c(23,"div",12),s(24,"div",13)(25,"button",14),g("click",function(){return i.disable2fa()}),d(26),l(27,"translate"),m()()()()),e&2&&(t(3),x(p(4,10,"users.setup_2fa_disable")),t(2),h("aria-label",p(6,12,"form.button_close")),t(6),x(p(12,14,"users.setup_2fa_disable_current_password")),t(3),u("formControl",i.formGroup.controls.password)("placeholder",p(15,16,"users.label_password")),t(2),u("ngIf",i.invalidCredentials),t(3),h("aria-label",p(20,18,"form.button_close")),t(2),b(" ",p(22,20,"form.button_close")," "),t(4),u("disabled",i.formGroup.invalid),t(),b(" ",p(27,22,"form.button_disable")," "))},dependencies:[G,B,D,X,T],encapsulation:2}));let n=a;return n})();var Ee=Ae(Ge(),1);var Pe=["qrcode"],ze=n=>({timeDiffError:n});function Oe(n,a){if(n&1&&(s(0,"div",15)(1,"h3"),d(2),l(3,"translate"),m(),s(4,"p"),d(5),l(6,"translate"),m()()),n&2){let v=$();t(2),x(p(3,2,"users.setup_2fa_cannot_setup_2fa")),t(3),x(ce(6,4,"users.setup_2fa_server_time_out",y(7,ze,v.timeDiffError)))}}function Qe(n,a){n&1&&(s(0,"div")(1,"p"),d(2),l(3,"translate"),m()()),n&2&&(t(2),x(p(3,1,"users.setup_2fa_scan_qr_code")))}function Re(n,a){if(n&1&&(s(0,"div",18)(1,"p"),d(2),l(3,"translate"),m(),s(4,"div",19),c(5,"input",20),m()()),n&2){let v=$();t(2),x(p(3,2,"users.setup_2fa_enter_code")),t(3),u("formControl",v.formGroup.controls.code)}}function Le(n,a){if(n&1){let v=V();s(0,"button",21),g("click",function(){j(v);let e=$();return F(e.enable2fa())}),d(1),l(2,"translate"),m()}if(n&2){let v=$();u("disabled",v.formGroup.invalid),t(),b(" ",p(2,2,"form.button_enable")," ")}}var ke=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"user");o(this,"qrcodeElement");o(this,"timeDiffError",null);o(this,"otpString");o(this,"formGroup",new M({code:new C("",[w.required,w.minLength(6),w.maxLength(6)])}));this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}ngOnInit(){this.$api.post("/users/otp/setup",{}).subscribe({next:r=>{this.checkTimeDiff(r.timestamp),this.timeDiffError||(this.otpString=r.otpauth)},error:r=>{this.$activeModal.dismiss(),console.error(r),this.$toastr.error(this.$translate.instant("users.setup_2fa_enable_error"),this.$translate.instant("toast.title_error"))}})}checkTimeDiff(r){let e=(0,Ee.default)(r).diff(new Date,"millisecond");if(e<-5e3||e>5e3){this.timeDiffError=e;return}this.timeDiffError=null}enable2fa(){this.$api.post("/users/otp/activate",this.formGroup.value).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("users.setup_2fa_enabled_success"),this.$translate.instant("toast.title_success")),this.$activeModal.close()},error:r=>{console.error(r),this.$toastr.error(this.$translate.instant("users.setup_2fa_activate_error"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],viewQuery:function(e,i){if(e&1&&pe(Pe,7),e&2){let _;me(_=de())&&(i.qrcodeElement=_.first)}},inputs:{user:"user"},decls:27,vars:21,consts:[[1,"modal-content","setup2fa"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],["class","text-center",4,"ngIf"],["type","warning",3,"dismissible"],[4,"ngIf"],[1,"text-center","w-100","d-flex","justify-content-center"],[1,"mx-auto","my-2",2,"width","180px","height","180px",3,"data"],["class","mt-4",4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","class","btn btn-primary","data-dismiss","modal",3,"disabled","click",4,"ngIf"],[1,"mt-4"],[1,"form-group"],["type","text","placeholder","eg. 123456","autocomplete","one-time-code","autocapitalize","none","inputmode","numeric","pattern","[0-9]*",1,"form-control",3,"formControl"],["type","button","data-dismiss","modal",1,"btn","btn-primary",3,"click","disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h5",2),d(3),l(4,"translate"),m(),s(5,"button",3),l(6,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(7,"span",4),d(8,"\xD7"),m()()(),s(9,"div",5),U(10,Oe,7,9,"div",6),s(11,"ngb-alert",7),d(12),l(13,"translate"),m(),U(14,Qe,4,3,"div",8),s(15,"div",9),c(16,"app-qrcode",10),m(),U(17,Re,6,4,"div",11),m(),s(18,"div",12)(19,"div",13)(20,"button",14),l(21,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(22),l(23,"translate"),m()(),c(24,"div",15),s(25,"div",16),U(26,Le,3,4,"button",17),m()()()),e&2&&(t(3),x(p(4,11,"users.setup_2fa")),t(2),h("aria-label",p(6,13,"form.button_close")),t(5),u("ngIf",i.timeDiffError),t(),u("dismissible",!1),t(),b(" ",p(13,15,"users.setup_2fa_warning")," "),t(2),u("ngIf",!i.timeDiffError),t(2),u("data",i.otpString),t(),u("ngIf",!i.timeDiffError),t(3),h("aria-label",p(21,17,"form.button_close")),t(2),b(" ",p(23,19,"form.button_close")," "),t(4),u("ngIf",!i.timeDiffError))},dependencies:[G,B,D,he,X,we,ye,T],encapsulation:2}));let n=a;return n})();var Ue=n=>({active:n}),Te=n=>({"is-invalid":n}),Be=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"form",new M({username:new C("",[w.required]),name:new C("",[w.required]),password:new C("",[w.compose([w.required,w.minLength(4)])]),passwordConfirm:new C("",[w.required]),admin:new C(!0)},this.matchPassword));o(this,"page",{title:"users.title_add_user",save:"users.button_add_new_user",password:"users.label_password"});this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}matchPassword(r){let e=r.get("password").value,i=r.get("passwordConfirm").value;if(e!==i)r.get("passwordConfirm").setErrors({matchPassword:!0});else return null}onSubmit({value:r}){this.$api.post("/users",r).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.toast_added_new_user"),this.$translate.instant("toast.title_success"))},error:e=>{this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_add_user"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],decls:59,vars:57,consts:[[1,"modal-content"],["novalidate","",3,"ngSubmit","formGroup"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"container","px-1"],[1,"md-form"],["formControlName","username","type","text","id","form-username","autocomplete","username","autocapitalize","none",1,"form-control","px-0"],["for","form-username",3,"ngClass"],[1,"fas","fa-fw","fa-user-shield"],["formControlName","name","type","text","id","form-name","autocomplete","name",1,"form-control","px-0"],["for","form-name",3,"ngClass"],[1,"fas","fa-fw","fa-user"],["formControlName","password","type","password","autocomplete","new-password","id","form-pass",1,"form-control","px-0",3,"ngClass"],["for","form-pass"],[1,"fas","fa-fw","fa-lock"],["formControlName","passwordConfirm","type","password","autocomplete","new-password","id","form-pass-confirm",1,"form-control","px-0",3,"ngClass"],["for","form-pass-confirm"],[1,"form-group","row","align-items-center"],[1,"col-6","col-form-label","grey-text"],[1,"fas","fa-fw","fa-user-secret"],[1,"col-6","text-right"],["type","checkbox","formControlName","admin","id","isAdmin",1,"rendux-input"],["for","isAdmin",1,"rendux-label","ml-3",2,"min-width","50px"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","submit",1,"btn","btn-primary",3,"disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"form",1),g("ngSubmit",function(){return i.onSubmit(i.form)}),s(2,"div",2)(3,"h5",3),d(4),l(5,"translate"),m(),s(6,"button",4),l(7,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(8,"span",5),d(9,"\xD7"),m()()(),s(10,"div",6)(11,"div",7)(12,"div",8),c(13,"input",9),l(14,"translate"),s(15,"label",10),c(16,"i",11),d(17),l(18,"translate"),m()(),s(19,"div",8),c(20,"input",12),l(21,"translate"),s(22,"label",13),c(23,"i",14),d(24),l(25,"translate"),m()(),s(26,"div",8),c(27,"input",15),l(28,"translate"),s(29,"label",16),c(30,"i",17),d(31),l(32,"translate"),m()(),s(33,"div",8),c(34,"input",18),l(35,"translate"),s(36,"label",19),c(37,"i",17),d(38),l(39,"translate"),m()(),s(40,"div",20)(41,"label",21),c(42,"i",22),d(43),l(44,"translate"),m(),s(45,"div",23),c(46,"input",24),l(47,"translate"),c(48,"label",25),m()()()(),s(49,"div",26)(50,"div",27)(51,"button",28),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(52),l(53,"translate"),m()(),c(54,"div",29),s(55,"div",30)(56,"button",31),d(57),l(58,"translate"),m()()()()()),e&2&&(t(),u("formGroup",i.form),t(3),x(p(5,21,"users.title_add_user")),t(2),h("aria-label",p(7,23,"form.button_close")),t(7),h("disabled",i.page.title==="users.title_edit_user"?!0:null)("aria-label",p(14,25,"users.label_username")),t(2),u("ngClass",y(49,Ue,i.page.title==="users.title_edit_user")),t(2),b(" ",p(18,27,"users.label_username")," "),t(3),h("aria-label",p(21,29,"users.label_full_name")),t(2),u("ngClass",y(51,Ue,i.page.title==="users.title_edit_user")),t(2),b(" ",p(25,31,"users.label_full_name")," "),t(3),u("ngClass",y(53,Te,i.form.controls.password.dirty&&i.form.controls.password.errors)),h("aria-label",p(28,33,i.page.password)),t(4),b(" ",p(32,35,i.page.password)," "),t(3),u("ngClass",y(55,Te,i.form.controls.passwordConfirm.dirty&&i.form.controls.passwordConfirm.errors)),h("aria-label",p(35,37,"users.label_confirm_password")),t(4),b(" ",p(39,39,"users.label_confirm_password")," "),t(5),b(" ",p(44,41,"users.label_admin_user")," "),t(3),h("aria-label",p(47,43,"users.label_admin_user")),t(6),b(" ",p(53,45,"form.button_close")," "),t(4),u("disabled",!i.form.valid),t(),b(" ",p(58,47,"form.button_save")," "))},dependencies:[L,W,B,J,D,K,Y,Z,T],encapsulation:2}));let n=a;return n})();var De=n=>({active:n}),Me=n=>({"is-invalid":n}),Ne=(()=>{let a=class a{constructor(r,e,i,_,re){o(this,"$activeModal");o(this,"$api");o(this,"$auth");o(this,"$toastr");o(this,"$translate");o(this,"user");o(this,"form",new M({username:new C("",[w.required]),name:new C("",[w.required]),password:new C(""),passwordConfirm:new C(""),admin:new C(!0)},this.matchPassword));o(this,"page",{title:"users.title_edit_user",save:"form.button_save",password:"users.label_new_password"});o(this,"isCurrentUser",!1);this.$activeModal=r,this.$api=e,this.$auth=i,this.$toastr=_,this.$translate=re}ngOnInit(){this.isCurrentUser=this.$auth.user.username===this.user.username,this.form.patchValue(this.user)}matchPassword(r){let e=r.get("password").value,i=r.get("passwordConfirm").value;if(e!==i)r.get("passwordConfirm").setErrors({matchPassword:!0});else return null}onSubmit({value:r}){this.$api.patch(`/users/${this.user.id}`,r).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.toast_updated_user"),this.$translate.instant("toast.title_success")),this.isCurrentUser&&r.username!==this.$auth.user.username&&this.$auth.logout()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_add_user"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(H),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],inputs:{user:"user"},decls:59,vars:56,consts:[[1,"modal-content"],["novalidate","",3,"ngSubmit","formGroup"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"container","px-1"],[1,"md-form"],["formControlName","username","type","text","id","form-username","autocomplete","off","autocapitalize","none",1,"form-control","px-0"],["for","form-username",3,"ngClass"],[1,"fas","fa-fw","fa-user-shield"],["formControlName","name","type","text","id","form-name","autocomplete","name",1,"form-control","px-0"],["for","form-name",3,"ngClass"],[1,"fas","fa-fw","fa-user"],["formControlName","password","type","password","autocomplete","new-password","id","form-pass",1,"form-control","px-0",3,"ngClass"],["for","form-pass"],[1,"fas","fa-fw","fa-lock"],["formControlName","passwordConfirm","type","password","autocomplete","new-password","id","form-pass-confirm",1,"form-control","px-0",3,"ngClass"],["for","form-pass-confirm"],[1,"form-group","row","align-items-center"],[1,"col-6","col-form-label","grey-text"],[1,"fas","fa-fw","fa-user-secret"],[1,"col-6","text-right"],["type","checkbox","formControlName","admin","id","isAdmin",1,"rendux-input"],["for","isAdmin",1,"rendux-label","ml-3",2,"min-width","50px"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","submit",1,"btn","btn-primary",3,"disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"form",1),g("ngSubmit",function(){return i.onSubmit(i.form)}),s(2,"div",2)(3,"h5",3),d(4),l(5,"translate"),m(),s(6,"button",4),l(7,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(8,"span",5),d(9,"\xD7"),m()()(),s(10,"div",6)(11,"div",7)(12,"div",8),c(13,"input",9),l(14,"translate"),s(15,"label",10),c(16,"i",11),d(17),l(18,"translate"),m()(),s(19,"div",8),c(20,"input",12),l(21,"translate"),s(22,"label",13),c(23,"i",14),d(24),l(25,"translate"),m()(),s(26,"div",8),c(27,"input",15),l(28,"translate"),s(29,"label",16),c(30,"i",17),d(31),l(32,"translate"),m()(),s(33,"div",8),c(34,"input",18),l(35,"translate"),s(36,"label",19),c(37,"i",17),d(38),l(39,"translate"),m()(),s(40,"div",20)(41,"label",21),c(42,"i",22),d(43),l(44,"translate"),m(),s(45,"div",23),c(46,"input",24),l(47,"translate"),c(48,"label",25),m()()()(),s(49,"div",26)(50,"div",27)(51,"button",28),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(52),l(53,"translate"),m()(),c(54,"div",29),s(55,"div",30)(56,"button",31),d(57),l(58,"translate"),m()()()()()),e&2&&(t(),u("formGroup",i.form),t(3),x(p(5,20,"users.title_edit_user")),t(2),h("aria-label",p(7,22,"form.button_close")),t(7),h("aria-label",p(14,24,"users.label_username")),t(2),u("ngClass",y(48,De,i.page.title==="users.title_edit_user")),t(2),b(" ",p(18,26,"users.label_username")," "),t(3),h("aria-label",p(21,28,"users.label_full_name")),t(2),u("ngClass",y(50,De,i.page.title==="users.title_edit_user")),t(2),b(" ",p(25,30,"users.label_full_name")," "),t(3),u("ngClass",y(52,Me,i.form.controls.password.dirty&&i.form.controls.password.errors)),h("aria-label",p(28,32,i.page.password)),t(4),b(" ",p(32,34,i.page.password)," "),t(3),u("ngClass",y(54,Me,i.form.controls.passwordConfirm.dirty&&i.form.controls.passwordConfirm.errors)),h("aria-label",p(35,36,"users.label_confirm_password")),t(4),b(" ",p(39,38,"users.label_confirm_password")," "),t(5),b(" ",p(44,40,"users.label_admin_user")," "),t(3),h("aria-label",p(47,42,"users.label_admin_user")),t(6),b(" ",p(53,44,"form.button_close")," "),t(4),u("disabled",!i.form.valid),t(),b(" ",p(58,46,"form.button_save")," "))},dependencies:[L,W,B,J,D,K,Y,Z,T],encapsulation:2}));let n=a;return n})();function Ke(n,a){if(n&1){let v=V();s(0,"button",20),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.deleteUser(e.id))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"form.button_delete")," "))}function We(n,a){if(n&1){let v=V();s(0,"button",21),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.setup2fa(e))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"users.setup_2fa")," "))}function Xe(n,a){if(n&1){let v=V();s(0,"button",19),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.disable2fa(e))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"users.setup_2fa_disable")," "))}function Ye(n,a){if(n&1){let v=V();s(0,"div",8)(1,"div",9)(2,"div",10)(3,"div",11)(4,"span",12),c(5,"h4",13)(6,"h5",14),m()(),s(7,"div",15),U(8,Ke,3,3,"button",16)(9,We,3,3,"button",17)(10,Xe,3,3,"button",18),s(11,"button",19),g("click",function(){let e=j(v).$implicit,i=$();return F(i.openEditUser(e))}),d(12),l(13,"translate"),m()()()()()}if(n&2){let v=a.$implicit,r=$();t(5),u("innerText",v.name),t(),u("innerText",v.username),t(2),u("ngIf",r.$auth.user.username!==v.username),t(),u("ngIf",r.$auth.user.username===v.username&&!v.otpActive),t(),u("ngIf",r.$auth.user.username===v.username&&v.otpActive),t(2),x(p(13,6,"form.button_edit"))}}var je=(()=>{let a=class a{constructor(r,e,i,_,re,Ve){o(this,"$api");o(this,"$auth");o(this,"$modal");o(this,"$route");o(this,"$toastr");o(this,"$translate");o(this,"homebridgeUsers");this.$api=r,this.$auth=e,this.$modal=i,this.$route=_,this.$toastr=re,this.$translate=Ve}ngOnInit(){this.$route.data.subscribe(r=>{this.homebridgeUsers=r.homebridgeUsers})}reloadUsers(){return this.$api.get("/users").subscribe(r=>{this.homebridgeUsers=r})}openAddNewUser(){this.$modal.open(Be,{size:"lg",backdrop:"static"}).result.finally(()=>{this.reloadUsers()})}openEditUser(r){let e=this.$modal.open(Ne,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}deleteUser(r){this.$api.delete(`/users/${r}`).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("users.toast_user_deleted"),this.$translate.instant("toast.title_success")),this.reloadUsers()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_delete_user"),this.$translate.instant("toast.title_error"))}})}setup2fa(r){let e=this.$modal.open(ke,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}disable2fa(r){let e=this.$modal.open(Ie,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}};o(a,"\u0275fac",function(e){return new(e||a)(f(I),f(H),f(Ce),f(be),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["app-users"]],decls:11,vars:7,consts:[[1,"row","mb-3"],[1,"col-9"],[1,"primary-text","m-0"],[1,"col-3","text-right"],[1,"btn","btn-elegant","waves-effect","m-0",3,"click"],[1,"fas","fa-fw","fa-plus"],[1,"row"],["class","col-md-6 mb-4",4,"ngFor","ngForOf"],[1,"col-md-6","mb-4"],[1,"card","card-body"],[1,"d-flex","flex-column"],[1,"d-flex","flex-row","mb-3"],[1,"me-auto","my-0"],[3,"innerText"],[1,"small","text-truncate","primary-text",3,"innerText"],[1,"d-flex","flex-row","justify-content-between",2,"gap","10px"],["class","btn btn-elegant btn-sml m-0",3,"click",4,"ngIf"],["class","btn btn-primary mt-0 m-0",3,"click",4,"ngIf"],["class","btn btn-primary m-0",3,"click",4,"ngIf"],[1,"btn","btn-primary","m-0",3,"click"],[1,"btn","btn-elegant","btn-sml","m-0",3,"click"],[1,"btn","btn-primary","mt-0","m-0",3,"click"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h3",2),d(3),l(4,"translate"),m()(),s(5,"div",3)(6,"button",4),l(7,"translate"),g("click",function(){return i.openAddNewUser()}),c(8,"i",5),m()()(),s(9,"div",6),U(10,Ye,14,8,"div",7),m()),e&2&&(t(3),x(p(4,3,"users.title_users")),t(3),h("aria-label",p(7,5,"users.button_add_user")),t(4),u("ngForOf",i.homebridgeUsers))},dependencies:[ue,G,T],encapsulation:2}));let n=a;return n})();var ie=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$api");o(this,"$router");o(this,"$toastr");o(this,"$translate");this.$api=r,this.$router=e,this.$toastr=i,this.$translate=_}resolve(){return se(this,null,function*(){try{return yield oe(this.$api.get("/users"))}catch(r){console.error(r),this.$toastr.error(r.message,this.$translate.instant("toast.title_error")),this.$router.navigate(["/"])}})}};o(a,"\u0275fac",function(e){return new(e||a)(q(I),q(_e),q(E),q(S))}),o(a,"\u0275prov",le({token:a,factory:a.\u0275fac}));let n=a;return n})();var Ze=[{path:"",component:je,resolve:{homebridgeUsers:ie}}],Fe=(()=>{let a=class a{};o(a,"\u0275fac",function(e){return new(e||a)}),o(a,"\u0275mod",R({type:a})),o(a,"\u0275inj",Q({imports:[ne.forChild(Ze),ne]}));let n=a;return n})();var Qt=(()=>{let a=class a{};o(a,"\u0275fac",function(e){return new(e||a)}),o(a,"\u0275mod",R({type:a})),o(a,"\u0275inj",Q({providers:[ie],imports:[fe,ge,xe,ve.forChild(),$e,Se,Fe]}));let n=a;return n})();export{Qt as UsersModule};
1
+ import{f as Se}from"./chunk-AA4ALV5Q.js";import{b as ye}from"./chunk-CMASH2I6.js";import"./chunk-W5QNZH4U.js";import"./chunk-JM7QCDMZ.js";import{c as H}from"./chunk-V7NUKNPP.js";import{G as we,M as N,N as Ce,Q as $e,b as J,c as B,d as w,e as D,f as K,g as M,j as C,m as W,o as X,p as Y,q as Z,w as he,y as ge,z as xe}from"./chunk-WCDFKYP6.js";import{a as Ge,c as I,k as E}from"./chunk-54RIF7BL.js";import{a as S,b as T,c as ve}from"./chunk-F22FMU37.js";import{$ as k,$b as fe,Ab as ce,Ga as U,Ka as h,La as u,Pb as L,Qb as ue,Rb as G,Ua as s,Va as m,W as le,Wa as c,X as Q,Z as q,Za as V,aa as R,ab as g,bb as $,fb as pe,g as Ae,gb as me,h as o,ha as j,hb as de,i as se,ia as F,jb as d,kb as x,lb as b,qc as be,sc as _e,t as oe,ub as y,vc as ne,wa as t,xa as f,yb as l,zb as p}from"./chunk-IGUSDGD6.js";function qe(n,a){n&1&&(s(0,"p",15)(1,"small"),d(2),l(3,"translate"),m()()),n&2&&(t(2),x(p(3,1,"login.invalid_credentials")))}var Ie=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"formGroup",new M({password:new C("",[w.required])}));o(this,"invalidCredentials",!1);this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}disable2fa(){this.invalidCredentials=!1,this.$api.post("/users/otp/deactivate",this.formGroup.value).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.setup_2fa_disable_success"),this.$translate.instant("toast.title_success"))},error:()=>{this.formGroup.setValue({password:""}),this.invalidCredentials=!0}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],decls:28,vars:24,consts:[[1,"modal-content",2,"min-height","300px"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"form-group"],["type","password","autocomplete","current-password",1,"form-control",3,"formControl","placeholder"],["class","red-text",4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","data-dismiss","modal",1,"btn","btn-danger",3,"click","disabled"],[1,"red-text"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h5",2),d(3),l(4,"translate"),m(),s(5,"button",3),l(6,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(7,"span",4),d(8,"\xD7"),m()()(),s(9,"div",5)(10,"p"),d(11),l(12,"translate"),m(),s(13,"div",6),c(14,"input",7),l(15,"translate"),m(),U(16,qe,4,3,"p",8),m(),s(17,"div",9)(18,"div",10)(19,"button",11),l(20,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(21),l(22,"translate"),m()(),c(23,"div",12),s(24,"div",13)(25,"button",14),g("click",function(){return i.disable2fa()}),d(26),l(27,"translate"),m()()()()),e&2&&(t(3),x(p(4,10,"users.setup_2fa_disable")),t(2),h("aria-label",p(6,12,"form.button_close")),t(6),x(p(12,14,"users.setup_2fa_disable_current_password")),t(3),u("formControl",i.formGroup.controls.password)("placeholder",p(15,16,"users.label_password")),t(2),u("ngIf",i.invalidCredentials),t(3),h("aria-label",p(20,18,"form.button_close")),t(2),b(" ",p(22,20,"form.button_close")," "),t(4),u("disabled",i.formGroup.invalid),t(),b(" ",p(27,22,"form.button_disable")," "))},dependencies:[G,B,D,X,T],encapsulation:2}));let n=a;return n})();var Ee=Ae(Ge(),1);var Pe=["qrcode"],ze=n=>({timeDiffError:n});function Oe(n,a){if(n&1&&(s(0,"div",15)(1,"h3"),d(2),l(3,"translate"),m(),s(4,"p"),d(5),l(6,"translate"),m()()),n&2){let v=$();t(2),x(p(3,2,"users.setup_2fa_cannot_setup_2fa")),t(3),x(ce(6,4,"users.setup_2fa_server_time_out",y(7,ze,v.timeDiffError)))}}function Qe(n,a){n&1&&(s(0,"div")(1,"p"),d(2),l(3,"translate"),m()()),n&2&&(t(2),x(p(3,1,"users.setup_2fa_scan_qr_code")))}function Re(n,a){if(n&1&&(s(0,"div",18)(1,"p"),d(2),l(3,"translate"),m(),s(4,"div",19),c(5,"input",20),m()()),n&2){let v=$();t(2),x(p(3,2,"users.setup_2fa_enter_code")),t(3),u("formControl",v.formGroup.controls.code)}}function Le(n,a){if(n&1){let v=V();s(0,"button",21),g("click",function(){j(v);let e=$();return F(e.enable2fa())}),d(1),l(2,"translate"),m()}if(n&2){let v=$();u("disabled",v.formGroup.invalid),t(),b(" ",p(2,2,"form.button_enable")," ")}}var ke=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"user");o(this,"qrcodeElement");o(this,"timeDiffError",null);o(this,"otpString");o(this,"formGroup",new M({code:new C("",[w.required,w.minLength(6),w.maxLength(6)])}));this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}ngOnInit(){this.$api.post("/users/otp/setup",{}).subscribe({next:r=>{this.checkTimeDiff(r.timestamp),this.timeDiffError||(this.otpString=r.otpauth)},error:r=>{this.$activeModal.dismiss(),console.error(r),this.$toastr.error(this.$translate.instant("users.setup_2fa_enable_error"),this.$translate.instant("toast.title_error"))}})}checkTimeDiff(r){let e=(0,Ee.default)(r).diff(new Date,"millisecond");if(e<-5e3||e>5e3){this.timeDiffError=e;return}this.timeDiffError=null}enable2fa(){this.$api.post("/users/otp/activate",this.formGroup.value).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("users.setup_2fa_enabled_success"),this.$translate.instant("toast.title_success")),this.$activeModal.close()},error:r=>{console.error(r),this.$toastr.error(this.$translate.instant("users.setup_2fa_activate_error"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],viewQuery:function(e,i){if(e&1&&pe(Pe,7),e&2){let _;me(_=de())&&(i.qrcodeElement=_.first)}},inputs:{user:"user"},decls:27,vars:21,consts:[[1,"modal-content","setup2fa"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],["class","text-center",4,"ngIf"],["type","warning",3,"dismissible"],[4,"ngIf"],[1,"text-center","w-100","d-flex","justify-content-center"],[1,"mx-auto","my-2",2,"width","180px","height","180px",3,"data"],["class","mt-4",4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","class","btn btn-primary","data-dismiss","modal",3,"disabled","click",4,"ngIf"],[1,"mt-4"],[1,"form-group"],["type","text","placeholder","eg. 123456","autocomplete","one-time-code","autocapitalize","none","inputmode","numeric","pattern","[0-9]*",1,"form-control",3,"formControl"],["type","button","data-dismiss","modal",1,"btn","btn-primary",3,"click","disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h5",2),d(3),l(4,"translate"),m(),s(5,"button",3),l(6,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(7,"span",4),d(8,"\xD7"),m()()(),s(9,"div",5),U(10,Oe,7,9,"div",6),s(11,"ngb-alert",7),d(12),l(13,"translate"),m(),U(14,Qe,4,3,"div",8),s(15,"div",9),c(16,"app-qrcode",10),m(),U(17,Re,6,4,"div",11),m(),s(18,"div",12)(19,"div",13)(20,"button",14),l(21,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(22),l(23,"translate"),m()(),c(24,"div",15),s(25,"div",16),U(26,Le,3,4,"button",17),m()()()),e&2&&(t(3),x(p(4,11,"users.setup_2fa")),t(2),h("aria-label",p(6,13,"form.button_close")),t(5),u("ngIf",i.timeDiffError),t(),u("dismissible",!1),t(),b(" ",p(13,15,"users.setup_2fa_warning")," "),t(2),u("ngIf",!i.timeDiffError),t(2),u("data",i.otpString),t(),u("ngIf",!i.timeDiffError),t(3),h("aria-label",p(21,17,"form.button_close")),t(2),b(" ",p(23,19,"form.button_close")," "),t(4),u("ngIf",!i.timeDiffError))},dependencies:[G,B,D,he,X,we,ye,T],encapsulation:2}));let n=a;return n})();var Ue=n=>({active:n}),Te=n=>({"is-invalid":n}),Be=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$activeModal");o(this,"$api");o(this,"$toastr");o(this,"$translate");o(this,"form",new M({username:new C("",[w.required]),name:new C("",[w.required]),password:new C("",[w.compose([w.required,w.minLength(4)])]),passwordConfirm:new C("",[w.required]),admin:new C(!0)},this.matchPassword));o(this,"page",{title:"users.title_add_user",save:"users.button_add_new_user",password:"users.label_password"});this.$activeModal=r,this.$api=e,this.$toastr=i,this.$translate=_}matchPassword(r){let e=r.get("password").value,i=r.get("passwordConfirm").value;if(e!==i)r.get("passwordConfirm").setErrors({matchPassword:!0});else return null}onSubmit({value:r}){this.$api.post("/users",r).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.toast_added_new_user"),this.$translate.instant("toast.title_success"))},error:e=>{this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_add_user"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],decls:59,vars:57,consts:[[1,"modal-content"],["novalidate","",3,"ngSubmit","formGroup"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"container","px-1"],[1,"md-form"],["formControlName","username","type","text","id","form-username","autocomplete","username","autocapitalize","none",1,"form-control","px-0"],["for","form-username",3,"ngClass"],[1,"fas","fa-fw","fa-user-shield"],["formControlName","name","type","text","id","form-name","autocomplete","name",1,"form-control","px-0"],["for","form-name",3,"ngClass"],[1,"fas","fa-fw","fa-user"],["formControlName","password","type","password","autocomplete","new-password","id","form-pass",1,"form-control","px-0",3,"ngClass"],["for","form-pass"],[1,"fas","fa-fw","fa-lock"],["formControlName","passwordConfirm","type","password","autocomplete","new-password","id","form-pass-confirm",1,"form-control","px-0",3,"ngClass"],["for","form-pass-confirm"],[1,"form-group","row","align-items-center"],[1,"col-6","col-form-label","grey-text"],[1,"fas","fa-fw","fa-user-secret"],[1,"col-6","text-right"],["type","checkbox","formControlName","admin","id","isAdmin",1,"rendux-input"],["for","isAdmin",1,"rendux-label","ml-3",2,"min-width","50px"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","submit",1,"btn","btn-primary",3,"disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"form",1),g("ngSubmit",function(){return i.onSubmit(i.form)}),s(2,"div",2)(3,"h5",3),d(4),l(5,"translate"),m(),s(6,"button",4),l(7,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(8,"span",5),d(9,"\xD7"),m()()(),s(10,"div",6)(11,"div",7)(12,"div",8),c(13,"input",9),l(14,"translate"),s(15,"label",10),c(16,"i",11),d(17),l(18,"translate"),m()(),s(19,"div",8),c(20,"input",12),l(21,"translate"),s(22,"label",13),c(23,"i",14),d(24),l(25,"translate"),m()(),s(26,"div",8),c(27,"input",15),l(28,"translate"),s(29,"label",16),c(30,"i",17),d(31),l(32,"translate"),m()(),s(33,"div",8),c(34,"input",18),l(35,"translate"),s(36,"label",19),c(37,"i",17),d(38),l(39,"translate"),m()(),s(40,"div",20)(41,"label",21),c(42,"i",22),d(43),l(44,"translate"),m(),s(45,"div",23),c(46,"input",24),l(47,"translate"),c(48,"label",25),m()()()(),s(49,"div",26)(50,"div",27)(51,"button",28),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(52),l(53,"translate"),m()(),c(54,"div",29),s(55,"div",30)(56,"button",31),d(57),l(58,"translate"),m()()()()()),e&2&&(t(),u("formGroup",i.form),t(3),x(p(5,21,"users.title_add_user")),t(2),h("aria-label",p(7,23,"form.button_close")),t(7),h("disabled",i.page.title==="users.title_edit_user"?!0:null)("aria-label",p(14,25,"users.label_username")),t(2),u("ngClass",y(49,Ue,i.page.title==="users.title_edit_user")),t(2),b(" ",p(18,27,"users.label_username")," "),t(3),h("aria-label",p(21,29,"users.label_full_name")),t(2),u("ngClass",y(51,Ue,i.page.title==="users.title_edit_user")),t(2),b(" ",p(25,31,"users.label_full_name")," "),t(3),u("ngClass",y(53,Te,i.form.controls.password.dirty&&i.form.controls.password.errors)),h("aria-label",p(28,33,i.page.password)),t(4),b(" ",p(32,35,i.page.password)," "),t(3),u("ngClass",y(55,Te,i.form.controls.passwordConfirm.dirty&&i.form.controls.passwordConfirm.errors)),h("aria-label",p(35,37,"users.label_confirm_password")),t(4),b(" ",p(39,39,"users.label_confirm_password")," "),t(5),b(" ",p(44,41,"users.label_admin_user")," "),t(3),h("aria-label",p(47,43,"users.label_admin_user")),t(6),b(" ",p(53,45,"form.button_close")," "),t(4),u("disabled",!i.form.valid),t(),b(" ",p(58,47,"form.button_save")," "))},dependencies:[L,W,B,J,D,K,Y,Z,T],encapsulation:2}));let n=a;return n})();var De=n=>({active:n}),Me=n=>({"is-invalid":n}),Ne=(()=>{let a=class a{constructor(r,e,i,_,re){o(this,"$activeModal");o(this,"$api");o(this,"$auth");o(this,"$toastr");o(this,"$translate");o(this,"user");o(this,"form",new M({username:new C("",[w.required]),name:new C("",[w.required]),password:new C(""),passwordConfirm:new C(""),admin:new C(!0)},this.matchPassword));o(this,"page",{title:"users.title_edit_user",save:"form.button_save",password:"users.label_new_password"});o(this,"isCurrentUser",!1);this.$activeModal=r,this.$api=e,this.$auth=i,this.$toastr=_,this.$translate=re}ngOnInit(){this.isCurrentUser=this.$auth.user.username===this.user.username,this.form.patchValue(this.user)}matchPassword(r){let e=r.get("password").value,i=r.get("passwordConfirm").value;if(e!==i)r.get("passwordConfirm").setErrors({matchPassword:!0});else return null}onSubmit({value:r}){this.$api.patch(`/users/${this.user.id}`,r).subscribe({next:()=>{this.$activeModal.close(),this.$toastr.success(this.$translate.instant("users.toast_updated_user"),this.$translate.instant("toast.title_success")),this.isCurrentUser&&r.username!==this.$auth.user.username&&this.$auth.logout()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_add_user"),this.$translate.instant("toast.title_error"))}})}};o(a,"\u0275fac",function(e){return new(e||a)(f(N),f(I),f(H),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["ng-component"]],inputs:{user:"user"},decls:59,vars:56,consts:[[1,"modal-content"],["novalidate","",3,"ngSubmit","formGroup"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"container","px-1"],[1,"md-form"],["formControlName","username","type","text","id","form-username","autocomplete","off","autocapitalize","none",1,"form-control","px-0"],["for","form-username",3,"ngClass"],[1,"fas","fa-fw","fa-user-shield"],["formControlName","name","type","text","id","form-name","autocomplete","name",1,"form-control","px-0"],["for","form-name",3,"ngClass"],[1,"fas","fa-fw","fa-user"],["formControlName","password","type","password","autocomplete","new-password","id","form-pass",1,"form-control","px-0",3,"ngClass"],["for","form-pass"],[1,"fas","fa-fw","fa-lock"],["formControlName","passwordConfirm","type","password","autocomplete","new-password","id","form-pass-confirm",1,"form-control","px-0",3,"ngClass"],["for","form-pass-confirm"],[1,"form-group","row","align-items-center"],[1,"col-6","col-form-label","grey-text"],[1,"fas","fa-fw","fa-user-secret"],[1,"col-6","text-right"],["type","checkbox","formControlName","admin","id","isAdmin",1,"rendux-input"],["for","isAdmin",1,"rendux-label","ml-3",2,"min-width","50px"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","submit",1,"btn","btn-primary",3,"disabled"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"form",1),g("ngSubmit",function(){return i.onSubmit(i.form)}),s(2,"div",2)(3,"h5",3),d(4),l(5,"translate"),m(),s(6,"button",4),l(7,"translate"),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),s(8,"span",5),d(9,"\xD7"),m()()(),s(10,"div",6)(11,"div",7)(12,"div",8),c(13,"input",9),l(14,"translate"),s(15,"label",10),c(16,"i",11),d(17),l(18,"translate"),m()(),s(19,"div",8),c(20,"input",12),l(21,"translate"),s(22,"label",13),c(23,"i",14),d(24),l(25,"translate"),m()(),s(26,"div",8),c(27,"input",15),l(28,"translate"),s(29,"label",16),c(30,"i",17),d(31),l(32,"translate"),m()(),s(33,"div",8),c(34,"input",18),l(35,"translate"),s(36,"label",19),c(37,"i",17),d(38),l(39,"translate"),m()(),s(40,"div",20)(41,"label",21),c(42,"i",22),d(43),l(44,"translate"),m(),s(45,"div",23),c(46,"input",24),l(47,"translate"),c(48,"label",25),m()()()(),s(49,"div",26)(50,"div",27)(51,"button",28),g("click",function(){return i.$activeModal.dismiss("Dismiss")}),d(52),l(53,"translate"),m()(),c(54,"div",29),s(55,"div",30)(56,"button",31),d(57),l(58,"translate"),m()()()()()),e&2&&(t(),u("formGroup",i.form),t(3),x(p(5,20,"users.title_edit_user")),t(2),h("aria-label",p(7,22,"form.button_close")),t(7),h("aria-label",p(14,24,"users.label_username")),t(2),u("ngClass",y(48,De,i.page.title==="users.title_edit_user")),t(2),b(" ",p(18,26,"users.label_username")," "),t(3),h("aria-label",p(21,28,"users.label_full_name")),t(2),u("ngClass",y(50,De,i.page.title==="users.title_edit_user")),t(2),b(" ",p(25,30,"users.label_full_name")," "),t(3),u("ngClass",y(52,Me,i.form.controls.password.dirty&&i.form.controls.password.errors)),h("aria-label",p(28,32,i.page.password)),t(4),b(" ",p(32,34,i.page.password)," "),t(3),u("ngClass",y(54,Me,i.form.controls.passwordConfirm.dirty&&i.form.controls.passwordConfirm.errors)),h("aria-label",p(35,36,"users.label_confirm_password")),t(4),b(" ",p(39,38,"users.label_confirm_password")," "),t(5),b(" ",p(44,40,"users.label_admin_user")," "),t(3),h("aria-label",p(47,42,"users.label_admin_user")),t(6),b(" ",p(53,44,"form.button_close")," "),t(4),u("disabled",!i.form.valid),t(),b(" ",p(58,46,"form.button_save")," "))},dependencies:[L,W,B,J,D,K,Y,Z,T],encapsulation:2}));let n=a;return n})();function Ke(n,a){if(n&1){let v=V();s(0,"button",20),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.deleteUser(e.id))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"form.button_delete")," "))}function We(n,a){if(n&1){let v=V();s(0,"button",21),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.setup2fa(e))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"users.setup_2fa")," "))}function Xe(n,a){if(n&1){let v=V();s(0,"button",19),g("click",function(){j(v);let e=$().$implicit,i=$();return F(i.disable2fa(e))}),d(1),l(2,"translate"),m()}n&2&&(t(),b(" ",p(2,1,"users.setup_2fa_disable")," "))}function Ye(n,a){if(n&1){let v=V();s(0,"div",8)(1,"div",9)(2,"div",10)(3,"div",11)(4,"span",12),c(5,"h4",13)(6,"h5",14),m()(),s(7,"div",15),U(8,Ke,3,3,"button",16)(9,We,3,3,"button",17)(10,Xe,3,3,"button",18),s(11,"button",19),g("click",function(){let e=j(v).$implicit,i=$();return F(i.openEditUser(e))}),d(12),l(13,"translate"),m()()()()()}if(n&2){let v=a.$implicit,r=$();t(5),u("innerText",v.name),t(),u("innerText",v.username),t(2),u("ngIf",r.$auth.user.username!==v.username),t(),u("ngIf",r.$auth.user.username===v.username&&!v.otpActive),t(),u("ngIf",r.$auth.user.username===v.username&&v.otpActive),t(2),x(p(13,6,"form.button_edit"))}}var je=(()=>{let a=class a{constructor(r,e,i,_,re,Ve){o(this,"$api");o(this,"$auth");o(this,"$modal");o(this,"$route");o(this,"$toastr");o(this,"$translate");o(this,"homebridgeUsers");this.$api=r,this.$auth=e,this.$modal=i,this.$route=_,this.$toastr=re,this.$translate=Ve}ngOnInit(){this.$route.data.subscribe(r=>{this.homebridgeUsers=r.homebridgeUsers})}reloadUsers(){return this.$api.get("/users").subscribe(r=>{this.homebridgeUsers=r})}openAddNewUser(){this.$modal.open(Be,{size:"lg",backdrop:"static"}).result.finally(()=>{this.reloadUsers()})}openEditUser(r){let e=this.$modal.open(Ne,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}deleteUser(r){this.$api.delete(`/users/${r}`).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("users.toast_user_deleted"),this.$translate.instant("toast.title_success")),this.reloadUsers()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("users.toast_failed_to_delete_user"),this.$translate.instant("toast.title_error"))}})}setup2fa(r){let e=this.$modal.open(ke,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}disable2fa(r){let e=this.$modal.open(Ie,{size:"lg",backdrop:"static"});e.componentInstance.user=r,e.result.finally(()=>{this.reloadUsers()})}};o(a,"\u0275fac",function(e){return new(e||a)(f(I),f(H),f(Ce),f(be),f(E),f(S))}),o(a,"\u0275cmp",k({type:a,selectors:[["app-users"]],decls:11,vars:7,consts:[[1,"row","mb-3"],[1,"col-9"],[1,"primary-text","m-0"],[1,"col-3","text-right"],[1,"btn","btn-elegant","waves-effect","m-0",3,"click"],[1,"fas","fa-fw","fa-plus"],[1,"row"],["class","col-md-6 mb-4",4,"ngFor","ngForOf"],[1,"col-md-6","mb-4"],[1,"card","card-body"],[1,"d-flex","flex-column"],[1,"d-flex","flex-row","mb-3"],[1,"me-auto","my-0"],[3,"innerText"],[1,"small","text-truncate","primary-text",3,"innerText"],[1,"d-flex","flex-row","justify-content-between",2,"gap","10px"],["class","btn btn-elegant btn-sml m-0",3,"click",4,"ngIf"],["class","btn btn-primary mt-0 m-0",3,"click",4,"ngIf"],["class","btn btn-primary m-0",3,"click",4,"ngIf"],[1,"btn","btn-primary","m-0",3,"click"],[1,"btn","btn-elegant","btn-sml","m-0",3,"click"],[1,"btn","btn-primary","mt-0","m-0",3,"click"]],template:function(e,i){e&1&&(s(0,"div",0)(1,"div",1)(2,"h3",2),d(3),l(4,"translate"),m()(),s(5,"div",3)(6,"button",4),l(7,"translate"),g("click",function(){return i.openAddNewUser()}),c(8,"i",5),m()()(),s(9,"div",6),U(10,Ye,14,8,"div",7),m()),e&2&&(t(3),x(p(4,3,"users.title_users")),t(3),h("aria-label",p(7,5,"users.button_add_user")),t(4),u("ngForOf",i.homebridgeUsers))},dependencies:[ue,G,T],encapsulation:2}));let n=a;return n})();var ie=(()=>{let a=class a{constructor(r,e,i,_){o(this,"$api");o(this,"$router");o(this,"$toastr");o(this,"$translate");this.$api=r,this.$router=e,this.$toastr=i,this.$translate=_}resolve(){return se(this,null,function*(){try{return yield oe(this.$api.get("/users"))}catch(r){console.error(r),this.$toastr.error(r.message,this.$translate.instant("toast.title_error")),this.$router.navigate(["/"])}})}};o(a,"\u0275fac",function(e){return new(e||a)(q(I),q(_e),q(E),q(S))}),o(a,"\u0275prov",le({token:a,factory:a.\u0275fac}));let n=a;return n})();var Ze=[{path:"",component:je,resolve:{homebridgeUsers:ie}}],Fe=(()=>{let a=class a{};o(a,"\u0275fac",function(e){return new(e||a)}),o(a,"\u0275mod",R({type:a})),o(a,"\u0275inj",Q({imports:[ne.forChild(Ze),ne]}));let n=a;return n})();var Qt=(()=>{let a=class a{};o(a,"\u0275fac",function(e){return new(e||a)}),o(a,"\u0275mod",R({type:a})),o(a,"\u0275inj",Q({providers:[ie],imports:[fe,ge,xe,ve.forChild(),$e,Se,Fe]}));let n=a;return n})();export{Qt as UsersModule};
@@ -1 +1 @@
1
- import{a as R,b as K}from"./chunk-LS7T2AVU.js";import"./chunk-GNQUXZMN.js";import"./chunk-THFLPY67.js";import"./chunk-7564WJJL.js";import{a as I}from"./chunk-JM7QCDMZ.js";import"./chunk-RIWBPQF3.js";import{N as Q,O as q,Q as O}from"./chunk-WCDFKYP6.js";import{c as D,k as H}from"./chunk-S4SOWUAW.js";import{a as E,b as F,c as V}from"./chunk-F22FMU37.js";import{$ as x,$b as N,Ka as y,La as $,Ua as p,Va as d,Wa as b,X as f,Za as S,aa as u,ab as h,fb as j,g as G,gb as B,h as i,ha as w,hb as k,i as C,ia as v,jb as z,kb as M,l as T,va as L,vc as _,wa as g,xa as a,yb as l,zb as c}from"./chunk-IGUSDGD6.js";var A=G(K(),1);var U=["logoutput"],J=(()=>{let t=class t{constructor(o,e,r,s,m){i(this,"$api");i(this,"$log");i(this,"$modal");i(this,"$toastr");i(this,"$translate");i(this,"termTarget");i(this,"resizeEvent",new T);this.$api=o,this.$log=e,this.$modal=r,this.$toastr=s,this.$translate=m}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$log.startTerminal(this.termTarget,{},this.resizeEvent)}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$log.destroyTerminal()}downloadLogFile(){let o=this.$modal.open(I,{size:"lg",backdrop:"static"});o.componentInstance.title=this.$translate.instant("logs.title_download_log_file"),o.componentInstance.message=this.$translate.instant("logs.download_warning"),o.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_download"),o.componentInstance.faIconClass="fas fa-fw fa-user-secret primary-text",o.result.then(()=>{this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}).subscribe({next:e=>{(0,A.saveAs)(e.body,"homebridge.log.txt")},error:e=>C(this,null,function*(){let r;try{r=JSON.parse(yield e.error.text()).message}catch(s){console.error(s)}this.$toastr.error(r||this.$translate.instant("logs.download.error"),this.$translate.instant("toast.title_error"))})})}).catch(()=>{})}truncateLogFile(){let o=this.$modal.open(I,{size:"lg",backdrop:"static"});o.componentInstance.title=this.$translate.instant("logs.title_truncate_log_file"),o.componentInstance.message=this.$translate.instant("logs.truncate_log_warning"),o.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_delete"),o.componentInstance.confirmButtonClass="btn-danger",o.componentInstance.faIconClass="fas fa-fw fa-circle-exclamation primary-text",o.result.then(()=>{this.$api.put("/platform-tools/hb-service/log/truncate",{}).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("logs.log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("logs.truncate.error"),this.$translate.instant("toast.title_error"))}})}).catch(()=>{})}};i(t,"\u0275fac",function(e){return new(e||t)(a(D),a(R),a(Q),a(H),a(E))}),i(t,"\u0275cmp",x({type:t,selectors:[["ng-component"]],viewQuery:function(e,r){if(e&1&&j(U,7),e&2){let s;B(s=k())&&(r.termTarget=s.first)}},hostBindings:function(e,r){e&1&&h("resize",function(m){return r.onWindowResize(m)},!1,L)},decls:17,vars:15,consts:[["logoutput",""],[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-right"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-download"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0","mr-0",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-trash-alt"],[1,"flex-column","d-flex","align-items-stretch","adjust-for-mobile"],["id","log-output",1,"align-self-end","w-100","h-100","mb-1"]],template:function(e,r){if(e&1){let s=S();p(0,"div",1)(1,"div",2)(2,"h3",3),z(3),l(4,"translate"),d()(),p(5,"div",4)(6,"button",5),l(7,"translate"),l(8,"translate"),h("click",function(){return w(s),v(r.downloadLogFile())}),b(9,"i",6),d(),p(10,"button",7),l(11,"translate"),l(12,"translate"),h("click",function(){return w(s),v(r.truncateLogFile())}),b(13,"i",8),d()()(),p(14,"div",9),b(15,"div",10,0),d()}e&2&&(g(3),M(c(4,5,"menu.linux.label_logs")),g(3),$("ngbTooltip",c(7,7,"form.button_download")),y("aria-label",c(8,9,"form.button_download")),g(4),$("ngbTooltip",c(11,11,"form.button_delete")),y("aria-label",c(12,13,"form.button_delete")))},dependencies:[q,F],encapsulation:2}));let n=t;return n})();var X=[{path:"",component:J}],P=(()=>{let t=class t{};i(t,"\u0275fac",function(e){return new(e||t)}),i(t,"\u0275mod",u({type:t})),i(t,"\u0275inj",f({imports:[_.forChild(X),_]}));let n=t;return n})();var ht=(()=>{let t=class t{};i(t,"\u0275fac",function(e){return new(e||t)}),i(t,"\u0275mod",u({type:t})),i(t,"\u0275inj",f({imports:[N,P,O,V.forChild()]}));let n=t;return n})();export{ht as LogsModule};
1
+ import{a as R,b as K}from"./chunk-EEAGROCO.js";import"./chunk-GNQUXZMN.js";import"./chunk-THFLPY67.js";import"./chunk-NJRXPLIM.js";import{a as I}from"./chunk-JM7QCDMZ.js";import"./chunk-V7NUKNPP.js";import{N as Q,O as q,Q as O}from"./chunk-WCDFKYP6.js";import{c as D,k as H}from"./chunk-54RIF7BL.js";import{a as E,b as F,c as V}from"./chunk-F22FMU37.js";import{$ as x,$b as N,Ka as y,La as $,Ua as p,Va as d,Wa as b,X as f,Za as S,aa as u,ab as h,fb as j,g as G,gb as B,h as i,ha as w,hb as k,i as C,ia as v,jb as z,kb as M,l as T,va as L,vc as _,wa as g,xa as a,yb as l,zb as c}from"./chunk-IGUSDGD6.js";var A=G(K(),1);var U=["logoutput"],J=(()=>{let t=class t{constructor(o,e,r,s,m){i(this,"$api");i(this,"$log");i(this,"$modal");i(this,"$toastr");i(this,"$translate");i(this,"termTarget");i(this,"resizeEvent",new T);this.$api=o,this.$log=e,this.$modal=r,this.$toastr=s,this.$translate=m}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$log.startTerminal(this.termTarget,{},this.resizeEvent)}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$log.destroyTerminal()}downloadLogFile(){let o=this.$modal.open(I,{size:"lg",backdrop:"static"});o.componentInstance.title=this.$translate.instant("logs.title_download_log_file"),o.componentInstance.message=this.$translate.instant("logs.download_warning"),o.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_download"),o.componentInstance.faIconClass="fas fa-fw fa-user-secret primary-text",o.result.then(()=>{this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}).subscribe({next:e=>{(0,A.saveAs)(e.body,"homebridge.log.txt")},error:e=>C(this,null,function*(){let r;try{r=JSON.parse(yield e.error.text()).message}catch(s){console.error(s)}this.$toastr.error(r||this.$translate.instant("logs.download.error"),this.$translate.instant("toast.title_error"))})})}).catch(()=>{})}truncateLogFile(){let o=this.$modal.open(I,{size:"lg",backdrop:"static"});o.componentInstance.title=this.$translate.instant("logs.title_truncate_log_file"),o.componentInstance.message=this.$translate.instant("logs.truncate_log_warning"),o.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_delete"),o.componentInstance.confirmButtonClass="btn-danger",o.componentInstance.faIconClass="fas fa-fw fa-circle-exclamation primary-text",o.result.then(()=>{this.$api.put("/platform-tools/hb-service/log/truncate",{}).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("logs.log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("logs.truncate.error"),this.$translate.instant("toast.title_error"))}})}).catch(()=>{})}};i(t,"\u0275fac",function(e){return new(e||t)(a(D),a(R),a(Q),a(H),a(E))}),i(t,"\u0275cmp",x({type:t,selectors:[["ng-component"]],viewQuery:function(e,r){if(e&1&&j(U,7),e&2){let s;B(s=k())&&(r.termTarget=s.first)}},hostBindings:function(e,r){e&1&&h("resize",function(m){return r.onWindowResize(m)},!1,L)},decls:17,vars:15,consts:[["logoutput",""],[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-right"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-download"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0","mr-0",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-trash-alt"],[1,"flex-column","d-flex","align-items-stretch","adjust-for-mobile"],["id","log-output",1,"align-self-end","w-100","h-100","mb-1"]],template:function(e,r){if(e&1){let s=S();p(0,"div",1)(1,"div",2)(2,"h3",3),z(3),l(4,"translate"),d()(),p(5,"div",4)(6,"button",5),l(7,"translate"),l(8,"translate"),h("click",function(){return w(s),v(r.downloadLogFile())}),b(9,"i",6),d(),p(10,"button",7),l(11,"translate"),l(12,"translate"),h("click",function(){return w(s),v(r.truncateLogFile())}),b(13,"i",8),d()()(),p(14,"div",9),b(15,"div",10,0),d()}e&2&&(g(3),M(c(4,5,"menu.linux.label_logs")),g(3),$("ngbTooltip",c(7,7,"form.button_download")),y("aria-label",c(8,9,"form.button_download")),g(4),$("ngbTooltip",c(11,11,"form.button_delete")),y("aria-label",c(12,13,"form.button_delete")))},dependencies:[q,F],encapsulation:2}));let n=t;return n})();var X=[{path:"",component:J}],P=(()=>{let t=class t{};i(t,"\u0275fac",function(e){return new(e||t)}),i(t,"\u0275mod",u({type:t})),i(t,"\u0275inj",f({imports:[_.forChild(X),_]}));let n=t;return n})();var ht=(()=>{let t=class t{};i(t,"\u0275fac",function(e){return new(e||t)}),i(t,"\u0275mod",u({type:t})),i(t,"\u0275inj",f({imports:[N,P,O,V.forChild()]}));let n=t;return n})();export{ht as LogsModule};
@@ -1,4 +1,4 @@
1
- import{a as fe}from"./chunk-BROUJ7PT.js";import{a as Ie}from"./chunk-4R6MSI5I.js";import{a as de,b as me,c as pe}from"./chunk-SJTXTMYT.js";import{a as le}from"./chunk-B6C32ZRK.js";import{a as ce}from"./chunk-7R6JSPNH.js";import{M as ne,N as re,O as ae,Q as se,c as Z,e as ee,l as te,y as ie,z as oe}from"./chunk-WCDFKYP6.js";import{c as k,k as I,m as X}from"./chunk-S4SOWUAW.js";import{a as E,b as P,c as Q}from"./chunk-F22FMU37.js";import{$ as j,$b as W,Ab as J,Ba as F,Ga as x,Ka as C,La as d,Qb as K,Rb as H,Ua as l,Va as c,W as B,Wa as v,X as V,Z as T,Za as w,Zb as U,aa as A,ab as b,bb as p,g as ke,h as r,ha as u,i as M,ia as h,jb as _,kb as $,lb as D,ob as L,pb as q,qb as z,qc as Y,sc as G,t as S,vc as O,wa as s,xa as g,yb as m,zb as f}from"./chunk-IGUSDGD6.js";function Se(o,n){o&1&&(l(0,"div",15),v(1,"i",16),c())}function Ve(o,n){if(o&1){let a=w();l(0,"tr")(1,"td",19),_(2),m(3,"date"),c(),l(4,"td",20)(5,"a",21),b("click",function(){let t=u(a).$implicit,i=p(2);return h(i.restore(t.id))}),_(6),m(7,"translate"),v(8,"i",22),c()()()}if(o&2){let a=n.$implicit;s(2),$(J(3,2,a.timestamp,"medium")),s(4),D(" ",f(7,5,"config.restore.copy_to_editor")," ")}}function je(o,n){if(o&1&&(l(0,"table",17)(1,"tbody"),x(2,Ve,9,7,"tr",18),c()()),o&2){let a=p();s(2),d("ngForOf",a.backupList)}}function Ae(o,n){o&1&&(l(0,"div")(1,"h3",12),_(2),m(3,"translate"),c()()),o&2&&(s(2),$(f(3,1,"config.restore.no_backups")))}function De(o,n){if(o&1){let a=w();l(0,"button",23),m(1,"translate"),b("click",function(){u(a);let t=p();return h(t.deleteAllBackups())}),_(2),m(3,"translate"),c()}o&2&&(C("aria-label",f(1,2,"form.button_remove")),s(2),D(" ",f(3,4,"form.button_remove")," "))}var be=(()=>{let n=class n{constructor(e,t,i,y){r(this,"$activeModal");r(this,"$api");r(this,"$toastr");r(this,"$translate");r(this,"loading",!0);r(this,"backupList",[]);this.$activeModal=e,this.$api=t,this.$toastr=i,this.$translate=y}ngOnInit(){this.$api.get("/config-editor/backups").subscribe({next:e=>{this.loading=!1,this.backupList=e},error:e=>{this.loading=!1,console.error(e),this.$toastr.error(e.error.message||e.message,this.$translate.instant("toast.title_error"))}})}restore(e){return this.$activeModal.close(e)}deleteAllBackups(){return this.$api.delete("/config-editor/backups").subscribe({next:()=>{this.$activeModal.dismiss(),this.$toastr.success(this.$translate.instant("config.restore.toast_backups_deleted"),this.$translate.instant("toast.title_success"))},error:e=>{console.error(e),this.$toastr.error(e.error.message||e.message,this.$translate.instant("toast.title_error"))}})}};r(n,"\u0275fac",function(t){return new(t||n)(g(ne),g(k),g(I),g(E))}),r(n,"\u0275cmp",j({type:n,selectors:[["ng-component"]],decls:22,vars:16,consts:[[1,"modal-content"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],["class","text-center primary-text",4,"ngIf"],["class","table table-borderless table-hover table-sm",4,"ngIf"],[4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","class","btn btn-danger mr-auto",3,"click",4,"ngIf"],[1,"text-center","primary-text"],[1,"fa","fa-fw","fa-cog","fa-spin",2,"font-size","75px"],[1,"table","table-borderless","table-hover","table-sm"],[4,"ngFor","ngForOf"],[1,"w-100"],["nowrap",""],[1,"card-link",3,"click"],[1,"fas","fa-fw","fa-arrow-right"],["type","button",1,"btn","btn-danger","mr-auto",3,"click"]],template:function(t,i){t&1&&(l(0,"div",0)(1,"div",1)(2,"h5",2),_(3),m(4,"translate"),c(),l(5,"button",3),m(6,"translate"),b("click",function(){return i.$activeModal.dismiss("Dismiss")}),l(7,"span",4),_(8,"\xD7"),c()()(),l(9,"div",5),x(10,Se,2,0,"div",6)(11,je,3,1,"table",7)(12,Ae,4,3,"div",8),c(),l(13,"div",9)(14,"div",10)(15,"button",11),m(16,"translate"),b("click",function(){return i.$activeModal.dismiss("Dismiss")}),_(17),m(18,"translate"),c()(),v(19,"div",12),l(20,"div",13),x(21,De,4,6,"button",14),c()()()),t&2&&(s(3),$(f(4,8,"config.restore.title_restore_homebridge_backup")),s(2),C("aria-label",f(6,10,"form.button_close")),s(5),d("ngIf",i.loading),s(),d("ngIf",!i.loading&&i.backupList&&i.backupList.length),s(),d("ngIf",!i.loading&&(!i.backupList||!i.backupList.length)),s(3),C("aria-label",f(16,12,"form.button_close")),s(2),D(" ",f(18,14,"form.button_close")," "),s(4),d("ngIf",!i.loading&&i.backupList.length))},dependencies:[K,H,U,P],encapsulation:2}));let o=n;return o})();var _e=ke(Ie(),1);function Pe(o,n){if(o&1){let a=w();l(0,"button",13),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onExportConfig())}),v(3,"i",14),c()}o&2&&(d("ngbTooltip",f(1,2,"form.button_download")),C("aria-label",f(2,4,"form.button_download")))}function Re(o,n){if(o&1){let a=w();l(0,"button",15),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onCancelRestore())}),v(3,"i",16),c()}if(o&2){let a=p();d("disabled",a.saveInProgress)("ngbTooltip",f(1,3,"form.button_cancel")),C("aria-label",f(2,5,"form.button_cancel"))}}function Ne(o,n){if(o&1){let a=w();l(0,"button",13),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onRestore())}),v(3,"i",17),c()}o&2&&(d("ngbTooltip",f(1,2,"form.button_restore")),C("aria-label",f(2,4,"form.button_restore")))}function Oe(o,n){o&1&&v(0,"i",18)}function Be(o,n){o&1&&v(0,"i",19)}function Fe(o,n){if(o&1){let a=w();l(0,"ngx-monaco-editor",20),b("onInit",function(t){u(a);let i=p();return h(i.onEditorInit(t))})("keydown.control.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())})("keydown.meta.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())}),c()}if(o&2){let a=p();d("options",a.editorOptions)("model",a.monacoEditorModel)}}function Le(o,n){if(o&1){let a=w();l(0,"ngx-monaco-diff-editor",21),b("onInit",function(t){u(a);let i=p();return h(i.onInitDiffEditor(t))})("keydown.control.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())})("keydown.meta.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())}),c()}if(o&2){let a=p();d("options",a.editorOptions)("originalModel",a.monacoEditorModel)("modifiedModel",a.monacoEditorModel)}}function qe(o,n){if(o&1){let a=w();l(0,"textarea",22),z("ngModelChange",function(t){u(a);let i=p();return q(i.homebridgeConfig,t)||(i.homebridgeConfig=t),h(t)}),_(1," "),c()}if(o&2){let a=p();L("ngModel",a.homebridgeConfig)}}var ye=(()=>{let n=class n{constructor(e,t,i,y,we,Ce,xe,$e,Ee){r(this,"$api");r(this,"$md");r(this,"$modal");r(this,"$monacoEditor");r(this,"$route");r(this,"$renderer");r(this,"$settings");r(this,"$toastr");r(this,"$translate");r(this,"homebridgeConfig");r(this,"originalConfig");r(this,"saveInProgress");r(this,"isMobile",!1);r(this,"monacoEditor");r(this,"editorOptions");r(this,"monacoEditorModel");r(this,"editorDecorations",[]);r(this,"lastHeight");r(this,"visualViewPortEventCallback");this.$api=e,this.$md=t,this.$modal=i,this.$monacoEditor=y,this.$route=we,this.$renderer=Ce,this.$settings=xe,this.$toastr=$e,this.$translate=Ee,this.isMobile=this.$md.detect.mobile()}ngOnInit(){this.editorOptions={language:"json",theme:this.$settings.actualLightingMode==="dark"?"vs-dark":"vs-light",automaticLayout:!0};let e=document.querySelector(".content");this.$renderer.setStyle(e,"height","100%"),this.visualViewPortEventCallback=()=>this.visualViewPortChanged(),this.lastHeight=window.innerHeight,window.visualViewport&&!this.isMobile&&(window.visualViewport.addEventListener("resize",this.visualViewPortEventCallback,!0),this.$md.disableTouchMove()),this.visualViewPortEventCallback=()=>this.visualViewPortChanged(),this.lastHeight=window.innerHeight,window.visualViewport&&!this.isMobile&&(window.visualViewport.addEventListener("resize",this.visualViewPortEventCallback,!0),this.$md.disableTouchMove()),this.$route.data.subscribe(t=>{this.homebridgeConfig=t.config}),this.monacoEditorModel={value:"{}",language:"json",uri:window.monaco?window.monaco.Uri.parse("a://homebridge/config.json"):void 0},window.monaco?this.setMonacoEditorModel():this.$monacoEditor.readyEvent.subscribe({next:()=>{this.setMonacoEditorModel()}})}onEditorInit(e){window.editor=e,this.monacoEditor=e,this.monacoEditor.getModel().setValue(this.homebridgeConfig)}onInitDiffEditor(e){this.monacoEditor=e.modifiedEditor,e.getModel().original.setValue(this.originalConfig),e.getModel().modified.setValue(this.homebridgeConfig),window.editor=e}onSave(){return M(this,null,function*(){if(!this.saveInProgress){this.monacoEditor&&(this.editorDecorations=this.monacoEditor.deltaDecorations(this.editorDecorations,[])),this.saveInProgress=!0;try{if(!this.isMobile){yield this.monacoEditor.getAction("editor.action.formatDocument").run();let t=window.monaco.editor.getModelMarkers({owner:"json"});for(let i of t)if(i.message==="Duplicate object key"){this.saveInProgress=!1,this.$toastr.error(this.$translate.instant("config.config_invalid_json"),this.$translate.instant("toast.title_error"));return}this.homebridgeConfig=this.monacoEditor.getModel().getValue()}let e=this.parseConfigFromEditor();this.homebridgeConfig=JSON.stringify(e,null,4),typeof e.bridge!="object"?this.$toastr.error(this.$translate.instant("config.config_bridge_missing"),this.$translate.instant("toast.title_error")):/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i.test(e.bridge.username)?e.accessories&&!Array.isArray(e.accessories)?this.$toastr.error(this.$translate.instant("config.config_accessory_must_be_array"),this.$translate.instant("toast.title_error")):e.platforms&&!Array.isArray(e.platforms)?this.$toastr.error(this.$translate.instant("config.config_platform_must_be_array"),this.$translate.instant("toast.title_error")):e.platforms&&Array.isArray(e.platforms)&&!this.validateSection(e.platforms,"platform")||e.accessories&&Array.isArray(e.accessories)&&!this.validateSection(e.accessories,"accessory")||e.plugins&&Array.isArray(e.plugins)&&!this.validatePlugins(e.plugins,"plugins")||e.disabledPlugins&&Array.isArray(e.disabledPlugins)&&!this.validatePlugins(e.disabledPlugins,"disabledPlugins")||(yield this.saveConfig(e),this.originalConfig=""):this.$toastr.error(this.$translate.instant("config.config_username_error"),this.$translate.instant("toast.title_error"))}catch(e){console.error(e),this.$toastr.error(this.$translate.instant("config.config_invalid_json"),this.$translate.instant("toast.title_error"))}this.saveInProgress=!1}})}parseConfigFromEditor(){try{return JSON.parse(this.homebridgeConfig)}catch{let t=_e.default.parse(this.homebridgeConfig);return this.homebridgeConfig=JSON.stringify(t,null,4),this.monacoEditor&&this.monacoEditor.getModel().setValue(this.homebridgeConfig),t}}saveConfig(e){return M(this,null,function*(){try{let t=yield S(this.$api.post("/config-editor",e));this.homebridgeConfig=JSON.stringify(t,null,4),this.$modal.open(ce,{size:"lg",backdrop:"static"})}catch(t){console.error(t),this.$toastr.error(this.$translate.instant("config.failed_to_save_config"),this.$translate.instant("toast.title_error"))}})}onRestore(){this.$modal.open(be,{size:"lg",backdrop:"static"}).result.then(e=>{this.originalConfig||(this.originalConfig=this.homebridgeConfig),this.$api.get(`/config-editor/backups/${e}`).subscribe({next:t=>{this.$toastr.info(this.$translate.instant("config.restore.confirm"),this.$translate.instant("config.title_backup_loaded")),this.homebridgeConfig=JSON.stringify(t,null,4),this.monacoEditor&&window.editor.modifiedEditor&&(this.editorDecorations=this.monacoEditor.deltaDecorations(this.editorDecorations,[]),this.monacoEditor.executeEdits("beautifier",[{identifier:"delete",range:new monaco.Range(1,1,this.monacoEditor.getModel().getLineCount()+10,1),text:"",forceMoveMarkers:!0}]),this.monacoEditor.executeEdits("beautifier",[{identifier:"insert",range:new monaco.Range(1,1,1,1),text:this.homebridgeConfig,forceMoveMarkers:!0}]))},error:t=>{console.error(t),this.$toastr.error(t.error.message||this.$translate.instant("backup.load_error"),this.$translate.instant("toast.title_error"))}})}).catch(()=>{})}onExportConfig(){let e=`data:text/json;charset=utf-8,${encodeURIComponent(this.homebridgeConfig)}`,t=document.createElement("a");t.setAttribute("href",e),t.setAttribute("download","config.json"),document.body.appendChild(t),t.click(),t.remove()}onCancelRestore(){this.homebridgeConfig=this.originalConfig,this.originalConfig=""}validateSection(e,t){for(let i of e){if(typeof i!="object"||Array.isArray(i))return this.$toastr.error(this.$translate.instant("config.error_blocks_objects",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1;if(!i[t])return this.$toastr.error(this.$translate.instant("config.error_blocks_type",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1;if(typeof i[t]!="string")return this.$toastr.error(this.$translate.instant("config.error_string_type",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1}return!0}validatePlugins(e,t){for(let i of e)if(typeof i!="string")return this.$toastr.error(this.$translate.instant("config.error_string_array",{key:t}),this.$translate.instant("toast.title_error")),!1;return!0}highlightOffendingArrayItem(e){this.monacoEditor&&(e=JSON.stringify(e,null,4).split(`
1
+ import{a as fe}from"./chunk-BROUJ7PT.js";import{a as Ie}from"./chunk-4R6MSI5I.js";import{a as de,b as me,c as pe}from"./chunk-SJTXTMYT.js";import{a as le}from"./chunk-B6C32ZRK.js";import{a as ce}from"./chunk-W5QNZH4U.js";import{M as ne,N as re,O as ae,Q as se,c as Z,e as ee,l as te,y as ie,z as oe}from"./chunk-WCDFKYP6.js";import{c as k,k as I,m as X}from"./chunk-54RIF7BL.js";import{a as E,b as P,c as Q}from"./chunk-F22FMU37.js";import{$ as j,$b as W,Ab as J,Ba as F,Ga as x,Ka as C,La as d,Qb as K,Rb as H,Ua as l,Va as c,W as B,Wa as v,X as V,Z as T,Za as w,Zb as U,aa as A,ab as b,bb as p,g as ke,h as r,ha as u,i as M,ia as h,jb as _,kb as $,lb as D,ob as L,pb as q,qb as z,qc as Y,sc as G,t as S,vc as O,wa as s,xa as g,yb as m,zb as f}from"./chunk-IGUSDGD6.js";function Se(o,n){o&1&&(l(0,"div",15),v(1,"i",16),c())}function Ve(o,n){if(o&1){let a=w();l(0,"tr")(1,"td",19),_(2),m(3,"date"),c(),l(4,"td",20)(5,"a",21),b("click",function(){let t=u(a).$implicit,i=p(2);return h(i.restore(t.id))}),_(6),m(7,"translate"),v(8,"i",22),c()()()}if(o&2){let a=n.$implicit;s(2),$(J(3,2,a.timestamp,"medium")),s(4),D(" ",f(7,5,"config.restore.copy_to_editor")," ")}}function je(o,n){if(o&1&&(l(0,"table",17)(1,"tbody"),x(2,Ve,9,7,"tr",18),c()()),o&2){let a=p();s(2),d("ngForOf",a.backupList)}}function Ae(o,n){o&1&&(l(0,"div")(1,"h3",12),_(2),m(3,"translate"),c()()),o&2&&(s(2),$(f(3,1,"config.restore.no_backups")))}function De(o,n){if(o&1){let a=w();l(0,"button",23),m(1,"translate"),b("click",function(){u(a);let t=p();return h(t.deleteAllBackups())}),_(2),m(3,"translate"),c()}o&2&&(C("aria-label",f(1,2,"form.button_remove")),s(2),D(" ",f(3,4,"form.button_remove")," "))}var be=(()=>{let n=class n{constructor(e,t,i,y){r(this,"$activeModal");r(this,"$api");r(this,"$toastr");r(this,"$translate");r(this,"loading",!0);r(this,"backupList",[]);this.$activeModal=e,this.$api=t,this.$toastr=i,this.$translate=y}ngOnInit(){this.$api.get("/config-editor/backups").subscribe({next:e=>{this.loading=!1,this.backupList=e},error:e=>{this.loading=!1,console.error(e),this.$toastr.error(e.error.message||e.message,this.$translate.instant("toast.title_error"))}})}restore(e){return this.$activeModal.close(e)}deleteAllBackups(){return this.$api.delete("/config-editor/backups").subscribe({next:()=>{this.$activeModal.dismiss(),this.$toastr.success(this.$translate.instant("config.restore.toast_backups_deleted"),this.$translate.instant("toast.title_success"))},error:e=>{console.error(e),this.$toastr.error(e.error.message||e.message,this.$translate.instant("toast.title_error"))}})}};r(n,"\u0275fac",function(t){return new(t||n)(g(ne),g(k),g(I),g(E))}),r(n,"\u0275cmp",j({type:n,selectors:[["ng-component"]],decls:22,vars:16,consts:[[1,"modal-content"],[1,"modal-header"],[1,"modal-title"],["type","button","data-dismiss","modal",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],["class","text-center primary-text",4,"ngIf"],["class","table table-borderless table-hover table-sm",4,"ngIf"],[4,"ngIf"],[1,"modal-footer","justify-content-between"],[1,"text-left"],["type","button","data-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-center"],[1,"text-right"],["type","button","class","btn btn-danger mr-auto",3,"click",4,"ngIf"],[1,"text-center","primary-text"],[1,"fa","fa-fw","fa-cog","fa-spin",2,"font-size","75px"],[1,"table","table-borderless","table-hover","table-sm"],[4,"ngFor","ngForOf"],[1,"w-100"],["nowrap",""],[1,"card-link",3,"click"],[1,"fas","fa-fw","fa-arrow-right"],["type","button",1,"btn","btn-danger","mr-auto",3,"click"]],template:function(t,i){t&1&&(l(0,"div",0)(1,"div",1)(2,"h5",2),_(3),m(4,"translate"),c(),l(5,"button",3),m(6,"translate"),b("click",function(){return i.$activeModal.dismiss("Dismiss")}),l(7,"span",4),_(8,"\xD7"),c()()(),l(9,"div",5),x(10,Se,2,0,"div",6)(11,je,3,1,"table",7)(12,Ae,4,3,"div",8),c(),l(13,"div",9)(14,"div",10)(15,"button",11),m(16,"translate"),b("click",function(){return i.$activeModal.dismiss("Dismiss")}),_(17),m(18,"translate"),c()(),v(19,"div",12),l(20,"div",13),x(21,De,4,6,"button",14),c()()()),t&2&&(s(3),$(f(4,8,"config.restore.title_restore_homebridge_backup")),s(2),C("aria-label",f(6,10,"form.button_close")),s(5),d("ngIf",i.loading),s(),d("ngIf",!i.loading&&i.backupList&&i.backupList.length),s(),d("ngIf",!i.loading&&(!i.backupList||!i.backupList.length)),s(3),C("aria-label",f(16,12,"form.button_close")),s(2),D(" ",f(18,14,"form.button_close")," "),s(4),d("ngIf",!i.loading&&i.backupList.length))},dependencies:[K,H,U,P],encapsulation:2}));let o=n;return o})();var _e=ke(Ie(),1);function Pe(o,n){if(o&1){let a=w();l(0,"button",13),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onExportConfig())}),v(3,"i",14),c()}o&2&&(d("ngbTooltip",f(1,2,"form.button_download")),C("aria-label",f(2,4,"form.button_download")))}function Re(o,n){if(o&1){let a=w();l(0,"button",15),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onCancelRestore())}),v(3,"i",16),c()}if(o&2){let a=p();d("disabled",a.saveInProgress)("ngbTooltip",f(1,3,"form.button_cancel")),C("aria-label",f(2,5,"form.button_cancel"))}}function Ne(o,n){if(o&1){let a=w();l(0,"button",13),m(1,"translate"),m(2,"translate"),b("click",function(){u(a);let t=p();return h(t.onRestore())}),v(3,"i",17),c()}o&2&&(d("ngbTooltip",f(1,2,"form.button_restore")),C("aria-label",f(2,4,"form.button_restore")))}function Oe(o,n){o&1&&v(0,"i",18)}function Be(o,n){o&1&&v(0,"i",19)}function Fe(o,n){if(o&1){let a=w();l(0,"ngx-monaco-editor",20),b("onInit",function(t){u(a);let i=p();return h(i.onEditorInit(t))})("keydown.control.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())})("keydown.meta.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())}),c()}if(o&2){let a=p();d("options",a.editorOptions)("model",a.monacoEditorModel)}}function Le(o,n){if(o&1){let a=w();l(0,"ngx-monaco-diff-editor",21),b("onInit",function(t){u(a);let i=p();return h(i.onInitDiffEditor(t))})("keydown.control.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())})("keydown.meta.s",function(t){u(a);let i=p();return t.preventDefault(),h(i.onSave())}),c()}if(o&2){let a=p();d("options",a.editorOptions)("originalModel",a.monacoEditorModel)("modifiedModel",a.monacoEditorModel)}}function qe(o,n){if(o&1){let a=w();l(0,"textarea",22),z("ngModelChange",function(t){u(a);let i=p();return q(i.homebridgeConfig,t)||(i.homebridgeConfig=t),h(t)}),_(1," "),c()}if(o&2){let a=p();L("ngModel",a.homebridgeConfig)}}var ye=(()=>{let n=class n{constructor(e,t,i,y,we,Ce,xe,$e,Ee){r(this,"$api");r(this,"$md");r(this,"$modal");r(this,"$monacoEditor");r(this,"$route");r(this,"$renderer");r(this,"$settings");r(this,"$toastr");r(this,"$translate");r(this,"homebridgeConfig");r(this,"originalConfig");r(this,"saveInProgress");r(this,"isMobile",!1);r(this,"monacoEditor");r(this,"editorOptions");r(this,"monacoEditorModel");r(this,"editorDecorations",[]);r(this,"lastHeight");r(this,"visualViewPortEventCallback");this.$api=e,this.$md=t,this.$modal=i,this.$monacoEditor=y,this.$route=we,this.$renderer=Ce,this.$settings=xe,this.$toastr=$e,this.$translate=Ee,this.isMobile=this.$md.detect.mobile()}ngOnInit(){this.editorOptions={language:"json",theme:this.$settings.actualLightingMode==="dark"?"vs-dark":"vs-light",automaticLayout:!0};let e=document.querySelector(".content");this.$renderer.setStyle(e,"height","100%"),this.visualViewPortEventCallback=()=>this.visualViewPortChanged(),this.lastHeight=window.innerHeight,window.visualViewport&&!this.isMobile&&(window.visualViewport.addEventListener("resize",this.visualViewPortEventCallback,!0),this.$md.disableTouchMove()),this.visualViewPortEventCallback=()=>this.visualViewPortChanged(),this.lastHeight=window.innerHeight,window.visualViewport&&!this.isMobile&&(window.visualViewport.addEventListener("resize",this.visualViewPortEventCallback,!0),this.$md.disableTouchMove()),this.$route.data.subscribe(t=>{this.homebridgeConfig=t.config}),this.monacoEditorModel={value:"{}",language:"json",uri:window.monaco?window.monaco.Uri.parse("a://homebridge/config.json"):void 0},window.monaco?this.setMonacoEditorModel():this.$monacoEditor.readyEvent.subscribe({next:()=>{this.setMonacoEditorModel()}})}onEditorInit(e){window.editor=e,this.monacoEditor=e,this.monacoEditor.getModel().setValue(this.homebridgeConfig)}onInitDiffEditor(e){this.monacoEditor=e.modifiedEditor,e.getModel().original.setValue(this.originalConfig),e.getModel().modified.setValue(this.homebridgeConfig),window.editor=e}onSave(){return M(this,null,function*(){if(!this.saveInProgress){this.monacoEditor&&(this.editorDecorations=this.monacoEditor.deltaDecorations(this.editorDecorations,[])),this.saveInProgress=!0;try{if(!this.isMobile){yield this.monacoEditor.getAction("editor.action.formatDocument").run();let t=window.monaco.editor.getModelMarkers({owner:"json"});for(let i of t)if(i.message==="Duplicate object key"){this.saveInProgress=!1,this.$toastr.error(this.$translate.instant("config.config_invalid_json"),this.$translate.instant("toast.title_error"));return}this.homebridgeConfig=this.monacoEditor.getModel().getValue()}let e=this.parseConfigFromEditor();this.homebridgeConfig=JSON.stringify(e,null,4),typeof e.bridge!="object"?this.$toastr.error(this.$translate.instant("config.config_bridge_missing"),this.$translate.instant("toast.title_error")):/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i.test(e.bridge.username)?e.accessories&&!Array.isArray(e.accessories)?this.$toastr.error(this.$translate.instant("config.config_accessory_must_be_array"),this.$translate.instant("toast.title_error")):e.platforms&&!Array.isArray(e.platforms)?this.$toastr.error(this.$translate.instant("config.config_platform_must_be_array"),this.$translate.instant("toast.title_error")):e.platforms&&Array.isArray(e.platforms)&&!this.validateSection(e.platforms,"platform")||e.accessories&&Array.isArray(e.accessories)&&!this.validateSection(e.accessories,"accessory")||e.plugins&&Array.isArray(e.plugins)&&!this.validatePlugins(e.plugins,"plugins")||e.disabledPlugins&&Array.isArray(e.disabledPlugins)&&!this.validatePlugins(e.disabledPlugins,"disabledPlugins")||(yield this.saveConfig(e),this.originalConfig=""):this.$toastr.error(this.$translate.instant("config.config_username_error"),this.$translate.instant("toast.title_error"))}catch(e){console.error(e),this.$toastr.error(this.$translate.instant("config.config_invalid_json"),this.$translate.instant("toast.title_error"))}this.saveInProgress=!1}})}parseConfigFromEditor(){try{return JSON.parse(this.homebridgeConfig)}catch{let t=_e.default.parse(this.homebridgeConfig);return this.homebridgeConfig=JSON.stringify(t,null,4),this.monacoEditor&&this.monacoEditor.getModel().setValue(this.homebridgeConfig),t}}saveConfig(e){return M(this,null,function*(){try{let t=yield S(this.$api.post("/config-editor",e));this.homebridgeConfig=JSON.stringify(t,null,4),this.$modal.open(ce,{size:"lg",backdrop:"static"})}catch(t){console.error(t),this.$toastr.error(this.$translate.instant("config.failed_to_save_config"),this.$translate.instant("toast.title_error"))}})}onRestore(){this.$modal.open(be,{size:"lg",backdrop:"static"}).result.then(e=>{this.originalConfig||(this.originalConfig=this.homebridgeConfig),this.$api.get(`/config-editor/backups/${e}`).subscribe({next:t=>{this.$toastr.info(this.$translate.instant("config.restore.confirm"),this.$translate.instant("config.title_backup_loaded")),this.homebridgeConfig=JSON.stringify(t,null,4),this.monacoEditor&&window.editor.modifiedEditor&&(this.editorDecorations=this.monacoEditor.deltaDecorations(this.editorDecorations,[]),this.monacoEditor.executeEdits("beautifier",[{identifier:"delete",range:new monaco.Range(1,1,this.monacoEditor.getModel().getLineCount()+10,1),text:"",forceMoveMarkers:!0}]),this.monacoEditor.executeEdits("beautifier",[{identifier:"insert",range:new monaco.Range(1,1,1,1),text:this.homebridgeConfig,forceMoveMarkers:!0}]))},error:t=>{console.error(t),this.$toastr.error(t.error.message||this.$translate.instant("backup.load_error"),this.$translate.instant("toast.title_error"))}})}).catch(()=>{})}onExportConfig(){let e=`data:text/json;charset=utf-8,${encodeURIComponent(this.homebridgeConfig)}`,t=document.createElement("a");t.setAttribute("href",e),t.setAttribute("download","config.json"),document.body.appendChild(t),t.click(),t.remove()}onCancelRestore(){this.homebridgeConfig=this.originalConfig,this.originalConfig=""}validateSection(e,t){for(let i of e){if(typeof i!="object"||Array.isArray(i))return this.$toastr.error(this.$translate.instant("config.error_blocks_objects",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1;if(!i[t])return this.$toastr.error(this.$translate.instant("config.error_blocks_type",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1;if(typeof i[t]!="string")return this.$toastr.error(this.$translate.instant("config.error_string_type",{type:t}),this.$translate.instant("toast.title_error")),this.highlightOffendingArrayItem(i),!1}return!0}validatePlugins(e,t){for(let i of e)if(typeof i!="string")return this.$toastr.error(this.$translate.instant("config.error_string_array",{key:t}),this.$translate.instant("toast.title_error")),!1;return!0}highlightOffendingArrayItem(e){this.monacoEditor&&(e=JSON.stringify(e,null,4).split(`
2
2
  `).map(t=>` ${t}`).join(`
3
3
  `),setTimeout(()=>{let t=this.monacoEditor.getModel().findMatches(e);if(t.length){let i=t[0].range,y=new monaco.Range(i.startLineNumber,i.startColumn,i.endLineNumber,i.endColumn);this.editorDecorations=this.monacoEditor.deltaDecorations(this.editorDecorations,[{range:y,options:{isWholeLine:!0,linesDecorationsClassName:"hb-monaco-editor-line-error"}}])}},200))}setMonacoEditorModel(){if(window.monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas.some(t=>t.uri==="http://homebridge/config.json"))return;let e=monaco.Uri.parse("a://homebridge/config.json");window.monaco.languages.json.jsonDefaults.setDiagnosticsOptions({allowComments:!1,validate:!0,schemas:[{uri:"http://homebridge/config.json",fileMatch:[e.toString()],schema:{type:"object",required:["bridge"],properties:{bridge:{type:"object",required:["name","username","port","pin"],properties:{name:{type:"string",description:`The Homebridge instance name.
4
4
  This should be unique if you are running multiple instances of Homebridge.`,default:"Homebridge"},username:{type:"string",description:`Homebridge username must be 6 pairs of colon-separated hexadecimal characters (A-F 0-9).