iobroker.aura 0.0.8 → 0.0.9
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.
package/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -449,7 +449,7 @@ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}
|
|
|
449
449
|
*
|
|
450
450
|
* This source code is licensed under the ISC license.
|
|
451
451
|
* See the LICENSE file in the root directory of this source tree.
|
|
452
|
-
*/const Uge=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],il=Ce("zap",Uge),Jo=Object.create(null);Jo.open="0";Jo.close="1";Jo.ping="2";Jo.pong="3";Jo.message="4";Jo.upgrade="5";Jo.noop="6";const gw=Object.create(null);Object.keys(Jo).forEach(e=>{gw[Jo[e]]=e});const rE={type:"error",data:"parser error"},gZ=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yZ=typeof ArrayBuffer=="function",mZ=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_j=({type:e,data:t},r,n)=>gZ&&t instanceof Blob?r?n(t):$3(t,n):yZ&&(t instanceof ArrayBuffer||mZ(t))?r?n(t):$3(new Blob([t]),n):n(Jo[e]+(t||"")),$3=(e,t)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];t("b"+(n||""))},r.readAsDataURL(e)};function B3(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let LA;function Yge(e,t){if(gZ&&e.data instanceof Blob)return e.data.arrayBuffer().then(B3).then(t);if(yZ&&(e.data instanceof ArrayBuffer||mZ(e.data)))return t(B3(e.data));_j(e,!1,r=>{LA||(LA=new TextEncoder),t(LA.encode(r))})}const F3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fy=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<F3.length;e++)fy[F3.charCodeAt(e)]=e;const Xge=e=>{let t=e.length*.75,r=e.length,n,a=0,i,o,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),c=new Uint8Array(u);for(n=0;n<r;n+=4)i=fy[e.charCodeAt(n)],o=fy[e.charCodeAt(n+1)],s=fy[e.charCodeAt(n+2)],l=fy[e.charCodeAt(n+3)],c[a++]=i<<2|o>>4,c[a++]=(o&15)<<4|s>>2,c[a++]=(s&3)<<6|l&63;return u},qge=typeof ArrayBuffer=="function",Sj=(e,t)=>{if(typeof e!="string")return{type:"message",data:xZ(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:Kge(e.substring(1),t)}:gw[r]?e.length>1?{type:gw[r],data:e.substring(1)}:{type:gw[r]}:rE},Kge=(e,t)=>{if(qge){const r=Xge(e);return xZ(r,t)}else return{base64:!0,data:e}},xZ=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bZ="",Zge=(e,t)=>{const r=e.length,n=new Array(r);let a=0;e.forEach((i,o)=>{_j(i,!1,s=>{n[o]=s,++a===r&&t(n.join(bZ))})})},Jge=(e,t)=>{const r=e.split(bZ),n=[];for(let a=0;a<r.length;a++){const i=Sj(r[a],t);if(n.push(i),i.type==="error")break}return n};function Qge(){return new TransformStream({transform(e,t){Yge(e,r=>{const n=r.length;let a;if(n<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,n);else if(n<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(r)})}})}let IA;function hb(e){return e.reduce((t,r)=>t+r.length,0)}function pb(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let a=0;a<t;a++)r[a]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function eye(e,t){IA||(IA=new TextDecoder);const r=[];let n=0,a=-1,i=!1;return new TransformStream({transform(o,s){for(r.push(o);;){if(n===0){if(hb(r)<1)break;const l=pb(r,1);i=(l[0]&128)===128,a=l[0]&127,a<126?n=3:a===126?n=1:n=2}else if(n===1){if(hb(r)<2)break;const l=pb(r,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),n=3}else if(n===2){if(hb(r)<8)break;const l=pb(r,8),u=new DataView(l.buffer,l.byteOffset,l.length),c=u.getUint32(0);if(c>Math.pow(2,21)-1){s.enqueue(rE);break}a=c*Math.pow(2,32)+u.getUint32(4),n=3}else{if(hb(r)<a)break;const l=pb(r,a);s.enqueue(Sj(i?l:IA.decode(l),t)),n=0}if(a===0||a>e){s.enqueue(rE);break}}}})}const wZ=4;function Mr(e){if(e)return tye(e)}function tye(e){for(var t in Mr.prototype)e[t]=Mr.prototype[t];return e}Mr.prototype.on=Mr.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Mr.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Mr.prototype.off=Mr.prototype.removeListener=Mr.prototype.removeAllListeners=Mr.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,a=0;a<r.length;a++)if(n=r[a],n===t||n.fn===t){r.splice(a,1);break}return r.length===0&&delete this._callbacks["$"+e],this};Mr.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,a=r.length;n<a;++n)r[n].apply(this,t)}return this};Mr.prototype.emitReserved=Mr.prototype.emit;Mr.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Mr.prototype.hasListeners=function(e){return!!this.listeners(e).length};const aC=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0),oi=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),rye="arraybuffer";function _Z(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(r[n]=e[n]),r),{})}const nye=oi.setTimeout,aye=oi.clearTimeout;function iC(e,t){t.useNativeTimers?(e.setTimeoutFn=nye.bind(oi),e.clearTimeoutFn=aye.bind(oi)):(e.setTimeoutFn=oi.setTimeout.bind(oi),e.clearTimeoutFn=oi.clearTimeout.bind(oi))}const iye=1.33;function oye(e){return typeof e=="string"?sye(e):Math.ceil((e.byteLength||e.size)*iye)}function sye(e){let t=0,r=0;for(let n=0,a=e.length;n<a;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function SZ(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function lye(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function uye(e){let t={},r=e.split("&");for(let n=0,a=r.length;n<a;n++){let i=r[n].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class cye extends Error{constructor(t,r,n){super(t),this.description=r,this.context=n,this.type="TransportError"}}class Tj extends Mr{constructor(t){super(),this.writable=!1,iC(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,r,n){return super.emitReserved("error",new cye(t,r,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const r=Sj(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const r=lye(t);return r.length?"?"+r:""}}class fye extends Tj{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};Jge(t,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Zge(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=SZ()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}}let TZ=!1;try{TZ=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const dye=TZ;function hye(){}class pye extends fye{constructor(t){if(super(t),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}}doWrite(t,r){const n=this.request({method:"POST",data:t});n.on("success",r),n.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=t}}let Vh=class yw extends Mr{constructor(t,r,n){super(),this.createRequest=t,iC(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;const r=_Z(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&n.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var a;n.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=yw.requestsCount++,yw.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=hye,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete yw.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Vh.requestsCount=0;Vh.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",V3);else if(typeof addEventListener=="function"){const e="onpagehide"in oi?"pagehide":"unload";addEventListener(e,V3,!1)}}function V3(){for(let e in Vh.requests)Vh.requests.hasOwnProperty(e)&&Vh.requests[e].abort()}const vye=function(){const e=CZ({xdomain:!1});return e&&e.responseType!==null}();class gye extends pye{constructor(t){super(t);const r=t&&t.forceBase64;this.supportsBinary=vye&&!r}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Vh(CZ,this.uri(),t)}}function CZ(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||dye))return new XMLHttpRequest}catch{}if(!t)try{return new oi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const AZ=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yye extends Tj{get name(){return"websocket"}doOpen(){const t=this.uri(),r=this.opts.protocols,n=AZ?{}:_Z(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,r,n)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],a=r===t.length-1;_j(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{}a&&aC(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=SZ()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}}const jA=oi.WebSocket||oi.MozWebSocket;class mye extends yye{createSocket(t,r,n){return AZ?new jA(t,r,n):r?new jA(t,r):new jA(t)}doWrite(t,r){this.ws.send(r)}}class xye extends Tj{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const r=eye(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(r).getReader(),a=Qge();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{n.read().then(({done:s,value:l})=>{s||(this.onPacket(l),i())}).catch(s=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],a=r===t.length-1;this._writer.write(n).then(()=>{a&&aC(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const bye={websocket:mye,webtransport:xye,polling:gye},wye=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,_ye=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function nE(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let a=wye.exec(e||""),i={},o=14;for(;o--;)i[_ye[o]]=a[o]||"";return r!=-1&&n!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Sye(i,i.path),i.queryKey=Tye(i,i.query),i}function Sye(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Tye(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,a,i){a&&(r[a]=i)}),r}const aE=typeof addEventListener=="function"&&typeof removeEventListener=="function",mw=[];aE&&addEventListener("offline",()=>{mw.forEach(e=>e())},!1);class xu extends Mr{constructor(t,r){if(super(),this.binaryType=rye,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){const n=nE(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=nE(r.host).host);iC(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const a=n.prototype.name;this.transports.push(a),this._transportsByName[a]=n}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=uye(this.opts.query)),aE&&(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"})},mw.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=wZ,r.transport=t,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&xu.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(t);r.open(),this.setTransport(r)}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",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",xu.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":const r=new Error("server error");r.code=t.data,this._onError(r);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);const 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){const 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 r=1;for(let n=0;n<this.writeBuffer.length;n++){const a=this.writeBuffer[n].data;if(a&&(r+=oye(a)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,aC(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,a){if(typeof r=="function"&&(a=r,r=void 0),typeof n=="function"&&(a=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const i={type:t,data:r,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():t()}):this.upgrading?n():t()),this}_onError(t){if(xu.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,r){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(),aE&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=mw.indexOf(this._offlineEventListener);n!==-1&&mw.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}}xu.protocol=wZ;class Cye extends xu{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let r=this.createTransport(t),n=!1;xu.priorWebsocketSuccess=!1;const a=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;xu.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(c(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=r.name,this.emitReserved("upgradeError",d)}}))};function i(){n||(n=!0,c(),r.close(),r=null)}const o=f=>{const d=new Error("probe error: "+f);d.transport=r.name,i(),this.emitReserved("upgradeError",d)};function s(){o("transport closed")}function l(){o("socket closed")}function u(f){r&&f.name!==r.name&&i()}const c=()=>{r.removeListener("open",a),r.removeListener("error",o),r.removeListener("close",s),this.off("close",l),this.off("upgrading",u)};r.once("open",a),r.once("error",o),r.once("close",s),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const r=[];for(let n=0;n<t.length;n++)~this.transports.indexOf(t[n])&&r.push(t[n]);return r}}let Aye=class extends Cye{constructor(t,r={}){const n=typeof t=="object"?t:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(a=>bye[a]).filter(a=>!!a)),super(t,n)}};function kye(e,t="",r){let n=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),n=nE(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}const Mye=typeof ArrayBuffer=="function",Pye=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,kZ=Object.prototype.toString,Dye=typeof Blob=="function"||typeof Blob<"u"&&kZ.call(Blob)==="[object BlobConstructor]",Eye=typeof File=="function"||typeof File<"u"&&kZ.call(File)==="[object FileConstructor]";function Cj(e){return Mye&&(e instanceof ArrayBuffer||Pye(e))||Dye&&e instanceof Blob||Eye&&e instanceof File}function xw(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(xw(e[r]))return!0;return!1}if(Cj(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return xw(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&xw(e[r]))return!0;return!1}function Nye(e){const t=[],r=e.data,n=e;return n.data=iE(r,t),n.attachments=t.length,{packet:n,buffers:t}}function iE(e,t){if(!e)return e;if(Cj(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=iE(e[n],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=iE(e[n],t));return r}return e}function Oye(e,t){return e.data=oE(e.data,t),delete e.attachments,e}function oE(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=oE(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=oE(e[r],t));return e}const Lye=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var xt;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(xt||(xt={}));class Iye{constructor(t){this.replacer=t}encode(t){return(t.type===xt.EVENT||t.type===xt.ACK)&&xw(t)?this.encodeAsBinary({type:t.type===xt.EVENT?xt.BINARY_EVENT:xt.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===xt.BINARY_EVENT||t.type===xt.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=Nye(t),n=this.encodeAsString(r.packet),a=r.buffers;return a.unshift(n),a}}class Aj extends Mr{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const n=r.type===xt.BINARY_EVENT;n||r.type===xt.BINARY_ACK?(r.type=n?xt.EVENT:xt.ACK,this.reconstructor=new jye(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Cj(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const n={type:Number(t.charAt(0))};if(xt[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===xt.BINARY_EVENT||n.type===xt.BINARY_ACK){const i=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const o=t.substring(i,r);if(o!=Number(o)||t.charAt(r)!=="-")throw new Error("Illegal attachments");const s=Number(o);if(!Rye(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=s}if(t.charAt(r+1)==="/"){const i=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(i,r)}else n.nsp="/";const a=t.charAt(r+1);if(a!==""&&Number(a)==a){const i=r+1;for(;++r;){const o=t.charAt(r);if(o==null||Number(o)!=o){--r;break}if(r===t.length)break}n.id=Number(t.substring(i,r+1))}if(t.charAt(++r)){const i=this.tryParse(t.substr(r));if(Aj.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case xt.CONNECT:return W3(r);case xt.DISCONNECT:return r===void 0;case xt.CONNECT_ERROR:return typeof r=="string"||W3(r);case xt.EVENT:case xt.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&Lye.indexOf(r[0])===-1);case xt.ACK:case xt.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class jye{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=Oye(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Rye=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function W3(e){return Object.prototype.toString.call(e)==="[object Object]"}const zye=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Aj,Encoder:Iye,get PacketType(){return xt}},Symbol.toStringTag,{value:"Module"}));function Wi(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const $ye=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class MZ extends Mr{constructor(t,r,n){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=t,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Wi(t,"open",this.onopen.bind(this)),Wi(t,"packet",this.onpacket.bind(this)),Wi(t,"error",this.onerror.bind(this)),Wi(t,"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(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){var n,a,i;if($ye.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const o={type:xt.EVENT,data:r};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const c=this.ids++,f=r.pop();this._registerAckCallback(c,f),o.id=c}const s=(a=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||a===void 0?void 0:a.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,r){var n;const a=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(a===void 0){this.acks[t]=r;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);r.call(this,new Error("operation has timed out"))},a),o=(...s)=>{this.io.clearTimeoutFn(i),r.apply(this,s)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...r){return new Promise((n,a)=>{const i=(o,s)=>o?a(o):n(s);i.withError=!0,r.push(i),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>(this._queue[0],a!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(a)):(this._queue.shift(),r&&r(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:xt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(n=>String(n.id)===t)){const n=this.acks[t];delete this.acks[t],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case xt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.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 xt.EVENT:case xt.BINARY_EVENT:this.onevent(t);break;case xt.ACK:case xt.BINARY_ACK:this.onack(t);break;case xt.DISCONNECT:this.ondisconnect();break;case xt.CONNECT_ERROR:this.destroy();const n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const r=this;let n=!1;return function(...a){n||(n=!0,r.packet({type:xt.ACK,id:t,data:a}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(delete this.acks[t.id],r.withError&&t.data.unshift(null),r.apply(this,t.data))}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,t.data)}}}function lv(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}lv.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};lv.prototype.reset=function(){this.attempts=0};lv.prototype.setMin=function(e){this.ms=e};lv.prototype.setMax=function(e){this.max=e};lv.prototype.setJitter=function(e){this.jitter=e};class sE extends Mr{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,iC(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new lv({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const a=r.parser||zye;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Aye(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const a=Wi(r,"open",function(){n.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=Wi(r,"error",i);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),r.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Wi(t,"ping",this.onping.bind(this)),Wi(t,"data",this.ondata.bind(this)),Wi(t,"error",this.onerror.bind(this)),Wi(t,"close",this.onclose.bind(this)),Wi(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){aC(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new MZ(this,t,r),this.nsps[t]=n),n}_destroy(t){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let n=0;n<r.length;n++)this.engine.write(r[n],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const ug={};function bw(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=kye(e,t.path||"/socket.io"),n=r.source,a=r.id,i=r.path,o=ug[a]&&i in ug[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new sE(n,t):(ug[a]||(ug[a]=new sE(n,t)),l=ug[a]),r.query&&!t.query&&(t.query=r.queryKey),l.socket(r.path,t)}Object.assign(bw,{Manager:sE,Socket:MZ,io:bw,connect:bw});let Wh=null;const Uc=new Map,Om=new Set;function Bye(){var e;try{const t=localStorage.getItem("aura-connection");if(t){const r=JSON.parse(t);if((e=r.state)!=null&&e.ioBrokerUrl)return r.state.ioBrokerUrl}}catch{}return window.location.origin}let PZ=Bye();function Fye(e){const t=bw(e,{path:"/socket.io",transports:["websocket","polling"]});return t.on("connect",()=>{Om.forEach(r=>r(!0)),Uc.forEach((r,n)=>t.emit("subscribe",n))}),t.on("disconnect",()=>Om.forEach(r=>r(!1))),t.on("stateChange",(...r)=>{var i;const n=r[0],a=r[1];(i=Uc.get(n))==null||i.forEach(o=>o(a))}),t}function ni(){return Wh||(Wh=Fye(PZ)),Wh}function Vye(){Wh&&(Wh.disconnect(),Wh=null),Om.forEach(e=>e(!1)),ni()}async function DZ(e){PZ=e,Vye()}function $n(){const[e,t]=I.useState(()=>ni().connected);I.useEffect(()=>(t(ni().connected),Om.add(t),()=>{Om.delete(t)}),[]);const r=I.useCallback((o,s)=>(Uc.has(o)||(Uc.set(o,new Set),ni().emit("subscribe",o)),Uc.get(o).add(s),()=>{const l=Uc.get(o);l&&(l.delete(s),l.size===0&&(Uc.delete(o),ni().emit("unsubscribe",o)))}),[]),n=I.useCallback((o,s)=>{ni().emit("setState",o,{val:s,ack:!1})},[]),a=I.useCallback(o=>new Promise(s=>{ni().emit("getState",o,(l,u)=>s(u))}),[]),i=I.useCallback(o=>new Promise(s=>{ni().emit("getObjectView","system",o,{startkey:"",endkey:"香"},(l,u)=>s(u??{rows:[]}))}),[]);return{connected:e,subscribe:r,setState:n,getState:a,getObjectView:i}}function y_(e){return new Promise(t=>{ni().emit("getObject",e,(r,n)=>t(n??null))})}function EZ(e,t){return new Promise(r=>{ni().emit("getHistory",e,{instance:t.instance,start:t.start,end:t.end??Date.now(),count:t.count??1e3,step:t.step??null,aggregate:t.aggregate??"average",from:!1,ack:!1,q:!1,addID:!1,ignoreNull:!1},(n,a)=>r(a??[]))})}function H3(e,t="",r="香"){return new Promise(n=>{ni().emit("getObjectView","system",e,{startkey:t,endkey:r},(a,i)=>n(i??{rows:[]}))})}const Wye={},G3=e=>{let t;const r=new Set,n=(c,f)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(p=>p(t,h))}},a=()=>t,l={setState:n,getState:a,getInitialState:()=>u,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{(Wye?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},u=t=e(n,a,l);return l},Hye=e=>e?G3(e):G3;var NZ={exports:{}},OZ={},LZ={exports:{}},IZ={};/**
|
|
452
|
+
*/const Uge=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],il=Ce("zap",Uge),Jo=Object.create(null);Jo.open="0";Jo.close="1";Jo.ping="2";Jo.pong="3";Jo.message="4";Jo.upgrade="5";Jo.noop="6";const gw=Object.create(null);Object.keys(Jo).forEach(e=>{gw[Jo[e]]=e});const rE={type:"error",data:"parser error"},gZ=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yZ=typeof ArrayBuffer=="function",mZ=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_j=({type:e,data:t},r,n)=>gZ&&t instanceof Blob?r?n(t):$3(t,n):yZ&&(t instanceof ArrayBuffer||mZ(t))?r?n(t):$3(new Blob([t]),n):n(Jo[e]+(t||"")),$3=(e,t)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];t("b"+(n||""))},r.readAsDataURL(e)};function B3(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let LA;function Yge(e,t){if(gZ&&e.data instanceof Blob)return e.data.arrayBuffer().then(B3).then(t);if(yZ&&(e.data instanceof ArrayBuffer||mZ(e.data)))return t(B3(e.data));_j(e,!1,r=>{LA||(LA=new TextEncoder),t(LA.encode(r))})}const F3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fy=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<F3.length;e++)fy[F3.charCodeAt(e)]=e;const Xge=e=>{let t=e.length*.75,r=e.length,n,a=0,i,o,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),c=new Uint8Array(u);for(n=0;n<r;n+=4)i=fy[e.charCodeAt(n)],o=fy[e.charCodeAt(n+1)],s=fy[e.charCodeAt(n+2)],l=fy[e.charCodeAt(n+3)],c[a++]=i<<2|o>>4,c[a++]=(o&15)<<4|s>>2,c[a++]=(s&3)<<6|l&63;return u},qge=typeof ArrayBuffer=="function",Sj=(e,t)=>{if(typeof e!="string")return{type:"message",data:xZ(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:Kge(e.substring(1),t)}:gw[r]?e.length>1?{type:gw[r],data:e.substring(1)}:{type:gw[r]}:rE},Kge=(e,t)=>{if(qge){const r=Xge(e);return xZ(r,t)}else return{base64:!0,data:e}},xZ=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bZ="",Zge=(e,t)=>{const r=e.length,n=new Array(r);let a=0;e.forEach((i,o)=>{_j(i,!1,s=>{n[o]=s,++a===r&&t(n.join(bZ))})})},Jge=(e,t)=>{const r=e.split(bZ),n=[];for(let a=0;a<r.length;a++){const i=Sj(r[a],t);if(n.push(i),i.type==="error")break}return n};function Qge(){return new TransformStream({transform(e,t){Yge(e,r=>{const n=r.length;let a;if(n<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,n);else if(n<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(r)})}})}let IA;function hb(e){return e.reduce((t,r)=>t+r.length,0)}function pb(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let a=0;a<t;a++)r[a]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function eye(e,t){IA||(IA=new TextDecoder);const r=[];let n=0,a=-1,i=!1;return new TransformStream({transform(o,s){for(r.push(o);;){if(n===0){if(hb(r)<1)break;const l=pb(r,1);i=(l[0]&128)===128,a=l[0]&127,a<126?n=3:a===126?n=1:n=2}else if(n===1){if(hb(r)<2)break;const l=pb(r,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),n=3}else if(n===2){if(hb(r)<8)break;const l=pb(r,8),u=new DataView(l.buffer,l.byteOffset,l.length),c=u.getUint32(0);if(c>Math.pow(2,21)-1){s.enqueue(rE);break}a=c*Math.pow(2,32)+u.getUint32(4),n=3}else{if(hb(r)<a)break;const l=pb(r,a);s.enqueue(Sj(i?l:IA.decode(l),t)),n=0}if(a===0||a>e){s.enqueue(rE);break}}}})}const wZ=4;function Mr(e){if(e)return tye(e)}function tye(e){for(var t in Mr.prototype)e[t]=Mr.prototype[t];return e}Mr.prototype.on=Mr.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Mr.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Mr.prototype.off=Mr.prototype.removeListener=Mr.prototype.removeAllListeners=Mr.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,a=0;a<r.length;a++)if(n=r[a],n===t||n.fn===t){r.splice(a,1);break}return r.length===0&&delete this._callbacks["$"+e],this};Mr.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,a=r.length;n<a;++n)r[n].apply(this,t)}return this};Mr.prototype.emitReserved=Mr.prototype.emit;Mr.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Mr.prototype.hasListeners=function(e){return!!this.listeners(e).length};const aC=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0),oi=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),rye="arraybuffer";function _Z(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(r[n]=e[n]),r),{})}const nye=oi.setTimeout,aye=oi.clearTimeout;function iC(e,t){t.useNativeTimers?(e.setTimeoutFn=nye.bind(oi),e.clearTimeoutFn=aye.bind(oi)):(e.setTimeoutFn=oi.setTimeout.bind(oi),e.clearTimeoutFn=oi.clearTimeout.bind(oi))}const iye=1.33;function oye(e){return typeof e=="string"?sye(e):Math.ceil((e.byteLength||e.size)*iye)}function sye(e){let t=0,r=0;for(let n=0,a=e.length;n<a;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function SZ(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function lye(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function uye(e){let t={},r=e.split("&");for(let n=0,a=r.length;n<a;n++){let i=r[n].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class cye extends Error{constructor(t,r,n){super(t),this.description=r,this.context=n,this.type="TransportError"}}class Tj extends Mr{constructor(t){super(),this.writable=!1,iC(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,r,n){return super.emitReserved("error",new cye(t,r,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const r=Sj(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const r=lye(t);return r.length?"?"+r:""}}class fye extends Tj{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};Jge(t,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Zge(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=SZ()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}}let TZ=!1;try{TZ=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const dye=TZ;function hye(){}class pye extends fye{constructor(t){if(super(t),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}}doWrite(t,r){const n=this.request({method:"POST",data:t});n.on("success",r),n.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=t}}let Vh=class yw extends Mr{constructor(t,r,n){super(),this.createRequest=t,iC(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;const r=_Z(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&n.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var a;n.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=yw.requestsCount++,yw.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=hye,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete yw.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Vh.requestsCount=0;Vh.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",V3);else if(typeof addEventListener=="function"){const e="onpagehide"in oi?"pagehide":"unload";addEventListener(e,V3,!1)}}function V3(){for(let e in Vh.requests)Vh.requests.hasOwnProperty(e)&&Vh.requests[e].abort()}const vye=function(){const e=CZ({xdomain:!1});return e&&e.responseType!==null}();class gye extends pye{constructor(t){super(t);const r=t&&t.forceBase64;this.supportsBinary=vye&&!r}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Vh(CZ,this.uri(),t)}}function CZ(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||dye))return new XMLHttpRequest}catch{}if(!t)try{return new oi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const AZ=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yye extends Tj{get name(){return"websocket"}doOpen(){const t=this.uri(),r=this.opts.protocols,n=AZ?{}:_Z(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,r,n)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],a=r===t.length-1;_j(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{}a&&aC(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=SZ()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}}const jA=oi.WebSocket||oi.MozWebSocket;class mye extends yye{createSocket(t,r,n){return AZ?new jA(t,r,n):r?new jA(t,r):new jA(t)}doWrite(t,r){this.ws.send(r)}}class xye extends Tj{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const r=eye(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(r).getReader(),a=Qge();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{n.read().then(({done:s,value:l})=>{s||(this.onPacket(l),i())}).catch(s=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],a=r===t.length-1;this._writer.write(n).then(()=>{a&&aC(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const bye={websocket:mye,webtransport:xye,polling:gye},wye=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,_ye=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function nE(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let a=wye.exec(e||""),i={},o=14;for(;o--;)i[_ye[o]]=a[o]||"";return r!=-1&&n!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Sye(i,i.path),i.queryKey=Tye(i,i.query),i}function Sye(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Tye(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,a,i){a&&(r[a]=i)}),r}const aE=typeof addEventListener=="function"&&typeof removeEventListener=="function",mw=[];aE&&addEventListener("offline",()=>{mw.forEach(e=>e())},!1);class xu extends Mr{constructor(t,r){if(super(),this.binaryType=rye,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){const n=nE(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=nE(r.host).host);iC(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const a=n.prototype.name;this.transports.push(a),this._transportsByName[a]=n}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=uye(this.opts.query)),aE&&(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"})},mw.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=wZ,r.transport=t,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&xu.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(t);r.open(),this.setTransport(r)}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",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",xu.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":const r=new Error("server error");r.code=t.data,this._onError(r);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);const 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){const 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 r=1;for(let n=0;n<this.writeBuffer.length;n++){const a=this.writeBuffer[n].data;if(a&&(r+=oye(a)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,aC(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,a){if(typeof r=="function"&&(a=r,r=void 0),typeof n=="function"&&(a=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const i={type:t,data:r,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():t()}):this.upgrading?n():t()),this}_onError(t){if(xu.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,r){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(),aE&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=mw.indexOf(this._offlineEventListener);n!==-1&&mw.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}}xu.protocol=wZ;class Cye extends xu{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let r=this.createTransport(t),n=!1;xu.priorWebsocketSuccess=!1;const a=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;xu.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(c(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=r.name,this.emitReserved("upgradeError",d)}}))};function i(){n||(n=!0,c(),r.close(),r=null)}const o=f=>{const d=new Error("probe error: "+f);d.transport=r.name,i(),this.emitReserved("upgradeError",d)};function s(){o("transport closed")}function l(){o("socket closed")}function u(f){r&&f.name!==r.name&&i()}const c=()=>{r.removeListener("open",a),r.removeListener("error",o),r.removeListener("close",s),this.off("close",l),this.off("upgrading",u)};r.once("open",a),r.once("error",o),r.once("close",s),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const r=[];for(let n=0;n<t.length;n++)~this.transports.indexOf(t[n])&&r.push(t[n]);return r}}let Aye=class extends Cye{constructor(t,r={}){const n=typeof t=="object"?t:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(a=>bye[a]).filter(a=>!!a)),super(t,n)}};function kye(e,t="",r){let n=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),n=nE(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}const Mye=typeof ArrayBuffer=="function",Pye=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,kZ=Object.prototype.toString,Dye=typeof Blob=="function"||typeof Blob<"u"&&kZ.call(Blob)==="[object BlobConstructor]",Eye=typeof File=="function"||typeof File<"u"&&kZ.call(File)==="[object FileConstructor]";function Cj(e){return Mye&&(e instanceof ArrayBuffer||Pye(e))||Dye&&e instanceof Blob||Eye&&e instanceof File}function xw(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(xw(e[r]))return!0;return!1}if(Cj(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return xw(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&xw(e[r]))return!0;return!1}function Nye(e){const t=[],r=e.data,n=e;return n.data=iE(r,t),n.attachments=t.length,{packet:n,buffers:t}}function iE(e,t){if(!e)return e;if(Cj(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=iE(e[n],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=iE(e[n],t));return r}return e}function Oye(e,t){return e.data=oE(e.data,t),delete e.attachments,e}function oE(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=oE(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=oE(e[r],t));return e}const Lye=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var xt;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(xt||(xt={}));class Iye{constructor(t){this.replacer=t}encode(t){return(t.type===xt.EVENT||t.type===xt.ACK)&&xw(t)?this.encodeAsBinary({type:t.type===xt.EVENT?xt.BINARY_EVENT:xt.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===xt.BINARY_EVENT||t.type===xt.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=Nye(t),n=this.encodeAsString(r.packet),a=r.buffers;return a.unshift(n),a}}class Aj extends Mr{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const n=r.type===xt.BINARY_EVENT;n||r.type===xt.BINARY_ACK?(r.type=n?xt.EVENT:xt.ACK,this.reconstructor=new jye(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Cj(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const n={type:Number(t.charAt(0))};if(xt[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===xt.BINARY_EVENT||n.type===xt.BINARY_ACK){const i=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const o=t.substring(i,r);if(o!=Number(o)||t.charAt(r)!=="-")throw new Error("Illegal attachments");const s=Number(o);if(!Rye(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=s}if(t.charAt(r+1)==="/"){const i=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(i,r)}else n.nsp="/";const a=t.charAt(r+1);if(a!==""&&Number(a)==a){const i=r+1;for(;++r;){const o=t.charAt(r);if(o==null||Number(o)!=o){--r;break}if(r===t.length)break}n.id=Number(t.substring(i,r+1))}if(t.charAt(++r)){const i=this.tryParse(t.substr(r));if(Aj.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case xt.CONNECT:return W3(r);case xt.DISCONNECT:return r===void 0;case xt.CONNECT_ERROR:return typeof r=="string"||W3(r);case xt.EVENT:case xt.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&Lye.indexOf(r[0])===-1);case xt.ACK:case xt.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class jye{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=Oye(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Rye=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function W3(e){return Object.prototype.toString.call(e)==="[object Object]"}const zye=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Aj,Encoder:Iye,get PacketType(){return xt}},Symbol.toStringTag,{value:"Module"}));function Wi(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const $ye=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class MZ extends Mr{constructor(t,r,n){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=t,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Wi(t,"open",this.onopen.bind(this)),Wi(t,"packet",this.onpacket.bind(this)),Wi(t,"error",this.onerror.bind(this)),Wi(t,"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(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){var n,a,i;if($ye.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const o={type:xt.EVENT,data:r};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const c=this.ids++,f=r.pop();this._registerAckCallback(c,f),o.id=c}const s=(a=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||a===void 0?void 0:a.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,r){var n;const a=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(a===void 0){this.acks[t]=r;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);r.call(this,new Error("operation has timed out"))},a),o=(...s)=>{this.io.clearTimeoutFn(i),r.apply(this,s)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...r){return new Promise((n,a)=>{const i=(o,s)=>o?a(o):n(s);i.withError=!0,r.push(i),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>(this._queue[0],a!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(a)):(this._queue.shift(),r&&r(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:xt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(n=>String(n.id)===t)){const n=this.acks[t];delete this.acks[t],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case xt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.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 xt.EVENT:case xt.BINARY_EVENT:this.onevent(t);break;case xt.ACK:case xt.BINARY_ACK:this.onack(t);break;case xt.DISCONNECT:this.ondisconnect();break;case xt.CONNECT_ERROR:this.destroy();const n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const r=this;let n=!1;return function(...a){n||(n=!0,r.packet({type:xt.ACK,id:t,data:a}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(delete this.acks[t.id],r.withError&&t.data.unshift(null),r.apply(this,t.data))}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,t.data)}}}function lv(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}lv.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};lv.prototype.reset=function(){this.attempts=0};lv.prototype.setMin=function(e){this.ms=e};lv.prototype.setMax=function(e){this.max=e};lv.prototype.setJitter=function(e){this.jitter=e};class sE extends Mr{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,iC(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new lv({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const a=r.parser||zye;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Aye(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const a=Wi(r,"open",function(){n.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=Wi(r,"error",i);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),r.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Wi(t,"ping",this.onping.bind(this)),Wi(t,"data",this.ondata.bind(this)),Wi(t,"error",this.onerror.bind(this)),Wi(t,"close",this.onclose.bind(this)),Wi(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){aC(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new MZ(this,t,r),this.nsps[t]=n),n}_destroy(t){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let n=0;n<r.length;n++)this.engine.write(r[n],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const ug={};function bw(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=kye(e,t.path||"/socket.io"),n=r.source,a=r.id,i=r.path,o=ug[a]&&i in ug[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new sE(n,t):(ug[a]||(ug[a]=new sE(n,t)),l=ug[a]),r.query&&!t.query&&(t.query=r.queryKey),l.socket(r.path,t)}Object.assign(bw,{Manager:sE,Socket:MZ,io:bw,connect:bw});let Wh=null;const Uc=new Map,Om=new Set;function Bye(){var e;try{const t=localStorage.getItem("aura-connection");if(t){const r=JSON.parse(t);if((e=r.state)!=null&&e.ioBrokerUrl)return r.state.ioBrokerUrl}}catch{}return`${window.location.protocol}//${window.location.hostname}:8084`}let PZ=Bye();function Fye(e){const t=bw(e,{path:"/socket.io",transports:["websocket","polling"]});return t.on("connect",()=>{Om.forEach(r=>r(!0)),Uc.forEach((r,n)=>t.emit("subscribe",n))}),t.on("disconnect",()=>Om.forEach(r=>r(!1))),t.on("stateChange",(...r)=>{var i;const n=r[0],a=r[1];(i=Uc.get(n))==null||i.forEach(o=>o(a))}),t}function ni(){return Wh||(Wh=Fye(PZ)),Wh}function Vye(){Wh&&(Wh.disconnect(),Wh=null),Om.forEach(e=>e(!1)),ni()}async function DZ(e){PZ=e,Vye()}function $n(){const[e,t]=I.useState(()=>ni().connected);I.useEffect(()=>(t(ni().connected),Om.add(t),()=>{Om.delete(t)}),[]);const r=I.useCallback((o,s)=>(Uc.has(o)||(Uc.set(o,new Set),ni().emit("subscribe",o)),Uc.get(o).add(s),()=>{const l=Uc.get(o);l&&(l.delete(s),l.size===0&&(Uc.delete(o),ni().emit("unsubscribe",o)))}),[]),n=I.useCallback((o,s)=>{ni().emit("setState",o,{val:s,ack:!1})},[]),a=I.useCallback(o=>new Promise(s=>{ni().emit("getState",o,(l,u)=>s(u))}),[]),i=I.useCallback(o=>new Promise(s=>{ni().emit("getObjectView","system",o,{startkey:"",endkey:"香"},(l,u)=>s(u??{rows:[]}))}),[]);return{connected:e,subscribe:r,setState:n,getState:a,getObjectView:i}}function y_(e){return new Promise(t=>{ni().emit("getObject",e,(r,n)=>t(n??null))})}function EZ(e,t){return new Promise(r=>{ni().emit("getHistory",e,{instance:t.instance,start:t.start,end:t.end??Date.now(),count:t.count??1e3,step:t.step??null,aggregate:t.aggregate??"average",from:!1,ack:!1,q:!1,addID:!1,ignoreNull:!1},(n,a)=>r(a??[]))})}function H3(e,t="",r="香"){return new Promise(n=>{ni().emit("getObjectView","system",e,{startkey:t,endkey:r},(a,i)=>n(i??{rows:[]}))})}const Wye={},G3=e=>{let t;const r=new Set,n=(c,f)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(p=>p(t,h))}},a=()=>t,l={setState:n,getState:a,getInitialState:()=>u,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{(Wye?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},u=t=e(n,a,l);return l},Hye=e=>e?G3(e):G3;var NZ={exports:{}},OZ={},LZ={exports:{}},IZ={};/**
|
|
453
453
|
* @license React
|
|
454
454
|
* use-sync-external-store-shim.production.js
|
|
455
455
|
*
|
|
@@ -605,7 +605,7 @@ yyyy`);var n=ps(t),a=r?"getUTC":"get",i=n[a+"FullYear"](),o=n[a+"Month"]()+1,s=n
|
|
|
605
605
|
.widget-card:hover { transform: scale(1.02); }
|
|
606
606
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');
|
|
607
607
|
body { font-family: 'Inter', sans-serif; }`,className:"w-full rounded-xl px-4 py-3 text-xs font-mono focus:outline-none resize-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)",lineHeight:1.7}}),m.jsx("p",{className:"text-xs mt-2",style:{color:"var(--text-secondary)"},children:i.customCSS.trim()?`${i.customCSS.split(`
|
|
608
|
-
`).length} Zeilen`:"Kein Custom CSS"})]})]})}const Pct="http://192.168.188.168:8082",Dct=uv()(cv(e=>({ioBrokerUrl:Pct,setIoBrokerUrl:t=>{ube(),DZ(t),e({ioBrokerUrl:t})}}),{name:"aura-connection"}));async function Ect(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Nct({value:e,onChange:t}){return m.jsx("button",{onClick:()=>t(!e),className:"relative w-9 h-5 rounded-full transition-colors duration-200 focus:outline-none shrink-0",style:{background:e?"var(--accent-green)":"var(--app-border)"},children:m.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ${e?"translate-x-4":"translate-x-0"}`})})}function ZY({label:e,value:t,onChange:r}){return m.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-b-0",style:{borderColor:"var(--app-border)"},children:[m.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),m.jsx(Nct,{value:t,onChange:r})]})}function Dy({title:e,children:t}){return m.jsxs("div",{className:"rounded-xl p-4 space-y-3",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[m.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest",style:{color:"var(--text-secondary)"},children:e}),t]})}function tD({label:e,value:t,min:r,max:n,step:a,unit:i="",onChange:o,presets:s}){return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center justify-between mb-1",children:[m.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),m.jsxs("span",{className:"text-xs font-mono font-bold px-2 py-0.5 rounded-md",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[t,i]})]}),m.jsx("input",{type:"range",min:r,max:n,step:a,value:t,onChange:l=>o(Number(l.target.value)),className:"w-full accent-[var(--accent)] mb-2"}),m.jsx("div",{className:"flex gap-1.5 flex-wrap",children:s.map(l=>{const u=t===l.value;return m.jsx("button",{onClick:()=>o(l.value),className:"px-2.5 py-1 rounded-lg text-xs font-medium hover:opacity-80",style:{background:u?"var(--accent)":"var(--app-bg)",color:u?"#fff":"var(--text-secondary)",border:`1px solid ${u?"var(--accent)":"var(--app-border)"}`},children:l.label},l.value)})})]})}function Oct(){const{pinHash:e}=ed(),{ioBrokerUrl:t,setIoBrokerUrl:r}=Dct(),[n,a]=I.useState(!1),[i,o]=I.useState(""),[s,l]=I.useState(""),[u,c]=I.useState(t),[f,d]=I.useState(!1),h=async v=>{v.preventDefault(),await Ect(i)===e?(a(!0),l(""),o("")):l("Falscher PIN")},p=async()=>{const v=u.trim();v&&(r(v),await DZ(v),d(!0),setTimeout(()=>d(!1),2500))};return m.jsxs(Dy,{title:"Experten",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[n?m.jsx(qve,{size:14,style:{color:"var(--accent-yellow)"}}):m.jsx(cZ,{size:14,style:{color:"var(--text-secondary)"}}),m.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:n?"Entsperrt":"Zugang mit Admin-PIN"})]}),n?m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{children:[m.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"ioBroker Web-Adapter URL"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{type:"text",value:u,onChange:v=>{c(v.target.value),d(!1)},className:"flex-1 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),m.jsxs("button",{onClick:p,disabled:u.trim()===t&&!f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80 disabled:opacity-40 shrink-0",style:{background:f?"var(--accent-green)":"var(--accent)"},children:[m.jsx(xj,{size:12}),f?"OK":"Verbinden"]})]})]}),m.jsx("button",{onClick:()=>a(!1),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Sperren"})]}):m.jsxs("form",{onSubmit:h,className:"flex gap-2",children:[m.jsx("input",{type:"password",value:i,onChange:v=>{o(v.target.value),l("")},placeholder:"Admin-PIN",className:"flex-1 rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:`1px solid ${s?"var(--accent-red)":"var(--app-border)"}`}}),m.jsx("button",{type:"submit",className:"px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Entsperren"})]})]})}function Lct(){const e=fv().tabs,{frontend:t,updateFrontend:r}=so(),[n,a]=I.useState(""),[i,o]=I.useState(""),[s,l]=I.useState(!1),[u,c]=I.useState(""),[f,d]=I.useState(!1),h=async g=>{if(g.preventDefault(),n.length<4){c("Mindestens 4 Zeichen");return}if(n!==i){c("PINs stimmen nicht überein");return}await Eue(n),c("PIN erfolgreich geändert"),a(""),o(""),setTimeout(()=>c(""),3e3)},p=()=>{const g={dashboard:JSON.parse(localStorage.getItem("aura-dashboard")??"{}"),theme:JSON.parse(localStorage.getItem("aura-theme")??"{}"),config:JSON.parse(localStorage.getItem("aura-config")??"{}"),exported:new Date().toISOString()},y=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),x=URL.createObjectURL(y),b=document.createElement("a");b.href=x,b.download=`aura-backup-${Date.now()}.json`,b.click(),URL.revokeObjectURL(x)},v=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];if(!y)return;const x=new FileReader;x.onload=w=>{var _;try{const S=JSON.parse((_=w.target)==null?void 0:_.result);S.dashboard&&localStorage.setItem("aura-dashboard",JSON.stringify(S.dashboard)),S.theme&&localStorage.setItem("aura-theme",JSON.stringify(S.theme)),S.config&&localStorage.setItem("aura-config",JSON.stringify(S.config)),window.location.reload()}catch{alert("Ungültige Backup-Datei")}},x.readAsText(y)};return m.jsxs("div",{className:"p-5 max-w-3xl space-y-4",children:[m.jsxs("div",{children:[m.jsx("h1",{className:"text-lg font-bold",style:{color:"var(--text-primary)"},children:"Einstellungen"}),m.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-secondary)"},children:"Frontend, Grid, Sicherheit und Backup"})]}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[m.jsxs(Dy,{title:"Frontend",children:[m.jsx(ZY,{label:"Header anzeigen",value:t.showHeader,onChange:g=>r({showHeader:g})}),t.showHeader&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"py-2 border-b",style:{borderColor:"var(--app-border)"},children:[m.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Dashboard-Titel"}),m.jsx("input",{value:t.headerTitle,onChange:g=>r({headerTitle:g.target.value}),className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),m.jsx(ZY,{label:"Verbindungsstatus",value:t.showConnectionBadge,onChange:g=>r({showConnectionBadge:g})})]})]}),m.jsxs(Dy,{title:"Grid & Mobil",children:[m.jsx(tD,{label:"Zeilenhöhe",value:t.gridRowHeight??80,min:30,max:160,step:10,unit:" px",onChange:g=>r({gridRowHeight:g}),presets:[{label:"XS·40",value:40},{label:"S·60",value:60},{label:"M·80",value:80},{label:"L·100",value:100},{label:"XL·120",value:120}]}),m.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:m.jsx(tD,{label:"Mobile-Breakpoint",value:t.mobileBreakpoint??600,min:0,max:1024,step:10,unit:" px",onChange:g=>r({mobileBreakpoint:g}),presets:[{label:"480",value:480},{label:"600",value:600},{label:"768",value:768},{label:"Aus",value:0}]})}),m.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:m.jsx(tD,{label:"Wizard Max-Datenpunkte",value:t.wizardMaxDatapoints??500,min:100,max:5e3,step:100,onChange:g=>r({wizardMaxDatapoints:g}),presets:[{label:"200",value:200},{label:"500",value:500},{label:"1k",value:1e3},{label:"2k",value:2e3},{label:"5k",value:5e3}]})})]})]}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[m.jsx(Dy,{title:"Admin-PIN",children:m.jsxs("form",{onSubmit:h,className:"space-y-2",children:[m.jsxs("div",{className:"relative",children:[m.jsx("input",{type:s?"text":"password",value:n,onChange:g=>a(g.target.value),placeholder:"Neuer PIN (min. 4 Zeichen)",className:"w-full rounded-lg px-3 py-2 pr-9 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),m.jsx("button",{type:"button",onClick:()=>l(g=>!g),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:s?m.jsx(gj,{size:13}):m.jsx(nZ,{size:13})})]}),m.jsx("input",{type:s?"text":"password",value:i,onChange:g=>o(g.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),u&&m.jsx("p",{className:"text-xs",style:{color:u.includes("erfolgreich")?"var(--accent-green)":"var(--accent-red)"},children:u}),m.jsx("button",{type:"submit",className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"PIN speichern"})]})}),m.jsxs(Dy,{title:"Backup & Restore",children:[m.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Dashboard (",e.length," Tab",e.length!==1?"s":"","), Theme und Config als JSON."]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{onClick:p,className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Download Backup"}),m.jsxs("label",{className:"px-4 py-2 rounded-lg text-sm font-medium text-center cursor-pointer hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:["Backup importieren",m.jsx("input",{type:"file",accept:".json",onChange:v,className:"hidden"})]})]})]})]}),m.jsx(Oct,{}),m.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--app-surface)",border:"1px solid var(--accent-red)44"},children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsx(jge,{size:15,style:{color:"var(--accent-red)"}}),m.jsx("p",{className:"text-sm font-semibold",style:{color:"var(--accent-red)"},children:"Alles zurücksetzen"})]}),m.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-secondary)"},children:"Löscht alle Dashboards, Widgets, Themes und Einstellungen. Nicht rückgängig."}),f?m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:()=>{["aura-dashboard","aura-theme","aura-config"].forEach(g=>localStorage.removeItem(g)),window.location.href="/"},className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Ja, alles löschen"}),m.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"})]}):m.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--accent-red)22",color:"var(--accent-red)",border:"1px solid var(--accent-red)44"},children:"Zurücksetzen…"})]})]})}function Ict(e,t){if(!e)return t==="boolean"?"switch":"value";const r=e.toLowerCase();return r==="switch"||r==="button"||r.startsWith("switch.")||r==="indicator"?"switch":r.includes("dimmer")||r.includes("brightness")||r==="level"||r.startsWith("level.")?"dimmer":r.includes("temperature")&&r.includes("level")?"thermostat":r.includes("temperature")?"value":t==="boolean"?"switch":"value"}function JY(e){const t=e.common.name;return t?typeof t=="string"?t:t.de??t.en??Object.values(t)[0]??e._id:e._id.split(".").pop()??e._id}function QY(e){const t=e.split(".");return t.length>=2?`${t[0]}.${t[1]}`:t[0]}function Nue(){const{getObjectView:e}=$n(),[t,r]=I.useState([]),[n,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useCallback(async()=>{a(!0);try{const[l,u,c]=await Promise.all([e("device"),e("channel"),e("state")]),f=new Map;for(const{value:p}of c.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");f.has(g)||f.set(g,[]),f.get(g).push({id:p._id,obj:p,suggestedWidget:Ict(p.common.role,p.common.type),unit:p.common.unit})}const d=[];for(const{value:p}of l.rows){if(!p)continue;const v=[];for(const[g,y]of f.entries())(g===p._id||g.startsWith(p._id+"."))&&v.push(...y);v.length!==0&&d.push({id:p._id,name:JY(p),adapter:QY(p._id),states:v})}const h=new Set(d.map(p=>p.id));for(const{value:p}of u.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");if(h.has(g))continue;const y=f.get(p._id)??[];y.length!==0&&d.push({id:p._id,name:JY(p),adapter:QY(p._id),states:y})}d.sort((p,v)=>p.adapter.localeCompare(v.adapter)||p.name.localeCompare(v.name)),r(d),o(!0)}finally{a(!1)}},[e]);return{devices:t,loading:n,loaded:i,load:s}}const jct={switch:m.jsx(il,{size:13}),value:m.jsx(tf,{size:13}),dimmer:m.jsx(hZ,{size:13}),thermostat:m.jsx(bf,{size:13}),chart:m.jsx(yu,{size:13}),list:m.jsx(uZ,{size:13}),clock:m.jsx(tZ,{size:13}),calendar:m.jsx(Em,{size:13}),header:m.jsx(oZ,{size:13}),group:m.jsx(yj,{size:13}),echart:m.jsx(yu,{size:13}),evcc:m.jsx(il,{size:13}),weather:m.jsx(_ve,{size:13}),gauge:m.jsx(Lve,{size:13}),camera:m.jsx(v_,{size:13})},Rct={switch:{t:"Wohnzimmer",v:"AN"},value:{t:"Temperatur",v:"21.5",u:"°C"},dimmer:{t:"Licht",v:"75",u:"%"},thermostat:{t:"Heizung",v:"21.0",sub:"Ist: 19.5°"},chart:{t:"Verbrauch",v:"245",u:"W"},list:{t:"Alle Geräte",v:""},clock:{t:"Uhrzeit",v:"12:34"},calendar:{t:"Kalender",v:"3"},header:{t:"Abschnitt",v:""},group:{t:"Gruppe",v:""},echart:{t:"EChart",v:""},evcc:{t:"evcc",v:""},weather:{t:"Wetter",v:"18°",sub:"⛅ Bewölkt"},gauge:{t:"Gauge",v:"72",u:"kW"},camera:{t:"Kamera",v:""}};function ew({on:e}){return m.jsx("div",{className:"relative w-8 h-4 rounded-full shrink-0",style:{background:e!==!1?"var(--accent-green)":"var(--app-border)"},children:m.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow",style:{left:e!==!1?"18px":"2px",transition:"left 0.15s"}})})}function zct({type:e,layout:t,title:r}){const n=Rct[e],a=r||n.t,i=jct[e];if(e==="clock")return t==="minimal"||t==="card"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[m.jsx("p",{className:"text-3xl font-black tabular-nums leading-none",style:{color:"var(--accent)"},children:"12:34"}),t==="card"&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("p",{className:"text-xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),m.jsx("span",{style:{color:"var(--app-border)"},children:"·"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Mo., 7. Apr."})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a}),m.jsxs("div",{children:[m.jsx("p",{className:"text-2xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]})]});if(e==="calendar"){const o=[{label:"Team-Meeting",date:"Heute, 10:00",dot:"var(--accent)"},{label:"Zahnarzt",date:"Morgen, 14:30",dot:"var(--accent-green)"},{label:"Geburtstag Lisa",date:"Mi, 9. Apr",dot:"var(--accent-yellow)"}];return t==="minimal"||t==="card"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:"3"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Termine"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx(Em,{size:16,style:{color:"var(--accent)"}}),m.jsxs("div",{children:[m.jsx("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Team-Meeting"}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--accent)"},children:"Heute, 10:00"})]})]}):t==="agenda"?m.jsxs("div",{className:"flex flex-col h-full gap-0.5",children:[m.jsx("p",{className:"text-[11px] font-medium mb-0.5",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("div",{className:"w-0.5 self-stretch rounded-full shrink-0",style:{background:s.dot}}),m.jsxs("span",{className:"text-[8px] w-8 truncate shrink-0",style:{color:s.dot},children:["Cal ",l+1]}),m.jsx("p",{className:"flex-1 text-[9px] font-medium truncate",style:{color:"var(--text-primary)"},children:s.label}),m.jsx("p",{className:"text-[8px] shrink-0",style:{color:"var(--text-secondary)"},children:s.date.split(", ")[1]??s.date})]},l))]}):m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>m.jsxs("div",{className:"flex items-start gap-1.5",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full mt-1 shrink-0",style:{background:s.dot}}),m.jsxs("div",{children:[m.jsx("p",{className:"text-[10px] font-medium leading-tight",style:{color:"var(--text-primary)"},children:s.label}),m.jsx("p",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:s.date})]})]},l))]})}if(e==="weather")return t==="minimal"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsx("span",{style:{fontSize:"2rem",lineHeight:1},children:"⛅"}),m.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1},children:"⛅"}),m.jsx("span",{className:"text-xl font-bold",style:{color:"var(--text-primary)"},children:"18°"}),m.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Bewölkt"})]}):m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:"⛅"}),m.jsxs("div",{children:[m.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"}),m.jsx("span",{className:"text-[11px] ml-1",style:{color:"var(--text-secondary)"},children:"Bewölkt"}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Gefühlt 15°"})]})]}),m.jsxs("div",{className:"text-[10px] flex gap-2",style:{color:"var(--text-secondary)"},children:[m.jsx("span",{children:"💧 65%"}),m.jsx("span",{children:"💨 12 km/h"})]}),m.jsx("div",{className:"flex gap-1 pt-1",style:{borderTop:"1px solid var(--app-border)"},children:[["Mo","☁️","18°"],["Di","🌧️","15°"],["Mi","☀️","22°"]].map(([o,s,l])=>m.jsxs("div",{className:"flex-1 flex flex-col items-center",style:{fontSize:"9px",color:"var(--text-secondary)"},children:[m.jsx("span",{children:o}),m.jsx("span",{style:{fontSize:"11px"},children:s}),m.jsx("span",{style:{color:"var(--text-primary)",fontWeight:"bold"},children:l})]},o))})]});if(e==="gauge")return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsxs("svg",{viewBox:"0 0 200 120",style:{width:120,height:72},children:[m.jsx("path",{d:"M 20 100 A 80 80 0 0 1 180 100",fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),m.jsx("path",{d:"M 20 100 A 80 80 0 0 1 131.13 33.57",fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),m.jsx("text",{x:100,y:95,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:"72"}),m.jsx("text",{x:100,y:110,textAnchor:"middle",fontSize:10,fill:"var(--text-secondary)",children:n.u})]}),a&&m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="camera")return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",style:{background:"var(--app-bg)",borderRadius:4},children:[m.jsx(v_,{size:20,style:{color:"var(--text-secondary)"}}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="chart"){const o=[40,60,45,75,55,80,65,90,70];return m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsx("div",{className:"flex-1 flex items-end gap-0.5",children:o.map((s,l)=>m.jsx("div",{className:"flex-1 rounded-sm",style:{height:`${s}%`,background:l===o.length-1?"var(--accent)":"color-mix(in srgb, var(--accent) 45%, transparent)"}},l))}),m.jsxs("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:[n.v,n.u&&m.jsxs("span",{style:{color:"var(--text-secondary)",fontWeight:400},children:[" ",n.u]})]})]})}return e==="list"?m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium truncate",style:{color:"var(--text-secondary)"},children:a}),["Gerät 1","Gerät 2","Gerät 3"].map((o,s)=>m.jsxs("div",{className:"flex items-center justify-between px-1.5 py-0.5 rounded",style:{background:"var(--app-bg)"},children:[m.jsx("span",{className:"text-[10px]",style:{color:"var(--text-primary)"},children:o}),m.jsx(ew,{on:s===0})]},s))]}):t==="card"?e==="switch"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 rounded-md",style:{background:"color-mix(in srgb, var(--accent-green) 20%, transparent)"},children:[m.jsx(il,{size:26,style:{color:"var(--accent-green)"}}),m.jsx("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:a}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--accent-green)"},children:"AN"})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsx("span",{style:{color:"var(--accent)"},children:i})]}),m.jsxs("div",{children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u})]})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("span",{style:{color:"var(--text-secondary)",flexShrink:0},children:i}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-[10px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsxs("p",{className:"text-base font-bold leading-tight",style:{color:"var(--text-primary)"},children:[n.v,n.u&&m.jsx("span",{className:"text-[10px] font-normal ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})]}),e==="switch"&&m.jsx(ew,{}),e==="thermostat"&&m.jsxs("div",{className:"flex gap-0.5 shrink-0",children:[m.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"}),m.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"})]}),e==="dimmer"&&m.jsx("div",{className:"w-14 h-2 rounded-full overflow-hidden shrink-0",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):t==="minimal"?e==="switch"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1.5",children:[m.jsx(ew,{}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]}):m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u}),m.jsx("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:a})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{style:{color:"var(--text-secondary)"},children:i}),m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a})]}),m.jsx("div",{children:e==="switch"?m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-xl font-bold",style:{color:"var(--accent-green)"},children:"AN"}),m.jsx(ew,{})]}):e==="thermostat"?m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{children:[m.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,"°"]}),n.sub&&m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n.sub})]}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"}),m.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"})]})]}):e==="dimmer"?m.jsxs("div",{children:[m.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,m.jsx("span",{className:"text-sm ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]}),m.jsx("div",{className:"w-full h-2 mt-1 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):m.jsxs("div",{className:"flex items-end gap-1",children:[m.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:n.v}),n.u&&m.jsx("span",{className:"text-xs mb-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})})]})}function q0({type:e,layout:t="default",title:r}){return m.jsx("div",{className:"rounded-lg overflow-hidden shrink-0 relative",style:{width:Math.round(200*.62),height:Math.round(140*.62),background:"var(--widget-bg)",border:"1px solid var(--app-border)"},children:m.jsx("div",{style:{position:"absolute",top:0,left:0,width:200,height:140,transform:`scale(${.62})`,transformOrigin:"top left",padding:14,boxSizing:"border-box",pointerEvents:"none"},children:m.jsx(zct,{type:e,layout:t,title:r??""})})})}const eX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Gruppenliste",clock:"Uhrzeit",calendar:"Kalender",header:"Abschnittstitel",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"},ny={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function $ct({onAdd:e,onClose:t}){const{devices:r,loading:n,loaded:a,load:i}=Nue(),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(null),[d,h]=I.useState(new Map),p=I.useMemo(()=>Array.from(new Set(r.map(b=>b.adapter))).sort(),[r]),v=I.useMemo(()=>r.filter(b=>{if(l&&b.adapter!==l)return!1;if(o){const w=o.toLowerCase();return b.name.toLowerCase().includes(w)||b.id.toLowerCase().includes(w)||b.states.some(_=>_.id.toLowerCase().includes(w))}return!0}),[r,o,l]),g=(b,w)=>{h(_=>{const S=new Map(_);return S.has(w.id)?S.delete(w.id):S.set(w.id,{state:w,device:b,widgetType:w.suggestedWidget,title:`${b.name} – ${w.obj._id.split(".").pop()}`}),S})},y=(b,w)=>h(_=>{const S=new Map(_),T=S.get(b);return T&&S.set(b,{...T,...w}),S}),x=()=>{e(Array.from(d.values()).map((b,w)=>({id:`${b.widgetType}-${Date.now()}-${w}`,type:b.widgetType,title:b.title,datapoint:b.state.id,gridPos:{x:w*2%12,y:1/0,w:b.widgetType==="chart"?4:2,h:b.widgetType==="chart"?3:2},options:{...b.state.unit?{unit:b.state.unit}:{},...b.actualDatapoint?{actualDatapoint:b.actualDatapoint}:{}}}))),t()};return m.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:t,children:m.jsxs("div",{className:"rounded-xl w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},onClick:b=>b.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Geräte aus ioBroker"}),m.jsx("button",{onClick:t,className:"hover:opacity-60",style:{color:"var(--text-secondary)"},children:"✕"})]}),a?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex gap-3 px-6 py-3",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsx("input",{value:o,onChange:b=>s(b.target.value),placeholder:"Suchen…",className:"flex-1 rounded-lg px-3 py-1.5 text-sm focus:outline-none",style:{...ny,outlineColor:"var(--accent)"}}),m.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"rounded-lg px-3 py-1.5 text-sm",style:ny,children:[m.jsx("option",{value:"",children:"Alle Adapter"}),p.map(b=>m.jsx("option",{value:b,children:b},b))]}),m.jsxs("span",{className:"text-sm self-center whitespace-nowrap",style:{color:"var(--text-secondary)"},children:[v.length," Geräte"]})]}),m.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 space-y-2",children:v.map(b=>{const w=Array.from(d.values()).filter(_=>_.device.id===b.id).length;return m.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--app-border)"},children:[m.jsxs("button",{className:"w-full flex items-center justify-between px-4 py-3 text-left hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)"},onClick:()=>f(c===b.id?null:b.id),children:[m.jsxs("div",{children:[m.jsx("p",{className:"font-medium text-sm",style:{color:"var(--text-primary)"},children:b.name}),m.jsx("p",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:b.id})]}),m.jsxs("div",{className:"flex items-center gap-3",children:[w>0&&m.jsx("span",{className:"px-2 py-0.5 text-xs text-white rounded-full",style:{background:"var(--accent)"},children:w}),m.jsxs("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[b.states.length," DP ",c===b.id?"▲":"▼"]})]})]}),c===b.id&&b.states.map(_=>{const S=d.get(_.id);return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 cursor-pointer transition-opacity hover:opacity-80",style:{background:S?"var(--accent)11":"var(--app-surface)",borderTop:"1px solid var(--app-border)"},onClick:()=>g(b,_),children:[m.jsx("input",{type:"checkbox",checked:!!S,readOnly:!0,style:{accentColor:"var(--accent)"},className:"w-4 h-4 shrink-0"}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-mono truncate",style:{color:"var(--text-primary)"},children:_.id.split(".").pop()}),m.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:_.id})]}),m.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.unit&&m.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:_.unit}),S?m.jsx("select",{value:S.widgetType,onClick:T=>T.stopPropagation(),onChange:T=>y(_.id,{widgetType:T.target.value}),className:"text-xs rounded px-2 py-1",style:ny,children:Object.entries(eX).map(([T,C])=>m.jsx("option",{value:T,children:C},T))}):m.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:eX[_.suggestedWidget]})]})]}),S&&m.jsxs("div",{className:"px-4 pb-3 pt-2 flex gap-3 items-start",style:{background:"var(--accent)08",borderTop:"1px solid var(--app-border)"},onClick:T=>T.stopPropagation(),children:[m.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[m.jsx("input",{value:S.title,onChange:T=>y(_.id,{title:T.target.value}),placeholder:"Titel",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:ny}),S.widgetType==="thermostat"&&m.jsx("input",{value:S.actualDatapoint??"",onChange:T=>y(_.id,{actualDatapoint:T.target.value}),placeholder:"Ist-Temperatur Datenpunkt (optional)",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:ny})]}),m.jsx(q0,{type:S.widgetType,title:S.title})]})]},_.id)})]},b.id)})}),m.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:"1px solid var(--app-border)"},children:[m.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:d.size===0?"Keine ausgewählt":`${d.size} Widget${d.size!==1?"s":""}`}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"}),m.jsx("button",{onClick:x,disabled:d.size===0,className:"px-4 py-2 text-sm font-medium text-white rounded-lg hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Zum Dashboard hinzufügen"})]})]})]}):m.jsx("div",{className:"flex flex-col items-center justify-center flex-1 gap-4 py-12",children:n?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-8 h-8 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"var(--accent)",borderTopColor:"transparent"}}),m.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Lade Geräte…"})]}):m.jsxs(m.Fragment,{children:[m.jsx("p",{style:{color:"var(--text-secondary)"},children:"Alle verfügbaren Geräte und Datenpunkte laden"}),m.jsx("button",{onClick:i,className:"px-6 py-2 text-white rounded-lg font-medium hover:opacity-80",style:{background:"var(--accent)"},children:"Geräte laden"})]})})]})})}function Bct(e){const t=(e.role??"").toLowerCase(),r=e.name.toLowerCase(),n=e.unit??"";return t.includes("thermostat")||t.includes("temp.set")||r.includes("solltemp")||r.includes("setpoint")?{type:"thermostat"}:t.includes("temperature")||r.includes("temperatur")||n==="°C"?{type:"value",unit:n||"°C"}:t.includes("level.dimmer")||t.includes("level.brightness")||r.includes("dimmer")||r.includes("helligkeit")?{type:"dimmer"}:n==="W"||n==="VA"||t.includes("value.power")?{type:"value",unit:n}:n==="kWh"||t.includes("value.energy")?{type:"value",unit:n}:n==="%"&&(t.includes("level")||r.includes("rollade")||r.includes("rollo")||r.includes("jalousie")||r.includes("shutter")||r.includes("blind"))?{type:"dimmer",unit:"%"}:n==="%"&&(t.includes("humid")||r.includes("feuchte"))?{type:"value",unit:"%"}:e.type==="boolean"||t.includes("switch")||t.includes("button")?{type:"switch"}:e.type==="number"?{type:"value",unit:n||void 0}:{type:"value"}}function lI(e){return e.toLowerCase().trim()}function tX(e,t){const r=lI(t);for(const n of e){const a=lI(n);if(a===r)return 1;if(a.includes(r)||r.includes(a))return .85}return 0}const rX={licht:["light","lamp","lampe","led","leuchte","beleuchtung","dimmer","bulb","switch"],heizung:["heiz","heat","thermostat","radiator","boiler","solltemp","setpoint"],temperatur:["temp","temperature","celsius","klima","grad"],steckdose:["socket","outlet","plug","stecker","dose"],rollade:["shutter","blind","rolladen","jalousie","vorhang","curtain","rollo","level"],energie:["energy","power","strom","verbrauch","watt","kwh","leistung"],sicherheit:["security","alarm","door","window","motion","contact","tür","fenster"],klima:["climate","ac","klimaanlage","luft","humidity","feuchte","lüftung"]};function Fct(e,t){const r=lI(t),n=e.name.toLowerCase(),a=e.id.toLowerCase(),i=(e.role??"").toLowerCase();if(n.includes(r)||i.includes(r))return .75;if(a.split(".").some(s=>s===r))return .7;if(a.includes(r))return .6;const o=rX[r]??[];for(const s of o)if(n.includes(s)||i.includes(s)||a.includes(s))return .65;for(const[,s]of Object.entries(rX))if(s.includes(r)&&s.some(l=>n.includes(l)||i.includes(l)))return .5;return 0}function Vct(e,t){const r=tX(e.funcs,t);if(r>0)return r;const n=tX(e.rooms,t);return n>0?n:Fct(e,t)}function Wct(e){return e.name&&e.name!==e.id.split(".").pop()?e.name:e.id.split(".").slice(-2).join(" › ")}function Oue(e,t,r=500){const n=[];for(const a of e){const i=Vct(a,t);if(i===0)continue;const{type:o,unit:s}=Bct(a);n.push({datapoint:a,type:o,title:Wct(a),unit:s,score:i})}return n.sort((a,i)=>i.score-a.score).slice(0,r)}const Hct=[{topic:"temperatur",max:4,label:"Temperatur"},{topic:"licht",max:5,label:"Licht"},{topic:"energie",max:3,label:"Energie"},{topic:"heizung",max:3,label:"Heizung"},{topic:"klima",max:2,label:"Klima"},{topic:"rollade",max:3,label:"Rolläden"},{topic:"sicherheit",max:3,label:"Sicherheit"}];function Gct(e){const t=new Set,r=[],n={datapoint:{id:"__clock__",name:"Uhrzeit",rooms:[],funcs:[]},type:"clock",title:"Uhrzeit",score:1};r.push({label:"Uhrzeit",widgets:[n]}),t.add("__clock__");for(const{topic:a,max:i,label:o}of Hct){const s=Oue(e,a,i*10).filter(l=>!t.has(l.datapoint.id)).slice(0,i);s.length!==0&&(s.forEach(l=>t.add(l.datapoint.id)),r.push({label:o,widgets:s}))}return{sections:r,allWidgets:r.flatMap(a=>a.widgets)}}const Uct={compact:{switch:[2,3],value:[3,3],dimmer:[3,4],thermostat:[4,4],chart:[6,4],list:[4,4],clock:[4,3],calendar:[6,4]},standard:{switch:[2,4],value:[3,4],dimmer:[3,5],thermostat:[4,5],chart:[6,5],list:[4,5],clock:[5,4],calendar:[6,5]},wide:{switch:[3,5],value:[4,5],dimmer:[4,6],thermostat:[5,6],chart:[8,5],list:[5,6],clock:[6,4],calendar:[8,6]}},rD={compact:"card",standard:"default",wide:"card"},Lue=12,Iue=Date.now();function nD(e,t,r,n){const a=Uct[t];if(!n)return nX(e,a,t,r,0,0);const i=new Map,o=[];for(const c of e){const f=n(c.datapoint.id);i.has(f)||(i.set(f,[]),o.push(f)),i.get(f).push(c)}const s=[];let l=0,u=0;for(const c of o){s.push({id:`wiz-header-${u}-${Iue}`,type:"header",title:c,datapoint:"",layout:"default",gridPos:{x:0,y:l,w:Lue,h:1},options:{}}),l+=1,u+=1;const f=i.get(c),d=nX(f,a,t,r,0,l,u);s.push(...d),u+=d.length,l=d.reduce((p,v)=>Math.max(p,v.gridPos.y+v.gridPos.h),l)+1}return s}function nX(e,t,r,n,a,i,o=0){const s=[];let l=a,u=i,c=0;return e.forEach((f,d)=>{const[h,p]=t[f.type]??[3,4];l+h>Lue&&(l=0,u+=c,c=0),s.push({id:`wiz-${r}-${o+d}-${Iue}`,type:f.type,title:f.title,datapoint:f.datapoint.id==="__clock__"?"":f.datapoint.id,layout:n,gridPos:{x:l,y:u,w:h,h:p},options:f.unit?{unit:f.unit}:{}}),c=Math.max(c,p),l+=h}),s}function Yct(e,t){return e.length===0?[]:[{id:"compact",label:"Kompakt",description:"Mehr Widgets auf einen Blick – kleinere Kacheln",widgets:nD(e,"compact",rD.compact,t)},{id:"standard",label:"Standard",description:"Ausgewogene Darstellung mit gut lesbaren Widgets",widgets:nD(e,"standard",rD.standard,t)},{id:"wide",label:"Großzügig",description:"Große Kacheln – ideal für Wandtablets",widgets:nD(e,"wide",rD.wide,t)}]}const Gc={switch:"#3b82f6",value:"#22c55e",dimmer:"#f59e0b",thermostat:"#ef4444",chart:"#8b5cf6",list:"#06b6d4",clock:"#ec4899",calendar:"#f97316",header:"#94a3b8",group:"#a78bfa",echart:"#10b981",evcc:"#6366f1",weather:"#0ea5e9",gauge:"#f97316",camera:"#6b7280"},zT=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#f97316","#84cc16","#a78bfa"];function Xct({widgets:e,cols:t=12,groupMapper:r}){const a=240/t,i=e.reduce((l,u)=>Math.max(l,u.gridPos.y+u.gridPos.h),2),o=Math.min(i*a,140),s=I.useMemo(()=>{if(!r)return null;const l=new Map;let u=0;for(const c of e){const f=r(c.datapoint);l.has(f)||(l.set(f,zT[u%zT.length]),u++)}return l},[e,r]);return e.length===0?m.jsx("div",{className:"rounded-lg",style:{width:240,height:80,background:"var(--app-bg)"}}):m.jsx("div",{className:"rounded-lg overflow-hidden shrink-0",style:{width:240,height:o,background:"var(--app-bg)",position:"relative"},children:e.map((l,u)=>{const c=s?s.get(r(l.datapoint))??"var(--accent)":Gc[l.type]??"var(--accent)";return m.jsx("div",{style:{position:"absolute",left:l.gridPos.x*a+1,top:l.gridPos.y*a+1,width:l.gridPos.w*a-2,height:l.gridPos.h*a-2,background:c,opacity:.65,borderRadius:3}},u)})})}const qct=[{label:"Licht",icon:m.jsx(lZ,{size:14})},{label:"Heizung",icon:m.jsx(bf,{size:14})},{label:"Energie",icon:m.jsx(il,{size:14})},{label:"Klima",icon:m.jsx(wj,{size:14})},{label:"Rolläden",icon:m.jsx(ive,{size:14})},{label:"Steckdosen",icon:m.jsx(tE,{size:14})},{label:"Sicherheit",icon:m.jsx(xge,{size:14})}],aX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Liste",clock:"Uhr",calendar:"Kalender",header:"Abschnitt",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"};function Kct({onAdd:e,onClose:t}){const[r,n]=I.useState("mode"),[a,i]=I.useState("topic"),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(new Set),[d,h]=I.useState(""),[p,v]=I.useState("standard"),[g,y]=I.useState("none"),{datapoints:x,loading:b,load:w}=CJ(),_=so(F=>F.frontend.wizardMaxDatapoints??500);I.useEffect(()=>{w(!0)},[w]);const S=I.useMemo(()=>o?Oue(x,o,_):[],[x,o,_]),{sections:T,allWidgets:C}=I.useMemo(()=>a==="homepage"?Gct(x):{sections:[],allWidgets:[]},[a,x]);I.useEffect(()=>{const F=a==="homepage"?C:S;f(new Set(F.map(W=>W.datapoint.id)))},[S,C,a]);const A=I.useMemo(()=>{if(!d)return S;const F=d.toLowerCase();return S.filter(W=>W.datapoint.name.toLowerCase().includes(F)||W.datapoint.id.toLowerCase().includes(F))},[S,d]),P=(a==="homepage"?C:S).filter(F=>c.has(F.datapoint.id)),k=I.useMemo(()=>P.some(F=>F.datapoint.rooms.length>0),[P]),D=I.useMemo(()=>P.some(F=>F.datapoint.funcs.length>0),[P]),E=k||D;I.useEffect(()=>{g==="room"&&!k&&y("none"),g==="func"&&!D&&y("none")},[k,D,g]);const L=F=>g==="room"?F.datapoint.rooms[0]??"Sonstige":g==="func"?F.datapoint.funcs[0]??"Sonstige":"",O=I.useMemo(()=>{if(g==="none")return new Map;const F=new Map;for(const W of P){const ee=L(W);F.has(ee)||F.set(ee,[]),F.get(ee).push(W)}return F},[P,g]),j=I.useMemo(()=>{const F=new Map;return O.forEach((W,ee)=>W.forEach(Z=>F.set(Z.datapoint.id,ee))),F},[O]),R=g!=="none"&&O.size>=2?F=>j.get(F)??"Sonstige":void 0,z=I.useMemo(()=>Yct(P,R),[P,R]),$=z.find(F=>F.id===p)??z[0],V=()=>{r==="mode"?n(a==="homepage"?"homepage-review":"topic-input"):r==="topic-input"?n("datapoints"):r==="datapoints"?n(E?"grouping":"layout"):(r==="grouping"||r==="homepage-review")&&n("layout")},B=()=>{r==="layout"?n(a==="homepage"?"homepage-review":E?"grouping":"datapoints"):r==="grouping"?n("datapoints"):r==="datapoints"?n("topic-input"):(r==="topic-input"||r==="homepage-review")&&n("mode")},K=()=>{if(!$||P.length===0)return;const F=l.trim()||(a==="homepage"?"Startseite":o),W=Date.now(),ee=$.widgets.map((Z,U)=>({...Z,id:`wiz-${W}-${U}`}));e(F,ee)},re=a==="homepage"?["mode","homepage-review","layout"]:E?["mode","topic-input","datapoints","grouping","layout"]:["mode","topic-input","datapoints","layout"],ie=re.indexOf(r),ye=r==="mode"||r==="topic-input"&&o.trim().length>0&&(b||S.length>0)||(r==="datapoints"||r==="grouping"||r==="homepage-review")&&P.length>0,je=!!$&&P.length>0;return m.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:t,children:m.jsxs("div",{className:"rounded-2xl w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)",maxHeight:"90vh"},onClick:F=>F.stopPropagation(),children:[m.jsxs("div",{className:"px-6 pt-5 pb-4 shrink-0",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsxs("div",{className:"flex items-center justify-between mb-3",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(vZ,{size:18,style:{color:"var(--accent)"}}),m.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Tab-Wizard"})]}),m.jsx("button",{onClick:t,className:"hover:opacity-70",style:{color:"var(--text-secondary)"},children:m.jsx(pn,{size:18})})]}),m.jsx("div",{className:"flex items-center gap-2",children:re.map((F,W)=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"w-2 h-2 rounded-full transition-colors",style:{background:W<=ie?"var(--accent)":"var(--app-border)"}}),W<re.length-1&&m.jsx("div",{className:"w-6 h-px",style:{background:"var(--app-border)"}})]},F))})]}),b&&m.jsx("div",{className:"h-0.5 shrink-0 overflow-hidden",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full",style:{background:"var(--accent)",animation:"wizard-loading 1.4s ease-in-out infinite"}})}),m.jsx("style",{children:`
|
|
608
|
+
`).length} Zeilen`:"Kein Custom CSS"})]})]})}const Pct=`${window.location.protocol}//${window.location.hostname}:8084`,Dct=uv()(cv(e=>({ioBrokerUrl:Pct,setIoBrokerUrl:t=>{ube(),DZ(t),e({ioBrokerUrl:t})}}),{name:"aura-connection"}));async function Ect(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Nct({value:e,onChange:t}){return m.jsx("button",{onClick:()=>t(!e),className:"relative w-9 h-5 rounded-full transition-colors duration-200 focus:outline-none shrink-0",style:{background:e?"var(--accent-green)":"var(--app-border)"},children:m.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ${e?"translate-x-4":"translate-x-0"}`})})}function ZY({label:e,value:t,onChange:r}){return m.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-b-0",style:{borderColor:"var(--app-border)"},children:[m.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),m.jsx(Nct,{value:t,onChange:r})]})}function Dy({title:e,children:t}){return m.jsxs("div",{className:"rounded-xl p-4 space-y-3",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[m.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest",style:{color:"var(--text-secondary)"},children:e}),t]})}function tD({label:e,value:t,min:r,max:n,step:a,unit:i="",onChange:o,presets:s}){return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center justify-between mb-1",children:[m.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),m.jsxs("span",{className:"text-xs font-mono font-bold px-2 py-0.5 rounded-md",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[t,i]})]}),m.jsx("input",{type:"range",min:r,max:n,step:a,value:t,onChange:l=>o(Number(l.target.value)),className:"w-full accent-[var(--accent)] mb-2"}),m.jsx("div",{className:"flex gap-1.5 flex-wrap",children:s.map(l=>{const u=t===l.value;return m.jsx("button",{onClick:()=>o(l.value),className:"px-2.5 py-1 rounded-lg text-xs font-medium hover:opacity-80",style:{background:u?"var(--accent)":"var(--app-bg)",color:u?"#fff":"var(--text-secondary)",border:`1px solid ${u?"var(--accent)":"var(--app-border)"}`},children:l.label},l.value)})})]})}function Oct(){const{pinHash:e}=ed(),{ioBrokerUrl:t,setIoBrokerUrl:r}=Dct(),[n,a]=I.useState(!1),[i,o]=I.useState(""),[s,l]=I.useState(""),[u,c]=I.useState(t),[f,d]=I.useState(!1),h=async v=>{v.preventDefault(),await Ect(i)===e?(a(!0),l(""),o("")):l("Falscher PIN")},p=async()=>{const v=u.trim();v&&(r(v),await DZ(v),d(!0),setTimeout(()=>d(!1),2500))};return m.jsxs(Dy,{title:"Experten",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[n?m.jsx(qve,{size:14,style:{color:"var(--accent-yellow)"}}):m.jsx(cZ,{size:14,style:{color:"var(--text-secondary)"}}),m.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:n?"Entsperrt":"Zugang mit Admin-PIN"})]}),n?m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{children:[m.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"ioBroker Web-Adapter URL"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{type:"text",value:u,onChange:v=>{c(v.target.value),d(!1)},className:"flex-1 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),m.jsxs("button",{onClick:p,disabled:u.trim()===t&&!f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80 disabled:opacity-40 shrink-0",style:{background:f?"var(--accent-green)":"var(--accent)"},children:[m.jsx(xj,{size:12}),f?"OK":"Verbinden"]})]})]}),m.jsx("button",{onClick:()=>a(!1),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Sperren"})]}):m.jsxs("form",{onSubmit:h,className:"flex gap-2",children:[m.jsx("input",{type:"password",value:i,onChange:v=>{o(v.target.value),l("")},placeholder:"Admin-PIN",className:"flex-1 rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:`1px solid ${s?"var(--accent-red)":"var(--app-border)"}`}}),m.jsx("button",{type:"submit",className:"px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Entsperren"})]})]})}function Lct(){const e=fv().tabs,{frontend:t,updateFrontend:r}=so(),[n,a]=I.useState(""),[i,o]=I.useState(""),[s,l]=I.useState(!1),[u,c]=I.useState(""),[f,d]=I.useState(!1),h=async g=>{if(g.preventDefault(),n.length<4){c("Mindestens 4 Zeichen");return}if(n!==i){c("PINs stimmen nicht überein");return}await Eue(n),c("PIN erfolgreich geändert"),a(""),o(""),setTimeout(()=>c(""),3e3)},p=()=>{const g={dashboard:JSON.parse(localStorage.getItem("aura-dashboard")??"{}"),theme:JSON.parse(localStorage.getItem("aura-theme")??"{}"),config:JSON.parse(localStorage.getItem("aura-config")??"{}"),exported:new Date().toISOString()},y=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),x=URL.createObjectURL(y),b=document.createElement("a");b.href=x,b.download=`aura-backup-${Date.now()}.json`,b.click(),URL.revokeObjectURL(x)},v=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];if(!y)return;const x=new FileReader;x.onload=w=>{var _;try{const S=JSON.parse((_=w.target)==null?void 0:_.result);S.dashboard&&localStorage.setItem("aura-dashboard",JSON.stringify(S.dashboard)),S.theme&&localStorage.setItem("aura-theme",JSON.stringify(S.theme)),S.config&&localStorage.setItem("aura-config",JSON.stringify(S.config)),window.location.reload()}catch{alert("Ungültige Backup-Datei")}},x.readAsText(y)};return m.jsxs("div",{className:"p-5 max-w-3xl space-y-4",children:[m.jsxs("div",{children:[m.jsx("h1",{className:"text-lg font-bold",style:{color:"var(--text-primary)"},children:"Einstellungen"}),m.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-secondary)"},children:"Frontend, Grid, Sicherheit und Backup"})]}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[m.jsxs(Dy,{title:"Frontend",children:[m.jsx(ZY,{label:"Header anzeigen",value:t.showHeader,onChange:g=>r({showHeader:g})}),t.showHeader&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"py-2 border-b",style:{borderColor:"var(--app-border)"},children:[m.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Dashboard-Titel"}),m.jsx("input",{value:t.headerTitle,onChange:g=>r({headerTitle:g.target.value}),className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),m.jsx(ZY,{label:"Verbindungsstatus",value:t.showConnectionBadge,onChange:g=>r({showConnectionBadge:g})})]})]}),m.jsxs(Dy,{title:"Grid & Mobil",children:[m.jsx(tD,{label:"Zeilenhöhe",value:t.gridRowHeight??80,min:30,max:160,step:10,unit:" px",onChange:g=>r({gridRowHeight:g}),presets:[{label:"XS·40",value:40},{label:"S·60",value:60},{label:"M·80",value:80},{label:"L·100",value:100},{label:"XL·120",value:120}]}),m.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:m.jsx(tD,{label:"Mobile-Breakpoint",value:t.mobileBreakpoint??600,min:0,max:1024,step:10,unit:" px",onChange:g=>r({mobileBreakpoint:g}),presets:[{label:"480",value:480},{label:"600",value:600},{label:"768",value:768},{label:"Aus",value:0}]})}),m.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:m.jsx(tD,{label:"Wizard Max-Datenpunkte",value:t.wizardMaxDatapoints??500,min:100,max:5e3,step:100,onChange:g=>r({wizardMaxDatapoints:g}),presets:[{label:"200",value:200},{label:"500",value:500},{label:"1k",value:1e3},{label:"2k",value:2e3},{label:"5k",value:5e3}]})})]})]}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[m.jsx(Dy,{title:"Admin-PIN",children:m.jsxs("form",{onSubmit:h,className:"space-y-2",children:[m.jsxs("div",{className:"relative",children:[m.jsx("input",{type:s?"text":"password",value:n,onChange:g=>a(g.target.value),placeholder:"Neuer PIN (min. 4 Zeichen)",className:"w-full rounded-lg px-3 py-2 pr-9 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),m.jsx("button",{type:"button",onClick:()=>l(g=>!g),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:s?m.jsx(gj,{size:13}):m.jsx(nZ,{size:13})})]}),m.jsx("input",{type:s?"text":"password",value:i,onChange:g=>o(g.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),u&&m.jsx("p",{className:"text-xs",style:{color:u.includes("erfolgreich")?"var(--accent-green)":"var(--accent-red)"},children:u}),m.jsx("button",{type:"submit",className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"PIN speichern"})]})}),m.jsxs(Dy,{title:"Backup & Restore",children:[m.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Dashboard (",e.length," Tab",e.length!==1?"s":"","), Theme und Config als JSON."]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{onClick:p,className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Download Backup"}),m.jsxs("label",{className:"px-4 py-2 rounded-lg text-sm font-medium text-center cursor-pointer hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:["Backup importieren",m.jsx("input",{type:"file",accept:".json",onChange:v,className:"hidden"})]})]})]})]}),m.jsx(Oct,{}),m.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--app-surface)",border:"1px solid var(--accent-red)44"},children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsx(jge,{size:15,style:{color:"var(--accent-red)"}}),m.jsx("p",{className:"text-sm font-semibold",style:{color:"var(--accent-red)"},children:"Alles zurücksetzen"})]}),m.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-secondary)"},children:"Löscht alle Dashboards, Widgets, Themes und Einstellungen. Nicht rückgängig."}),f?m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:()=>{["aura-dashboard","aura-theme","aura-config"].forEach(g=>localStorage.removeItem(g)),window.location.href="/"},className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Ja, alles löschen"}),m.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"})]}):m.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--accent-red)22",color:"var(--accent-red)",border:"1px solid var(--accent-red)44"},children:"Zurücksetzen…"})]})]})}function Ict(e,t){if(!e)return t==="boolean"?"switch":"value";const r=e.toLowerCase();return r==="switch"||r==="button"||r.startsWith("switch.")||r==="indicator"?"switch":r.includes("dimmer")||r.includes("brightness")||r==="level"||r.startsWith("level.")?"dimmer":r.includes("temperature")&&r.includes("level")?"thermostat":r.includes("temperature")?"value":t==="boolean"?"switch":"value"}function JY(e){const t=e.common.name;return t?typeof t=="string"?t:t.de??t.en??Object.values(t)[0]??e._id:e._id.split(".").pop()??e._id}function QY(e){const t=e.split(".");return t.length>=2?`${t[0]}.${t[1]}`:t[0]}function Nue(){const{getObjectView:e}=$n(),[t,r]=I.useState([]),[n,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useCallback(async()=>{a(!0);try{const[l,u,c]=await Promise.all([e("device"),e("channel"),e("state")]),f=new Map;for(const{value:p}of c.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");f.has(g)||f.set(g,[]),f.get(g).push({id:p._id,obj:p,suggestedWidget:Ict(p.common.role,p.common.type),unit:p.common.unit})}const d=[];for(const{value:p}of l.rows){if(!p)continue;const v=[];for(const[g,y]of f.entries())(g===p._id||g.startsWith(p._id+"."))&&v.push(...y);v.length!==0&&d.push({id:p._id,name:JY(p),adapter:QY(p._id),states:v})}const h=new Set(d.map(p=>p.id));for(const{value:p}of u.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");if(h.has(g))continue;const y=f.get(p._id)??[];y.length!==0&&d.push({id:p._id,name:JY(p),adapter:QY(p._id),states:y})}d.sort((p,v)=>p.adapter.localeCompare(v.adapter)||p.name.localeCompare(v.name)),r(d),o(!0)}finally{a(!1)}},[e]);return{devices:t,loading:n,loaded:i,load:s}}const jct={switch:m.jsx(il,{size:13}),value:m.jsx(tf,{size:13}),dimmer:m.jsx(hZ,{size:13}),thermostat:m.jsx(bf,{size:13}),chart:m.jsx(yu,{size:13}),list:m.jsx(uZ,{size:13}),clock:m.jsx(tZ,{size:13}),calendar:m.jsx(Em,{size:13}),header:m.jsx(oZ,{size:13}),group:m.jsx(yj,{size:13}),echart:m.jsx(yu,{size:13}),evcc:m.jsx(il,{size:13}),weather:m.jsx(_ve,{size:13}),gauge:m.jsx(Lve,{size:13}),camera:m.jsx(v_,{size:13})},Rct={switch:{t:"Wohnzimmer",v:"AN"},value:{t:"Temperatur",v:"21.5",u:"°C"},dimmer:{t:"Licht",v:"75",u:"%"},thermostat:{t:"Heizung",v:"21.0",sub:"Ist: 19.5°"},chart:{t:"Verbrauch",v:"245",u:"W"},list:{t:"Alle Geräte",v:""},clock:{t:"Uhrzeit",v:"12:34"},calendar:{t:"Kalender",v:"3"},header:{t:"Abschnitt",v:""},group:{t:"Gruppe",v:""},echart:{t:"EChart",v:""},evcc:{t:"evcc",v:""},weather:{t:"Wetter",v:"18°",sub:"⛅ Bewölkt"},gauge:{t:"Gauge",v:"72",u:"kW"},camera:{t:"Kamera",v:""}};function ew({on:e}){return m.jsx("div",{className:"relative w-8 h-4 rounded-full shrink-0",style:{background:e!==!1?"var(--accent-green)":"var(--app-border)"},children:m.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow",style:{left:e!==!1?"18px":"2px",transition:"left 0.15s"}})})}function zct({type:e,layout:t,title:r}){const n=Rct[e],a=r||n.t,i=jct[e];if(e==="clock")return t==="minimal"||t==="card"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[m.jsx("p",{className:"text-3xl font-black tabular-nums leading-none",style:{color:"var(--accent)"},children:"12:34"}),t==="card"&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("p",{className:"text-xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),m.jsx("span",{style:{color:"var(--app-border)"},children:"·"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Mo., 7. Apr."})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a}),m.jsxs("div",{children:[m.jsx("p",{className:"text-2xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]})]});if(e==="calendar"){const o=[{label:"Team-Meeting",date:"Heute, 10:00",dot:"var(--accent)"},{label:"Zahnarzt",date:"Morgen, 14:30",dot:"var(--accent-green)"},{label:"Geburtstag Lisa",date:"Mi, 9. Apr",dot:"var(--accent-yellow)"}];return t==="minimal"||t==="card"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:"3"}),m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Termine"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx(Em,{size:16,style:{color:"var(--accent)"}}),m.jsxs("div",{children:[m.jsx("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Team-Meeting"}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--accent)"},children:"Heute, 10:00"})]})]}):t==="agenda"?m.jsxs("div",{className:"flex flex-col h-full gap-0.5",children:[m.jsx("p",{className:"text-[11px] font-medium mb-0.5",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("div",{className:"w-0.5 self-stretch rounded-full shrink-0",style:{background:s.dot}}),m.jsxs("span",{className:"text-[8px] w-8 truncate shrink-0",style:{color:s.dot},children:["Cal ",l+1]}),m.jsx("p",{className:"flex-1 text-[9px] font-medium truncate",style:{color:"var(--text-primary)"},children:s.label}),m.jsx("p",{className:"text-[8px] shrink-0",style:{color:"var(--text-secondary)"},children:s.date.split(", ")[1]??s.date})]},l))]}):m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>m.jsxs("div",{className:"flex items-start gap-1.5",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full mt-1 shrink-0",style:{background:s.dot}}),m.jsxs("div",{children:[m.jsx("p",{className:"text-[10px] font-medium leading-tight",style:{color:"var(--text-primary)"},children:s.label}),m.jsx("p",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:s.date})]})]},l))]})}if(e==="weather")return t==="minimal"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsx("span",{style:{fontSize:"2rem",lineHeight:1},children:"⛅"}),m.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1},children:"⛅"}),m.jsx("span",{className:"text-xl font-bold",style:{color:"var(--text-primary)"},children:"18°"}),m.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Bewölkt"})]}):m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:"⛅"}),m.jsxs("div",{children:[m.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"}),m.jsx("span",{className:"text-[11px] ml-1",style:{color:"var(--text-secondary)"},children:"Bewölkt"}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Gefühlt 15°"})]})]}),m.jsxs("div",{className:"text-[10px] flex gap-2",style:{color:"var(--text-secondary)"},children:[m.jsx("span",{children:"💧 65%"}),m.jsx("span",{children:"💨 12 km/h"})]}),m.jsx("div",{className:"flex gap-1 pt-1",style:{borderTop:"1px solid var(--app-border)"},children:[["Mo","☁️","18°"],["Di","🌧️","15°"],["Mi","☀️","22°"]].map(([o,s,l])=>m.jsxs("div",{className:"flex-1 flex flex-col items-center",style:{fontSize:"9px",color:"var(--text-secondary)"},children:[m.jsx("span",{children:o}),m.jsx("span",{style:{fontSize:"11px"},children:s}),m.jsx("span",{style:{color:"var(--text-primary)",fontWeight:"bold"},children:l})]},o))})]});if(e==="gauge")return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[m.jsxs("svg",{viewBox:"0 0 200 120",style:{width:120,height:72},children:[m.jsx("path",{d:"M 20 100 A 80 80 0 0 1 180 100",fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),m.jsx("path",{d:"M 20 100 A 80 80 0 0 1 131.13 33.57",fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),m.jsx("text",{x:100,y:95,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:"72"}),m.jsx("text",{x:100,y:110,textAnchor:"middle",fontSize:10,fill:"var(--text-secondary)",children:n.u})]}),a&&m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="camera")return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",style:{background:"var(--app-bg)",borderRadius:4},children:[m.jsx(v_,{size:20,style:{color:"var(--text-secondary)"}}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="chart"){const o=[40,60,45,75,55,80,65,90,70];return m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsx("div",{className:"flex-1 flex items-end gap-0.5",children:o.map((s,l)=>m.jsx("div",{className:"flex-1 rounded-sm",style:{height:`${s}%`,background:l===o.length-1?"var(--accent)":"color-mix(in srgb, var(--accent) 45%, transparent)"}},l))}),m.jsxs("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:[n.v,n.u&&m.jsxs("span",{style:{color:"var(--text-secondary)",fontWeight:400},children:[" ",n.u]})]})]})}return e==="list"?m.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium truncate",style:{color:"var(--text-secondary)"},children:a}),["Gerät 1","Gerät 2","Gerät 3"].map((o,s)=>m.jsxs("div",{className:"flex items-center justify-between px-1.5 py-0.5 rounded",style:{background:"var(--app-bg)"},children:[m.jsx("span",{className:"text-[10px]",style:{color:"var(--text-primary)"},children:o}),m.jsx(ew,{on:s===0})]},s))]}):t==="card"?e==="switch"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 rounded-md",style:{background:"color-mix(in srgb, var(--accent-green) 20%, transparent)"},children:[m.jsx(il,{size:26,style:{color:"var(--accent-green)"}}),m.jsx("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:a}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--accent-green)"},children:"AN"})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsx("span",{style:{color:"var(--accent)"},children:i})]}),m.jsxs("div",{children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u})]})]}):t==="compact"?m.jsxs("div",{className:"flex items-center gap-2 h-full",children:[m.jsx("span",{style:{color:"var(--text-secondary)",flexShrink:0},children:i}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-[10px] truncate",style:{color:"var(--text-secondary)"},children:a}),m.jsxs("p",{className:"text-base font-bold leading-tight",style:{color:"var(--text-primary)"},children:[n.v,n.u&&m.jsx("span",{className:"text-[10px] font-normal ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})]}),e==="switch"&&m.jsx(ew,{}),e==="thermostat"&&m.jsxs("div",{className:"flex gap-0.5 shrink-0",children:[m.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"}),m.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"})]}),e==="dimmer"&&m.jsx("div",{className:"w-14 h-2 rounded-full overflow-hidden shrink-0",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):t==="minimal"?e==="switch"?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1.5",children:[m.jsx(ew,{}),m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]}):m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[m.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&m.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u}),m.jsx("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:a})]}):m.jsxs("div",{className:"flex flex-col h-full justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{style:{color:"var(--text-secondary)"},children:i}),m.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a})]}),m.jsx("div",{children:e==="switch"?m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-xl font-bold",style:{color:"var(--accent-green)"},children:"AN"}),m.jsx(ew,{})]}):e==="thermostat"?m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{children:[m.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,"°"]}),n.sub&&m.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n.sub})]}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"}),m.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"})]})]}):e==="dimmer"?m.jsxs("div",{children:[m.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,m.jsx("span",{className:"text-sm ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]}),m.jsx("div",{className:"w-full h-2 mt-1 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):m.jsxs("div",{className:"flex items-end gap-1",children:[m.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:n.v}),n.u&&m.jsx("span",{className:"text-xs mb-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})})]})}function q0({type:e,layout:t="default",title:r}){return m.jsx("div",{className:"rounded-lg overflow-hidden shrink-0 relative",style:{width:Math.round(200*.62),height:Math.round(140*.62),background:"var(--widget-bg)",border:"1px solid var(--app-border)"},children:m.jsx("div",{style:{position:"absolute",top:0,left:0,width:200,height:140,transform:`scale(${.62})`,transformOrigin:"top left",padding:14,boxSizing:"border-box",pointerEvents:"none"},children:m.jsx(zct,{type:e,layout:t,title:r??""})})})}const eX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Gruppenliste",clock:"Uhrzeit",calendar:"Kalender",header:"Abschnittstitel",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"},ny={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function $ct({onAdd:e,onClose:t}){const{devices:r,loading:n,loaded:a,load:i}=Nue(),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(null),[d,h]=I.useState(new Map),p=I.useMemo(()=>Array.from(new Set(r.map(b=>b.adapter))).sort(),[r]),v=I.useMemo(()=>r.filter(b=>{if(l&&b.adapter!==l)return!1;if(o){const w=o.toLowerCase();return b.name.toLowerCase().includes(w)||b.id.toLowerCase().includes(w)||b.states.some(_=>_.id.toLowerCase().includes(w))}return!0}),[r,o,l]),g=(b,w)=>{h(_=>{const S=new Map(_);return S.has(w.id)?S.delete(w.id):S.set(w.id,{state:w,device:b,widgetType:w.suggestedWidget,title:`${b.name} – ${w.obj._id.split(".").pop()}`}),S})},y=(b,w)=>h(_=>{const S=new Map(_),T=S.get(b);return T&&S.set(b,{...T,...w}),S}),x=()=>{e(Array.from(d.values()).map((b,w)=>({id:`${b.widgetType}-${Date.now()}-${w}`,type:b.widgetType,title:b.title,datapoint:b.state.id,gridPos:{x:w*2%12,y:1/0,w:b.widgetType==="chart"?4:2,h:b.widgetType==="chart"?3:2},options:{...b.state.unit?{unit:b.state.unit}:{},...b.actualDatapoint?{actualDatapoint:b.actualDatapoint}:{}}}))),t()};return m.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:t,children:m.jsxs("div",{className:"rounded-xl w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},onClick:b=>b.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Geräte aus ioBroker"}),m.jsx("button",{onClick:t,className:"hover:opacity-60",style:{color:"var(--text-secondary)"},children:"✕"})]}),a?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex gap-3 px-6 py-3",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsx("input",{value:o,onChange:b=>s(b.target.value),placeholder:"Suchen…",className:"flex-1 rounded-lg px-3 py-1.5 text-sm focus:outline-none",style:{...ny,outlineColor:"var(--accent)"}}),m.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"rounded-lg px-3 py-1.5 text-sm",style:ny,children:[m.jsx("option",{value:"",children:"Alle Adapter"}),p.map(b=>m.jsx("option",{value:b,children:b},b))]}),m.jsxs("span",{className:"text-sm self-center whitespace-nowrap",style:{color:"var(--text-secondary)"},children:[v.length," Geräte"]})]}),m.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 space-y-2",children:v.map(b=>{const w=Array.from(d.values()).filter(_=>_.device.id===b.id).length;return m.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--app-border)"},children:[m.jsxs("button",{className:"w-full flex items-center justify-between px-4 py-3 text-left hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)"},onClick:()=>f(c===b.id?null:b.id),children:[m.jsxs("div",{children:[m.jsx("p",{className:"font-medium text-sm",style:{color:"var(--text-primary)"},children:b.name}),m.jsx("p",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:b.id})]}),m.jsxs("div",{className:"flex items-center gap-3",children:[w>0&&m.jsx("span",{className:"px-2 py-0.5 text-xs text-white rounded-full",style:{background:"var(--accent)"},children:w}),m.jsxs("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[b.states.length," DP ",c===b.id?"▲":"▼"]})]})]}),c===b.id&&b.states.map(_=>{const S=d.get(_.id);return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 cursor-pointer transition-opacity hover:opacity-80",style:{background:S?"var(--accent)11":"var(--app-surface)",borderTop:"1px solid var(--app-border)"},onClick:()=>g(b,_),children:[m.jsx("input",{type:"checkbox",checked:!!S,readOnly:!0,style:{accentColor:"var(--accent)"},className:"w-4 h-4 shrink-0"}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-mono truncate",style:{color:"var(--text-primary)"},children:_.id.split(".").pop()}),m.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:_.id})]}),m.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.unit&&m.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:_.unit}),S?m.jsx("select",{value:S.widgetType,onClick:T=>T.stopPropagation(),onChange:T=>y(_.id,{widgetType:T.target.value}),className:"text-xs rounded px-2 py-1",style:ny,children:Object.entries(eX).map(([T,C])=>m.jsx("option",{value:T,children:C},T))}):m.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:eX[_.suggestedWidget]})]})]}),S&&m.jsxs("div",{className:"px-4 pb-3 pt-2 flex gap-3 items-start",style:{background:"var(--accent)08",borderTop:"1px solid var(--app-border)"},onClick:T=>T.stopPropagation(),children:[m.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[m.jsx("input",{value:S.title,onChange:T=>y(_.id,{title:T.target.value}),placeholder:"Titel",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:ny}),S.widgetType==="thermostat"&&m.jsx("input",{value:S.actualDatapoint??"",onChange:T=>y(_.id,{actualDatapoint:T.target.value}),placeholder:"Ist-Temperatur Datenpunkt (optional)",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:ny})]}),m.jsx(q0,{type:S.widgetType,title:S.title})]})]},_.id)})]},b.id)})}),m.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:"1px solid var(--app-border)"},children:[m.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:d.size===0?"Keine ausgewählt":`${d.size} Widget${d.size!==1?"s":""}`}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"}),m.jsx("button",{onClick:x,disabled:d.size===0,className:"px-4 py-2 text-sm font-medium text-white rounded-lg hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Zum Dashboard hinzufügen"})]})]})]}):m.jsx("div",{className:"flex flex-col items-center justify-center flex-1 gap-4 py-12",children:n?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-8 h-8 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"var(--accent)",borderTopColor:"transparent"}}),m.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Lade Geräte…"})]}):m.jsxs(m.Fragment,{children:[m.jsx("p",{style:{color:"var(--text-secondary)"},children:"Alle verfügbaren Geräte und Datenpunkte laden"}),m.jsx("button",{onClick:i,className:"px-6 py-2 text-white rounded-lg font-medium hover:opacity-80",style:{background:"var(--accent)"},children:"Geräte laden"})]})})]})})}function Bct(e){const t=(e.role??"").toLowerCase(),r=e.name.toLowerCase(),n=e.unit??"";return t.includes("thermostat")||t.includes("temp.set")||r.includes("solltemp")||r.includes("setpoint")?{type:"thermostat"}:t.includes("temperature")||r.includes("temperatur")||n==="°C"?{type:"value",unit:n||"°C"}:t.includes("level.dimmer")||t.includes("level.brightness")||r.includes("dimmer")||r.includes("helligkeit")?{type:"dimmer"}:n==="W"||n==="VA"||t.includes("value.power")?{type:"value",unit:n}:n==="kWh"||t.includes("value.energy")?{type:"value",unit:n}:n==="%"&&(t.includes("level")||r.includes("rollade")||r.includes("rollo")||r.includes("jalousie")||r.includes("shutter")||r.includes("blind"))?{type:"dimmer",unit:"%"}:n==="%"&&(t.includes("humid")||r.includes("feuchte"))?{type:"value",unit:"%"}:e.type==="boolean"||t.includes("switch")||t.includes("button")?{type:"switch"}:e.type==="number"?{type:"value",unit:n||void 0}:{type:"value"}}function lI(e){return e.toLowerCase().trim()}function tX(e,t){const r=lI(t);for(const n of e){const a=lI(n);if(a===r)return 1;if(a.includes(r)||r.includes(a))return .85}return 0}const rX={licht:["light","lamp","lampe","led","leuchte","beleuchtung","dimmer","bulb","switch"],heizung:["heiz","heat","thermostat","radiator","boiler","solltemp","setpoint"],temperatur:["temp","temperature","celsius","klima","grad"],steckdose:["socket","outlet","plug","stecker","dose"],rollade:["shutter","blind","rolladen","jalousie","vorhang","curtain","rollo","level"],energie:["energy","power","strom","verbrauch","watt","kwh","leistung"],sicherheit:["security","alarm","door","window","motion","contact","tür","fenster"],klima:["climate","ac","klimaanlage","luft","humidity","feuchte","lüftung"]};function Fct(e,t){const r=lI(t),n=e.name.toLowerCase(),a=e.id.toLowerCase(),i=(e.role??"").toLowerCase();if(n.includes(r)||i.includes(r))return .75;if(a.split(".").some(s=>s===r))return .7;if(a.includes(r))return .6;const o=rX[r]??[];for(const s of o)if(n.includes(s)||i.includes(s)||a.includes(s))return .65;for(const[,s]of Object.entries(rX))if(s.includes(r)&&s.some(l=>n.includes(l)||i.includes(l)))return .5;return 0}function Vct(e,t){const r=tX(e.funcs,t);if(r>0)return r;const n=tX(e.rooms,t);return n>0?n:Fct(e,t)}function Wct(e){return e.name&&e.name!==e.id.split(".").pop()?e.name:e.id.split(".").slice(-2).join(" › ")}function Oue(e,t,r=500){const n=[];for(const a of e){const i=Vct(a,t);if(i===0)continue;const{type:o,unit:s}=Bct(a);n.push({datapoint:a,type:o,title:Wct(a),unit:s,score:i})}return n.sort((a,i)=>i.score-a.score).slice(0,r)}const Hct=[{topic:"temperatur",max:4,label:"Temperatur"},{topic:"licht",max:5,label:"Licht"},{topic:"energie",max:3,label:"Energie"},{topic:"heizung",max:3,label:"Heizung"},{topic:"klima",max:2,label:"Klima"},{topic:"rollade",max:3,label:"Rolläden"},{topic:"sicherheit",max:3,label:"Sicherheit"}];function Gct(e){const t=new Set,r=[],n={datapoint:{id:"__clock__",name:"Uhrzeit",rooms:[],funcs:[]},type:"clock",title:"Uhrzeit",score:1};r.push({label:"Uhrzeit",widgets:[n]}),t.add("__clock__");for(const{topic:a,max:i,label:o}of Hct){const s=Oue(e,a,i*10).filter(l=>!t.has(l.datapoint.id)).slice(0,i);s.length!==0&&(s.forEach(l=>t.add(l.datapoint.id)),r.push({label:o,widgets:s}))}return{sections:r,allWidgets:r.flatMap(a=>a.widgets)}}const Uct={compact:{switch:[2,3],value:[3,3],dimmer:[3,4],thermostat:[4,4],chart:[6,4],list:[4,4],clock:[4,3],calendar:[6,4]},standard:{switch:[2,4],value:[3,4],dimmer:[3,5],thermostat:[4,5],chart:[6,5],list:[4,5],clock:[5,4],calendar:[6,5]},wide:{switch:[3,5],value:[4,5],dimmer:[4,6],thermostat:[5,6],chart:[8,5],list:[5,6],clock:[6,4],calendar:[8,6]}},rD={compact:"card",standard:"default",wide:"card"},Lue=12,Iue=Date.now();function nD(e,t,r,n){const a=Uct[t];if(!n)return nX(e,a,t,r,0,0);const i=new Map,o=[];for(const c of e){const f=n(c.datapoint.id);i.has(f)||(i.set(f,[]),o.push(f)),i.get(f).push(c)}const s=[];let l=0,u=0;for(const c of o){s.push({id:`wiz-header-${u}-${Iue}`,type:"header",title:c,datapoint:"",layout:"default",gridPos:{x:0,y:l,w:Lue,h:1},options:{}}),l+=1,u+=1;const f=i.get(c),d=nX(f,a,t,r,0,l,u);s.push(...d),u+=d.length,l=d.reduce((p,v)=>Math.max(p,v.gridPos.y+v.gridPos.h),l)+1}return s}function nX(e,t,r,n,a,i,o=0){const s=[];let l=a,u=i,c=0;return e.forEach((f,d)=>{const[h,p]=t[f.type]??[3,4];l+h>Lue&&(l=0,u+=c,c=0),s.push({id:`wiz-${r}-${o+d}-${Iue}`,type:f.type,title:f.title,datapoint:f.datapoint.id==="__clock__"?"":f.datapoint.id,layout:n,gridPos:{x:l,y:u,w:h,h:p},options:f.unit?{unit:f.unit}:{}}),c=Math.max(c,p),l+=h}),s}function Yct(e,t){return e.length===0?[]:[{id:"compact",label:"Kompakt",description:"Mehr Widgets auf einen Blick – kleinere Kacheln",widgets:nD(e,"compact",rD.compact,t)},{id:"standard",label:"Standard",description:"Ausgewogene Darstellung mit gut lesbaren Widgets",widgets:nD(e,"standard",rD.standard,t)},{id:"wide",label:"Großzügig",description:"Große Kacheln – ideal für Wandtablets",widgets:nD(e,"wide",rD.wide,t)}]}const Gc={switch:"#3b82f6",value:"#22c55e",dimmer:"#f59e0b",thermostat:"#ef4444",chart:"#8b5cf6",list:"#06b6d4",clock:"#ec4899",calendar:"#f97316",header:"#94a3b8",group:"#a78bfa",echart:"#10b981",evcc:"#6366f1",weather:"#0ea5e9",gauge:"#f97316",camera:"#6b7280"},zT=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#f97316","#84cc16","#a78bfa"];function Xct({widgets:e,cols:t=12,groupMapper:r}){const a=240/t,i=e.reduce((l,u)=>Math.max(l,u.gridPos.y+u.gridPos.h),2),o=Math.min(i*a,140),s=I.useMemo(()=>{if(!r)return null;const l=new Map;let u=0;for(const c of e){const f=r(c.datapoint);l.has(f)||(l.set(f,zT[u%zT.length]),u++)}return l},[e,r]);return e.length===0?m.jsx("div",{className:"rounded-lg",style:{width:240,height:80,background:"var(--app-bg)"}}):m.jsx("div",{className:"rounded-lg overflow-hidden shrink-0",style:{width:240,height:o,background:"var(--app-bg)",position:"relative"},children:e.map((l,u)=>{const c=s?s.get(r(l.datapoint))??"var(--accent)":Gc[l.type]??"var(--accent)";return m.jsx("div",{style:{position:"absolute",left:l.gridPos.x*a+1,top:l.gridPos.y*a+1,width:l.gridPos.w*a-2,height:l.gridPos.h*a-2,background:c,opacity:.65,borderRadius:3}},u)})})}const qct=[{label:"Licht",icon:m.jsx(lZ,{size:14})},{label:"Heizung",icon:m.jsx(bf,{size:14})},{label:"Energie",icon:m.jsx(il,{size:14})},{label:"Klima",icon:m.jsx(wj,{size:14})},{label:"Rolläden",icon:m.jsx(ive,{size:14})},{label:"Steckdosen",icon:m.jsx(tE,{size:14})},{label:"Sicherheit",icon:m.jsx(xge,{size:14})}],aX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Liste",clock:"Uhr",calendar:"Kalender",header:"Abschnitt",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"};function Kct({onAdd:e,onClose:t}){const[r,n]=I.useState("mode"),[a,i]=I.useState("topic"),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(new Set),[d,h]=I.useState(""),[p,v]=I.useState("standard"),[g,y]=I.useState("none"),{datapoints:x,loading:b,load:w}=CJ(),_=so(F=>F.frontend.wizardMaxDatapoints??500);I.useEffect(()=>{w(!0)},[w]);const S=I.useMemo(()=>o?Oue(x,o,_):[],[x,o,_]),{sections:T,allWidgets:C}=I.useMemo(()=>a==="homepage"?Gct(x):{sections:[],allWidgets:[]},[a,x]);I.useEffect(()=>{const F=a==="homepage"?C:S;f(new Set(F.map(W=>W.datapoint.id)))},[S,C,a]);const A=I.useMemo(()=>{if(!d)return S;const F=d.toLowerCase();return S.filter(W=>W.datapoint.name.toLowerCase().includes(F)||W.datapoint.id.toLowerCase().includes(F))},[S,d]),P=(a==="homepage"?C:S).filter(F=>c.has(F.datapoint.id)),k=I.useMemo(()=>P.some(F=>F.datapoint.rooms.length>0),[P]),D=I.useMemo(()=>P.some(F=>F.datapoint.funcs.length>0),[P]),E=k||D;I.useEffect(()=>{g==="room"&&!k&&y("none"),g==="func"&&!D&&y("none")},[k,D,g]);const L=F=>g==="room"?F.datapoint.rooms[0]??"Sonstige":g==="func"?F.datapoint.funcs[0]??"Sonstige":"",O=I.useMemo(()=>{if(g==="none")return new Map;const F=new Map;for(const W of P){const ee=L(W);F.has(ee)||F.set(ee,[]),F.get(ee).push(W)}return F},[P,g]),j=I.useMemo(()=>{const F=new Map;return O.forEach((W,ee)=>W.forEach(Z=>F.set(Z.datapoint.id,ee))),F},[O]),R=g!=="none"&&O.size>=2?F=>j.get(F)??"Sonstige":void 0,z=I.useMemo(()=>Yct(P,R),[P,R]),$=z.find(F=>F.id===p)??z[0],V=()=>{r==="mode"?n(a==="homepage"?"homepage-review":"topic-input"):r==="topic-input"?n("datapoints"):r==="datapoints"?n(E?"grouping":"layout"):(r==="grouping"||r==="homepage-review")&&n("layout")},B=()=>{r==="layout"?n(a==="homepage"?"homepage-review":E?"grouping":"datapoints"):r==="grouping"?n("datapoints"):r==="datapoints"?n("topic-input"):(r==="topic-input"||r==="homepage-review")&&n("mode")},K=()=>{if(!$||P.length===0)return;const F=l.trim()||(a==="homepage"?"Startseite":o),W=Date.now(),ee=$.widgets.map((Z,U)=>({...Z,id:`wiz-${W}-${U}`}));e(F,ee)},re=a==="homepage"?["mode","homepage-review","layout"]:E?["mode","topic-input","datapoints","grouping","layout"]:["mode","topic-input","datapoints","layout"],ie=re.indexOf(r),ye=r==="mode"||r==="topic-input"&&o.trim().length>0&&(b||S.length>0)||(r==="datapoints"||r==="grouping"||r==="homepage-review")&&P.length>0,je=!!$&&P.length>0;return m.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:t,children:m.jsxs("div",{className:"rounded-2xl w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)",maxHeight:"90vh"},onClick:F=>F.stopPropagation(),children:[m.jsxs("div",{className:"px-6 pt-5 pb-4 shrink-0",style:{borderBottom:"1px solid var(--app-border)"},children:[m.jsxs("div",{className:"flex items-center justify-between mb-3",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(vZ,{size:18,style:{color:"var(--accent)"}}),m.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Tab-Wizard"})]}),m.jsx("button",{onClick:t,className:"hover:opacity-70",style:{color:"var(--text-secondary)"},children:m.jsx(pn,{size:18})})]}),m.jsx("div",{className:"flex items-center gap-2",children:re.map((F,W)=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"w-2 h-2 rounded-full transition-colors",style:{background:W<=ie?"var(--accent)":"var(--app-border)"}}),W<re.length-1&&m.jsx("div",{className:"w-6 h-px",style:{background:"var(--app-border)"}})]},F))})]}),b&&m.jsx("div",{className:"h-0.5 shrink-0 overflow-hidden",style:{background:"var(--app-border)"},children:m.jsx("div",{className:"h-full",style:{background:"var(--accent)",animation:"wizard-loading 1.4s ease-in-out infinite"}})}),m.jsx("style",{children:`
|
|
609
609
|
@keyframes wizard-loading {
|
|
610
610
|
0% { transform: translateX(-100%); width: 40%; }
|
|
611
611
|
50% { transform: translateX(160%); width: 60%; }
|
package/www/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/aura/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Aura – ioBroker Dashboard</title>
|
|
8
|
-
<script type="module" crossorigin src="/aura/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/aura/assets/index-CFZA4qdN.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/aura/assets/index-JkH4kIOv.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|