chatroom-cli 1.108.2 → 1.108.3

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.
@@ -96,7 +96,7 @@ Error generating stack: `+a.message+`
96
96
  *
97
97
  * This source code is licensed under the ISC license.
98
98
  * See the LICENSE file in the root directory of this source tree.
99
- */const ww=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],h0=Oa("x",ww);function Rw({status:n}){return A.jsxs("header",{className:"flex items-center justify-between border-b border-chatroom-border px-6 py-4",children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx(d0,{className:"size-5 text-chatroom-text-muted","aria-hidden":!0}),A.jsx("h1",{className:"text-sm font-semibold uppercase tracking-widest",children:"Chatroom Daemon"})]}),n]})}function Ow({children:n}){return A.jsx("nav",{className:"flex gap-1 border-b border-chatroom-border px-6 py-2",children:n})}function Eb({active:n=!1,children:i,onClick:r}){return A.jsx("span",{className:n?"bg-chatroom-bg-secondary px-3 py-1.5 text-xs font-medium uppercase tracking-wide":"px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-chatroom-text-muted",onClick:r,role:r?"button":void 0,children:i})}function Tb(n){return new URLSearchParams(n.startsWith("?")?n.slice(1):n).get("tab")==="event-stream"?"event-stream":"logs"}function Cw(n){const i=new URLSearchParams(window.location.search);n.tab!==void 0&&(n.tab==="event-stream"?i.set("tab","event-stream"):i.delete("tab")),n.chatroomId!==void 0&&(n.chatroomId?i.set("chatroomId",n.chatroomId):i.delete("chatroomId"));const r=i.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}`)}function Aw(){const[n,i]=O.useState(()=>Tb(window.location.search)),r=O.useCallback(o=>{i(o),Cw({tab:o})},[]);return O.useEffect(()=>{const o=()=>i(Tb(window.location.search));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{activeTab:n,setActiveTab:r}}const mi=Object.create(null);mi.open="0";mi.close="1";mi.ping="2";mi.pong="3";mi.message="4";mi.upgrade="5";mi.noop="6";const _c=Object.create(null);Object.keys(mi).forEach(n=>{_c[mi[n]]=n});const ih={type:"error",data:"parser error"},m0=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",p0=typeof ArrayBuffer=="function",g0=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Ah=({type:n,data:i},r,o)=>m0&&i instanceof Blob?r?o(i):wb(i,o):p0&&(i instanceof ArrayBuffer||g0(i))?r?o(i):wb(new Blob([i]),o):o(mi[n]+(i||"")),wb=(n,i)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];i("b"+(o||""))},r.readAsDataURL(n)};function Rb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Rd;function _w(n,i){if(m0&&n.data instanceof Blob)return n.data.arrayBuffer().then(Rb).then(i);if(p0&&(n.data instanceof ArrayBuffer||g0(n.data)))return i(Rb(n.data));Ah(n,!1,r=>{Rd||(Rd=new TextEncoder),i(Rd.encode(r))})}const Ob="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Ob.length;n++)Mo[Ob.charCodeAt(n)]=n;const Mw=n=>{let i=n.length*.75,r=n.length,o,c=0,f,d,m,g;n[n.length-1]==="="&&(i--,n[n.length-2]==="="&&i--);const p=new ArrayBuffer(i),y=new Uint8Array(p);for(o=0;o<r;o+=4)f=Mo[n.charCodeAt(o)],d=Mo[n.charCodeAt(o+1)],m=Mo[n.charCodeAt(o+2)],g=Mo[n.charCodeAt(o+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|g&63;return p},Nw=typeof ArrayBuffer=="function",_h=(n,i)=>{if(typeof n!="string")return{type:"message",data:y0(n,i)};const r=n.charAt(0);return r==="b"?{type:"message",data:Dw(n.substring(1),i)}:_c[r]?n.length>1?{type:_c[r],data:n.substring(1)}:{type:_c[r]}:ih},Dw=(n,i)=>{if(Nw){const r=Mw(n);return y0(r,i)}else return{base64:!0,data:n}},y0=(n,i)=>{switch(i){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},b0="",zw=(n,i)=>{const r=n.length,o=new Array(r);let c=0;n.forEach((f,d)=>{Ah(f,!1,m=>{o[d]=m,++c===r&&i(o.join(b0))})})},kw=(n,i)=>{const r=n.split(b0),o=[];for(let c=0;c<r.length;c++){const f=_h(r[c],i);if(o.push(f),f.type==="error")break}return o};function jw(){return new TransformStream({transform(n,i){_w(n,r=>{const o=r.length;let c;if(o<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,o);else if(o<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(c[0]|=128),i.enqueue(c),i.enqueue(r)})}})}let Od;function bc(n){return n.reduce((i,r)=>i+r.length,0)}function vc(n,i){if(n[0].length===i)return n.shift();const r=new Uint8Array(i);let o=0;for(let c=0;c<i;c++)r[c]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function Uw(n,i){Od||(Od=new TextDecoder);const r=[];let o=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(o===0){if(bc(r)<1)break;const g=vc(r,1);f=(g[0]&128)===128,c=g[0]&127,c<126?o=3:c===126?o=1:o=2}else if(o===1){if(bc(r)<2)break;const g=vc(r,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(bc(r)<8)break;const g=vc(r,8),p=new DataView(g.buffer,g.byteOffset,g.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(ih);break}c=y*Math.pow(2,32)+p.getUint32(4),o=3}else{if(bc(r)<c)break;const g=vc(r,c);m.enqueue(_h(f?g:Od.decode(g),i)),o=0}if(c===0||c>n){m.enqueue(ih);break}}}})}const v0=4;function zt(n){if(n)return Lw(n)}function Lw(n){for(var i in zt.prototype)n[i]=zt.prototype[i];return n}zt.prototype.on=zt.prototype.addEventListener=function(n,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(i),this};zt.prototype.once=function(n,i){function r(){this.off(n,r),i.apply(this,arguments)}return r.fn=i,this.on(n,r),this};zt.prototype.off=zt.prototype.removeListener=zt.prototype.removeAllListeners=zt.prototype.removeEventListener=function(n,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,c=0;c<r.length;c++)if(o=r[c],o===i||o.fn===i){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};zt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)i[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,c=r.length;o<c;++o)r[o].apply(this,i)}return this};zt.prototype.emitReserved=zt.prototype.emit;zt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};zt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Wc=typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,r)=>r(i,0),Xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Bw="arraybuffer";function S0(n,...i){return i.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const Hw=Xn.setTimeout,qw=Xn.clearTimeout;function $c(n,i){i.useNativeTimers?(n.setTimeoutFn=Hw.bind(Xn),n.clearTimeoutFn=qw.bind(Xn)):(n.setTimeoutFn=Xn.setTimeout.bind(Xn),n.clearTimeoutFn=Xn.clearTimeout.bind(Xn))}const Yw=1.33;function Vw(n){return typeof n=="string"?Gw(n):Math.ceil((n.byteLength||n.size)*Yw)}function Gw(n){let i=0,r=0;for(let o=0,c=n.length;o<c;o++)i=n.charCodeAt(o),i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(o++,r+=4);return r}function x0(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Qw(n){let i="";for(let r in n)n.hasOwnProperty(r)&&(i.length&&(i+="&"),i+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return i}function Xw(n){let i={},r=n.split("&");for(let o=0,c=r.length;o<c;o++){let f=r[o].split("=");i[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return i}class Fw extends Error{constructor(i,r,o){super(i),this.description=r,this.context=o,this.type="TransportError"}}class Mh extends zt{constructor(i){super(),this.writable=!1,$c(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,r,o){return super.emitReserved("error",new Fw(i,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(i){this.readyState==="open"&&this.write(i)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(i){const r=_h(i,this.socket.binaryType);this.onPacket(r)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,r={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_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(i){const r=Qw(i);return r.length?"?"+r:""}}class Kw extends Mh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const r=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};kw(i,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const i=()=>{this.write([{type:"close"}])};this.readyState==="open"?i():this.once("open",i)}write(i){this.writable=!1,zw(i,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=x0()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(i,r)}}let E0=!1;try{E0=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Zw=E0;function Pw(){}class Iw extends Kw{constructor(i){if(super(i),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||o!==i.port}}doWrite(i,r){const o=this.request({method:"POST",data:i});o.on("success",r),o.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=i}}class hi extends zt{constructor(i,r,o){super(),this.createRequest=i,$c(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var i;const r=S0(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&o.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var c;o.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=hi.requestsCount++,hi.requests[this._index]=this)}_onError(i){this.emitReserved("error",i,this._xhr),this._cleanup(!0)}_cleanup(i){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Pw,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete hi.requests[this._index],this._xhr=null}}_onLoad(){const i=this._xhr.responseText;i!==null&&(this.emitReserved("data",i),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}hi.requestsCount=0;hi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Cb);else if(typeof addEventListener=="function"){const n="onpagehide"in Xn?"pagehide":"unload";addEventListener(n,Cb,!1)}}function Cb(){for(let n in hi.requests)hi.requests.hasOwnProperty(n)&&hi.requests[n].abort()}const Jw=function(){const n=T0({xdomain:!1});return n&&n.responseType!==null}();class Ww extends Iw{constructor(i){super(i);const r=i&&i.forceBase64;this.supportsBinary=Jw&&!r}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new hi(T0,this.uri(),i)}}function T0(n){const i=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||Zw))return new XMLHttpRequest}catch{}if(!i)try{return new Xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const w0=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class $w extends Mh{get name(){return"websocket"}doOpen(){const i=this.uri(),r=this.opts.protocols,o=w0?{}:S0(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,r,o)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=i=>this.onClose({description:"websocket connection closed",context:i}),this.ws.onmessage=i=>this.onData(i.data),this.ws.onerror=i=>this.onError("websocket error",i)}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;Ah(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}c&&Wc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const i=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=x0()),this.supportsBinary||(r.b64=1),this.createUri(i,r)}}const Cd=Xn.WebSocket||Xn.MozWebSocket;class eR extends $w{createSocket(i,r,o){return w0?new Cd(i,r,o):r?new Cd(i,r):new Cd(i)}doWrite(i,r){this.ws.send(r)}}class tR extends Mh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(i){return this.emitReserved("error",i)}this._transport.closed.then(()=>{this.onClose()}).catch(i=>{this.onError("webtransport error",i)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(i=>{const r=Uw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=i.readable.pipeThrough(r).getReader(),c=jw();c.readable.pipeTo(i.writable),this._writer=c.writable.getWriter();const f=()=>{o.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;this._writer.write(o).then(()=>{c&&Wc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const nR={websocket:eR,webtransport:tR,polling:Ww},iR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,sR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function sh(n){if(n.length>8e3)throw"URI too long";const i=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let c=iR.exec(n||""),f={},d=14;for(;d--;)f[sR[d]]=c[d]||"";return r!=-1&&o!=-1&&(f.source=i,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=rR(f,f.path),f.queryKey=aR(f,f.query),f}function rR(n,i){const r=/\/{2,9}/g,o=i.replace(r,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&o.splice(0,1),i.slice(-1)=="/"&&o.splice(o.length-1,1),o}function aR(n,i){const r={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,c,f){c&&(r[c]=f)}),r}const rh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mc=[];rh&&addEventListener("offline",()=>{Mc.forEach(n=>n())},!1);class Os extends zt{constructor(i,r){if(super(),this.binaryType=Bw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(r=i,i=null),i){const o=sh(i);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=sh(r.host).host);$c(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(o=>{const c=o.prototype.name;this.transports.push(c),this._transportsByName[c]=o}),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=Xw(this.opts.query)),rh&&(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"})},Mc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const r=Object.assign({},this.opts.query);r.EIO=v0,r.transport=i,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Os.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(i);r.open(),this.setTransport(r)}setTransport(i){this.transport&&this.transport.removeAllListeners(),this.transport=i,i.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",Os.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",i),this.emitReserved("heartbeat"),i.type){case"open":this.onHandshake(JSON.parse(i.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=i.data,this._onError(r);break;case"message":this.emitReserved("data",i.data),this.emitReserved("message",i.data);break}}onHandshake(i){this.emitReserved("handshake",i),this.id=i.sid,this.transport.query.sid=i.sid,this._pingInterval=i.pingInterval,this._pingTimeout=i.pingTimeout,this._maxPayload=i.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const i=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+i,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},i),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 i=this._getWritablePackets();this.transport.send(i),this._prevBufferLen=i.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const c=this.writeBuffer[o].data;if(c&&(r+=Vw(c)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,Wc(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,r,o){return this._sendPacket("message",i,r,o),this}send(i,r,o){return this._sendPacket("message",i,r,o),this}_sendPacket(i,r,o,c){if(typeof r=="function"&&(c=r,r=void 0),typeof o=="function"&&(c=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:i,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),i()},o=()=>{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?o():i()}):this.upgrading?o():i()),this}_onError(i){if(Os.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",i),this._onClose("transport error",i)}_onClose(i,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(),rh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Mc.indexOf(this._offlineEventListener);o!==-1&&Mc.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,r),this.writeBuffer=[],this._prevBufferLen=0}}}Os.protocol=v0;class oR extends Os{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let i=0;i<this._upgrades.length;i++)this._probe(this._upgrades[i])}_probe(i){let r=this.createTransport(i),o=!1;Os.priorWebsocketSuccess=!1;const c=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Os.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,y(),r.close(),r=null)}const d=v=>{const S=new Error("probe error: "+v);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function m(){d("transport closed")}function g(){d("socket closed")}function p(v){r&&v.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",g),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",g),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const r=[];for(let o=0;o<i.length;o++)~this.transports.indexOf(i[o])&&r.push(i[o]);return r}}let lR=class extends oR{constructor(i,r={}){const o=typeof i=="object",c=o?{...i}:{...r};(!c.transports||c.transports&&typeof c.transports[0]=="string")&&(c.transports=(c.transports||["polling","websocket","webtransport"]).map(f=>nR[f]).filter(f=>!!f)),super(o?c:i,c)}};function cR(n,i="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=sh(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+i,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const uR=typeof ArrayBuffer=="function",fR=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,R0=Object.prototype.toString,dR=typeof Blob=="function"||typeof Blob<"u"&&R0.call(Blob)==="[object BlobConstructor]",hR=typeof File=="function"||typeof File<"u"&&R0.call(File)==="[object FileConstructor]";function Nh(n){return uR&&(n instanceof ArrayBuffer||fR(n))||dR&&n instanceof Blob||hR&&n instanceof File}function Nc(n,i){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(Nc(n[r]))return!0;return!1}if(Nh(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Nc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Nc(n[r]))return!0;return!1}function mR(n){const i=[],r=n.data,o=n;return o.data=Dc(r,i),o.attachments=i.length,{packet:o,buffers:i}}function Dc(n,i,r){if(!n)return n;if(Nh(n)){const o={_placeholder:!0,num:i.length};return i.push(n),o}else if(Array.isArray(n)){const o=new Array(n.length);for(let c=0;c<n.length;c++)o[c]=Dc(n[c],i);return o}else if(typeof n=="object"&&!(n instanceof Date)){if(n.toJSON&&typeof n.toJSON=="function"&&!r)return Dc(n.toJSON(),i,!0);const o={};for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(o[c]=Dc(n[c],i));return o}return n}function pR(n,i){return n.data=ah(n.data,i),delete n.attachments,n}function ah(n,i){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<i.length)return i[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=ah(n[r],i);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=ah(n[r],i));return n}const O0=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],gR=5;var Ne;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ne||(Ne={}));class yR{constructor(i){this.replacer=i}encode(i){return(i.type===Ne.EVENT||i.type===Ne.ACK)&&Nc(i)?this.encodeAsBinary({type:i.type===Ne.EVENT?Ne.BINARY_EVENT:Ne.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let r=""+i.type;return(i.type===Ne.BINARY_EVENT||i.type===Ne.BINARY_ACK)&&(r+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(r+=i.nsp+","),i.id!=null&&(r+=i.id),i.data!=null&&(r+=JSON.stringify(i.data,this.replacer)),r}encodeAsBinary(i){const r=mR(i),o=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(o),c}}class Dh extends zt{constructor(i){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof i=="function"?{reviver:i}:i)}add(i){let r;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(i);const o=r.type===Ne.BINARY_EVENT;o||r.type===Ne.BINARY_ACK?(r.type=o?Ne.EVENT:Ne.ACK,this.reconstructor=new bR(r)):super.emitReserved("decoded",r)}else if(Nh(i)||i.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(i),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: "+i)}decodeString(i){let r=0;const o={type:Number(i.charAt(0))};if(Ne[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Ne.BINARY_EVENT||o.type===Ne.BINARY_ACK){const f=r+1;for(;i.charAt(++r)!=="-"&&r!=i.length;);const d=i.substring(f,r);if(d!=Number(d)||i.charAt(r)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!C0(m)||m<1)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");o.attachments=m}if(i.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(i.charAt(r)===","||r===i.length););o.nsp=i.substring(f,r)}else o.nsp="/";const c=i.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=i.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===i.length)break}o.id=Number(i.substring(f,r+1))}if(i.charAt(++r)){const f=this.tryParse(i.substr(r));if(Dh.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(i){try{return JSON.parse(i,this.opts.reviver)}catch{return!1}}static isPayloadValid(i,r){switch(i){case Ne.CONNECT:return Yc(r);case Ne.DISCONNECT:return r===void 0;case Ne.CONNECT_ERROR:return typeof r=="string"||Yc(r);case Ne.EVENT:case Ne.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&O0.indexOf(r[0])===-1);case Ne.ACK:case Ne.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class bR{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const r=pR(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function vR(n){return typeof n=="string"}const C0=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function SR(n){return n===void 0||C0(n)}function Yc(n){return Object.prototype.toString.call(n)==="[object Object]"}function xR(n,i){switch(n){case Ne.CONNECT:return i===void 0||Yc(i);case Ne.DISCONNECT:return i===void 0;case Ne.EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&O0.indexOf(i[0])===-1);case Ne.ACK:return Array.isArray(i);case Ne.CONNECT_ERROR:return typeof i=="string"||Yc(i);default:return!1}}function ER(n){return vR(n.nsp)&&SR(n.id)&&xR(n.type,n.data)}const TR=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Dh,Encoder:yR,get PacketType(){return Ne},isPacketValid:ER,protocol:gR},Symbol.toStringTag,{value:"Module"}));function Wn(n,i,r){return n.on(i,r),function(){n.off(i,r)}}const wR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class A0 extends zt{constructor(i,r,o){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=i,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[Wn(i,"open",this.onopen.bind(this)),Wn(i,"packet",this.onpacket.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"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(...i){return i.unshift("message"),this.emit.apply(this,i),this}emit(i,...r){var o,c,f;if(wR.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(r.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:Ne.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,v=r.pop();this._registerAckCallback(y,v),d.id=y}const m=(c=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(i,r){var o;const c=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(c===void 0){this.acks[i]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===i&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[i]=d}emitWithAck(i,...r){return new Promise((o,c)=>{const f=(d,m)=>d?c(d):o(m);f.withError=!0,r.push(f),this.emit(i,...r)})}_addToQueue(i){let r;typeof i[i.length-1]=="function"&&(r=i.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((c,...f)=>(this._queue[0],c!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!i||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(i){i.nsp=this.nsp,this.io._packet(i)}onopen(){typeof this.auth=="function"?this.auth(i=>{this._sendConnectPacket(i)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(i){this.packet({type:Ne.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},i):i})}onerror(i){this.connected||this.emitReserved("connect_error",i)}onclose(i,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(o=>String(o.id)===i)){const o=this.acks[i];delete this.acks[i],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case Ne.CONNECT:i.data&&i.data.sid?this.onconnect(i.data.sid,i.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 Ne.EVENT:case Ne.BINARY_EVENT:this.onevent(i);break;case Ne.ACK:case Ne.BINARY_ACK:this.onack(i);break;case Ne.DISCONNECT:this.ondisconnect();break;case Ne.CONNECT_ERROR:this.destroy();const o=new Error(i.data.message);o.data=i.data.data,this.emitReserved("connect_error",o);break}}onevent(i){const r=i.data||[];i.id!=null&&r.push(this.ack(i.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,i)}super.emit.apply(this,i),this._pid&&i.length&&typeof i[i.length-1]=="string"&&(this._lastOffset=i[i.length-1])}ack(i){const r=this;let o=!1;return function(...c){o||(o=!0,r.packet({type:Ne.ACK,id:i,data:c}))}}onack(i){const r=this.acks[i.id];typeof r=="function"&&(delete this.acks[i.id],r.withError&&i.data.unshift(null),r.apply(this,i.data))}onconnect(i,r){this.id=i,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(i=>this.emitEvent(i)),this.receiveBuffer=[],this.sendBuffer.forEach(i=>{this.notifyOutgoingListeners(i),this.packet(i)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(i=>i()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ne.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(i){return this.flags.compress=i,this}get volatile(){return this.flags.volatile=!0,this}timeout(i){return this.flags.timeout=i,this}onAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(i),this}prependAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(i),this}offAny(i){if(!this._anyListeners)return this;if(i){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(i),this}prependAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(i),this}offAnyOutgoing(i){if(!this._anyOutgoingListeners)return this;if(i){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,i.data)}}}function Ca(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Ca.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),r=Math.floor(i*this.jitter*n);n=(Math.floor(i*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Ca.prototype.reset=function(){this.attempts=0};Ca.prototype.setMin=function(n){this.ms=n};Ca.prototype.setMax=function(n){this.max=n};Ca.prototype.setJitter=function(n){this.jitter=n};class oh extends zt{constructor(i,r){var o;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(r=i,i=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,$c(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new Ca({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=i;const c=r.parser||TR;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(i){return arguments.length?(this._reconnection=!!i,i||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(i){return i===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=i,this)}reconnectionDelay(i){var r;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(r=this.backoff)===null||r===void 0||r.setMin(i),this)}randomizationFactor(i){var r;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(r=this.backoff)===null||r===void 0||r.setJitter(i),this)}reconnectionDelayMax(i){var r;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(r=this.backoff)===null||r===void 0||r.setMax(i),this)}timeout(i){return arguments.length?(this._timeout=i,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(i){if(~this._readyState.indexOf("open"))return this;this.engine=new lR(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const c=Wn(r,"open",function(){o.onopen(),i&&i()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),i?i(m):this.maybeReconnectOnOpen()},d=Wn(r,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(d),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(Wn(i,"ping",this.onping.bind(this)),Wn(i,"data",this.ondata.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(r){this.onclose("parse error",r)}}ondecoded(i){Wc(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,r){let o=this.nsps[i];return o?this._autoConnect&&!o.active&&o.connect():(o=new A0(this,i,r),this.nsps[i]=o),o}_destroy(i){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(i){const r=this.encoder.encode(i);for(let o=0;o<r.length;o++)this.engine.write(r[o],i.options)}cleanup(){this.subs.forEach(i=>i()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(i,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const i=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 o=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(c=>{c?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",c)):i.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Ro={};function zc(n,i){typeof n=="object"&&(i=n,n=void 0),i=i||{};const r=cR(n,i.path||"/socket.io"),o=r.source,c=r.id,f=r.path,d=Ro[c]&&f in Ro[c].nsps,m=i.forceNew||i["force new connection"]||i.multiplex===!1||d;let g;return m?g=new oh(o,i):(Ro[c]||(Ro[c]=new oh(o,i)),g=Ro[c]),r.query&&!i.query&&(i.query=r.queryKey),g.socket(r.path,i)}Object.assign(zc,{Manager:oh,Socket:A0,io:zc,connect:zc});let Ad=null;function dr(){return Ad||(Ad=zc({transports:["websocket"],autoConnect:!0})),Ad}async function RR(){const n=dr();return await Ko(n),n.emitWithAck("health.get")}async function Ko(n){n.connected||await new Promise((i,r)=>{const o=()=>{f(),i()},c=d=>{f(),r(d)},f=()=>{n.off("connect",o),n.off("connect_error",c)};n.on("connect",o),n.on("connect_error",c),n.connect()})}async function OR(n){const i=dr();return await Ko(i),i.emitWithAck("logs.history",n)}async function CR(n,i){const r=dr();return await Ko(r),r.emitWithAck("logs.dimensions",{chatroomId:n,limit:i})}async function AR(){const n=dr();return await Ko(n),n.emitWithAck("chatrooms.list")}async function _R(n){const i=dr();return await Ko(i),i.emitWithAck("eventStream.history",n??{})}function MR(n){const i=dr();return i.connect(),i.emit("eventStream.stream.subscribe"),i.on("eventStream.stream",n),()=>i.off("eventStream.stream",n)}function NR(n){const i=dr();return i.connect(),i.emit("logs.stream.subscribe"),i.on("logs.stream",n),()=>i.off("logs.stream",n)}function DR(){return Hv({queryKey:["daemon","health"],queryFn:async()=>{const n=await RR();if(!n.ok)throw new Error(n.error.message);return n.data},retry:2})}const zR={info:{badge:"bg-chatroom-status-info/15 text-chatroom-status-info"},success:{badge:"bg-chatroom-status-success/15 text-chatroom-status-success"},warning:{badge:"bg-chatroom-status-warning/15 text-chatroom-status-warning"},error:{badge:"bg-chatroom-status-error/15 text-chatroom-status-error"},muted:{badge:"bg-chatroom-text-muted/15 text-chatroom-text-muted"},purple:{badge:"bg-chatroom-status-purple/15 text-chatroom-status-purple"}};function kR(n){return zR[n]}const jR={"agent.started":["Agent Started","success"],"agent.exited":["Agent Exited","error"],"agent.circuitOpen":["Circuit Open","warning"],"agent.requestStart":["Agent Request Start","warning"],"agent.requestStop":["Agent Request Stop","error"],"agent.registered":["Agent Registered","success"],"agent.waiting":["Agent Waiting","success"],"agent.startFailed":["Agent Start Failed","error"],"agent.providerUnavailable":["Provider Unavailable","warning"],"agent.sessionResumeRequested":["Session Reconnect Requested","info"],"agent.sessionResumed":["Session Reconnected","success"],"agent.sessionResumeFailed":["Session Reconnect Failed","warning"],"agent.sessionReopenRetry":["Session Reopen Retry","info"],"agent.sessionCompacted":["Session Compacted","info"],"agent.sessionAugmented":["Session Augmented","info"],"agent.resumeStormAborted":["Resume Storm Aborted","error"],"agent.restart":["Agent Restarting","info"],"agent.restartCompleted":["Agent Restarted","success"],"agent.restartPhase":["Agent Restart Progress","info"],"agent.restartLimitReached":["Agent Restart Limit","error"],"agent.stopTimeout":["Agent Stop Timeout","warning"],"agent.harnessSessionIdUpdated":["Harness Session ID Updated","info"],"agent.awaitingHandoff":["Awaiting Handoff","warning"],"agent.enhancing":["Planning Review","info"],"agent.taskDelivered":["Task Delivered","success"],"agent.taskDeliveryFailed":["Task Delivery Failed","error"],"machine.switched":["Machine Switched","info"],"connection.terminated":["Connection Terminated","muted"],"workflow.started":["Workflow Started","info"],"workflow.stepCompleted":["Workflow Step Completed","success"],"workflow.stepCancelled":["Workflow Step Cancelled","warning"],"workflow.completed":["Workflow Completed","success"],"workflow.created":["Workflow Created","info"],"workflow.specified":["Workflow Specified","info"],"workflow.stepStarted":["Workflow Step Started","info"],"task.activated":["Task Activated","success"],"task.acknowledged":["Task Acknowledged","success"],"task.inProgress":["Task In Progress","info"],"task.completed":["Task Completed","success"],"skill.activated":["Skill Activated","purple"],"daemon.ping":["Daemon Ping","muted"],"daemon.pong":["Daemon Pong","muted"],"daemon.gitRefresh":["Git Refresh","muted"],"daemon.workspaceListChanged":["Workspace List Changed","muted"],"daemon.refreshCapabilities":["Capabilities Refresh","muted"],"daemon.pickFolder":["Pick Folder","muted"],"daemon.localAction":["Local Action","muted"],"config.requestRemoval":["Config Request Removal","warning"],"command.run":["Command Run","warning"],"command.stop":["Command Stop","error"],"enhancer.job.created":["Planning Review Started","info"],"enhancer.attempt.failed":["Planning Review Attempt Failed","warning"],"enhancer.job.failed":["Planning Review Failed","error"],"enhancer.job.complete":["Planning Review Complete","success"],"enhancer.job.cancelled":["Planning Review Cancelled","warning"]},UR=Object.fromEntries(Object.entries(jR).map(([n,[i,r]])=>[n,{label:i,classification:r}]));function LR(n){const i=n.toLowerCase();return i.includes("failed")||i.includes("error")||i.includes("timeout")?"error":n.startsWith("task.")?"success":n.startsWith("agent.")||n.startsWith("workflow.")||n.startsWith("enhancer.")?"info":n.startsWith("daemon.")?"muted":n.startsWith("command.")?"warning":n.startsWith("skill.")?"purple":"muted"}function BR(n){return UR[n]??{label:n,classification:LR(n)}}function _0({type:n,className:i}){const r=BR(n);return A.jsx("span",{className:un("shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider",kR(r.classification).badge,i),children:r.label})}function eu(){return typeof window<"u"}function $t(n){return zh(n)?(n.nodeName||"").toLowerCase():"#document"}function kt(n){var i;return(n==null||(i=n.ownerDocument)==null?void 0:i.defaultView)||window}function Xi(n){var i;return(i=(zh(n)?n.ownerDocument:n.document)||window.document)==null?void 0:i.documentElement}function zh(n){return eu()?n instanceof Node||n instanceof kt(n).Node:!1}function Je(n){return eu()?n instanceof Element||n instanceof kt(n).Element:!1}function Rt(n){return eu()?n instanceof HTMLElement||n instanceof kt(n).HTMLElement:!1}function xa(n){return!eu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof kt(n).ShadowRoot}function hr(n){const{overflow:i,overflowX:r,overflowY:o,display:c}=zn(n);return/auto|scroll|overlay|hidden|clip/.test(i+o+r)&&c!=="inline"&&c!=="contents"}function HR(n){return/^(table|td|th)$/.test($t(n))}function tu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const qR=/transform|translate|scale|rotate|perspective|filter/,YR=/paint|layout|strict|content/,Ws=n=>!!n&&n!=="none";let _d;function kh(n){const i=Je(n)?zn(n):n;return Ws(i.transform)||Ws(i.translate)||Ws(i.scale)||Ws(i.rotate)||Ws(i.perspective)||!jh()&&(Ws(i.backdropFilter)||Ws(i.filter))||qR.test(i.willChange||"")||YR.test(i.contain||"")}function VR(n){let i=As(n);for(;Rt(i)&&!Cs(i);){if(kh(i))return i;if(tu(i))return null;i=As(i)}return null}function jh(){return _d==null&&(_d=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_d}function Cs(n){return/^(html|body|#document)$/.test($t(n))}function zn(n){return kt(n).getComputedStyle(n)}function nu(n){return Je(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function As(n){if($t(n)==="html")return n;const i=n.assignedSlot||n.parentNode||xa(n)&&n.host||Xi(n);return xa(i)?i.host:i}function M0(n){const i=As(n);return Cs(i)?(n.ownerDocument||n).body:Rt(i)&&hr(i)?i:M0(i)}function zo(n,i,r){var o;i===void 0&&(i=[]),r===void 0&&(r=!0);const c=M0(n),f=c===((o=n.ownerDocument)==null?void 0:o.body),d=kt(c);if(f){const m=lh(d);return i.concat(d,d.visualViewport||[],hr(c)?c:[],m&&r?zo(m):[])}else return i.concat(c,zo(c,[],r))}function lh(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Uh={...o1},Md=Uh.useInsertionEffect,GR=Md&&Md!==Uh.useLayoutEffect?Md:n=>n();function $e(n){const i=Qi(QR).current;return i.next=n,GR(i.effect),i.trampoline}function QR(){const n={next:void 0,callback:XR,trampoline:(...i)=>{var r;return(r=n.callback)==null?void 0:r.call(n,...i)},effect:()=>{n.callback=n.next}};return n}function XR(){}const FR=()=>{},Xe=typeof document<"u"?O.useLayoutEffect:FR,KR=O.createContext(void 0);function ZR(n=!1){const i=O.useContext(KR);if(i===void 0&&!n)throw new Error(ur(16));return i}function PR(n){const{focusableWhenDisabled:i,disabled:r,composite:o=!1,tabIndex:c=0,isNativeButton:f}=n,d=o&&i!==!1,m=o&&i===!1;return{props:O.useMemo(()=>{const p={onKeyDown(y){r&&i&&y.key!=="Tab"&&y.preventDefault()}};return o||(p.tabIndex=c,!f&&r&&(p.tabIndex=i?c:-1)),(f&&(i||d)||!f&&r)&&(p["aria-disabled"]=r),f&&(!i||m)&&(p.disabled=r),p},[o,r,i,d,m,f,c])}}function N0(n={}){const{disabled:i=!1,focusableWhenDisabled:r,tabIndex:o=0,native:c=!0,composite:f}=n,d=O.useRef(null),m=ZR(!0),g=f??m!==void 0,{props:p}=PR({focusableWhenDisabled:r,disabled:i,composite:g,tabIndex:o,isNativeButton:c}),y=O.useCallback(()=>{const E=d.current;Nd(E)&&g&&i&&p.disabled===void 0&&E.disabled&&(E.disabled=!1)},[i,p.disabled,g]);Xe(y,[y]);const v=O.useCallback((E={})=>{const{onClick:x,onMouseDown:w,onKeyUp:_,onKeyDown:D,onPointerDown:C,...j}=E;return Fo({onClick(k){if(i){k.preventDefault();return}x==null||x(k)},onMouseDown(k){i||w==null||w(k)},onKeyDown(k){if(i||(Bc(k),D==null||D(k),k.baseUIHandlerPrevented))return;const q=k.target===k.currentTarget,F=k.currentTarget,B=Nd(F),U=!c&&IR(F),K=q&&(c?B:!U),se=k.key==="Enter",pe=k.key===" ",ae=F.getAttribute("role"),W=(ae==null?void 0:ae.startsWith("menuitem"))||ae==="option"||ae==="gridcell";if(q&&g&&pe){if(k.defaultPrevented&&W)return;k.preventDefault(),U||c&&B?(F.click(),k.preventBaseUIHandler()):K&&(x==null||x(k),k.preventBaseUIHandler());return}K&&(!c&&(pe||se)&&k.preventDefault(),!c&&se&&(x==null||x(k)))},onKeyUp(k){if(!i){if(Bc(k),_==null||_(k),k.target===k.currentTarget&&c&&g&&Nd(k.currentTarget)&&k.key===" "){k.preventDefault();return}k.baseUIHandlerPrevented||k.target===k.currentTarget&&!c&&!g&&k.key===" "&&(x==null||x(k))}},onPointerDown(k){if(i){k.preventDefault();return}C==null||C(k)}},c?{type:"button"}:{role:"button"},p,j)},[i,p,g,c]),S=$e(E=>{d.current=E,y()});return{getButtonProps:v,buttonRef:S}}function Nd(n){return Rt(n)&&n.tagName==="BUTTON"}function IR(n){return!!((n==null?void 0:n.tagName)==="A"&&(n!=null&&n.href))}const JR=O.forwardRef(function(i,r){const{render:o,className:c,disabled:f=!1,focusableWhenDisabled:d=!1,nativeButton:m=!0,style:g,...p}=i,{getButtonProps:y,buttonRef:v}=N0({disabled:f,focusableWhenDisabled:d,native:m});return Ra("button",i,{state:{disabled:f},ref:[r,v],props:[p,y]})}),WR=Iv("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input",ghost:"hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2",sm:"h-8 px-3"}},defaultVariants:{variant:"default",size:"default"}});function D0({className:n,variant:i="default",size:r="default",...o}){return A.jsx(JR,{"data-slot":"button",className:un(WR({variant:i,size:r,className:n})),...o})}function $R(n,i){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:i==null?void 0:i.timeZone})}function z0(n,i){return new Date(n).toLocaleString(void 0,{timeZone:i==null?void 0:i.timeZone})}function eO({entry:n,onClose:i}){const r=n.payload;return A.jsxs("aside",{className:"flex w-96 max-w-[40%] shrink-0 flex-col border-l border-chatroom-border bg-chatroom-bg-primary",role:"dialog","aria-modal":"true","aria-label":"Event detail",children:[A.jsxs("div",{className:"flex items-center justify-between border-b border-chatroom-border px-4 py-3",children:[A.jsx("h3",{className:"text-sm font-medium",children:"Event detail"}),A.jsx(D0,{variant:"ghost",size:"sm",onClick:i,"aria-label":"Close detail panel",children:A.jsx(h0,{className:"size-4"})})]}),A.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 text-xs",children:[A.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[A.jsx(_0,{type:n.type}),A.jsx("span",{className:"text-chatroom-text-muted",children:z0(n.timestamp)})]}),A.jsxs("div",{className:"space-y-1 text-chatroom-text-muted",children:[A.jsxs("div",{children:["Type: ",A.jsx("span",{className:"text-chatroom-text-primary",children:n.type})]}),A.jsxs("div",{children:["ID: ",A.jsx("span",{className:"text-chatroom-text-primary",children:n.id})]}),typeof r.chatroomId=="string"&&A.jsxs("div",{children:["Chatroom: ",A.jsx("span",{className:"text-chatroom-text-primary",children:r.chatroomId})]})]}),A.jsxs("div",{children:[A.jsx("p",{className:"mb-1 text-chatroom-text-muted",children:"Payload"}),A.jsx("pre",{className:"whitespace-pre-wrap border border-chatroom-border bg-chatroom-bg-secondary p-2 font-mono text-[11px]",children:JSON.stringify(r,null,2)})]})]})]})}function tO(n,i,r){const o=i.trim().toLowerCase();return o?n.filter(c=>r(c).toLowerCase().includes(o)):[...n]}function Vc({children:n,selected:i,onSelect:r,disabled:o,className:c,endAdornment:f,trailingActions:d,multiline:m=!1}){const g=un("min-w-0 px-3 py-2 text-xs text-left flex justify-between gap-2",m?"items-start":"items-center","cursor-pointer hover:bg-chatroom-bg-hover transition-colors","outline-none focus-visible:outline-none focus-visible:bg-chatroom-bg-hover","disabled:opacity-50 disabled:cursor-not-allowed",i&&"bg-chatroom-bg-hover",d?"flex-1 rounded-none":"w-full",!d&&c),p=A.jsxs("button",{type:"button",role:"option","aria-selected":i??!1,disabled:o,onClick:r,className:g,children:[A.jsx("span",{className:un("min-w-0 flex-1",m?"overflow-hidden":"truncate"),children:n}),f,i&&!d?A.jsx(bw,{size:12,className:"shrink-0 text-chatroom-accent"}):null]});return d?A.jsxs("div",{className:un("flex items-center w-full min-w-0",c),children:[p,d]}):p}function nO({children:n,className:i,maxHeightClassName:r="max-h-[60vh]"}){return A.jsx("div",{"data-picker-scroll-body":!0,className:un("min-h-0 overflow-y-auto overscroll-contain",r,i),children:n})}function iO({value:n,onChange:i,placeholder:r="Search…",autoFocus:o,className:c}){const f=o??!0;return A.jsx("div",{className:un("px-3 py-1.5 border-b border-chatroom-border shrink-0",c),"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),onClick:d=>{const m=d.currentTarget.querySelector("input");m==null||m.focus()},children:A.jsx("input",{type:"search",enterKeyHint:"search",value:n,onChange:d=>i(d.target.value),placeholder:r,autoFocus:f,"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),className:"w-full bg-chatroom-bg-tertiary border border-chatroom-border px-2 py-1 text-[11px] text-chatroom-text-primary placeholder:text-chatroom-text-muted focus:outline-none focus:border-chatroom-accent rounded-none"})})}const k0="min-w-[8rem] max-w-[14rem] border border-chatroom-border bg-chatroom-bg-secondary text-xs text-chatroom-text-primary px-2 py-1.5 h-[28px] cursor-pointer hover:border-chatroom-border-strong focus:outline-none focus:border-chatroom-accent disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between gap-1",j0="shrink-0 text-chatroom-text-muted";function sO(n){const[i,r]=O.useState(""),o=O.useCallback(c=>{c||r(""),n(c)},[n]);return{searchTerm:i,setSearchTerm:r,handleOpenChange:o}}const rO=[];function Lh(n){O.useEffect(n,rO)}const Oo=0;class ei{constructor(){tt(this,"currentId",Oo);tt(this,"clear",()=>{this.currentId!==Oo&&(clearTimeout(this.currentId),this.currentId=Oo)});tt(this,"disposeEffect",()=>this.clear)}static create(){return new ei}start(i,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Oo,r()},i)}isStarted(){return this.currentId!==Oo}}function Ea(){const n=Qi(ei.create).current;return Lh(n.disposeEffect),n}function aO(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:oO,platform:lO,maxTouchPoints:cO}=aO(),iu=oO.toLowerCase(),ko=lO.toLowerCase(),su=/^i(os$|p)/.test(ko)||ko==="macintel"&&cO>1,Ab="android",ch=ko===Ab||iu.includes(Ab),uO=!su&&ko.startsWith("mac");ko.startsWith("win");const fO=uO||su;var Cv;const Aa=typeof CSS<"u"&&!!((Cv=CSS.supports)!=null&&Cv.call(CSS,"-webkit-backdrop-filter:none"));!Aa&&iu.includes("firefox");!Aa&&iu.includes("chrom");const dO=fO,hO=/jsdom|happydom/.test(iu);function mO(n){n.preventDefault(),n.stopPropagation()}function pO(n){return"nativeEvent"in n}function gO(n){return n.pointerType===""&&n.isTrusted?!0:ch&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function yO(n){return hO?!1:!ch&&n.width===0&&n.height===0||ch&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function jo(n,i){const r=["mouse","pen"];return i||r.push("",void 0),r.includes(n)}function bO(n){const i=n.type;return i==="click"||i==="mousedown"||i==="keydown"||i==="keyup"}const uh="data-base-ui-focusable",U0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Ui(n){var r;let i=n.activeElement;for(;((r=i==null?void 0:i.shadowRoot)==null?void 0:r.activeElement)!=null;)i=i.shadowRoot.activeElement;return i}function Me(n,i){var o;if(!n||!i)return!1;const r=(o=i.getRootNode)==null?void 0:o.call(i);if(n.contains(i))return!0;if(r&&xa(r)){let c=i;for(;c;){if(n===c)return!0;c=c.parentNode||c.host}}return!1}function $n(n){return"composedPath"in n?n.composedPath()[0]:n.target}function L0(n,i){if(!Je(n))return!1;const r=n;if(i.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,o]of i.entries())if(Me(o,r))return!o.hasAttribute("data-trigger-disabled");return!1}function Dd(n,i){if(i==null)return!1;if("composedPath"in n)return n.composedPath().includes(i);const r=n;return r.target!=null&&i.contains(r.target)}function vO(n){return n.matches("html,body")}function Bh(n){return Rt(n)&&n.matches(U0)}function SO(n){return(n==null?void 0:n.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${U0}`))!=null}function _b(n){return n?n.getAttribute("role")==="combobox"&&Bh(n):!1}function Mb(n){return n?n.hasAttribute(uh)?n:n.querySelector(`[${uh}]`)||n:null}function xO(n,i){return i!=null&&!jo(i)?0:typeof n=="function"?n():n}function fh(n,i,r){const o=xO(n,r);return typeof o=="number"?o:o==null?void 0:o[i]}function Nb(n){return typeof n=="function"?n():n}function B0(n,i){return i||n==="click"||n==="mousedown"}function EO(n){return(n==null?void 0:n.includes("mouse"))&&n!=="mousedown"}const TO="none",Uo="trigger-press",xn="trigger-hover",H0="outside-press",wO="close-press",Lo="focus-out",q0="escape-key",RO="imperative-action";function Xt(n,i,r,o){let c=!1,f=!1;const d=Wt;return{reason:n,event:i??new Event("base-ui"),cancel(){c=!0},allowPropagation(){f=!0},get isCanceled(){return c},get isPropagationAllowed(){return f},trigger:r,...d}}function Ke(n,i,r,o){return n.addEventListener(i,r,o),()=>{n.removeEventListener(i,r,o)}}function qi(...n){return()=>{for(let i=0;i<n.length;i+=1){const r=n[i];r&&r()}}}function En(n){const i=Qi(OO,n).current;return i.next=n,Xe(i.effect),i}function OO(n){const i={current:n,next:n,effect:()=>{i.current=i.next}};return i}const Sc=null;class CO{constructor(){tt(this,"callbacks",[]);tt(this,"callbacksCount",0);tt(this,"nextId",1);tt(this,"startId",1);tt(this,"isScheduled",!1);tt(this,"tick",i=>{var c;this.isScheduled=!1;const r=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let f=0;f<r.length;f+=1)(c=r[f])==null||c.call(r,i)})}request(i){const r=this.nextId;return this.nextId+=1,this.callbacks.push(i),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(i){const r=i-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const xc=new CO;class di{constructor(){tt(this,"currentId",Sc);tt(this,"cancel",()=>{this.currentId!==Sc&&(xc.cancel(this.currentId),this.currentId=Sc)});tt(this,"disposeEffect",()=>this.cancel)}static create(){return new di}static request(i){return xc.request(i)}static cancel(i){return xc.cancel(i)}request(i){this.cancel(),this.currentId=xc.request(()=>{this.currentId=Sc,i()})}}function Hh(){const n=Qi(di.create).current;return Lh(n.disposeEffect),n}function ut(n){return(n==null?void 0:n.ownerDocument)||document}const AO={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},_O={...AO,position:"fixed",top:0,left:0},Ta=O.forwardRef(function(i,r){const[o,c]=O.useState();Xe(()=>{dO&&Aa&&c("button")},[]);const f={tabIndex:0,role:o};return A.jsx("span",{...i,ref:r,style:_O,"aria-hidden":o?void 0:!0,...f,"data-base-ui-focus-guard":""})}),MO=["top","right","bottom","left"],wa=Math.min,Yi=Math.max,Gc=Math.round,Ec=Math.floor,Vi=n=>({x:n,y:n}),NO={left:"right",right:"left",bottom:"top",top:"bottom"};function Y0(n,i,r){return Yi(n,wa(i,r))}function Gi(n,i){return typeof n=="function"?n(i):n}function Dn(n){return n.split("-")[0]}function Ds(n){return n.split("-")[1]}function qh(n){return n==="x"?"y":"x"}function Yh(n){return n==="y"?"height":"width"}function Fn(n){const i=n[0];return i==="t"||i==="b"?"y":"x"}function Vh(n){return qh(Fn(n))}function DO(n,i,r){r===void 0&&(r=!1);const o=Ds(n),c=Vh(n),f=Yh(c);let d=c==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return i.reference[f]>i.floating[f]&&(d=Qc(d)),[d,Qc(d)]}function zO(n){const i=Qc(n);return[dh(n),i,dh(i)]}function dh(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Db=["left","right"],zb=["right","left"],kO=["top","bottom"],jO=["bottom","top"];function UO(n,i,r){switch(n){case"top":case"bottom":return r?i?zb:Db:i?Db:zb;case"left":case"right":return i?kO:jO;default:return[]}}function LO(n,i,r,o){const c=Ds(n);let f=UO(Dn(n),r==="start",o);return c&&(f=f.map(d=>d+"-"+c),i&&(f=f.concat(f.map(dh)))),f}function Qc(n){const i=Dn(n);return NO[i]+n.slice(i.length)}function BO(n){var i,r,o,c;return{top:(i=n.top)!=null?i:0,right:(r=n.right)!=null?r:0,bottom:(o=n.bottom)!=null?o:0,left:(c=n.left)!=null?c:0}}function V0(n){return typeof n!="number"?BO(n):{top:n,right:n,bottom:n,left:n}}function Xc(n){const{x:i,y:r,width:o,height:c}=n;return{width:o,height:c,top:r,left:i,right:i+o,bottom:r+c,x:i,y:r}}function HO(n){return n.visibility==="hidden"||n.visibility==="collapse"}function G0(n,i=n?zn(n):null){return!n||!n.isConnected||!i||HO(i)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():i.display!=="none"&&i.display!=="contents"}const qO='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function YO(n){const i=n.assignedSlot;if(i)return i;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return xa(r)?r.host:null}function hh(n){for(const i of Array.from(n.children))if($t(i)==="summary")return i;return null}function VO(n,i){const r=hh(i);return!!r&&(n===r||Me(r,n))}function Q0(n){const i=n?$t(n):"";return n!=null&&n.matches(qO)&&(i!=="summary"||n.parentElement!=null&&$t(n.parentElement)==="details"&&hh(n.parentElement)===n)&&(i!=="details"||hh(n)==null)&&(i!=="input"||n.type!=="hidden")}function X0(n){if(!Q0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let i=n;i;i=YO(i)){const r=i!==n,o=$t(i)==="slot";if(i.hasAttribute("inert")||r&&$t(i)==="details"&&!i.open&&!VO(n,i)||i.hasAttribute("hidden")||!o&&!GO(i,r))return!1}return!0}function GO(n,i){const r=zn(n);return i?r.display!=="none":G0(n,r)}function F0(n){const i=n.tabIndex;if(i<0){const r=$t(n);if(r==="details"||r==="audio"||r==="video"||Rt(n)&&n.isContentEditable)return 0}return i}function zd(n){if($t(n)!=="input")return null;const i=n;return i.type==="radio"&&i.name!==""?i:null}function QO(n,i){const r=zd(n);if(!r)return!0;const o=i.find(c=>{const f=zd(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form&&f.checked});return o?o===r:i.find(c=>{const f=zd(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form})===r}function K0(n){if(Rt(n)&&$t(n)==="slot"){const i=n.assignedElements({flatten:!0});if(i.length>0)return i}return Rt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function Z0(n,i){K0(n).forEach(r=>{Q0(r)&&i.push(r),Z0(r,i)})}function P0(n,i,r){K0(n).forEach(o=>{Rt(o)&&o.matches(i)&&r.push(o),P0(o,i,r)})}function Gh(n){return X0(n)&&F0(n)>=0}function I0(n){const i=[];return Z0(n,i),i.filter(X0)}function Zo(n){const i=I0(n);return i.filter(r=>F0(r)>=0&&QO(r,i))}function J0(n,i){const r=Zo(n),o=r.length;if(o===0)return;const c=Ui(ut(n)),f=r.indexOf(c),d=f===-1?i===1?0:o-1:f+i;return r[d]}function Qh(n){return J0(ut(n).body,1)||n}function W0(n){return J0(ut(n).body,-1)||n}function $0(n,i){if(!n)return null;const r=Zo(ut(n).body),o=r.length;if(o===0)return null;const c=r.indexOf(n);if(c===-1)return null;const f=(c+i+o)%o;return r[f]}function XO(n){return $0(n,1)}function FO(n){return $0(n,-1)}function ra(n,i){const r=i||n.currentTarget,o=n.relatedTarget;return!o||!Me(r,o)}function KO(n){Zo(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function kb(n){const i=[];P0(n,"[data-tabindex]",i),i.forEach(r=>{const o=r.dataset.tabindex;delete r.dataset.tabindex,o?r.setAttribute("tabindex",o):r.removeAttribute("tabindex")})}function _s(n,i,r=!0){return n.filter(c=>c.parentId===i).flatMap(c=>{var f;return[...!r||(f=c.context)!=null&&f.open?[c]:[],..._s(n,c.id,r)]})}function jb(n,i){var c;let r=[],o=(c=n.find(f=>f.id===i))==null?void 0:c.parentId;for(;o;){const f=n.find(d=>d.id===o);o=f==null?void 0:f.parentId,f&&(r=r.concat(f))}return r}function Fc(n){return`data-base-ui-${n}`}let Tc=0;function kd(n,i={}){const{preventScroll:r=!1,sync:o=!1,shouldFocus:c}=i;cancelAnimationFrame(Tc);function f(){c&&!c()||n==null||n.focus({preventScroll:r})}if(o)return f(),Rh;const d=requestAnimationFrame(f);return Tc=d,()=>{Tc===d&&(cancelAnimationFrame(d),Tc=0)}}const jd={inert:new WeakMap,"aria-hidden":new WeakMap},Ub="data-base-ui-inert",mh={inert:new WeakSet,"aria-hidden":new WeakSet};let Co=new WeakMap,Ud=0;function ZO(n){return mh[n]}function eS(n){return n?xa(n)?n.host:eS(n.parentNode):null}const Lb=(n,i)=>i.map(r=>{if(n.contains(r))return r;const o=eS(r);return n.contains(o)?o:null}).filter(r=>r!=null),Bb=n=>{const i=new Set;return n.forEach(r=>{let o=r;for(;o&&!i.has(o);)i.add(o),o=o.parentNode}),i},Hb=(n,i,r)=>{const o=[],c=f=>{!f||r.has(f)||Array.from(f.children).forEach(d=>{$t(d)!=="script"&&(i.has(d)?c(d):o.push(d))})};return c(n),o};function PO(n,i,r,o,{mark:c=!0}){let f=null;o?f="inert":r&&(f="aria-hidden");let d=null,m=null;const g=Lb(i,n),p=c?Hb(i,Bb(g),new Set(g)):[],y=[],v=[];if(f){const S=jd[f],E=ZO(f);m=E,d=S;const x=Lb(i,Array.from(i.querySelectorAll("[aria-live]"))),w=g.concat(x);Hb(i,Bb(w),new Set(w)).forEach(D=>{const C=D.getAttribute(f),j=C!==null&&C!=="false",k=(S.get(D)||0)+1;S.set(D,k),y.push(D),k===1&&j&&E.add(D),j||D.setAttribute(f,f==="inert"?"":"true")})}return c&&p.forEach(S=>{const E=(Co.get(S)||0)+1;Co.set(S,E),v.push(S),E===1&&S.setAttribute(Ub,"")}),Ud+=1,()=>{d&&y.forEach(S=>{const x=(d.get(S)||0)-1;d.set(S,x),x||(!(m!=null&&m.has(S))&&f&&S.removeAttribute(f),m==null||m.delete(S))}),c&&v.forEach(S=>{const E=(Co.get(S)||0)-1;Co.set(S,E),E||S.removeAttribute(Ub)}),Ud-=1,Ud||(jd.inert=new WeakMap,jd["aria-hidden"]=new WeakMap,mh.inert=new WeakSet,mh["aria-hidden"]=new WeakSet,Co=new WeakMap)}}function qb(n,i={}){const{ariaHidden:r=!1,inert:o=!1,mark:c=!0}=i,f=ut(n[0]).body;return PO(n,f,r,o,{mark:c})}var Ms=qv();let Yb=0;function IO(n,i="mui"){const[r,o]=O.useState(n),c=n||r;return O.useEffect(()=>{r==null&&(Yb+=1,o(`${i}-${Yb}`))},[r,i]),c}const Vb=Uh.useId;function Po(n,i){if(Vb!==void 0){const r=Vb();return n??(i?`${i}-${r}`:r)}return IO(n,i)}const JO=500,WO={style:{transition:"none"}},tS="data-base-ui-click-trigger",$O={fallbackAxisSide:"end"},eC={clipPath:"inset(50%)",position:"fixed",top:0,left:0},nS=O.createContext(null),iS=()=>O.useContext(nS),tC=Fc("portal");function nC(n={}){const{ref:i,container:r,componentProps:o=Wt,elementProps:c}=n,f=Po(),d=iS(),m=d==null?void 0:d.portalNode,[g,p]=O.useState(null),[y,v]=O.useState(null),S=$e(_=>{_!==null&&v(_)}),E=O.useRef(null);Xe(()=>{if(r===null){E.current&&(E.current=null,v(null),p(null));return}if(f==null)return;const _=(r&&(zh(r)?r:r.current))??m??document.body;if(_==null){E.current&&(E.current=null,v(null),p(null));return}E.current!==_&&(E.current=_,v(null),p(_))},[r,m,f]);const x=Ra("div",o,{ref:[i,S],props:[{id:f,[tC]:""},c]});return{portalNode:y,portalSubtree:g&&x?Ms.createPortal(x,g):null}}const iC=O.forwardRef(function(i,r){const{render:o,className:c,style:f,children:d,container:m,renderGuards:g,...p}=i,{portalNode:y,portalSubtree:v}=nC({container:m,ref:r,componentProps:i,elementProps:p}),S=O.useRef(null),E=O.useRef(null),x=O.useRef(null),w=O.useRef(null),[_,D]=O.useState(null),C=O.useRef(!1),j=_==null?void 0:_.modal,k=_==null?void 0:_.open,q=typeof g=="boolean"?g:!!_&&!_.modal&&_.open&&!!y;O.useEffect(()=>{if(!y||j)return;function B(U){y&&U.relatedTarget&&ra(U)&&(U.type==="focusin"?C.current&&(kb(y),C.current=!1):(KO(y),C.current=!0))}return qi(Ke(y,"focusin",B,!0),Ke(y,"focusout",B,!0))},[y,j]),Xe(()=>{!y||k!==!0||!C.current||(kb(y),C.current=!1)},[k,y]);const F=O.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:E,beforeInsideRef:x,afterInsideRef:w,portalNode:y,setFocusManagerState:D}),[y]);return A.jsxs(O.Fragment,{children:[v,A.jsxs(nS.Provider,{value:F,children:[q&&y&&A.jsx(Ta,{"data-type":"outside",ref:S,onFocus:B=>{var U;if(ra(B,y))(U=x.current)==null||U.focus();else{const K=_?_.domReference:null,se=W0(K);se==null||se.focus()}}}),q&&y&&A.jsx("span",{"aria-owns":y.id,style:eC}),y&&Ms.createPortal(d,y),q&&y&&A.jsx(Ta,{"data-type":"outside",ref:E,onFocus:B=>{var U;if(ra(B,y))(U=w.current)==null||U.focus();else{const K=_?_.domReference:null,se=Qh(K);se==null||se.focus(),_!=null&&_.closeOnFocusOut&&(_==null||_.onOpenChange(!1,Xt(Lo,B.nativeEvent)))}}})]})]})});function sS(){const n=new Map;return{emit(i,r){var o;(o=n.get(i))==null||o.forEach(c=>c(r))},on(i,r){n.has(i)||n.set(i,new Set),n.get(i).add(r)},off(i,r){var o;(o=n.get(i))==null||o.delete(r)}}}class sC{constructor(){tt(this,"nodesRef",{current:[]});tt(this,"events",sS())}addNode(i){this.nodesRef.current.push(i)}removeNode(i){const r=this.nodesRef.current.findIndex(o=>o===i);r!==-1&&this.nodesRef.current.splice(r,1)}}const rS=O.createContext(null),aS=O.createContext(null),_a=()=>{var n;return((n=O.useContext(rS))==null?void 0:n.id)||null},Ma=n=>{const i=O.useContext(aS);return n??i};function rC(n){const i=Po(),r=Ma(n),o=_a();return Xe(()=>{if(!i)return;const c={id:i,parentId:o};return r==null||r.addNode(c),()=>{r==null||r.removeNode(c)}},[r,i,o]),i}function aC(n){const{children:i,id:r}=n,o=_a();return A.jsx(rS.Provider,{value:O.useMemo(()=>({id:r,parentId:o}),[r,o]),children:i})}function oC(n){const{children:i,externalTree:r}=n,o=Qi(()=>r??new sC).current;return A.jsx(aS.Provider,{value:o,children:i})}function Li(n){return n==null?n:"current"in n?n.current:n}function lC(n,i){const r=kt($n(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?i||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?i||(n.detail===0?"keyboard":"mouse"):""}const cC=20;let Rs=[];function Xh(){Rs=Rs.filter(n=>{var i;return(i=n.deref())==null?void 0:i.isConnected})}function Gb(n){Xh(),n&&$t(n)!=="body"&&(Rs.push(new WeakRef(n)),Rs.length>cC&&(Rs=Rs.slice(-20)))}function Qb(){var n;return Xh(),(n=Rs[Rs.length-1])==null?void 0:n.deref()}function uC(n){return n?Gh(n)?n:Zo(n)[0]||n:null}function Xb(n){var c;if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!((c=n.getAttribute("role"))!=null&&c.includes("dialog")))return;const r=I0(n).filter(f=>{const d=f.getAttribute("data-tabindex")||"";return Gh(f)||f.hasAttribute("data-tabindex")&&!d.startsWith("-")}),o=n.getAttribute("tabindex");r.length===0?o!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(o!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function fC(n){const{context:i,children:r,disabled:o=!1,initialFocus:c=!0,returnFocus:f=!0,restoreFocus:d=!1,modal:m=!0,closeOnFocusOut:g=!0,openInteractionType:p="",nextFocusableElement:y,previousFocusableElement:v,beforeContentFocusGuardRef:S,externalTree:E,getInsideElements:x}=n,w="rootStore"in i?i.rootStore:i,_=w.useState("open"),D=w.useState("domReferenceElement"),C=w.useState("floatingElement"),{events:j,dataRef:k}=w.context,q=$e(()=>{var ve;return(ve=k.current.floatingContext)==null?void 0:ve.nodeId}),F=c===!1,B=_b(D)&&F,U=En(c),K=En(f),se=En(p),pe=En(_),ae=Ma(E),W=iS(),le=O.useRef(!1),ie=O.useRef(!1),N=O.useRef(!1),Q=O.useRef(null),I=O.useRef(""),oe=O.useRef(""),Y=O.useRef(null),T=O.useRef(null),H=Hc(Y,S,W==null?void 0:W.beforeInsideRef),te=Hc(T,W==null?void 0:W.afterInsideRef),ne=Ea(),re=Ea(),ee=Hh(),ge=W!=null,ce=Mb(C),fe=$e((ve=ce)=>ve?Zo(ve):[]),Ze=$e(()=>(x==null?void 0:x().filter(ve=>ve!=null))??[]);O.useEffect(()=>{if(o||!m)return;function ve(Oe){Oe.key==="Tab"&&Me(ce,Ui(ut(ce)))&&fe().length===0&&!B&&mO(Oe)}const ze=ut(ce);return Ke(ze,"keydown",ve)},[o,ce,m,B,fe]),O.useEffect(()=>{if(o||!_)return;const ve=ut(ce);function ze(){N.current=!1}function Oe(vt){const Re=$n(vt),ke=Ze(),Ee=Me(C,Re)||Me(D,Re)||Me(W==null?void 0:W.portalNode,Re)||ke.some(mt=>mt===Re||Me(mt,Re));N.current=!Ee,oe.current=vt.pointerType||"keyboard",Re!=null&&Re.closest(`[${tS}]`)&&(ie.current=!0,re.start(0,()=>{ie.current=!1}))}function ft(){oe.current="keyboard"}return qi(Ke(ve,"pointerdown",Oe,!0),Ke(ve,"pointerup",ze,!0),Ke(ve,"pointercancel",ze,!0),Ke(ve,"keydown",ft,!0),ze)},[o,C,D,ce,_,W,re,Ze]),O.useEffect(()=>{if(o||!g)return;const ve=ut(ce);function ze(){ie.current=!0,re.start(0,()=>{ie.current=!1})}function Oe(ke){const Ee=$n(ke);Gh(Ee)&&(Q.current=Ee)}function ft(ke){const Ee=ke.relatedTarget,mt=ke.currentTarget,dt=$n(ke);m&&Ee==null&&dt!=null&&Me(C,dt)&&Gb(dt),queueMicrotask(()=>{const je=q(),xt=w.context.triggerElements,ue=Ze(),xe=(Ee==null?void 0:Ee.hasAttribute(Fc("focus-guard")))&&[Y.current,T.current,W==null?void 0:W.beforeInsideRef.current,W==null?void 0:W.afterInsideRef.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,Li(v),Li(y)].includes(Ee),ht=!(Me(D,Ee)||Me(C,Ee)||Me(Ee,C)||Me(W==null?void 0:W.portalNode,Ee)||ue.some(Be=>Be===Ee||Me(Be,Ee))||Ee!=null&&xt.hasElement(Ee)||xt.hasMatchingElement(Be=>Me(Be,Ee))||xe||ae&&(_s(ae.nodesRef.current,je).find(Be=>{var pt,jt;return Me((pt=Be.context)==null?void 0:pt.elements.floating,Ee)||Me((jt=Be.context)==null?void 0:jt.elements.domReference,Ee)})||jb(ae.nodesRef.current,je).find(Be=>{var pt,jt,sn;return[(pt=Be.context)==null?void 0:pt.elements.floating,Mb((jt=Be.context)==null?void 0:jt.elements.floating)].includes(Ee)||((sn=Be.context)==null?void 0:sn.elements.domReference)===Ee})));if(mt===D&&ce&&Xb(ce),d&&mt!==D&&!G0(dt)&&Ui(ve)===ve.body){if(Rt(ce)&&(ce.focus(),d==="popup")){ee.request(()=>{ce.focus()});return}const Be=fe(),pt=Q.current,jt=(pt&&Be.includes(pt)?pt:null)||Be[Be.length-1]||ce;Rt(jt)&&jt.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(B||!m)&&Ee&&ht&&!ie.current&&(B||Ee!==Qb())&&(le.current=!0,w.setOpen(!1,Xt(Lo,ke)))})}function vt(){N.current||(k.current.insideReactTree=!0,ne.start(0,()=>{k.current.insideReactTree=!1}))}const Re=Rt(D)?D:null;if(!(!C&&!Re))return qi(Re&&Ke(Re,"focusout",ft),Re&&Ke(Re,"pointerdown",ze),C&&Ke(C,"focusin",Oe),C&&Ke(C,"focusout",ft),C&&W&&Ke(C,"focusout",vt,!0))},[o,D,C,ce,m,ae,W,w,g,d,fe,B,q,k,ne,re,ee,y,v,Ze]),O.useEffect(()=>{var mt,dt,je;if(o||!C||!_)return;const ve=Array.from(((mt=W==null?void 0:W.portalNode)==null?void 0:mt.querySelectorAll(`[${Fc("portal")}]`))||[]),Oe=(je=(dt=(ae?jb(ae.nodesRef.current,q()):[]).find(xt=>{var ue;return _b(((ue=xt.context)==null?void 0:ue.elements.domReference)||null)}))==null?void 0:dt.context)==null?void 0:je.elements.domReference,vt=[...[C,...ve,Y.current,T.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,...Ze()],Oe,Li(v),Li(y),B?D:null].filter(xt=>xt!=null),Re=qb(vt,{ariaHidden:m||B,mark:!1}),ke=[C,...ve].filter(xt=>xt!=null),Ee=qb(ke);return()=>{Ee(),Re()}},[_,o,D,C,m,W,B,ae,q,y,v,Ze]),Xe(()=>{if(!_||o||!Rt(ce))return;const ve=ut(ce),ze=Ui(ve);queueMicrotask(()=>{const Oe=U.current,ft=typeof Oe=="function"?Oe(se.current||""):Oe;if(ft===void 0||ft===!1||Me(ce,ze))return;let Re=null;const ke=()=>(Re==null&&(Re=fe(ce)),Re[0]||ce);let Ee;ft===!0||ft===null?Ee=ke():Ee=Li(ft),Ee=Ee||ke();const mt=Me(ce,Ui(ve));kd(Ee,{preventScroll:Ee===ce,shouldFocus(){if(!pe.current)return!1;if(mt)return!0;const dt=Ui(ve);return!(dt!==Ee&&Me(ce,dt))}})})},[o,_,ce,fe,U,se,pe]),Xe(()=>{if(o||!ce)return;const ve=ut(ce),ze=Ui(ve),Oe=se.current==null;Gb(ze);function ft(Re){if(Re.open||(I.current=lC(Re.nativeEvent,oe.current)),Re.reason===xn&&Re.nativeEvent.type==="mouseleave"&&(le.current=!0),Re.reason===H0)if(Re.nested)le.current=!1;else if(gO(Re.nativeEvent)||yO(Re.nativeEvent))le.current=!1;else{let ke=!1;ut(ce).createElement("div").focus({get preventScroll(){return ke=!0,!1}}),ke?le.current=!1:le.current=!0}}j.on("openchange",ft);function vt(){const Re=K.current;let ke=typeof Re=="function"?Re(I.current):Re;if(ke===void 0||ke===!1)return null;ke===null&&(ke=!0);const Ee=D!=null&&D.isConnected?D:null,mt=ze!=null&&ze.isConnected&&$t(ze)!=="body"?ze:null;let dt=Oe?mt||Ee:Ee||mt;return dt||(dt=Qb()||null),typeof ke=="boolean"?dt:Li(ke)||dt||null}return()=>{j.off("openchange",ft);const Re=Ui(ve),ke=Ze(),Ee=Me(C,Re)||ke.some(je=>je===Re||Me(je,Re))||ae&&_s(ae.nodesRef.current,q(),!1).some(je=>{var xt;return Me((xt=je.context)==null?void 0:xt.elements.floating,Re)}),mt=K.current,dt=vt();queueMicrotask(()=>{const je=uC(dt),xt=typeof mt!="boolean";mt&&!le.current&&Rt(je)&&(!(!xt&&je!==Re&&Re!==ve.body)||Ee)&&je.focus({preventScroll:!0}),le.current=!1})}},[o,C,ce,K,se,j,ae,D,q,Ze]),Xe(()=>{if(!Aa||_||!C)return;const ve=Ui(ut(C));!Rt(ve)||!Bh(ve)||Me(C,ve)&&ve.blur()},[_,C]),Xe(()=>{if(!(o||!W))return W.setFocusManagerState({modal:m,closeOnFocusOut:g,open:_,onOpenChange:w.setOpen,domReference:D}),()=>{W.setFocusManagerState(null)}},[o,W,m,_,w,g,D]),Xe(()=>{if(!(o||!ce))return Xb(ce),()=>{queueMicrotask(Xh)}},[o,ce]);const nt=!o&&(m?!B:!0)&&(ge||m);return A.jsxs(O.Fragment,{children:[nt&&A.jsx(Ta,{"data-type":"inside",ref:H,onFocus:ve=>{var ze;if(m){const Oe=fe();kd(Oe[Oe.length-1])}else if(W!=null&&W.portalNode)if(le.current=!1,ra(ve,W.portalNode)){const Oe=Qh(D);Oe==null||Oe.focus()}else(ze=Li(v??W.beforeOutsideRef))==null||ze.focus()}}),r,nt&&A.jsx(Ta,{"data-type":"inside",ref:te,onFocus:ve=>{var ze;if(m)kd(fe()[0]);else if(W!=null&&W.portalNode)if(g&&(le.current=!0),ra(ve,W.portalNode)){const Oe=W0(D);Oe==null||Oe.focus()}else(ze=Li(y??W.afterOutsideRef))==null||ze.focus()}})]})}function dC(n,i={}){const{enabled:r=!0,event:o="click",toggle:c=!0,ignoreMouse:f=!1,stickIfOpen:d=!0,touchOpenDelay:m=0,reason:g=Uo}=i,p="rootStore"in n?n.rootStore:n,y=p.context.dataRef,v=O.useRef(void 0),S=Hh(),E=Ea(),x=O.useMemo(()=>{function w(D,C,j,k){const q=Xt(g,C,j);D&&k==="touch"&&m>0?E.start(m,()=>{p.setOpen(!0,q)}):p.setOpen(D,q)}function _(D,C,j){const k=y.current.openEvent,q=p.select("domReferenceElement")!==C;return D&&q||!D||!c?!0:k&&d?!j(k.type):!1}return{onPointerDown(D){v.current=D.pointerType},onMouseDown(D){const C=v.current,j=D.nativeEvent,k=p.select("open");if(D.button!==0||o==="click"||jo(C,!0)&&f)return;const q=_(k,D.currentTarget,U=>U==="click"||U==="mousedown"),F=$n(j);if(Bh(F)){w(q,j,F,C);return}const B=D.currentTarget;S.request(()=>{w(q,j,B,C)})},onClick(D){if(o==="mousedown-only")return;const C=v.current;if(o==="mousedown"&&C){v.current=void 0;return}if(jo(C,!0)&&f)return;const j=p.select("open"),k=_(j,D.currentTarget,q=>q==="click"||q==="mousedown"||q==="keydown"||q==="keyup");w(k,D.nativeEvent,D.currentTarget,C)},onKeyDown(){v.current=void 0}}},[y,o,f,g,p,d,c,S,E,m]);return O.useMemo(()=>r?{reference:x}:Wt,[r,x])}function hC(){return!1}function mC(n){return{escapeKey:typeof n=="boolean"?n:(n==null?void 0:n.escapeKey)??!1,outsidePress:typeof n=="boolean"?n:(n==null?void 0:n.outsidePress)??!0}}function pC(n,i={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:c=!0,outsidePressEvent:f="sloppy",referencePress:d=hC,bubbles:m,externalTree:g}=i,p="rootStore"in n?n.rootStore:n,y=p.useState("open"),v=p.useState("floatingElement"),{dataRef:S}=p.context,E=Ma(g),x=$e(typeof c=="function"?c:()=>!1),w=typeof c=="function"?x:c,_=w!==!1,D=$e(()=>f),{escapeKey:C,outsidePress:j}=mC(m),k=O.useRef(!1),q=O.useRef(!1),F=O.useRef(!1),B=O.useRef(!1),U=O.useRef(""),K=O.useRef(null),se=Ea(),pe=Ea(),ae=$e(()=>{pe.clear(),S.current.insideReactTree=!1}),W=$e(H=>{var re;const te=(re=S.current.floatingContext)==null?void 0:re.nodeId;return(E?_s(E.nodesRef.current,te):[]).some(ee=>{var ge;return((ge=ee.context)==null?void 0:ge.open)&&!ee.context.dataRef.current[H]})}),le=$e(H=>Dd(H,p.select("floatingElement"))||Dd(H,p.select("domReferenceElement"))),ie=$e(H=>{d()&&p.setOpen(!1,Xt(Uo,H.nativeEvent))}),N=$e(H=>{if(!y||!r||!o||H.key!=="Escape"||B.current||!C&&W("__escapeKeyBubbles"))return;const te=pO(H)?H.nativeEvent:H,ne=Xt(q0,te);p.setOpen(!1,ne),ne.isCanceled||H.preventDefault(),!C&&!ne.isPropagationAllowed&&H.stopPropagation()}),Q=$e(()=>{S.current.insideReactTree=!0,pe.start(0,ae)}),I=$e(H=>{if(!y||!r||H.button!==0)return;const te=$n(H.nativeEvent);Me(p.select("floatingElement"),te)&&(k.current||(k.current=!0,q.current=!1))}),oe=$e(H=>{!y||!r||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&k.current&&(q.current=!0)});O.useEffect(()=>{if(!y||!r)return;S.current.__escapeKeyBubbles=C,S.current.__outsidePressBubbles=j;const H=new ei,te=new ei;function ne(){H.clear(),B.current=!0}function re(){H.start(Aa?5:0,()=>{B.current=!1})}function ee(){F.current=!0,te.start(0,()=>{F.current=!1})}function ge(){k.current=!1,q.current=!1}function ce(){const ue=U.current,xe=ue==="pen"||!ue?"mouse":ue,ht=D(),Be=typeof ht=="function"?ht():ht;return typeof Be=="string"?Be:Be[xe]}function fe(ue){const xe=ce();return xe==="intentional"&&ue.type!=="click"||xe==="sloppy"&&ue.type==="click"}function Ze(ue){var Be;const xe=(Be=S.current.floatingContext)==null?void 0:Be.nodeId,ht=E&&_s(E.nodesRef.current,xe).some(pt=>{var jt;return Dd(ue,(jt=pt.context)==null?void 0:jt.elements.floating)});return le(ue)||ht}function nt(ue){if(fe(ue)){ue.type!=="click"&&!le(ue)&&(te.clear(),F.current=!1),ae();return}if(S.current.insideReactTree){ae();return}const xe=$n(ue),ht=`[${Fc("inert")}]`,Be=Je(xe)?xe.getRootNode():null,pt=Array.from((xa(Be)?Be:ut(p.select("floatingElement"))).querySelectorAll(ht)),jt=p.context.triggerElements;if(xe&&(jt.hasElement(xe)||jt.hasMatchingElement(rn=>Me(rn,xe))))return;let sn=Je(xe)?xe:null;for(;sn&&!Cs(sn);){const rn=As(sn);if(Cs(rn)||!Je(rn))break;sn=rn}if(!(pt.length&&Je(xe)&&!vO(xe)&&!Me(xe,p.select("floatingElement"))&&pt.every(rn=>!Me(sn,rn)))){if(Rt(xe)&&!("touches"in ue)){const rn=Cs(xe),ti=zn(xe),fn=/auto|scroll/,qt=rn||fn.test(ti.overflowX),Tn=rn||fn.test(ti.overflowY),Yt=qt&&xe.clientWidth>0&&xe.scrollWidth>xe.clientWidth,mr=Tn&&xe.clientHeight>0&&xe.scrollHeight>xe.clientHeight,pr=ti.direction==="rtl",gr=mr&&(pr?ue.offsetX<=xe.offsetWidth-xe.clientWidth:ue.offsetX>xe.clientWidth),pi=Yt&&ue.offsetY>xe.clientHeight;if(gr||pi)return}if(!Ze(ue)){if(ce()==="intentional"&&F.current){te.clear(),F.current=!1;return}typeof w=="function"&&!w(ue)||W("__outsidePressBubbles")||(p.setOpen(!1,Xt(H0,ue)),ae())}}}function ve(ue){ce()!=="sloppy"||ue.pointerType==="touch"||!p.select("open")||!r||le(ue)||nt(ue)}function ze(ue){if(ce()!=="sloppy"||!p.select("open")||!r||le(ue))return;const xe=ue.touches[0];xe&&(K.current={startTime:Date.now(),startX:xe.clientX,startY:xe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},se.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function Oe(ue,xe){const ht=$n(ue);if(!ht)return;const Be=Ke(ht,ue.type,()=>{xe(ue),Be()})}function ft(ue){U.current="touch",Oe(ue,ze)}function vt(ue){se.clear(),ue.type==="pointerdown"&&(U.current=ue.pointerType),!(ue.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&Oe(ue,xe=>{xe.type==="pointerdown"?ve(xe):nt(xe)})}function Re(ue){if(!k.current)return;const xe=q.current;if(ge(),ce()==="intentional"){if(ue.type==="pointercancel"){xe&&ee();return}if(!Ze(ue)){if(xe){ee();return}typeof w=="function"&&!w(ue)||(te.clear(),F.current=!0,ae())}}}function ke(ue){if(ce()!=="sloppy"||!K.current||le(ue))return;const xe=ue.touches[0];if(!xe)return;const ht=Math.abs(xe.clientX-K.current.startX),Be=Math.abs(xe.clientY-K.current.startY),pt=Math.sqrt(ht*ht+Be*Be);pt>5&&(K.current.dismissOnTouchEnd=!0),pt>10&&(nt(ue),se.clear(),K.current=null)}function Ee(ue){Oe(ue,ke)}function mt(ue){ce()!=="sloppy"||!K.current||le(ue)||(K.current.dismissOnTouchEnd&&nt(ue),se.clear(),K.current=null)}function dt(ue){Oe(ue,mt)}const je=ut(v),xt=qi(o&&qi(Ke(je,"keydown",N),Ke(je,"compositionstart",ne),Ke(je,"compositionend",re)),_&&qi(Ke(je,"click",vt,!0),Ke(je,"pointerdown",vt,!0),Ke(je,"pointerup",Re,!0),Ke(je,"pointercancel",Re,!0),Ke(je,"mousedown",vt,!0),Ke(je,"mouseup",Re,!0),Ke(je,"touchstart",ft,!0),Ke(je,"touchmove",Ee,!0),Ke(je,"touchend",dt,!0)));return()=>{xt(),H.clear(),te.clear(),ge(),F.current=!1}},[S,v,o,_,w,y,r,C,j,N,ae,D,W,le,E,p,se]),O.useEffect(ae,[w,ae]);const Y=O.useMemo(()=>({onKeyDown:N,onPointerDown:ie,onClick:ie}),[N,ie]),T=O.useMemo(()=>({onKeyDown:N,onPointerDown:oe,onMouseDown:oe,onClickCapture:Q,onMouseDownCapture(H){Q(),I(H)},onPointerDownCapture(H){Q(),I(H)},onMouseUpCapture:Q,onTouchEndCapture:Q,onTouchMoveCapture:Q}),[N,Q,I,oe]);return O.useMemo(()=>r?{reference:Y,floating:T,trigger:Y}:{},[r,Y,T])}function Fb(n,i,r){let{reference:o,floating:c}=n;const f=Fn(i),d=Vh(i),m=Yh(d),g=Dn(i),p=f==="y",y=o.x+o.width/2-c.width/2,v=o.y+o.height/2-c.height/2,S=o[m]/2-c[m]/2;let E;switch(g){case"top":E={x:y,y:o.y-c.height};break;case"bottom":E={x:y,y:o.y+o.height};break;case"right":E={x:o.x+o.width,y:v};break;case"left":E={x:o.x-c.width,y:v};break;default:E={x:o.x,y:o.y}}const x=Ds(i);return x&&(E[d]+=S*(x==="end"?1:-1)*(r&&p?-1:1)),E}async function gC(n,i){var r;i===void 0&&(i={});const{x:o,y:c,platform:f,rects:d,elements:m,strategy:g}=n,{boundary:p="clippingAncestors",rootBoundary:y="viewport",elementContext:v="floating",altBoundary:S=!1,padding:E=0}=Gi(i,n),x=V0(E),_=m[S?v==="floating"?"reference":"floating":v],D=Xc(await f.getClippingRect({element:(r=await(f.isElement==null?void 0:f.isElement(_)))==null||r?_:_.contextElement||await(f.getDocumentElement==null?void 0:f.getDocumentElement(m.floating)),boundary:p,rootBoundary:y,strategy:g})),C=v==="floating"?{x:o,y:c,width:d.floating.width,height:d.floating.height}:d.reference,j=await(f.getOffsetParent==null?void 0:f.getOffsetParent(m.floating)),k=await(f.isElement==null?void 0:f.isElement(j))&&await(f.getScale==null?void 0:f.getScale(j))||{x:1,y:1},q=Xc(f.convertOffsetParentRelativeRectToViewportRelativeRect?await f.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:C,offsetParent:j,strategy:g}):C);return{top:(D.top-q.top+x.top)/k.y,bottom:(q.bottom-D.bottom+x.bottom)/k.y,left:(D.left-q.left+x.left)/k.x,right:(q.right-D.right+x.right)/k.x}}const yC=50,bC=async(n,i,r)=>{const{placement:o="bottom",strategy:c="absolute",middleware:f=[],platform:d}=r,m=d.detectOverflow?d:{...d,detectOverflow:gC},g=await(d.isRTL==null?void 0:d.isRTL(i));let p=await d.getElementRects({reference:n,floating:i,strategy:c}),{x:y,y:v}=Fb(p,o,g),S=o,E=0;const x={};for(let w=0;w<f.length;w++){const _=f[w];if(!_)continue;const{name:D,fn:C}=_,{x:j,y:k,data:q,reset:F}=await C({x:y,y:v,initialPlacement:o,placement:S,strategy:c,middlewareData:x,rects:p,platform:m,elements:{reference:n,floating:i}});y=j??y,v=k??v,x[D]={...x[D],...q},F&&E<yC&&(E++,typeof F=="object"&&(F.placement&&(S=F.placement),F.rects&&(p=F.rects===!0?await d.getElementRects({reference:n,floating:i,strategy:c}):F.rects),{x:y,y:v}=Fb(p,S,g)),w=-1)}return{x:y,y:v,placement:S,strategy:c,middlewareData:x}},vC=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(i){var r,o;const{placement:c,middlewareData:f,rects:d,initialPlacement:m,platform:g,elements:p}=i,{mainAxis:y=!0,crossAxis:v=!0,fallbackPlacements:S,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:w=!0,..._}=Gi(n,i);if((r=f.arrow)!=null&&r.alignmentOffset)return{};const D=Dn(c),C=Fn(m),j=Dn(m)===m,k=await(g.isRTL==null?void 0:g.isRTL(p.floating)),q=S||(j||!w?[Qc(m)]:zO(m)),F=x!=="none";!S&&F&&q.push(...LO(m,w,x,k));const B=[m,...q],U=await g.detectOverflow(i,_),K=[];let se=((o=f.flip)==null?void 0:o.overflows)||[];if(y&&K.push(U[D]),v){const le=DO(c,d,k);K.push(U[le[0]],U[le[1]])}if(se=[...se,{placement:c,overflows:K}],!K.every(le=>le<=0)){var pe,ae;const le=(((pe=f.flip)==null?void 0:pe.index)||0)+1,ie=B[le];if(ie&&(!(v==="alignment"?C!==Fn(ie):!1)||se.every(I=>Fn(I.placement)===C?I.overflows[0]>0:!0)))return{data:{index:le,overflows:se},reset:{placement:ie}};let N=(ae=se.filter(Q=>Q.overflows[0]<=0).sort((Q,I)=>Q.overflows[1]-I.overflows[1])[0])==null?void 0:ae.placement;if(!N)switch(E){case"bestFit":{var W;const Q=(W=se.filter(I=>{if(F){const oe=Fn(I.placement);return oe===C||oe==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(oe=>oe>0).reduce((oe,Y)=>oe+Y,0)]).sort((I,oe)=>I[1]-oe[1])[0])==null?void 0:W[0];Q&&(N=Q);break}case"initialPlacement":N=m;break}if(c!==N)return{reset:{placement:N}}}return{}}}};function Kb(n,i){return{top:n.top-i.height,right:n.right-i.width,bottom:n.bottom-i.height,left:n.left-i.width}}function Zb(n){return MO.some(i=>n[i]>=0)}const SC=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(i){const{rects:r,platform:o}=i,{strategy:c="referenceHidden",...f}=Gi(n,i);switch(c){case"referenceHidden":{const d=await o.detectOverflow(i,{...f,elementContext:"reference"}),m=Kb(d,r.reference);return{data:{referenceHiddenOffsets:m,referenceHidden:Zb(m)}}}case"escaped":{const d=await o.detectOverflow(i,{...f,altBoundary:!0}),m=Kb(d,r.floating);return{data:{escapedOffsets:m,escaped:Zb(m)}}}default:return{}}}}},oS=new Set(["left","top"]);async function xC(n,i){const{placement:r,platform:o,elements:c}=n,f=await(o.isRTL==null?void 0:o.isRTL(c.floating)),d=Dn(r),m=Ds(r),g=Fn(r)==="y",p=oS.has(d)?-1:1,y=f&&g?-1:1,v=Gi(i,n);let{mainAxis:S,crossAxis:E,alignmentAxis:x}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return m&&typeof x=="number"&&(E=m==="end"?x*-1:x),g?{x:E*y,y:S*p}:{x:S*p,y:E*y}}const EC=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(i){var r,o;const{x:c,y:f,placement:d,middlewareData:m}=i,g=await xC(i,n);return d===((r=m.offset)==null?void 0:r.placement)&&(o=m.arrow)!=null&&o.alignmentOffset?{}:{x:c+g.x,y:f+g.y,data:{...g,placement:d}}}}},TC=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(i){const{x:r,y:o,placement:c,platform:f}=i,{mainAxis:d=!0,crossAxis:m=!1,limiter:g={fn:C=>{let{x:j,y:k}=C;return{x:j,y:k}}},...p}=Gi(n,i),y={x:r,y:o},v=await f.detectOverflow(i,p),S=Fn(c),E=qh(S);let x=y[E],w=y[S];const _=(C,j)=>Y0(j+v[C==="y"?"top":"left"],j,j-v[C==="y"?"bottom":"right"]);d&&(x=_(E,x)),m&&(w=_(S,w));const D=g.fn({...i,[E]:x,[S]:w});return{...D,data:{x:D.x-r,y:D.y-o,enabled:{[E]:d,[S]:m}}}}}},wC=function(n){return n===void 0&&(n={}),{options:n,fn(i){var r,o;const{x:c,y:f,placement:d,rects:m,middlewareData:g}=i,{offset:p=0,mainAxis:y=!0,crossAxis:v=!0}=Gi(n,i),S={x:c,y:f},E=Fn(d),x=qh(E);let w=S[x],_=S[E];const D=Gi(p,i),C=typeof D=="number"?{mainAxis:D,crossAxis:0}:{mainAxis:(r=D.mainAxis)!=null?r:0,crossAxis:(o=D.crossAxis)!=null?o:0};if(y){const q=x==="y"?"height":"width",F=m.reference[x]-m.floating[q]+C.mainAxis,B=m.reference[x]+m.reference[q]-C.mainAxis;w<F?w=F:w>B&&(w=B)}if(v){var j,k;const q=x==="y"?"width":"height",F=oS.has(Dn(d)),B=m.reference[E]-m.floating[q]+(F&&((j=g.offset)==null?void 0:j[E])||0)+(F?0:C.crossAxis),U=m.reference[E]+m.reference[q]+(F?0:((k=g.offset)==null?void 0:k[E])||0)-(F?C.crossAxis:0);_<B?_=B:_>U&&(_=U)}return{[x]:w,[E]:_}}}},RC=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(i){const{placement:r,rects:o,platform:c,elements:f}=i,{apply:d=()=>{},...m}=Gi(n,i),g=await c.detectOverflow(i,m),p=Dn(r),y=Ds(r),v=Fn(r)==="y",{width:S,height:E}=o.floating;let x,w;p==="top"||p==="bottom"?(x=p,w=y===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(w=p,x=y==="end"?"top":"bottom");const _=E-g.top-g.bottom,D=S-g.left-g.right,C=wa(E-g[x],_),j=wa(S-g[w],D),k=i.middlewareData.shift,q=!k;let F=C,B=j;k!=null&&k.enabled.x&&(B=D),k!=null&&k.enabled.y&&(F=_),q&&!y&&(v?B=S-2*Yi(g.left,g.right):F=E-2*Yi(g.top,g.bottom)),await d({...i,availableWidth:B,availableHeight:F});const U=await c.getDimensions(f.floating);return S!==U.width||E!==U.height?{reset:{rects:!0}}:{}}}};function lS(n){const i=zn(n);let r=parseFloat(i.width)||0,o=parseFloat(i.height)||0;const c=Rt(n),f=c?n.offsetWidth:r,d=c?n.offsetHeight:o,m=Gc(r)!==f||Gc(o)!==d;return m&&(r=f,o=d),{width:r,height:o,$:m}}function Fh(n){return Je(n)?n:n.contextElement}function aa(n){const i=Fh(n);if(!Rt(i))return Vi(1);const r=i.getBoundingClientRect(),{width:o,height:c,$:f}=lS(i);let d=(f?Gc(r.width):r.width)/o,m=(f?Gc(r.height):r.height)/c;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const OC=Vi(0);function cS(n){const i=kt(n);return!jh()||!i.visualViewport?OC:{x:i.visualViewport.offsetLeft,y:i.visualViewport.offsetTop}}function CC(n,i,r){return i===void 0&&(i=!1),!!r&&i&&r===kt(n)}function cr(n,i,r,o){i===void 0&&(i=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),f=Fh(n);let d=Vi(1);i&&(o?Je(o)&&(d=aa(o)):d=aa(n));const m=CC(f,r,o)?cS(f):Vi(0);let g=(c.left+m.x)/d.x,p=(c.top+m.y)/d.y,y=c.width/d.x,v=c.height/d.y;if(f&&o){const S=kt(f),E=Je(o)?kt(o):o;let x=S,w=lh(x);for(;w&&E!==x;){const _=aa(w),D=w.getBoundingClientRect(),C=zn(w),j=D.left+(w.clientLeft+parseFloat(C.paddingLeft))*_.x,k=D.top+(w.clientTop+parseFloat(C.paddingTop))*_.y;g*=_.x,p*=_.y,y*=_.x,v*=_.y,g+=j,p+=k,x=kt(w),w=lh(x)}}return Xc({width:y,height:v,x:g,y:p})}function ru(n,i){const r=nu(n).scrollLeft;return i?i.left+r:cr(Xi(n)).left+r}function uS(n,i){const r=n.getBoundingClientRect(),o=r.left+i.scrollLeft-ru(n,r),c=r.top+i.scrollTop;return{x:o,y:c}}function AC(n){let{elements:i,rect:r,offsetParent:o,strategy:c}=n;const f=c==="fixed",d=Xi(o),m=i?tu(i.floating):!1;if(o===d||m&&f)return r;let g={scrollLeft:0,scrollTop:0},p=Vi(1);const y=Vi(0),v=Rt(o);if((v||!f)&&(($t(o)!=="body"||hr(d))&&(g=nu(o)),v)){const E=cr(o);p=aa(o),y.x=E.x+o.clientLeft,y.y=E.y+o.clientTop}const S=d&&!v&&!f?uS(d,g):Vi(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-g.scrollLeft*p.x+y.x+S.x,y:r.y*p.y-g.scrollTop*p.y+y.y+S.y}}function _C(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function MC(n){const i=nu(n),r=n.ownerDocument.body,o=Yi(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=Yi(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let f=-i.scrollLeft+ru(n);const d=-i.scrollTop;return zn(r).direction==="rtl"&&(f+=Yi(n.clientWidth,r.clientWidth)-o),{width:o,height:c,x:f,y:d}}const NC=25;function DC(n,i,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",c=kt(n),f=Xi(n),d=c.visualViewport;let m=f.clientWidth,g=f.clientHeight,p=0,y=0;if(d){const S=!jh()||i==="fixed";o?S||(p=-d.offsetLeft,y=-d.offsetTop):(m=d.width,g=d.height,S&&(p=d.offsetLeft,y=d.offsetTop))}if(ru(f)<=0){const S=f.ownerDocument,E=S.body,x=getComputedStyle(E),w=S.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,_=Math.abs(f.clientWidth-E.clientWidth-w),D=getComputedStyle(f).scrollbarGutter==="stable both-edges"?_/2:_;D<=NC&&(m-=D)}return{width:m,height:g,x:p,y}}function zC(n,i){const r=cr(n,!0,i==="fixed"),o=r.top+n.clientTop,c=r.left+n.clientLeft,f=aa(n),d=n.clientWidth*f.x,m=n.clientHeight*f.y,g=c*f.x,p=o*f.y;return{width:d,height:m,x:g,y:p}}function Pb(n,i,r){let o;if(i==="viewport"||i==="layoutViewport")o=DC(n,r,i);else if(i==="document")o=MC(Xi(n));else if(Je(i))o=zC(i,r);else{const c=cS(n);o={x:i.x-c.x,y:i.y-c.y,width:i.width,height:i.height}}return Xc(o)}function kC(n,i){const r=i.get(n);if(r)return r;let o=zo(n,[],!1).filter(m=>Je(m)&&$t(m)!=="body"),c=null;const f=zn(n).position==="fixed";let d=f?As(n):n;for(;Je(d)&&!Cs(d);){const m=zn(d),g=kh(d),p=c?c.position:f?"fixed":"";!g&&(p==="fixed"||p==="absolute"&&m.position==="static")?o=o.filter(v=>v!==d):c=m,d=As(d)}return i.set(n,o),o}function jC(n){let{element:i,boundary:r,rootBoundary:o,strategy:c}=n;const d=[...r==="clippingAncestors"?tu(i)?[]:kC(i,this._c):[].concat(r),o],m=Pb(i,d[0],c);let g=m.top,p=m.right,y=m.bottom,v=m.left;for(let S=1;S<d.length;S++){const E=Pb(i,d[S],c);g=Yi(E.top,g),p=wa(E.right,p),y=wa(E.bottom,y),v=Yi(E.left,v)}return{width:p-v,height:y-g,x:v,y:g}}function UC(n){const{width:i,height:r}=lS(n);return{width:i,height:r}}function LC(n,i,r){const o=Rt(i),c=Xi(i),f=r==="fixed",d=cr(n,!0,f,i);let m={scrollLeft:0,scrollTop:0};const g=Vi(0);if((o||!f)&&(($t(i)!=="body"||hr(c))&&(m=nu(i)),o)){const S=cr(i,!0,f,i);g.x=S.x+i.clientLeft,g.y=S.y+i.clientTop}!o&&c&&(g.x=ru(c));const p=c&&!o&&!f?uS(c,m):Vi(0),y=d.left+m.scrollLeft-g.x-p.x,v=d.top+m.scrollTop-g.y-p.y;return{x:y,y:v,width:d.width,height:d.height}}function Ld(n){return zn(n).position==="static"}function Ib(n,i){if(!Rt(n)||zn(n).position==="fixed")return null;if(i)return i(n);let r=n.offsetParent;return Xi(n)===r&&(r=r.ownerDocument.body),r}function fS(n,i){const r=kt(n);if(tu(n))return r;if(!Rt(n)){let c=As(n);for(;c&&!Cs(c);){if(Je(c)&&!Ld(c))return c;c=As(c)}return r}let o=Ib(n,i);for(;o&&HR(o)&&Ld(o);)o=Ib(o,i);return o&&Cs(o)&&Ld(o)&&!kh(o)?r:o||VR(n)||r}const BC=async function(n){const i=this.getOffsetParent||fS,r=this.getDimensions,o=await r(n.floating);return{reference:LC(n.reference,await i(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function HC(n){return zn(n).direction==="rtl"}const qC={convertOffsetParentRelativeRectToViewportRelativeRect:AC,getDocumentElement:Xi,getClippingRect:jC,getOffsetParent:fS,getElementRects:BC,getClientRects:_C,getDimensions:UC,getScale:aa,isElement:Je,isRTL:HC};function dS(n,i){return n.x===i.x&&n.y===i.y&&n.width===i.width&&n.height===i.height}function YC(n,i,r){let o=null,c;const f=Xi(n);function d(){var y;clearTimeout(c),(y=o)==null||y.disconnect(),o=null}function m(y,v){y===void 0&&(y=!1),v===void 0&&(v=1),d();const S=n.getBoundingClientRect(),{left:E,top:x,width:w,height:_}=S;if(y||i(),!w||!_)return;const D=Ec(x),C=Ec(f.clientWidth-(E+w)),j=Ec(f.clientHeight-(x+_)),k=Ec(E),F={rootMargin:-D+"px "+-C+"px "+-j+"px "+-k+"px",threshold:Yi(0,wa(1,v))||1};let B=!0;function U(K){const se=K[0].intersectionRatio;if(!dS(S,n.getBoundingClientRect()))return m();if(se!==v){if(!B)return m();se?m(!1,se):c=setTimeout(()=>{m(!1,1e-7)},1e3)}B=!1}try{o=new IntersectionObserver(U,{...F,root:f.ownerDocument})}catch{o=new IntersectionObserver(U,F)}o.observe(n)}const g=kt(n),p=()=>m(r);return g.addEventListener("resize",p),m(!0),()=>{g.removeEventListener("resize",p),d()}}function Jb(n,i,r,o){o===void 0&&(o={});const{ancestorScroll:c=!0,ancestorResize:f=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:g=!1}=o,p=Fh(n),y=c||f?[...p?zo(p):[],...i?zo(i):[]]:[];y.forEach(D=>{c&&D.addEventListener("scroll",r),f&&D.addEventListener("resize",r)});const v=p&&m?YC(p,r,f):null;let S=-1,E=null;d&&(E=new ResizeObserver(D=>{let[C]=D;C&&C.target===p&&E&&i&&(E.unobserve(i),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var j;(j=E)==null||j.observe(i)})),r()}),p&&!g&&E.observe(p),i&&E.observe(i));let x,w=g?cr(n):null;g&&_();function _(){const D=cr(n);w&&!dS(w,D)&&r(),w=D,x=requestAnimationFrame(_)}return r(),()=>{var D;y.forEach(C=>{c&&C.removeEventListener("scroll",r),f&&C.removeEventListener("resize",r)}),v==null||v(),(D=E)==null||D.disconnect(),E=null,g&&cancelAnimationFrame(x)}}const VC=EC,GC=TC,QC=vC,XC=RC,FC=SC,KC=wC,ZC=(n,i,r)=>{const o=new Map,c=r??{},f={...qC,...c.platform,_c:o};return bC(n,i,{...c,platform:f})};var PC=typeof document<"u",IC=function(){},kc=PC?O.useLayoutEffect:IC;function Kc(n,i){if(n===i)return!0;if(typeof n!=typeof i)return!1;if(typeof n=="function"&&n.toString()===i.toString())return!0;let r,o,c;if(n&&i&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==i.length)return!1;for(o=r;o--!==0;)if(!Kc(n[o],i[o]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(i).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(i,c[o]))return!1;for(o=r;o--!==0;){const f=c[o];if(!(f==="_owner"&&n.$$typeof)&&!Kc(n[f],i[f]))return!1}return!0}return n!==n&&i!==i}function hS(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Wb(n,i){const r=hS(n);return Math.round(i*r)/r}function Bd(n){const i=O.useRef(n);return kc(()=>{i.current=n}),i}function JC(n){n===void 0&&(n={});const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:c,elements:{reference:f,floating:d}={},transform:m=!0,whileElementsMounted:g,open:p}=n,[y,v]=O.useState({x:0,y:0,strategy:r,placement:i,middlewareData:{},isPositioned:!1}),[S,E]=O.useState(o);Kc(S,o)||E(o);const[x,w]=O.useState(null),[_,D]=O.useState(null),C=O.useCallback(I=>{I!==F.current&&(F.current=I,w(I))},[]),j=O.useCallback(I=>{I!==B.current&&(B.current=I,D(I))},[]),k=f||x,q=d||_,F=O.useRef(null),B=O.useRef(null),U=O.useRef(y),K=g!=null,se=Bd(g),pe=Bd(c),ae=Bd(p),W=O.useCallback(()=>{if(!F.current||!B.current)return;const I={placement:i,strategy:r,middleware:S};pe.current&&(I.platform=pe.current),ZC(F.current,B.current,I).then(oe=>{const Y={...oe,isPositioned:ae.current!==!1};le.current&&!Kc(U.current,Y)&&(U.current=Y,Ms.flushSync(()=>{v(Y)}))})},[S,i,r,pe,ae]);kc(()=>{p===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,v(I=>({...I,isPositioned:!1})))},[p]);const le=O.useRef(!1);kc(()=>(le.current=!0,()=>{le.current=!1}),[]),kc(()=>{if(k&&(F.current=k),q&&(B.current=q),k&&q){if(se.current)return se.current(k,q,W);W()}},[k,q,W,se,K]);const ie=O.useMemo(()=>({reference:F,floating:B,setReference:C,setFloating:j}),[C,j]),N=O.useMemo(()=>({reference:k,floating:q}),[k,q]),Q=O.useMemo(()=>{const I={position:r,left:0,top:0};if(!N.floating)return I;const oe=Wb(N.floating,y.x),Y=Wb(N.floating,y.y);return m?{...I,transform:"translate("+oe+"px, "+Y+"px)",...hS(N.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:oe,top:Y}},[r,m,N.floating,y.x,y.y]);return O.useMemo(()=>({...y,update:W,refs:ie,elements:N,floatingStyles:Q}),[y,W,ie,N,Q])}const WC=(n,i)=>{const r=VC(n);return{name:r.name,fn:r.fn,options:[n,i]}},$C=(n,i)=>{const r=GC(n);return{name:r.name,fn:r.fn,options:[n,i]}},eA=(n,i)=>({fn:KC(n).fn,options:[n,i]}),tA=(n,i)=>{const r=QC(n);return{name:r.name,fn:r.fn,options:[n,i]}},nA=(n,i)=>{const r=XC(n);return{name:r.name,fn:r.fn,options:[n,i]}},iA=(n,i)=>{const r=FC(n);return{name:r.name,fn:r.fn,options:[n,i]}};function sA(n){const i=O.useRef(!0);i.current&&(i.current=!1,n())}const Ve=(n,i,r,o,c,f,...d)=>{if(d.length>0)throw new Error(ur(1));let m;if(n)m=n;else throw new Error("Missing arguments");return m};var Hd={exports:{}},qd={};/**
99
+ */const ww=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],h0=Oa("x",ww);function Rw({status:n}){return A.jsxs("header",{className:"flex items-center justify-between border-b border-chatroom-border px-6 py-4",children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx(d0,{className:"size-5 text-chatroom-text-muted","aria-hidden":!0}),A.jsx("h1",{className:"text-sm font-semibold uppercase tracking-widest",children:"Chatroom Daemon"})]}),n]})}function Ow({children:n}){return A.jsx("nav",{className:"flex gap-1 border-b border-chatroom-border px-6 py-2",children:n})}function Eb({active:n=!1,children:i,onClick:r}){return A.jsx("span",{className:n?"bg-chatroom-bg-secondary px-3 py-1.5 text-xs font-medium uppercase tracking-wide":"px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-chatroom-text-muted",onClick:r,role:r?"button":void 0,children:i})}function Tb(n){return new URLSearchParams(n.startsWith("?")?n.slice(1):n).get("tab")==="event-stream"?"event-stream":"logs"}function Cw(n){const i=new URLSearchParams(window.location.search);n.tab!==void 0&&(n.tab==="event-stream"?i.set("tab","event-stream"):i.delete("tab")),n.chatroomId!==void 0&&(n.chatroomId?i.set("chatroomId",n.chatroomId):i.delete("chatroomId"));const r=i.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}`)}function Aw(){const[n,i]=O.useState(()=>Tb(window.location.search)),r=O.useCallback(o=>{i(o),Cw({tab:o})},[]);return O.useEffect(()=>{const o=()=>i(Tb(window.location.search));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{activeTab:n,setActiveTab:r}}const mi=Object.create(null);mi.open="0";mi.close="1";mi.ping="2";mi.pong="3";mi.message="4";mi.upgrade="5";mi.noop="6";const _c=Object.create(null);Object.keys(mi).forEach(n=>{_c[mi[n]]=n});const ih={type:"error",data:"parser error"},m0=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",p0=typeof ArrayBuffer=="function",g0=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Ah=({type:n,data:i},r,o)=>m0&&i instanceof Blob?r?o(i):wb(i,o):p0&&(i instanceof ArrayBuffer||g0(i))?r?o(i):wb(new Blob([i]),o):o(mi[n]+(i||"")),wb=(n,i)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];i("b"+(o||""))},r.readAsDataURL(n)};function Rb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Rd;function _w(n,i){if(m0&&n.data instanceof Blob)return n.data.arrayBuffer().then(Rb).then(i);if(p0&&(n.data instanceof ArrayBuffer||g0(n.data)))return i(Rb(n.data));Ah(n,!1,r=>{Rd||(Rd=new TextEncoder),i(Rd.encode(r))})}const Ob="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Ob.length;n++)Mo[Ob.charCodeAt(n)]=n;const Mw=n=>{let i=n.length*.75,r=n.length,o,c=0,f,d,m,g;n[n.length-1]==="="&&(i--,n[n.length-2]==="="&&i--);const p=new ArrayBuffer(i),y=new Uint8Array(p);for(o=0;o<r;o+=4)f=Mo[n.charCodeAt(o)],d=Mo[n.charCodeAt(o+1)],m=Mo[n.charCodeAt(o+2)],g=Mo[n.charCodeAt(o+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|g&63;return p},Nw=typeof ArrayBuffer=="function",_h=(n,i)=>{if(typeof n!="string")return{type:"message",data:y0(n,i)};const r=n.charAt(0);return r==="b"?{type:"message",data:Dw(n.substring(1),i)}:_c[r]?n.length>1?{type:_c[r],data:n.substring(1)}:{type:_c[r]}:ih},Dw=(n,i)=>{if(Nw){const r=Mw(n);return y0(r,i)}else return{base64:!0,data:n}},y0=(n,i)=>{switch(i){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},b0="",zw=(n,i)=>{const r=n.length,o=new Array(r);let c=0;n.forEach((f,d)=>{Ah(f,!1,m=>{o[d]=m,++c===r&&i(o.join(b0))})})},kw=(n,i)=>{const r=n.split(b0),o=[];for(let c=0;c<r.length;c++){const f=_h(r[c],i);if(o.push(f),f.type==="error")break}return o};function jw(){return new TransformStream({transform(n,i){_w(n,r=>{const o=r.length;let c;if(o<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,o);else if(o<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(c[0]|=128),i.enqueue(c),i.enqueue(r)})}})}let Od;function bc(n){return n.reduce((i,r)=>i+r.length,0)}function vc(n,i){if(n[0].length===i)return n.shift();const r=new Uint8Array(i);let o=0;for(let c=0;c<i;c++)r[c]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function Uw(n,i){Od||(Od=new TextDecoder);const r=[];let o=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(o===0){if(bc(r)<1)break;const g=vc(r,1);f=(g[0]&128)===128,c=g[0]&127,c<126?o=3:c===126?o=1:o=2}else if(o===1){if(bc(r)<2)break;const g=vc(r,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(bc(r)<8)break;const g=vc(r,8),p=new DataView(g.buffer,g.byteOffset,g.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(ih);break}c=y*Math.pow(2,32)+p.getUint32(4),o=3}else{if(bc(r)<c)break;const g=vc(r,c);m.enqueue(_h(f?g:Od.decode(g),i)),o=0}if(c===0||c>n){m.enqueue(ih);break}}}})}const v0=4;function zt(n){if(n)return Lw(n)}function Lw(n){for(var i in zt.prototype)n[i]=zt.prototype[i];return n}zt.prototype.on=zt.prototype.addEventListener=function(n,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(i),this};zt.prototype.once=function(n,i){function r(){this.off(n,r),i.apply(this,arguments)}return r.fn=i,this.on(n,r),this};zt.prototype.off=zt.prototype.removeListener=zt.prototype.removeAllListeners=zt.prototype.removeEventListener=function(n,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,c=0;c<r.length;c++)if(o=r[c],o===i||o.fn===i){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};zt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)i[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,c=r.length;o<c;++o)r[o].apply(this,i)}return this};zt.prototype.emitReserved=zt.prototype.emit;zt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};zt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Wc=typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,r)=>r(i,0),Xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Bw="arraybuffer";function S0(n,...i){return i.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const Hw=Xn.setTimeout,qw=Xn.clearTimeout;function $c(n,i){i.useNativeTimers?(n.setTimeoutFn=Hw.bind(Xn),n.clearTimeoutFn=qw.bind(Xn)):(n.setTimeoutFn=Xn.setTimeout.bind(Xn),n.clearTimeoutFn=Xn.clearTimeout.bind(Xn))}const Yw=1.33;function Vw(n){return typeof n=="string"?Gw(n):Math.ceil((n.byteLength||n.size)*Yw)}function Gw(n){let i=0,r=0;for(let o=0,c=n.length;o<c;o++)i=n.charCodeAt(o),i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(o++,r+=4);return r}function x0(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Qw(n){let i="";for(let r in n)n.hasOwnProperty(r)&&(i.length&&(i+="&"),i+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return i}function Xw(n){let i={},r=n.split("&");for(let o=0,c=r.length;o<c;o++){let f=r[o].split("=");i[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return i}class Fw extends Error{constructor(i,r,o){super(i),this.description=r,this.context=o,this.type="TransportError"}}class Mh extends zt{constructor(i){super(),this.writable=!1,$c(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,r,o){return super.emitReserved("error",new Fw(i,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(i){this.readyState==="open"&&this.write(i)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(i){const r=_h(i,this.socket.binaryType);this.onPacket(r)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,r={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_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(i){const r=Qw(i);return r.length?"?"+r:""}}class Kw extends Mh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const r=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};kw(i,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const i=()=>{this.write([{type:"close"}])};this.readyState==="open"?i():this.once("open",i)}write(i){this.writable=!1,zw(i,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=x0()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(i,r)}}let E0=!1;try{E0=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Zw=E0;function Pw(){}class Iw extends Kw{constructor(i){if(super(i),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||o!==i.port}}doWrite(i,r){const o=this.request({method:"POST",data:i});o.on("success",r),o.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=i}}class hi extends zt{constructor(i,r,o){super(),this.createRequest=i,$c(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var i;const r=S0(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&o.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var c;o.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=hi.requestsCount++,hi.requests[this._index]=this)}_onError(i){this.emitReserved("error",i,this._xhr),this._cleanup(!0)}_cleanup(i){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Pw,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete hi.requests[this._index],this._xhr=null}}_onLoad(){const i=this._xhr.responseText;i!==null&&(this.emitReserved("data",i),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}hi.requestsCount=0;hi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Cb);else if(typeof addEventListener=="function"){const n="onpagehide"in Xn?"pagehide":"unload";addEventListener(n,Cb,!1)}}function Cb(){for(let n in hi.requests)hi.requests.hasOwnProperty(n)&&hi.requests[n].abort()}const Jw=function(){const n=T0({xdomain:!1});return n&&n.responseType!==null}();class Ww extends Iw{constructor(i){super(i);const r=i&&i.forceBase64;this.supportsBinary=Jw&&!r}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new hi(T0,this.uri(),i)}}function T0(n){const i=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||Zw))return new XMLHttpRequest}catch{}if(!i)try{return new Xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const w0=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class $w extends Mh{get name(){return"websocket"}doOpen(){const i=this.uri(),r=this.opts.protocols,o=w0?{}:S0(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,r,o)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=i=>this.onClose({description:"websocket connection closed",context:i}),this.ws.onmessage=i=>this.onData(i.data),this.ws.onerror=i=>this.onError("websocket error",i)}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;Ah(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}c&&Wc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const i=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=x0()),this.supportsBinary||(r.b64=1),this.createUri(i,r)}}const Cd=Xn.WebSocket||Xn.MozWebSocket;class eR extends $w{createSocket(i,r,o){return w0?new Cd(i,r,o):r?new Cd(i,r):new Cd(i)}doWrite(i,r){this.ws.send(r)}}class tR extends Mh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(i){return this.emitReserved("error",i)}this._transport.closed.then(()=>{this.onClose()}).catch(i=>{this.onError("webtransport error",i)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(i=>{const r=Uw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=i.readable.pipeThrough(r).getReader(),c=jw();c.readable.pipeTo(i.writable),this._writer=c.writable.getWriter();const f=()=>{o.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;this._writer.write(o).then(()=>{c&&Wc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const nR={websocket:eR,webtransport:tR,polling:Ww},iR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,sR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function sh(n){if(n.length>8e3)throw"URI too long";const i=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let c=iR.exec(n||""),f={},d=14;for(;d--;)f[sR[d]]=c[d]||"";return r!=-1&&o!=-1&&(f.source=i,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=rR(f,f.path),f.queryKey=aR(f,f.query),f}function rR(n,i){const r=/\/{2,9}/g,o=i.replace(r,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&o.splice(0,1),i.slice(-1)=="/"&&o.splice(o.length-1,1),o}function aR(n,i){const r={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,c,f){c&&(r[c]=f)}),r}const rh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mc=[];rh&&addEventListener("offline",()=>{Mc.forEach(n=>n())},!1);class Os extends zt{constructor(i,r){if(super(),this.binaryType=Bw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(r=i,i=null),i){const o=sh(i);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=sh(r.host).host);$c(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(o=>{const c=o.prototype.name;this.transports.push(c),this._transportsByName[c]=o}),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=Xw(this.opts.query)),rh&&(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"})},Mc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const r=Object.assign({},this.opts.query);r.EIO=v0,r.transport=i,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Os.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(i);r.open(),this.setTransport(r)}setTransport(i){this.transport&&this.transport.removeAllListeners(),this.transport=i,i.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",Os.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",i),this.emitReserved("heartbeat"),i.type){case"open":this.onHandshake(JSON.parse(i.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=i.data,this._onError(r);break;case"message":this.emitReserved("data",i.data),this.emitReserved("message",i.data);break}}onHandshake(i){this.emitReserved("handshake",i),this.id=i.sid,this.transport.query.sid=i.sid,this._pingInterval=i.pingInterval,this._pingTimeout=i.pingTimeout,this._maxPayload=i.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const i=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+i,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},i),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 i=this._getWritablePackets();this.transport.send(i),this._prevBufferLen=i.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const c=this.writeBuffer[o].data;if(c&&(r+=Vw(c)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,Wc(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,r,o){return this._sendPacket("message",i,r,o),this}send(i,r,o){return this._sendPacket("message",i,r,o),this}_sendPacket(i,r,o,c){if(typeof r=="function"&&(c=r,r=void 0),typeof o=="function"&&(c=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:i,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),i()},o=()=>{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?o():i()}):this.upgrading?o():i()),this}_onError(i){if(Os.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",i),this._onClose("transport error",i)}_onClose(i,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(),rh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Mc.indexOf(this._offlineEventListener);o!==-1&&Mc.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,r),this.writeBuffer=[],this._prevBufferLen=0}}}Os.protocol=v0;class oR extends Os{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let i=0;i<this._upgrades.length;i++)this._probe(this._upgrades[i])}_probe(i){let r=this.createTransport(i),o=!1;Os.priorWebsocketSuccess=!1;const c=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Os.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,y(),r.close(),r=null)}const d=v=>{const S=new Error("probe error: "+v);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function m(){d("transport closed")}function g(){d("socket closed")}function p(v){r&&v.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",g),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",g),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const r=[];for(let o=0;o<i.length;o++)~this.transports.indexOf(i[o])&&r.push(i[o]);return r}}let lR=class extends oR{constructor(i,r={}){const o=typeof i=="object",c=o?{...i}:{...r};(!c.transports||c.transports&&typeof c.transports[0]=="string")&&(c.transports=(c.transports||["polling","websocket","webtransport"]).map(f=>nR[f]).filter(f=>!!f)),super(o?c:i,c)}};function cR(n,i="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=sh(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+i,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const uR=typeof ArrayBuffer=="function",fR=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,R0=Object.prototype.toString,dR=typeof Blob=="function"||typeof Blob<"u"&&R0.call(Blob)==="[object BlobConstructor]",hR=typeof File=="function"||typeof File<"u"&&R0.call(File)==="[object FileConstructor]";function Nh(n){return uR&&(n instanceof ArrayBuffer||fR(n))||dR&&n instanceof Blob||hR&&n instanceof File}function Nc(n,i){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(Nc(n[r]))return!0;return!1}if(Nh(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Nc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Nc(n[r]))return!0;return!1}function mR(n){const i=[],r=n.data,o=n;return o.data=Dc(r,i),o.attachments=i.length,{packet:o,buffers:i}}function Dc(n,i,r){if(!n)return n;if(Nh(n)){const o={_placeholder:!0,num:i.length};return i.push(n),o}else if(Array.isArray(n)){const o=new Array(n.length);for(let c=0;c<n.length;c++)o[c]=Dc(n[c],i);return o}else if(typeof n=="object"&&!(n instanceof Date)){if(n.toJSON&&typeof n.toJSON=="function"&&!r)return Dc(n.toJSON(),i,!0);const o={};for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(o[c]=Dc(n[c],i));return o}return n}function pR(n,i){return n.data=ah(n.data,i),delete n.attachments,n}function ah(n,i){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<i.length)return i[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=ah(n[r],i);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=ah(n[r],i));return n}const O0=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],gR=5;var Ne;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ne||(Ne={}));class yR{constructor(i){this.replacer=i}encode(i){return(i.type===Ne.EVENT||i.type===Ne.ACK)&&Nc(i)?this.encodeAsBinary({type:i.type===Ne.EVENT?Ne.BINARY_EVENT:Ne.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let r=""+i.type;return(i.type===Ne.BINARY_EVENT||i.type===Ne.BINARY_ACK)&&(r+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(r+=i.nsp+","),i.id!=null&&(r+=i.id),i.data!=null&&(r+=JSON.stringify(i.data,this.replacer)),r}encodeAsBinary(i){const r=mR(i),o=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(o),c}}class Dh extends zt{constructor(i){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof i=="function"?{reviver:i}:i)}add(i){let r;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(i);const o=r.type===Ne.BINARY_EVENT;o||r.type===Ne.BINARY_ACK?(r.type=o?Ne.EVENT:Ne.ACK,this.reconstructor=new bR(r)):super.emitReserved("decoded",r)}else if(Nh(i)||i.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(i),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: "+i)}decodeString(i){let r=0;const o={type:Number(i.charAt(0))};if(Ne[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Ne.BINARY_EVENT||o.type===Ne.BINARY_ACK){const f=r+1;for(;i.charAt(++r)!=="-"&&r!=i.length;);const d=i.substring(f,r);if(d!=Number(d)||i.charAt(r)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!C0(m)||m<1)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");o.attachments=m}if(i.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(i.charAt(r)===","||r===i.length););o.nsp=i.substring(f,r)}else o.nsp="/";const c=i.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=i.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===i.length)break}o.id=Number(i.substring(f,r+1))}if(i.charAt(++r)){const f=this.tryParse(i.substr(r));if(Dh.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(i){try{return JSON.parse(i,this.opts.reviver)}catch{return!1}}static isPayloadValid(i,r){switch(i){case Ne.CONNECT:return Yc(r);case Ne.DISCONNECT:return r===void 0;case Ne.CONNECT_ERROR:return typeof r=="string"||Yc(r);case Ne.EVENT:case Ne.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&O0.indexOf(r[0])===-1);case Ne.ACK:case Ne.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class bR{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const r=pR(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function vR(n){return typeof n=="string"}const C0=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function SR(n){return n===void 0||C0(n)}function Yc(n){return Object.prototype.toString.call(n)==="[object Object]"}function xR(n,i){switch(n){case Ne.CONNECT:return i===void 0||Yc(i);case Ne.DISCONNECT:return i===void 0;case Ne.EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&O0.indexOf(i[0])===-1);case Ne.ACK:return Array.isArray(i);case Ne.CONNECT_ERROR:return typeof i=="string"||Yc(i);default:return!1}}function ER(n){return vR(n.nsp)&&SR(n.id)&&xR(n.type,n.data)}const TR=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Dh,Encoder:yR,get PacketType(){return Ne},isPacketValid:ER,protocol:gR},Symbol.toStringTag,{value:"Module"}));function Wn(n,i,r){return n.on(i,r),function(){n.off(i,r)}}const wR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class A0 extends zt{constructor(i,r,o){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=i,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[Wn(i,"open",this.onopen.bind(this)),Wn(i,"packet",this.onpacket.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"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(...i){return i.unshift("message"),this.emit.apply(this,i),this}emit(i,...r){var o,c,f;if(wR.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(r.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:Ne.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,v=r.pop();this._registerAckCallback(y,v),d.id=y}const m=(c=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(i,r){var o;const c=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(c===void 0){this.acks[i]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===i&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[i]=d}emitWithAck(i,...r){return new Promise((o,c)=>{const f=(d,m)=>d?c(d):o(m);f.withError=!0,r.push(f),this.emit(i,...r)})}_addToQueue(i){let r;typeof i[i.length-1]=="function"&&(r=i.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((c,...f)=>(this._queue[0],c!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!i||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(i){i.nsp=this.nsp,this.io._packet(i)}onopen(){typeof this.auth=="function"?this.auth(i=>{this._sendConnectPacket(i)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(i){this.packet({type:Ne.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},i):i})}onerror(i){this.connected||this.emitReserved("connect_error",i)}onclose(i,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(o=>String(o.id)===i)){const o=this.acks[i];delete this.acks[i],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case Ne.CONNECT:i.data&&i.data.sid?this.onconnect(i.data.sid,i.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 Ne.EVENT:case Ne.BINARY_EVENT:this.onevent(i);break;case Ne.ACK:case Ne.BINARY_ACK:this.onack(i);break;case Ne.DISCONNECT:this.ondisconnect();break;case Ne.CONNECT_ERROR:this.destroy();const o=new Error(i.data.message);o.data=i.data.data,this.emitReserved("connect_error",o);break}}onevent(i){const r=i.data||[];i.id!=null&&r.push(this.ack(i.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,i)}super.emit.apply(this,i),this._pid&&i.length&&typeof i[i.length-1]=="string"&&(this._lastOffset=i[i.length-1])}ack(i){const r=this;let o=!1;return function(...c){o||(o=!0,r.packet({type:Ne.ACK,id:i,data:c}))}}onack(i){const r=this.acks[i.id];typeof r=="function"&&(delete this.acks[i.id],r.withError&&i.data.unshift(null),r.apply(this,i.data))}onconnect(i,r){this.id=i,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(i=>this.emitEvent(i)),this.receiveBuffer=[],this.sendBuffer.forEach(i=>{this.notifyOutgoingListeners(i),this.packet(i)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(i=>i()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ne.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(i){return this.flags.compress=i,this}get volatile(){return this.flags.volatile=!0,this}timeout(i){return this.flags.timeout=i,this}onAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(i),this}prependAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(i),this}offAny(i){if(!this._anyListeners)return this;if(i){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(i),this}prependAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(i),this}offAnyOutgoing(i){if(!this._anyOutgoingListeners)return this;if(i){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,i.data)}}}function Ca(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Ca.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),r=Math.floor(i*this.jitter*n);n=(Math.floor(i*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Ca.prototype.reset=function(){this.attempts=0};Ca.prototype.setMin=function(n){this.ms=n};Ca.prototype.setMax=function(n){this.max=n};Ca.prototype.setJitter=function(n){this.jitter=n};class oh extends zt{constructor(i,r){var o;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(r=i,i=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,$c(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new Ca({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=i;const c=r.parser||TR;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(i){return arguments.length?(this._reconnection=!!i,i||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(i){return i===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=i,this)}reconnectionDelay(i){var r;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(r=this.backoff)===null||r===void 0||r.setMin(i),this)}randomizationFactor(i){var r;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(r=this.backoff)===null||r===void 0||r.setJitter(i),this)}reconnectionDelayMax(i){var r;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(r=this.backoff)===null||r===void 0||r.setMax(i),this)}timeout(i){return arguments.length?(this._timeout=i,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(i){if(~this._readyState.indexOf("open"))return this;this.engine=new lR(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const c=Wn(r,"open",function(){o.onopen(),i&&i()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),i?i(m):this.maybeReconnectOnOpen()},d=Wn(r,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(d),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(Wn(i,"ping",this.onping.bind(this)),Wn(i,"data",this.ondata.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(r){this.onclose("parse error",r)}}ondecoded(i){Wc(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,r){let o=this.nsps[i];return o?this._autoConnect&&!o.active&&o.connect():(o=new A0(this,i,r),this.nsps[i]=o),o}_destroy(i){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(i){const r=this.encoder.encode(i);for(let o=0;o<r.length;o++)this.engine.write(r[o],i.options)}cleanup(){this.subs.forEach(i=>i()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(i,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const i=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 o=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(c=>{c?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",c)):i.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Ro={};function zc(n,i){typeof n=="object"&&(i=n,n=void 0),i=i||{};const r=cR(n,i.path||"/socket.io"),o=r.source,c=r.id,f=r.path,d=Ro[c]&&f in Ro[c].nsps,m=i.forceNew||i["force new connection"]||i.multiplex===!1||d;let g;return m?g=new oh(o,i):(Ro[c]||(Ro[c]=new oh(o,i)),g=Ro[c]),r.query&&!i.query&&(i.query=r.queryKey),g.socket(r.path,i)}Object.assign(zc,{Manager:oh,Socket:A0,io:zc,connect:zc});let Ad=null;function dr(){return Ad||(Ad=zc({transports:["websocket"],autoConnect:!0})),Ad}async function RR(){const n=dr();return await Ko(n),n.emitWithAck("health.get")}async function Ko(n){n.connected||await new Promise((i,r)=>{const o=()=>{f(),i()},c=d=>{f(),r(d)},f=()=>{n.off("connect",o),n.off("connect_error",c)};n.on("connect",o),n.on("connect_error",c),n.connect()})}async function OR(n){const i=dr();return await Ko(i),i.emitWithAck("logs.history",n)}async function CR(n,i){const r=dr();return await Ko(r),r.emitWithAck("logs.dimensions",{chatroomId:n,limit:i})}async function AR(){const n=dr();return await Ko(n),n.emitWithAck("chatrooms.list")}async function _R(n){const i=dr();return await Ko(i),i.emitWithAck("eventStream.history",n??{})}function MR(n){const i=dr();return i.connect(),i.emit("eventStream.stream.subscribe"),i.on("eventStream.stream",n),()=>i.off("eventStream.stream",n)}function NR(n){const i=dr();return i.connect(),i.emit("logs.stream.subscribe"),i.on("logs.stream",n),()=>i.off("logs.stream",n)}function DR(){return Hv({queryKey:["daemon","health"],queryFn:async()=>{const n=await RR();if(!n.ok)throw new Error(n.error.message);return n.data},retry:2})}const zR={info:{badge:"bg-chatroom-status-info/15 text-chatroom-status-info"},success:{badge:"bg-chatroom-status-success/15 text-chatroom-status-success"},warning:{badge:"bg-chatroom-status-warning/15 text-chatroom-status-warning"},error:{badge:"bg-chatroom-status-error/15 text-chatroom-status-error"},muted:{badge:"bg-chatroom-text-muted/15 text-chatroom-text-muted"},purple:{badge:"bg-chatroom-status-purple/15 text-chatroom-status-purple"}};function kR(n){return zR[n]}const jR={"agent.started":["Agent Started","success"],"agent.exited":["Agent Exited","error"],"agent.circuitOpen":["Circuit Open","warning"],"agent.requestStart":["Agent Request Start","warning"],"agent.requestStop":["Agent Request Stop","error"],"agent.registered":["Agent Registered","success"],"agent.waiting":["Agent Waiting","success"],"agent.startFailed":["Agent Start Failed","error"],"agent.providerUnavailable":["Provider Unavailable","warning"],"agent.sessionResumeRequested":["Session Reconnect Requested","info"],"agent.sessionResumed":["Session Reconnected","success"],"agent.sessionResumeFailed":["Session Reconnect Failed","warning"],"agent.sessionReopenRetry":["Session Reopen Retry","info"],"agent.sessionCompacted":["Session Compacted","info"],"agent.sessionAugmented":["Session Augmented","info"],"agent.restart":["Agent Restarting","info"],"agent.restartCompleted":["Agent Restarted","success"],"agent.restartPhase":["Agent Restart Progress","info"],"agent.restartLimitReached":["Agent Restart Limit","error"],"agent.stopTimeout":["Agent Stop Timeout","warning"],"agent.harnessSessionIdUpdated":["Harness Session ID Updated","info"],"agent.awaitingHandoff":["Awaiting Handoff","warning"],"agent.enhancing":["Planning Review","info"],"agent.taskDelivered":["Task Delivered","success"],"agent.taskDeliveryFailed":["Task Delivery Failed","error"],"machine.switched":["Machine Switched","info"],"connection.terminated":["Connection Terminated","muted"],"workflow.started":["Workflow Started","info"],"workflow.stepCompleted":["Workflow Step Completed","success"],"workflow.stepCancelled":["Workflow Step Cancelled","warning"],"workflow.completed":["Workflow Completed","success"],"workflow.created":["Workflow Created","info"],"workflow.specified":["Workflow Specified","info"],"workflow.stepStarted":["Workflow Step Started","info"],"task.activated":["Task Activated","success"],"task.acknowledged":["Task Acknowledged","success"],"task.inProgress":["Task In Progress","info"],"task.completed":["Task Completed","success"],"skill.activated":["Skill Activated","purple"],"daemon.ping":["Daemon Ping","muted"],"daemon.pong":["Daemon Pong","muted"],"daemon.gitRefresh":["Git Refresh","muted"],"daemon.workspaceListChanged":["Workspace List Changed","muted"],"daemon.refreshCapabilities":["Capabilities Refresh","muted"],"daemon.pickFolder":["Pick Folder","muted"],"daemon.localAction":["Local Action","muted"],"config.requestRemoval":["Config Request Removal","warning"],"command.run":["Command Run","warning"],"command.stop":["Command Stop","error"],"enhancer.job.created":["Planning Review Started","info"],"enhancer.attempt.failed":["Planning Review Attempt Failed","warning"],"enhancer.job.failed":["Planning Review Failed","error"],"enhancer.job.complete":["Planning Review Complete","success"],"enhancer.job.cancelled":["Planning Review Cancelled","warning"]},UR=Object.fromEntries(Object.entries(jR).map(([n,[i,r]])=>[n,{label:i,classification:r}]));function LR(n){const i=n.toLowerCase();return i.includes("failed")||i.includes("error")||i.includes("timeout")?"error":n.startsWith("task.")?"success":n.startsWith("agent.")||n.startsWith("workflow.")||n.startsWith("enhancer.")?"info":n.startsWith("daemon.")?"muted":n.startsWith("command.")?"warning":n.startsWith("skill.")?"purple":"muted"}function BR(n){return UR[n]??{label:n,classification:LR(n)}}function _0({type:n,className:i}){const r=BR(n);return A.jsx("span",{className:un("shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider",kR(r.classification).badge,i),children:r.label})}function eu(){return typeof window<"u"}function $t(n){return zh(n)?(n.nodeName||"").toLowerCase():"#document"}function kt(n){var i;return(n==null||(i=n.ownerDocument)==null?void 0:i.defaultView)||window}function Xi(n){var i;return(i=(zh(n)?n.ownerDocument:n.document)||window.document)==null?void 0:i.documentElement}function zh(n){return eu()?n instanceof Node||n instanceof kt(n).Node:!1}function Je(n){return eu()?n instanceof Element||n instanceof kt(n).Element:!1}function Rt(n){return eu()?n instanceof HTMLElement||n instanceof kt(n).HTMLElement:!1}function xa(n){return!eu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof kt(n).ShadowRoot}function hr(n){const{overflow:i,overflowX:r,overflowY:o,display:c}=zn(n);return/auto|scroll|overlay|hidden|clip/.test(i+o+r)&&c!=="inline"&&c!=="contents"}function HR(n){return/^(table|td|th)$/.test($t(n))}function tu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const qR=/transform|translate|scale|rotate|perspective|filter/,YR=/paint|layout|strict|content/,Ws=n=>!!n&&n!=="none";let _d;function kh(n){const i=Je(n)?zn(n):n;return Ws(i.transform)||Ws(i.translate)||Ws(i.scale)||Ws(i.rotate)||Ws(i.perspective)||!jh()&&(Ws(i.backdropFilter)||Ws(i.filter))||qR.test(i.willChange||"")||YR.test(i.contain||"")}function VR(n){let i=As(n);for(;Rt(i)&&!Cs(i);){if(kh(i))return i;if(tu(i))return null;i=As(i)}return null}function jh(){return _d==null&&(_d=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_d}function Cs(n){return/^(html|body|#document)$/.test($t(n))}function zn(n){return kt(n).getComputedStyle(n)}function nu(n){return Je(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function As(n){if($t(n)==="html")return n;const i=n.assignedSlot||n.parentNode||xa(n)&&n.host||Xi(n);return xa(i)?i.host:i}function M0(n){const i=As(n);return Cs(i)?(n.ownerDocument||n).body:Rt(i)&&hr(i)?i:M0(i)}function zo(n,i,r){var o;i===void 0&&(i=[]),r===void 0&&(r=!0);const c=M0(n),f=c===((o=n.ownerDocument)==null?void 0:o.body),d=kt(c);if(f){const m=lh(d);return i.concat(d,d.visualViewport||[],hr(c)?c:[],m&&r?zo(m):[])}else return i.concat(c,zo(c,[],r))}function lh(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Uh={...o1},Md=Uh.useInsertionEffect,GR=Md&&Md!==Uh.useLayoutEffect?Md:n=>n();function $e(n){const i=Qi(QR).current;return i.next=n,GR(i.effect),i.trampoline}function QR(){const n={next:void 0,callback:XR,trampoline:(...i)=>{var r;return(r=n.callback)==null?void 0:r.call(n,...i)},effect:()=>{n.callback=n.next}};return n}function XR(){}const FR=()=>{},Xe=typeof document<"u"?O.useLayoutEffect:FR,KR=O.createContext(void 0);function ZR(n=!1){const i=O.useContext(KR);if(i===void 0&&!n)throw new Error(ur(16));return i}function PR(n){const{focusableWhenDisabled:i,disabled:r,composite:o=!1,tabIndex:c=0,isNativeButton:f}=n,d=o&&i!==!1,m=o&&i===!1;return{props:O.useMemo(()=>{const p={onKeyDown(y){r&&i&&y.key!=="Tab"&&y.preventDefault()}};return o||(p.tabIndex=c,!f&&r&&(p.tabIndex=i?c:-1)),(f&&(i||d)||!f&&r)&&(p["aria-disabled"]=r),f&&(!i||m)&&(p.disabled=r),p},[o,r,i,d,m,f,c])}}function N0(n={}){const{disabled:i=!1,focusableWhenDisabled:r,tabIndex:o=0,native:c=!0,composite:f}=n,d=O.useRef(null),m=ZR(!0),g=f??m!==void 0,{props:p}=PR({focusableWhenDisabled:r,disabled:i,composite:g,tabIndex:o,isNativeButton:c}),y=O.useCallback(()=>{const E=d.current;Nd(E)&&g&&i&&p.disabled===void 0&&E.disabled&&(E.disabled=!1)},[i,p.disabled,g]);Xe(y,[y]);const v=O.useCallback((E={})=>{const{onClick:x,onMouseDown:w,onKeyUp:_,onKeyDown:D,onPointerDown:C,...j}=E;return Fo({onClick(k){if(i){k.preventDefault();return}x==null||x(k)},onMouseDown(k){i||w==null||w(k)},onKeyDown(k){if(i||(Bc(k),D==null||D(k),k.baseUIHandlerPrevented))return;const q=k.target===k.currentTarget,F=k.currentTarget,B=Nd(F),U=!c&&IR(F),K=q&&(c?B:!U),se=k.key==="Enter",pe=k.key===" ",ae=F.getAttribute("role"),W=(ae==null?void 0:ae.startsWith("menuitem"))||ae==="option"||ae==="gridcell";if(q&&g&&pe){if(k.defaultPrevented&&W)return;k.preventDefault(),U||c&&B?(F.click(),k.preventBaseUIHandler()):K&&(x==null||x(k),k.preventBaseUIHandler());return}K&&(!c&&(pe||se)&&k.preventDefault(),!c&&se&&(x==null||x(k)))},onKeyUp(k){if(!i){if(Bc(k),_==null||_(k),k.target===k.currentTarget&&c&&g&&Nd(k.currentTarget)&&k.key===" "){k.preventDefault();return}k.baseUIHandlerPrevented||k.target===k.currentTarget&&!c&&!g&&k.key===" "&&(x==null||x(k))}},onPointerDown(k){if(i){k.preventDefault();return}C==null||C(k)}},c?{type:"button"}:{role:"button"},p,j)},[i,p,g,c]),S=$e(E=>{d.current=E,y()});return{getButtonProps:v,buttonRef:S}}function Nd(n){return Rt(n)&&n.tagName==="BUTTON"}function IR(n){return!!((n==null?void 0:n.tagName)==="A"&&(n!=null&&n.href))}const JR=O.forwardRef(function(i,r){const{render:o,className:c,disabled:f=!1,focusableWhenDisabled:d=!1,nativeButton:m=!0,style:g,...p}=i,{getButtonProps:y,buttonRef:v}=N0({disabled:f,focusableWhenDisabled:d,native:m});return Ra("button",i,{state:{disabled:f},ref:[r,v],props:[p,y]})}),WR=Iv("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input",ghost:"hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2",sm:"h-8 px-3"}},defaultVariants:{variant:"default",size:"default"}});function D0({className:n,variant:i="default",size:r="default",...o}){return A.jsx(JR,{"data-slot":"button",className:un(WR({variant:i,size:r,className:n})),...o})}function $R(n,i){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:i==null?void 0:i.timeZone})}function z0(n,i){return new Date(n).toLocaleString(void 0,{timeZone:i==null?void 0:i.timeZone})}function eO({entry:n,onClose:i}){const r=n.payload;return A.jsxs("aside",{className:"flex w-96 max-w-[40%] shrink-0 flex-col border-l border-chatroom-border bg-chatroom-bg-primary",role:"dialog","aria-modal":"true","aria-label":"Event detail",children:[A.jsxs("div",{className:"flex items-center justify-between border-b border-chatroom-border px-4 py-3",children:[A.jsx("h3",{className:"text-sm font-medium",children:"Event detail"}),A.jsx(D0,{variant:"ghost",size:"sm",onClick:i,"aria-label":"Close detail panel",children:A.jsx(h0,{className:"size-4"})})]}),A.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 text-xs",children:[A.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[A.jsx(_0,{type:n.type}),A.jsx("span",{className:"text-chatroom-text-muted",children:z0(n.timestamp)})]}),A.jsxs("div",{className:"space-y-1 text-chatroom-text-muted",children:[A.jsxs("div",{children:["Type: ",A.jsx("span",{className:"text-chatroom-text-primary",children:n.type})]}),A.jsxs("div",{children:["ID: ",A.jsx("span",{className:"text-chatroom-text-primary",children:n.id})]}),typeof r.chatroomId=="string"&&A.jsxs("div",{children:["Chatroom: ",A.jsx("span",{className:"text-chatroom-text-primary",children:r.chatroomId})]})]}),A.jsxs("div",{children:[A.jsx("p",{className:"mb-1 text-chatroom-text-muted",children:"Payload"}),A.jsx("pre",{className:"whitespace-pre-wrap border border-chatroom-border bg-chatroom-bg-secondary p-2 font-mono text-[11px]",children:JSON.stringify(r,null,2)})]})]})]})}function tO(n,i,r){const o=i.trim().toLowerCase();return o?n.filter(c=>r(c).toLowerCase().includes(o)):[...n]}function Vc({children:n,selected:i,onSelect:r,disabled:o,className:c,endAdornment:f,trailingActions:d,multiline:m=!1}){const g=un("min-w-0 px-3 py-2 text-xs text-left flex justify-between gap-2",m?"items-start":"items-center","cursor-pointer hover:bg-chatroom-bg-hover transition-colors","outline-none focus-visible:outline-none focus-visible:bg-chatroom-bg-hover","disabled:opacity-50 disabled:cursor-not-allowed",i&&"bg-chatroom-bg-hover",d?"flex-1 rounded-none":"w-full",!d&&c),p=A.jsxs("button",{type:"button",role:"option","aria-selected":i??!1,disabled:o,onClick:r,className:g,children:[A.jsx("span",{className:un("min-w-0 flex-1",m?"overflow-hidden":"truncate"),children:n}),f,i&&!d?A.jsx(bw,{size:12,className:"shrink-0 text-chatroom-accent"}):null]});return d?A.jsxs("div",{className:un("flex items-center w-full min-w-0",c),children:[p,d]}):p}function nO({children:n,className:i,maxHeightClassName:r="max-h-[60vh]"}){return A.jsx("div",{"data-picker-scroll-body":!0,className:un("min-h-0 overflow-y-auto overscroll-contain",r,i),children:n})}function iO({value:n,onChange:i,placeholder:r="Search…",autoFocus:o,className:c}){const f=o??!0;return A.jsx("div",{className:un("px-3 py-1.5 border-b border-chatroom-border shrink-0",c),"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),onClick:d=>{const m=d.currentTarget.querySelector("input");m==null||m.focus()},children:A.jsx("input",{type:"search",enterKeyHint:"search",value:n,onChange:d=>i(d.target.value),placeholder:r,autoFocus:f,"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),className:"w-full bg-chatroom-bg-tertiary border border-chatroom-border px-2 py-1 text-[11px] text-chatroom-text-primary placeholder:text-chatroom-text-muted focus:outline-none focus:border-chatroom-accent rounded-none"})})}const k0="min-w-[8rem] max-w-[14rem] border border-chatroom-border bg-chatroom-bg-secondary text-xs text-chatroom-text-primary px-2 py-1.5 h-[28px] cursor-pointer hover:border-chatroom-border-strong focus:outline-none focus:border-chatroom-accent disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between gap-1",j0="shrink-0 text-chatroom-text-muted";function sO(n){const[i,r]=O.useState(""),o=O.useCallback(c=>{c||r(""),n(c)},[n]);return{searchTerm:i,setSearchTerm:r,handleOpenChange:o}}const rO=[];function Lh(n){O.useEffect(n,rO)}const Oo=0;class ei{constructor(){tt(this,"currentId",Oo);tt(this,"clear",()=>{this.currentId!==Oo&&(clearTimeout(this.currentId),this.currentId=Oo)});tt(this,"disposeEffect",()=>this.clear)}static create(){return new ei}start(i,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Oo,r()},i)}isStarted(){return this.currentId!==Oo}}function Ea(){const n=Qi(ei.create).current;return Lh(n.disposeEffect),n}function aO(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:oO,platform:lO,maxTouchPoints:cO}=aO(),iu=oO.toLowerCase(),ko=lO.toLowerCase(),su=/^i(os$|p)/.test(ko)||ko==="macintel"&&cO>1,Ab="android",ch=ko===Ab||iu.includes(Ab),uO=!su&&ko.startsWith("mac");ko.startsWith("win");const fO=uO||su;var Cv;const Aa=typeof CSS<"u"&&!!((Cv=CSS.supports)!=null&&Cv.call(CSS,"-webkit-backdrop-filter:none"));!Aa&&iu.includes("firefox");!Aa&&iu.includes("chrom");const dO=fO,hO=/jsdom|happydom/.test(iu);function mO(n){n.preventDefault(),n.stopPropagation()}function pO(n){return"nativeEvent"in n}function gO(n){return n.pointerType===""&&n.isTrusted?!0:ch&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function yO(n){return hO?!1:!ch&&n.width===0&&n.height===0||ch&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function jo(n,i){const r=["mouse","pen"];return i||r.push("",void 0),r.includes(n)}function bO(n){const i=n.type;return i==="click"||i==="mousedown"||i==="keydown"||i==="keyup"}const uh="data-base-ui-focusable",U0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Ui(n){var r;let i=n.activeElement;for(;((r=i==null?void 0:i.shadowRoot)==null?void 0:r.activeElement)!=null;)i=i.shadowRoot.activeElement;return i}function Me(n,i){var o;if(!n||!i)return!1;const r=(o=i.getRootNode)==null?void 0:o.call(i);if(n.contains(i))return!0;if(r&&xa(r)){let c=i;for(;c;){if(n===c)return!0;c=c.parentNode||c.host}}return!1}function $n(n){return"composedPath"in n?n.composedPath()[0]:n.target}function L0(n,i){if(!Je(n))return!1;const r=n;if(i.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,o]of i.entries())if(Me(o,r))return!o.hasAttribute("data-trigger-disabled");return!1}function Dd(n,i){if(i==null)return!1;if("composedPath"in n)return n.composedPath().includes(i);const r=n;return r.target!=null&&i.contains(r.target)}function vO(n){return n.matches("html,body")}function Bh(n){return Rt(n)&&n.matches(U0)}function SO(n){return(n==null?void 0:n.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${U0}`))!=null}function _b(n){return n?n.getAttribute("role")==="combobox"&&Bh(n):!1}function Mb(n){return n?n.hasAttribute(uh)?n:n.querySelector(`[${uh}]`)||n:null}function xO(n,i){return i!=null&&!jo(i)?0:typeof n=="function"?n():n}function fh(n,i,r){const o=xO(n,r);return typeof o=="number"?o:o==null?void 0:o[i]}function Nb(n){return typeof n=="function"?n():n}function B0(n,i){return i||n==="click"||n==="mousedown"}function EO(n){return(n==null?void 0:n.includes("mouse"))&&n!=="mousedown"}const TO="none",Uo="trigger-press",xn="trigger-hover",H0="outside-press",wO="close-press",Lo="focus-out",q0="escape-key",RO="imperative-action";function Xt(n,i,r,o){let c=!1,f=!1;const d=Wt;return{reason:n,event:i??new Event("base-ui"),cancel(){c=!0},allowPropagation(){f=!0},get isCanceled(){return c},get isPropagationAllowed(){return f},trigger:r,...d}}function Ke(n,i,r,o){return n.addEventListener(i,r,o),()=>{n.removeEventListener(i,r,o)}}function qi(...n){return()=>{for(let i=0;i<n.length;i+=1){const r=n[i];r&&r()}}}function En(n){const i=Qi(OO,n).current;return i.next=n,Xe(i.effect),i}function OO(n){const i={current:n,next:n,effect:()=>{i.current=i.next}};return i}const Sc=null;class CO{constructor(){tt(this,"callbacks",[]);tt(this,"callbacksCount",0);tt(this,"nextId",1);tt(this,"startId",1);tt(this,"isScheduled",!1);tt(this,"tick",i=>{var c;this.isScheduled=!1;const r=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let f=0;f<r.length;f+=1)(c=r[f])==null||c.call(r,i)})}request(i){const r=this.nextId;return this.nextId+=1,this.callbacks.push(i),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(i){const r=i-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const xc=new CO;class di{constructor(){tt(this,"currentId",Sc);tt(this,"cancel",()=>{this.currentId!==Sc&&(xc.cancel(this.currentId),this.currentId=Sc)});tt(this,"disposeEffect",()=>this.cancel)}static create(){return new di}static request(i){return xc.request(i)}static cancel(i){return xc.cancel(i)}request(i){this.cancel(),this.currentId=xc.request(()=>{this.currentId=Sc,i()})}}function Hh(){const n=Qi(di.create).current;return Lh(n.disposeEffect),n}function ut(n){return(n==null?void 0:n.ownerDocument)||document}const AO={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},_O={...AO,position:"fixed",top:0,left:0},Ta=O.forwardRef(function(i,r){const[o,c]=O.useState();Xe(()=>{dO&&Aa&&c("button")},[]);const f={tabIndex:0,role:o};return A.jsx("span",{...i,ref:r,style:_O,"aria-hidden":o?void 0:!0,...f,"data-base-ui-focus-guard":""})}),MO=["top","right","bottom","left"],wa=Math.min,Yi=Math.max,Gc=Math.round,Ec=Math.floor,Vi=n=>({x:n,y:n}),NO={left:"right",right:"left",bottom:"top",top:"bottom"};function Y0(n,i,r){return Yi(n,wa(i,r))}function Gi(n,i){return typeof n=="function"?n(i):n}function Dn(n){return n.split("-")[0]}function Ds(n){return n.split("-")[1]}function qh(n){return n==="x"?"y":"x"}function Yh(n){return n==="y"?"height":"width"}function Fn(n){const i=n[0];return i==="t"||i==="b"?"y":"x"}function Vh(n){return qh(Fn(n))}function DO(n,i,r){r===void 0&&(r=!1);const o=Ds(n),c=Vh(n),f=Yh(c);let d=c==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return i.reference[f]>i.floating[f]&&(d=Qc(d)),[d,Qc(d)]}function zO(n){const i=Qc(n);return[dh(n),i,dh(i)]}function dh(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Db=["left","right"],zb=["right","left"],kO=["top","bottom"],jO=["bottom","top"];function UO(n,i,r){switch(n){case"top":case"bottom":return r?i?zb:Db:i?Db:zb;case"left":case"right":return i?kO:jO;default:return[]}}function LO(n,i,r,o){const c=Ds(n);let f=UO(Dn(n),r==="start",o);return c&&(f=f.map(d=>d+"-"+c),i&&(f=f.concat(f.map(dh)))),f}function Qc(n){const i=Dn(n);return NO[i]+n.slice(i.length)}function BO(n){var i,r,o,c;return{top:(i=n.top)!=null?i:0,right:(r=n.right)!=null?r:0,bottom:(o=n.bottom)!=null?o:0,left:(c=n.left)!=null?c:0}}function V0(n){return typeof n!="number"?BO(n):{top:n,right:n,bottom:n,left:n}}function Xc(n){const{x:i,y:r,width:o,height:c}=n;return{width:o,height:c,top:r,left:i,right:i+o,bottom:r+c,x:i,y:r}}function HO(n){return n.visibility==="hidden"||n.visibility==="collapse"}function G0(n,i=n?zn(n):null){return!n||!n.isConnected||!i||HO(i)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():i.display!=="none"&&i.display!=="contents"}const qO='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function YO(n){const i=n.assignedSlot;if(i)return i;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return xa(r)?r.host:null}function hh(n){for(const i of Array.from(n.children))if($t(i)==="summary")return i;return null}function VO(n,i){const r=hh(i);return!!r&&(n===r||Me(r,n))}function Q0(n){const i=n?$t(n):"";return n!=null&&n.matches(qO)&&(i!=="summary"||n.parentElement!=null&&$t(n.parentElement)==="details"&&hh(n.parentElement)===n)&&(i!=="details"||hh(n)==null)&&(i!=="input"||n.type!=="hidden")}function X0(n){if(!Q0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let i=n;i;i=YO(i)){const r=i!==n,o=$t(i)==="slot";if(i.hasAttribute("inert")||r&&$t(i)==="details"&&!i.open&&!VO(n,i)||i.hasAttribute("hidden")||!o&&!GO(i,r))return!1}return!0}function GO(n,i){const r=zn(n);return i?r.display!=="none":G0(n,r)}function F0(n){const i=n.tabIndex;if(i<0){const r=$t(n);if(r==="details"||r==="audio"||r==="video"||Rt(n)&&n.isContentEditable)return 0}return i}function zd(n){if($t(n)!=="input")return null;const i=n;return i.type==="radio"&&i.name!==""?i:null}function QO(n,i){const r=zd(n);if(!r)return!0;const o=i.find(c=>{const f=zd(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form&&f.checked});return o?o===r:i.find(c=>{const f=zd(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form})===r}function K0(n){if(Rt(n)&&$t(n)==="slot"){const i=n.assignedElements({flatten:!0});if(i.length>0)return i}return Rt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function Z0(n,i){K0(n).forEach(r=>{Q0(r)&&i.push(r),Z0(r,i)})}function P0(n,i,r){K0(n).forEach(o=>{Rt(o)&&o.matches(i)&&r.push(o),P0(o,i,r)})}function Gh(n){return X0(n)&&F0(n)>=0}function I0(n){const i=[];return Z0(n,i),i.filter(X0)}function Zo(n){const i=I0(n);return i.filter(r=>F0(r)>=0&&QO(r,i))}function J0(n,i){const r=Zo(n),o=r.length;if(o===0)return;const c=Ui(ut(n)),f=r.indexOf(c),d=f===-1?i===1?0:o-1:f+i;return r[d]}function Qh(n){return J0(ut(n).body,1)||n}function W0(n){return J0(ut(n).body,-1)||n}function $0(n,i){if(!n)return null;const r=Zo(ut(n).body),o=r.length;if(o===0)return null;const c=r.indexOf(n);if(c===-1)return null;const f=(c+i+o)%o;return r[f]}function XO(n){return $0(n,1)}function FO(n){return $0(n,-1)}function ra(n,i){const r=i||n.currentTarget,o=n.relatedTarget;return!o||!Me(r,o)}function KO(n){Zo(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function kb(n){const i=[];P0(n,"[data-tabindex]",i),i.forEach(r=>{const o=r.dataset.tabindex;delete r.dataset.tabindex,o?r.setAttribute("tabindex",o):r.removeAttribute("tabindex")})}function _s(n,i,r=!0){return n.filter(c=>c.parentId===i).flatMap(c=>{var f;return[...!r||(f=c.context)!=null&&f.open?[c]:[],..._s(n,c.id,r)]})}function jb(n,i){var c;let r=[],o=(c=n.find(f=>f.id===i))==null?void 0:c.parentId;for(;o;){const f=n.find(d=>d.id===o);o=f==null?void 0:f.parentId,f&&(r=r.concat(f))}return r}function Fc(n){return`data-base-ui-${n}`}let Tc=0;function kd(n,i={}){const{preventScroll:r=!1,sync:o=!1,shouldFocus:c}=i;cancelAnimationFrame(Tc);function f(){c&&!c()||n==null||n.focus({preventScroll:r})}if(o)return f(),Rh;const d=requestAnimationFrame(f);return Tc=d,()=>{Tc===d&&(cancelAnimationFrame(d),Tc=0)}}const jd={inert:new WeakMap,"aria-hidden":new WeakMap},Ub="data-base-ui-inert",mh={inert:new WeakSet,"aria-hidden":new WeakSet};let Co=new WeakMap,Ud=0;function ZO(n){return mh[n]}function eS(n){return n?xa(n)?n.host:eS(n.parentNode):null}const Lb=(n,i)=>i.map(r=>{if(n.contains(r))return r;const o=eS(r);return n.contains(o)?o:null}).filter(r=>r!=null),Bb=n=>{const i=new Set;return n.forEach(r=>{let o=r;for(;o&&!i.has(o);)i.add(o),o=o.parentNode}),i},Hb=(n,i,r)=>{const o=[],c=f=>{!f||r.has(f)||Array.from(f.children).forEach(d=>{$t(d)!=="script"&&(i.has(d)?c(d):o.push(d))})};return c(n),o};function PO(n,i,r,o,{mark:c=!0}){let f=null;o?f="inert":r&&(f="aria-hidden");let d=null,m=null;const g=Lb(i,n),p=c?Hb(i,Bb(g),new Set(g)):[],y=[],v=[];if(f){const S=jd[f],E=ZO(f);m=E,d=S;const x=Lb(i,Array.from(i.querySelectorAll("[aria-live]"))),w=g.concat(x);Hb(i,Bb(w),new Set(w)).forEach(D=>{const C=D.getAttribute(f),j=C!==null&&C!=="false",k=(S.get(D)||0)+1;S.set(D,k),y.push(D),k===1&&j&&E.add(D),j||D.setAttribute(f,f==="inert"?"":"true")})}return c&&p.forEach(S=>{const E=(Co.get(S)||0)+1;Co.set(S,E),v.push(S),E===1&&S.setAttribute(Ub,"")}),Ud+=1,()=>{d&&y.forEach(S=>{const x=(d.get(S)||0)-1;d.set(S,x),x||(!(m!=null&&m.has(S))&&f&&S.removeAttribute(f),m==null||m.delete(S))}),c&&v.forEach(S=>{const E=(Co.get(S)||0)-1;Co.set(S,E),E||S.removeAttribute(Ub)}),Ud-=1,Ud||(jd.inert=new WeakMap,jd["aria-hidden"]=new WeakMap,mh.inert=new WeakSet,mh["aria-hidden"]=new WeakSet,Co=new WeakMap)}}function qb(n,i={}){const{ariaHidden:r=!1,inert:o=!1,mark:c=!0}=i,f=ut(n[0]).body;return PO(n,f,r,o,{mark:c})}var Ms=qv();let Yb=0;function IO(n,i="mui"){const[r,o]=O.useState(n),c=n||r;return O.useEffect(()=>{r==null&&(Yb+=1,o(`${i}-${Yb}`))},[r,i]),c}const Vb=Uh.useId;function Po(n,i){if(Vb!==void 0){const r=Vb();return n??(i?`${i}-${r}`:r)}return IO(n,i)}const JO=500,WO={style:{transition:"none"}},tS="data-base-ui-click-trigger",$O={fallbackAxisSide:"end"},eC={clipPath:"inset(50%)",position:"fixed",top:0,left:0},nS=O.createContext(null),iS=()=>O.useContext(nS),tC=Fc("portal");function nC(n={}){const{ref:i,container:r,componentProps:o=Wt,elementProps:c}=n,f=Po(),d=iS(),m=d==null?void 0:d.portalNode,[g,p]=O.useState(null),[y,v]=O.useState(null),S=$e(_=>{_!==null&&v(_)}),E=O.useRef(null);Xe(()=>{if(r===null){E.current&&(E.current=null,v(null),p(null));return}if(f==null)return;const _=(r&&(zh(r)?r:r.current))??m??document.body;if(_==null){E.current&&(E.current=null,v(null),p(null));return}E.current!==_&&(E.current=_,v(null),p(_))},[r,m,f]);const x=Ra("div",o,{ref:[i,S],props:[{id:f,[tC]:""},c]});return{portalNode:y,portalSubtree:g&&x?Ms.createPortal(x,g):null}}const iC=O.forwardRef(function(i,r){const{render:o,className:c,style:f,children:d,container:m,renderGuards:g,...p}=i,{portalNode:y,portalSubtree:v}=nC({container:m,ref:r,componentProps:i,elementProps:p}),S=O.useRef(null),E=O.useRef(null),x=O.useRef(null),w=O.useRef(null),[_,D]=O.useState(null),C=O.useRef(!1),j=_==null?void 0:_.modal,k=_==null?void 0:_.open,q=typeof g=="boolean"?g:!!_&&!_.modal&&_.open&&!!y;O.useEffect(()=>{if(!y||j)return;function B(U){y&&U.relatedTarget&&ra(U)&&(U.type==="focusin"?C.current&&(kb(y),C.current=!1):(KO(y),C.current=!0))}return qi(Ke(y,"focusin",B,!0),Ke(y,"focusout",B,!0))},[y,j]),Xe(()=>{!y||k!==!0||!C.current||(kb(y),C.current=!1)},[k,y]);const F=O.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:E,beforeInsideRef:x,afterInsideRef:w,portalNode:y,setFocusManagerState:D}),[y]);return A.jsxs(O.Fragment,{children:[v,A.jsxs(nS.Provider,{value:F,children:[q&&y&&A.jsx(Ta,{"data-type":"outside",ref:S,onFocus:B=>{var U;if(ra(B,y))(U=x.current)==null||U.focus();else{const K=_?_.domReference:null,se=W0(K);se==null||se.focus()}}}),q&&y&&A.jsx("span",{"aria-owns":y.id,style:eC}),y&&Ms.createPortal(d,y),q&&y&&A.jsx(Ta,{"data-type":"outside",ref:E,onFocus:B=>{var U;if(ra(B,y))(U=w.current)==null||U.focus();else{const K=_?_.domReference:null,se=Qh(K);se==null||se.focus(),_!=null&&_.closeOnFocusOut&&(_==null||_.onOpenChange(!1,Xt(Lo,B.nativeEvent)))}}})]})]})});function sS(){const n=new Map;return{emit(i,r){var o;(o=n.get(i))==null||o.forEach(c=>c(r))},on(i,r){n.has(i)||n.set(i,new Set),n.get(i).add(r)},off(i,r){var o;(o=n.get(i))==null||o.delete(r)}}}class sC{constructor(){tt(this,"nodesRef",{current:[]});tt(this,"events",sS())}addNode(i){this.nodesRef.current.push(i)}removeNode(i){const r=this.nodesRef.current.findIndex(o=>o===i);r!==-1&&this.nodesRef.current.splice(r,1)}}const rS=O.createContext(null),aS=O.createContext(null),_a=()=>{var n;return((n=O.useContext(rS))==null?void 0:n.id)||null},Ma=n=>{const i=O.useContext(aS);return n??i};function rC(n){const i=Po(),r=Ma(n),o=_a();return Xe(()=>{if(!i)return;const c={id:i,parentId:o};return r==null||r.addNode(c),()=>{r==null||r.removeNode(c)}},[r,i,o]),i}function aC(n){const{children:i,id:r}=n,o=_a();return A.jsx(rS.Provider,{value:O.useMemo(()=>({id:r,parentId:o}),[r,o]),children:i})}function oC(n){const{children:i,externalTree:r}=n,o=Qi(()=>r??new sC).current;return A.jsx(aS.Provider,{value:o,children:i})}function Li(n){return n==null?n:"current"in n?n.current:n}function lC(n,i){const r=kt($n(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?i||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?i||(n.detail===0?"keyboard":"mouse"):""}const cC=20;let Rs=[];function Xh(){Rs=Rs.filter(n=>{var i;return(i=n.deref())==null?void 0:i.isConnected})}function Gb(n){Xh(),n&&$t(n)!=="body"&&(Rs.push(new WeakRef(n)),Rs.length>cC&&(Rs=Rs.slice(-20)))}function Qb(){var n;return Xh(),(n=Rs[Rs.length-1])==null?void 0:n.deref()}function uC(n){return n?Gh(n)?n:Zo(n)[0]||n:null}function Xb(n){var c;if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!((c=n.getAttribute("role"))!=null&&c.includes("dialog")))return;const r=I0(n).filter(f=>{const d=f.getAttribute("data-tabindex")||"";return Gh(f)||f.hasAttribute("data-tabindex")&&!d.startsWith("-")}),o=n.getAttribute("tabindex");r.length===0?o!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(o!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function fC(n){const{context:i,children:r,disabled:o=!1,initialFocus:c=!0,returnFocus:f=!0,restoreFocus:d=!1,modal:m=!0,closeOnFocusOut:g=!0,openInteractionType:p="",nextFocusableElement:y,previousFocusableElement:v,beforeContentFocusGuardRef:S,externalTree:E,getInsideElements:x}=n,w="rootStore"in i?i.rootStore:i,_=w.useState("open"),D=w.useState("domReferenceElement"),C=w.useState("floatingElement"),{events:j,dataRef:k}=w.context,q=$e(()=>{var ve;return(ve=k.current.floatingContext)==null?void 0:ve.nodeId}),F=c===!1,B=_b(D)&&F,U=En(c),K=En(f),se=En(p),pe=En(_),ae=Ma(E),W=iS(),le=O.useRef(!1),ie=O.useRef(!1),N=O.useRef(!1),Q=O.useRef(null),I=O.useRef(""),oe=O.useRef(""),Y=O.useRef(null),T=O.useRef(null),H=Hc(Y,S,W==null?void 0:W.beforeInsideRef),te=Hc(T,W==null?void 0:W.afterInsideRef),ne=Ea(),re=Ea(),ee=Hh(),ge=W!=null,ce=Mb(C),fe=$e((ve=ce)=>ve?Zo(ve):[]),Ze=$e(()=>(x==null?void 0:x().filter(ve=>ve!=null))??[]);O.useEffect(()=>{if(o||!m)return;function ve(Oe){Oe.key==="Tab"&&Me(ce,Ui(ut(ce)))&&fe().length===0&&!B&&mO(Oe)}const ze=ut(ce);return Ke(ze,"keydown",ve)},[o,ce,m,B,fe]),O.useEffect(()=>{if(o||!_)return;const ve=ut(ce);function ze(){N.current=!1}function Oe(vt){const Re=$n(vt),ke=Ze(),Ee=Me(C,Re)||Me(D,Re)||Me(W==null?void 0:W.portalNode,Re)||ke.some(mt=>mt===Re||Me(mt,Re));N.current=!Ee,oe.current=vt.pointerType||"keyboard",Re!=null&&Re.closest(`[${tS}]`)&&(ie.current=!0,re.start(0,()=>{ie.current=!1}))}function ft(){oe.current="keyboard"}return qi(Ke(ve,"pointerdown",Oe,!0),Ke(ve,"pointerup",ze,!0),Ke(ve,"pointercancel",ze,!0),Ke(ve,"keydown",ft,!0),ze)},[o,C,D,ce,_,W,re,Ze]),O.useEffect(()=>{if(o||!g)return;const ve=ut(ce);function ze(){ie.current=!0,re.start(0,()=>{ie.current=!1})}function Oe(ke){const Ee=$n(ke);Gh(Ee)&&(Q.current=Ee)}function ft(ke){const Ee=ke.relatedTarget,mt=ke.currentTarget,dt=$n(ke);m&&Ee==null&&dt!=null&&Me(C,dt)&&Gb(dt),queueMicrotask(()=>{const je=q(),xt=w.context.triggerElements,ue=Ze(),xe=(Ee==null?void 0:Ee.hasAttribute(Fc("focus-guard")))&&[Y.current,T.current,W==null?void 0:W.beforeInsideRef.current,W==null?void 0:W.afterInsideRef.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,Li(v),Li(y)].includes(Ee),ht=!(Me(D,Ee)||Me(C,Ee)||Me(Ee,C)||Me(W==null?void 0:W.portalNode,Ee)||ue.some(Be=>Be===Ee||Me(Be,Ee))||Ee!=null&&xt.hasElement(Ee)||xt.hasMatchingElement(Be=>Me(Be,Ee))||xe||ae&&(_s(ae.nodesRef.current,je).find(Be=>{var pt,jt;return Me((pt=Be.context)==null?void 0:pt.elements.floating,Ee)||Me((jt=Be.context)==null?void 0:jt.elements.domReference,Ee)})||jb(ae.nodesRef.current,je).find(Be=>{var pt,jt,sn;return[(pt=Be.context)==null?void 0:pt.elements.floating,Mb((jt=Be.context)==null?void 0:jt.elements.floating)].includes(Ee)||((sn=Be.context)==null?void 0:sn.elements.domReference)===Ee})));if(mt===D&&ce&&Xb(ce),d&&mt!==D&&!G0(dt)&&Ui(ve)===ve.body){if(Rt(ce)&&(ce.focus(),d==="popup")){ee.request(()=>{ce.focus()});return}const Be=fe(),pt=Q.current,jt=(pt&&Be.includes(pt)?pt:null)||Be[Be.length-1]||ce;Rt(jt)&&jt.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(B||!m)&&Ee&&ht&&!ie.current&&(B||Ee!==Qb())&&(le.current=!0,w.setOpen(!1,Xt(Lo,ke)))})}function vt(){N.current||(k.current.insideReactTree=!0,ne.start(0,()=>{k.current.insideReactTree=!1}))}const Re=Rt(D)?D:null;if(!(!C&&!Re))return qi(Re&&Ke(Re,"focusout",ft),Re&&Ke(Re,"pointerdown",ze),C&&Ke(C,"focusin",Oe),C&&Ke(C,"focusout",ft),C&&W&&Ke(C,"focusout",vt,!0))},[o,D,C,ce,m,ae,W,w,g,d,fe,B,q,k,ne,re,ee,y,v,Ze]),O.useEffect(()=>{var mt,dt,je;if(o||!C||!_)return;const ve=Array.from(((mt=W==null?void 0:W.portalNode)==null?void 0:mt.querySelectorAll(`[${Fc("portal")}]`))||[]),Oe=(je=(dt=(ae?jb(ae.nodesRef.current,q()):[]).find(xt=>{var ue;return _b(((ue=xt.context)==null?void 0:ue.elements.domReference)||null)}))==null?void 0:dt.context)==null?void 0:je.elements.domReference,vt=[...[C,...ve,Y.current,T.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,...Ze()],Oe,Li(v),Li(y),B?D:null].filter(xt=>xt!=null),Re=qb(vt,{ariaHidden:m||B,mark:!1}),ke=[C,...ve].filter(xt=>xt!=null),Ee=qb(ke);return()=>{Ee(),Re()}},[_,o,D,C,m,W,B,ae,q,y,v,Ze]),Xe(()=>{if(!_||o||!Rt(ce))return;const ve=ut(ce),ze=Ui(ve);queueMicrotask(()=>{const Oe=U.current,ft=typeof Oe=="function"?Oe(se.current||""):Oe;if(ft===void 0||ft===!1||Me(ce,ze))return;let Re=null;const ke=()=>(Re==null&&(Re=fe(ce)),Re[0]||ce);let Ee;ft===!0||ft===null?Ee=ke():Ee=Li(ft),Ee=Ee||ke();const mt=Me(ce,Ui(ve));kd(Ee,{preventScroll:Ee===ce,shouldFocus(){if(!pe.current)return!1;if(mt)return!0;const dt=Ui(ve);return!(dt!==Ee&&Me(ce,dt))}})})},[o,_,ce,fe,U,se,pe]),Xe(()=>{if(o||!ce)return;const ve=ut(ce),ze=Ui(ve),Oe=se.current==null;Gb(ze);function ft(Re){if(Re.open||(I.current=lC(Re.nativeEvent,oe.current)),Re.reason===xn&&Re.nativeEvent.type==="mouseleave"&&(le.current=!0),Re.reason===H0)if(Re.nested)le.current=!1;else if(gO(Re.nativeEvent)||yO(Re.nativeEvent))le.current=!1;else{let ke=!1;ut(ce).createElement("div").focus({get preventScroll(){return ke=!0,!1}}),ke?le.current=!1:le.current=!0}}j.on("openchange",ft);function vt(){const Re=K.current;let ke=typeof Re=="function"?Re(I.current):Re;if(ke===void 0||ke===!1)return null;ke===null&&(ke=!0);const Ee=D!=null&&D.isConnected?D:null,mt=ze!=null&&ze.isConnected&&$t(ze)!=="body"?ze:null;let dt=Oe?mt||Ee:Ee||mt;return dt||(dt=Qb()||null),typeof ke=="boolean"?dt:Li(ke)||dt||null}return()=>{j.off("openchange",ft);const Re=Ui(ve),ke=Ze(),Ee=Me(C,Re)||ke.some(je=>je===Re||Me(je,Re))||ae&&_s(ae.nodesRef.current,q(),!1).some(je=>{var xt;return Me((xt=je.context)==null?void 0:xt.elements.floating,Re)}),mt=K.current,dt=vt();queueMicrotask(()=>{const je=uC(dt),xt=typeof mt!="boolean";mt&&!le.current&&Rt(je)&&(!(!xt&&je!==Re&&Re!==ve.body)||Ee)&&je.focus({preventScroll:!0}),le.current=!1})}},[o,C,ce,K,se,j,ae,D,q,Ze]),Xe(()=>{if(!Aa||_||!C)return;const ve=Ui(ut(C));!Rt(ve)||!Bh(ve)||Me(C,ve)&&ve.blur()},[_,C]),Xe(()=>{if(!(o||!W))return W.setFocusManagerState({modal:m,closeOnFocusOut:g,open:_,onOpenChange:w.setOpen,domReference:D}),()=>{W.setFocusManagerState(null)}},[o,W,m,_,w,g,D]),Xe(()=>{if(!(o||!ce))return Xb(ce),()=>{queueMicrotask(Xh)}},[o,ce]);const nt=!o&&(m?!B:!0)&&(ge||m);return A.jsxs(O.Fragment,{children:[nt&&A.jsx(Ta,{"data-type":"inside",ref:H,onFocus:ve=>{var ze;if(m){const Oe=fe();kd(Oe[Oe.length-1])}else if(W!=null&&W.portalNode)if(le.current=!1,ra(ve,W.portalNode)){const Oe=Qh(D);Oe==null||Oe.focus()}else(ze=Li(v??W.beforeOutsideRef))==null||ze.focus()}}),r,nt&&A.jsx(Ta,{"data-type":"inside",ref:te,onFocus:ve=>{var ze;if(m)kd(fe()[0]);else if(W!=null&&W.portalNode)if(g&&(le.current=!0),ra(ve,W.portalNode)){const Oe=W0(D);Oe==null||Oe.focus()}else(ze=Li(y??W.afterOutsideRef))==null||ze.focus()}})]})}function dC(n,i={}){const{enabled:r=!0,event:o="click",toggle:c=!0,ignoreMouse:f=!1,stickIfOpen:d=!0,touchOpenDelay:m=0,reason:g=Uo}=i,p="rootStore"in n?n.rootStore:n,y=p.context.dataRef,v=O.useRef(void 0),S=Hh(),E=Ea(),x=O.useMemo(()=>{function w(D,C,j,k){const q=Xt(g,C,j);D&&k==="touch"&&m>0?E.start(m,()=>{p.setOpen(!0,q)}):p.setOpen(D,q)}function _(D,C,j){const k=y.current.openEvent,q=p.select("domReferenceElement")!==C;return D&&q||!D||!c?!0:k&&d?!j(k.type):!1}return{onPointerDown(D){v.current=D.pointerType},onMouseDown(D){const C=v.current,j=D.nativeEvent,k=p.select("open");if(D.button!==0||o==="click"||jo(C,!0)&&f)return;const q=_(k,D.currentTarget,U=>U==="click"||U==="mousedown"),F=$n(j);if(Bh(F)){w(q,j,F,C);return}const B=D.currentTarget;S.request(()=>{w(q,j,B,C)})},onClick(D){if(o==="mousedown-only")return;const C=v.current;if(o==="mousedown"&&C){v.current=void 0;return}if(jo(C,!0)&&f)return;const j=p.select("open"),k=_(j,D.currentTarget,q=>q==="click"||q==="mousedown"||q==="keydown"||q==="keyup");w(k,D.nativeEvent,D.currentTarget,C)},onKeyDown(){v.current=void 0}}},[y,o,f,g,p,d,c,S,E,m]);return O.useMemo(()=>r?{reference:x}:Wt,[r,x])}function hC(){return!1}function mC(n){return{escapeKey:typeof n=="boolean"?n:(n==null?void 0:n.escapeKey)??!1,outsidePress:typeof n=="boolean"?n:(n==null?void 0:n.outsidePress)??!0}}function pC(n,i={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:c=!0,outsidePressEvent:f="sloppy",referencePress:d=hC,bubbles:m,externalTree:g}=i,p="rootStore"in n?n.rootStore:n,y=p.useState("open"),v=p.useState("floatingElement"),{dataRef:S}=p.context,E=Ma(g),x=$e(typeof c=="function"?c:()=>!1),w=typeof c=="function"?x:c,_=w!==!1,D=$e(()=>f),{escapeKey:C,outsidePress:j}=mC(m),k=O.useRef(!1),q=O.useRef(!1),F=O.useRef(!1),B=O.useRef(!1),U=O.useRef(""),K=O.useRef(null),se=Ea(),pe=Ea(),ae=$e(()=>{pe.clear(),S.current.insideReactTree=!1}),W=$e(H=>{var re;const te=(re=S.current.floatingContext)==null?void 0:re.nodeId;return(E?_s(E.nodesRef.current,te):[]).some(ee=>{var ge;return((ge=ee.context)==null?void 0:ge.open)&&!ee.context.dataRef.current[H]})}),le=$e(H=>Dd(H,p.select("floatingElement"))||Dd(H,p.select("domReferenceElement"))),ie=$e(H=>{d()&&p.setOpen(!1,Xt(Uo,H.nativeEvent))}),N=$e(H=>{if(!y||!r||!o||H.key!=="Escape"||B.current||!C&&W("__escapeKeyBubbles"))return;const te=pO(H)?H.nativeEvent:H,ne=Xt(q0,te);p.setOpen(!1,ne),ne.isCanceled||H.preventDefault(),!C&&!ne.isPropagationAllowed&&H.stopPropagation()}),Q=$e(()=>{S.current.insideReactTree=!0,pe.start(0,ae)}),I=$e(H=>{if(!y||!r||H.button!==0)return;const te=$n(H.nativeEvent);Me(p.select("floatingElement"),te)&&(k.current||(k.current=!0,q.current=!1))}),oe=$e(H=>{!y||!r||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&k.current&&(q.current=!0)});O.useEffect(()=>{if(!y||!r)return;S.current.__escapeKeyBubbles=C,S.current.__outsidePressBubbles=j;const H=new ei,te=new ei;function ne(){H.clear(),B.current=!0}function re(){H.start(Aa?5:0,()=>{B.current=!1})}function ee(){F.current=!0,te.start(0,()=>{F.current=!1})}function ge(){k.current=!1,q.current=!1}function ce(){const ue=U.current,xe=ue==="pen"||!ue?"mouse":ue,ht=D(),Be=typeof ht=="function"?ht():ht;return typeof Be=="string"?Be:Be[xe]}function fe(ue){const xe=ce();return xe==="intentional"&&ue.type!=="click"||xe==="sloppy"&&ue.type==="click"}function Ze(ue){var Be;const xe=(Be=S.current.floatingContext)==null?void 0:Be.nodeId,ht=E&&_s(E.nodesRef.current,xe).some(pt=>{var jt;return Dd(ue,(jt=pt.context)==null?void 0:jt.elements.floating)});return le(ue)||ht}function nt(ue){if(fe(ue)){ue.type!=="click"&&!le(ue)&&(te.clear(),F.current=!1),ae();return}if(S.current.insideReactTree){ae();return}const xe=$n(ue),ht=`[${Fc("inert")}]`,Be=Je(xe)?xe.getRootNode():null,pt=Array.from((xa(Be)?Be:ut(p.select("floatingElement"))).querySelectorAll(ht)),jt=p.context.triggerElements;if(xe&&(jt.hasElement(xe)||jt.hasMatchingElement(rn=>Me(rn,xe))))return;let sn=Je(xe)?xe:null;for(;sn&&!Cs(sn);){const rn=As(sn);if(Cs(rn)||!Je(rn))break;sn=rn}if(!(pt.length&&Je(xe)&&!vO(xe)&&!Me(xe,p.select("floatingElement"))&&pt.every(rn=>!Me(sn,rn)))){if(Rt(xe)&&!("touches"in ue)){const rn=Cs(xe),ti=zn(xe),fn=/auto|scroll/,qt=rn||fn.test(ti.overflowX),Tn=rn||fn.test(ti.overflowY),Yt=qt&&xe.clientWidth>0&&xe.scrollWidth>xe.clientWidth,mr=Tn&&xe.clientHeight>0&&xe.scrollHeight>xe.clientHeight,pr=ti.direction==="rtl",gr=mr&&(pr?ue.offsetX<=xe.offsetWidth-xe.clientWidth:ue.offsetX>xe.clientWidth),pi=Yt&&ue.offsetY>xe.clientHeight;if(gr||pi)return}if(!Ze(ue)){if(ce()==="intentional"&&F.current){te.clear(),F.current=!1;return}typeof w=="function"&&!w(ue)||W("__outsidePressBubbles")||(p.setOpen(!1,Xt(H0,ue)),ae())}}}function ve(ue){ce()!=="sloppy"||ue.pointerType==="touch"||!p.select("open")||!r||le(ue)||nt(ue)}function ze(ue){if(ce()!=="sloppy"||!p.select("open")||!r||le(ue))return;const xe=ue.touches[0];xe&&(K.current={startTime:Date.now(),startX:xe.clientX,startY:xe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},se.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function Oe(ue,xe){const ht=$n(ue);if(!ht)return;const Be=Ke(ht,ue.type,()=>{xe(ue),Be()})}function ft(ue){U.current="touch",Oe(ue,ze)}function vt(ue){se.clear(),ue.type==="pointerdown"&&(U.current=ue.pointerType),!(ue.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&Oe(ue,xe=>{xe.type==="pointerdown"?ve(xe):nt(xe)})}function Re(ue){if(!k.current)return;const xe=q.current;if(ge(),ce()==="intentional"){if(ue.type==="pointercancel"){xe&&ee();return}if(!Ze(ue)){if(xe){ee();return}typeof w=="function"&&!w(ue)||(te.clear(),F.current=!0,ae())}}}function ke(ue){if(ce()!=="sloppy"||!K.current||le(ue))return;const xe=ue.touches[0];if(!xe)return;const ht=Math.abs(xe.clientX-K.current.startX),Be=Math.abs(xe.clientY-K.current.startY),pt=Math.sqrt(ht*ht+Be*Be);pt>5&&(K.current.dismissOnTouchEnd=!0),pt>10&&(nt(ue),se.clear(),K.current=null)}function Ee(ue){Oe(ue,ke)}function mt(ue){ce()!=="sloppy"||!K.current||le(ue)||(K.current.dismissOnTouchEnd&&nt(ue),se.clear(),K.current=null)}function dt(ue){Oe(ue,mt)}const je=ut(v),xt=qi(o&&qi(Ke(je,"keydown",N),Ke(je,"compositionstart",ne),Ke(je,"compositionend",re)),_&&qi(Ke(je,"click",vt,!0),Ke(je,"pointerdown",vt,!0),Ke(je,"pointerup",Re,!0),Ke(je,"pointercancel",Re,!0),Ke(je,"mousedown",vt,!0),Ke(je,"mouseup",Re,!0),Ke(je,"touchstart",ft,!0),Ke(je,"touchmove",Ee,!0),Ke(je,"touchend",dt,!0)));return()=>{xt(),H.clear(),te.clear(),ge(),F.current=!1}},[S,v,o,_,w,y,r,C,j,N,ae,D,W,le,E,p,se]),O.useEffect(ae,[w,ae]);const Y=O.useMemo(()=>({onKeyDown:N,onPointerDown:ie,onClick:ie}),[N,ie]),T=O.useMemo(()=>({onKeyDown:N,onPointerDown:oe,onMouseDown:oe,onClickCapture:Q,onMouseDownCapture(H){Q(),I(H)},onPointerDownCapture(H){Q(),I(H)},onMouseUpCapture:Q,onTouchEndCapture:Q,onTouchMoveCapture:Q}),[N,Q,I,oe]);return O.useMemo(()=>r?{reference:Y,floating:T,trigger:Y}:{},[r,Y,T])}function Fb(n,i,r){let{reference:o,floating:c}=n;const f=Fn(i),d=Vh(i),m=Yh(d),g=Dn(i),p=f==="y",y=o.x+o.width/2-c.width/2,v=o.y+o.height/2-c.height/2,S=o[m]/2-c[m]/2;let E;switch(g){case"top":E={x:y,y:o.y-c.height};break;case"bottom":E={x:y,y:o.y+o.height};break;case"right":E={x:o.x+o.width,y:v};break;case"left":E={x:o.x-c.width,y:v};break;default:E={x:o.x,y:o.y}}const x=Ds(i);return x&&(E[d]+=S*(x==="end"?1:-1)*(r&&p?-1:1)),E}async function gC(n,i){var r;i===void 0&&(i={});const{x:o,y:c,platform:f,rects:d,elements:m,strategy:g}=n,{boundary:p="clippingAncestors",rootBoundary:y="viewport",elementContext:v="floating",altBoundary:S=!1,padding:E=0}=Gi(i,n),x=V0(E),_=m[S?v==="floating"?"reference":"floating":v],D=Xc(await f.getClippingRect({element:(r=await(f.isElement==null?void 0:f.isElement(_)))==null||r?_:_.contextElement||await(f.getDocumentElement==null?void 0:f.getDocumentElement(m.floating)),boundary:p,rootBoundary:y,strategy:g})),C=v==="floating"?{x:o,y:c,width:d.floating.width,height:d.floating.height}:d.reference,j=await(f.getOffsetParent==null?void 0:f.getOffsetParent(m.floating)),k=await(f.isElement==null?void 0:f.isElement(j))&&await(f.getScale==null?void 0:f.getScale(j))||{x:1,y:1},q=Xc(f.convertOffsetParentRelativeRectToViewportRelativeRect?await f.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:C,offsetParent:j,strategy:g}):C);return{top:(D.top-q.top+x.top)/k.y,bottom:(q.bottom-D.bottom+x.bottom)/k.y,left:(D.left-q.left+x.left)/k.x,right:(q.right-D.right+x.right)/k.x}}const yC=50,bC=async(n,i,r)=>{const{placement:o="bottom",strategy:c="absolute",middleware:f=[],platform:d}=r,m=d.detectOverflow?d:{...d,detectOverflow:gC},g=await(d.isRTL==null?void 0:d.isRTL(i));let p=await d.getElementRects({reference:n,floating:i,strategy:c}),{x:y,y:v}=Fb(p,o,g),S=o,E=0;const x={};for(let w=0;w<f.length;w++){const _=f[w];if(!_)continue;const{name:D,fn:C}=_,{x:j,y:k,data:q,reset:F}=await C({x:y,y:v,initialPlacement:o,placement:S,strategy:c,middlewareData:x,rects:p,platform:m,elements:{reference:n,floating:i}});y=j??y,v=k??v,x[D]={...x[D],...q},F&&E<yC&&(E++,typeof F=="object"&&(F.placement&&(S=F.placement),F.rects&&(p=F.rects===!0?await d.getElementRects({reference:n,floating:i,strategy:c}):F.rects),{x:y,y:v}=Fb(p,S,g)),w=-1)}return{x:y,y:v,placement:S,strategy:c,middlewareData:x}},vC=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(i){var r,o;const{placement:c,middlewareData:f,rects:d,initialPlacement:m,platform:g,elements:p}=i,{mainAxis:y=!0,crossAxis:v=!0,fallbackPlacements:S,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:w=!0,..._}=Gi(n,i);if((r=f.arrow)!=null&&r.alignmentOffset)return{};const D=Dn(c),C=Fn(m),j=Dn(m)===m,k=await(g.isRTL==null?void 0:g.isRTL(p.floating)),q=S||(j||!w?[Qc(m)]:zO(m)),F=x!=="none";!S&&F&&q.push(...LO(m,w,x,k));const B=[m,...q],U=await g.detectOverflow(i,_),K=[];let se=((o=f.flip)==null?void 0:o.overflows)||[];if(y&&K.push(U[D]),v){const le=DO(c,d,k);K.push(U[le[0]],U[le[1]])}if(se=[...se,{placement:c,overflows:K}],!K.every(le=>le<=0)){var pe,ae;const le=(((pe=f.flip)==null?void 0:pe.index)||0)+1,ie=B[le];if(ie&&(!(v==="alignment"?C!==Fn(ie):!1)||se.every(I=>Fn(I.placement)===C?I.overflows[0]>0:!0)))return{data:{index:le,overflows:se},reset:{placement:ie}};let N=(ae=se.filter(Q=>Q.overflows[0]<=0).sort((Q,I)=>Q.overflows[1]-I.overflows[1])[0])==null?void 0:ae.placement;if(!N)switch(E){case"bestFit":{var W;const Q=(W=se.filter(I=>{if(F){const oe=Fn(I.placement);return oe===C||oe==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(oe=>oe>0).reduce((oe,Y)=>oe+Y,0)]).sort((I,oe)=>I[1]-oe[1])[0])==null?void 0:W[0];Q&&(N=Q);break}case"initialPlacement":N=m;break}if(c!==N)return{reset:{placement:N}}}return{}}}};function Kb(n,i){return{top:n.top-i.height,right:n.right-i.width,bottom:n.bottom-i.height,left:n.left-i.width}}function Zb(n){return MO.some(i=>n[i]>=0)}const SC=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(i){const{rects:r,platform:o}=i,{strategy:c="referenceHidden",...f}=Gi(n,i);switch(c){case"referenceHidden":{const d=await o.detectOverflow(i,{...f,elementContext:"reference"}),m=Kb(d,r.reference);return{data:{referenceHiddenOffsets:m,referenceHidden:Zb(m)}}}case"escaped":{const d=await o.detectOverflow(i,{...f,altBoundary:!0}),m=Kb(d,r.floating);return{data:{escapedOffsets:m,escaped:Zb(m)}}}default:return{}}}}},oS=new Set(["left","top"]);async function xC(n,i){const{placement:r,platform:o,elements:c}=n,f=await(o.isRTL==null?void 0:o.isRTL(c.floating)),d=Dn(r),m=Ds(r),g=Fn(r)==="y",p=oS.has(d)?-1:1,y=f&&g?-1:1,v=Gi(i,n);let{mainAxis:S,crossAxis:E,alignmentAxis:x}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return m&&typeof x=="number"&&(E=m==="end"?x*-1:x),g?{x:E*y,y:S*p}:{x:S*p,y:E*y}}const EC=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(i){var r,o;const{x:c,y:f,placement:d,middlewareData:m}=i,g=await xC(i,n);return d===((r=m.offset)==null?void 0:r.placement)&&(o=m.arrow)!=null&&o.alignmentOffset?{}:{x:c+g.x,y:f+g.y,data:{...g,placement:d}}}}},TC=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(i){const{x:r,y:o,placement:c,platform:f}=i,{mainAxis:d=!0,crossAxis:m=!1,limiter:g={fn:C=>{let{x:j,y:k}=C;return{x:j,y:k}}},...p}=Gi(n,i),y={x:r,y:o},v=await f.detectOverflow(i,p),S=Fn(c),E=qh(S);let x=y[E],w=y[S];const _=(C,j)=>Y0(j+v[C==="y"?"top":"left"],j,j-v[C==="y"?"bottom":"right"]);d&&(x=_(E,x)),m&&(w=_(S,w));const D=g.fn({...i,[E]:x,[S]:w});return{...D,data:{x:D.x-r,y:D.y-o,enabled:{[E]:d,[S]:m}}}}}},wC=function(n){return n===void 0&&(n={}),{options:n,fn(i){var r,o;const{x:c,y:f,placement:d,rects:m,middlewareData:g}=i,{offset:p=0,mainAxis:y=!0,crossAxis:v=!0}=Gi(n,i),S={x:c,y:f},E=Fn(d),x=qh(E);let w=S[x],_=S[E];const D=Gi(p,i),C=typeof D=="number"?{mainAxis:D,crossAxis:0}:{mainAxis:(r=D.mainAxis)!=null?r:0,crossAxis:(o=D.crossAxis)!=null?o:0};if(y){const q=x==="y"?"height":"width",F=m.reference[x]-m.floating[q]+C.mainAxis,B=m.reference[x]+m.reference[q]-C.mainAxis;w<F?w=F:w>B&&(w=B)}if(v){var j,k;const q=x==="y"?"width":"height",F=oS.has(Dn(d)),B=m.reference[E]-m.floating[q]+(F&&((j=g.offset)==null?void 0:j[E])||0)+(F?0:C.crossAxis),U=m.reference[E]+m.reference[q]+(F?0:((k=g.offset)==null?void 0:k[E])||0)-(F?C.crossAxis:0);_<B?_=B:_>U&&(_=U)}return{[x]:w,[E]:_}}}},RC=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(i){const{placement:r,rects:o,platform:c,elements:f}=i,{apply:d=()=>{},...m}=Gi(n,i),g=await c.detectOverflow(i,m),p=Dn(r),y=Ds(r),v=Fn(r)==="y",{width:S,height:E}=o.floating;let x,w;p==="top"||p==="bottom"?(x=p,w=y===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(w=p,x=y==="end"?"top":"bottom");const _=E-g.top-g.bottom,D=S-g.left-g.right,C=wa(E-g[x],_),j=wa(S-g[w],D),k=i.middlewareData.shift,q=!k;let F=C,B=j;k!=null&&k.enabled.x&&(B=D),k!=null&&k.enabled.y&&(F=_),q&&!y&&(v?B=S-2*Yi(g.left,g.right):F=E-2*Yi(g.top,g.bottom)),await d({...i,availableWidth:B,availableHeight:F});const U=await c.getDimensions(f.floating);return S!==U.width||E!==U.height?{reset:{rects:!0}}:{}}}};function lS(n){const i=zn(n);let r=parseFloat(i.width)||0,o=parseFloat(i.height)||0;const c=Rt(n),f=c?n.offsetWidth:r,d=c?n.offsetHeight:o,m=Gc(r)!==f||Gc(o)!==d;return m&&(r=f,o=d),{width:r,height:o,$:m}}function Fh(n){return Je(n)?n:n.contextElement}function aa(n){const i=Fh(n);if(!Rt(i))return Vi(1);const r=i.getBoundingClientRect(),{width:o,height:c,$:f}=lS(i);let d=(f?Gc(r.width):r.width)/o,m=(f?Gc(r.height):r.height)/c;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const OC=Vi(0);function cS(n){const i=kt(n);return!jh()||!i.visualViewport?OC:{x:i.visualViewport.offsetLeft,y:i.visualViewport.offsetTop}}function CC(n,i,r){return i===void 0&&(i=!1),!!r&&i&&r===kt(n)}function cr(n,i,r,o){i===void 0&&(i=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),f=Fh(n);let d=Vi(1);i&&(o?Je(o)&&(d=aa(o)):d=aa(n));const m=CC(f,r,o)?cS(f):Vi(0);let g=(c.left+m.x)/d.x,p=(c.top+m.y)/d.y,y=c.width/d.x,v=c.height/d.y;if(f&&o){const S=kt(f),E=Je(o)?kt(o):o;let x=S,w=lh(x);for(;w&&E!==x;){const _=aa(w),D=w.getBoundingClientRect(),C=zn(w),j=D.left+(w.clientLeft+parseFloat(C.paddingLeft))*_.x,k=D.top+(w.clientTop+parseFloat(C.paddingTop))*_.y;g*=_.x,p*=_.y,y*=_.x,v*=_.y,g+=j,p+=k,x=kt(w),w=lh(x)}}return Xc({width:y,height:v,x:g,y:p})}function ru(n,i){const r=nu(n).scrollLeft;return i?i.left+r:cr(Xi(n)).left+r}function uS(n,i){const r=n.getBoundingClientRect(),o=r.left+i.scrollLeft-ru(n,r),c=r.top+i.scrollTop;return{x:o,y:c}}function AC(n){let{elements:i,rect:r,offsetParent:o,strategy:c}=n;const f=c==="fixed",d=Xi(o),m=i?tu(i.floating):!1;if(o===d||m&&f)return r;let g={scrollLeft:0,scrollTop:0},p=Vi(1);const y=Vi(0),v=Rt(o);if((v||!f)&&(($t(o)!=="body"||hr(d))&&(g=nu(o)),v)){const E=cr(o);p=aa(o),y.x=E.x+o.clientLeft,y.y=E.y+o.clientTop}const S=d&&!v&&!f?uS(d,g):Vi(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-g.scrollLeft*p.x+y.x+S.x,y:r.y*p.y-g.scrollTop*p.y+y.y+S.y}}function _C(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function MC(n){const i=nu(n),r=n.ownerDocument.body,o=Yi(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=Yi(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let f=-i.scrollLeft+ru(n);const d=-i.scrollTop;return zn(r).direction==="rtl"&&(f+=Yi(n.clientWidth,r.clientWidth)-o),{width:o,height:c,x:f,y:d}}const NC=25;function DC(n,i,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",c=kt(n),f=Xi(n),d=c.visualViewport;let m=f.clientWidth,g=f.clientHeight,p=0,y=0;if(d){const S=!jh()||i==="fixed";o?S||(p=-d.offsetLeft,y=-d.offsetTop):(m=d.width,g=d.height,S&&(p=d.offsetLeft,y=d.offsetTop))}if(ru(f)<=0){const S=f.ownerDocument,E=S.body,x=getComputedStyle(E),w=S.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,_=Math.abs(f.clientWidth-E.clientWidth-w),D=getComputedStyle(f).scrollbarGutter==="stable both-edges"?_/2:_;D<=NC&&(m-=D)}return{width:m,height:g,x:p,y}}function zC(n,i){const r=cr(n,!0,i==="fixed"),o=r.top+n.clientTop,c=r.left+n.clientLeft,f=aa(n),d=n.clientWidth*f.x,m=n.clientHeight*f.y,g=c*f.x,p=o*f.y;return{width:d,height:m,x:g,y:p}}function Pb(n,i,r){let o;if(i==="viewport"||i==="layoutViewport")o=DC(n,r,i);else if(i==="document")o=MC(Xi(n));else if(Je(i))o=zC(i,r);else{const c=cS(n);o={x:i.x-c.x,y:i.y-c.y,width:i.width,height:i.height}}return Xc(o)}function kC(n,i){const r=i.get(n);if(r)return r;let o=zo(n,[],!1).filter(m=>Je(m)&&$t(m)!=="body"),c=null;const f=zn(n).position==="fixed";let d=f?As(n):n;for(;Je(d)&&!Cs(d);){const m=zn(d),g=kh(d),p=c?c.position:f?"fixed":"";!g&&(p==="fixed"||p==="absolute"&&m.position==="static")?o=o.filter(v=>v!==d):c=m,d=As(d)}return i.set(n,o),o}function jC(n){let{element:i,boundary:r,rootBoundary:o,strategy:c}=n;const d=[...r==="clippingAncestors"?tu(i)?[]:kC(i,this._c):[].concat(r),o],m=Pb(i,d[0],c);let g=m.top,p=m.right,y=m.bottom,v=m.left;for(let S=1;S<d.length;S++){const E=Pb(i,d[S],c);g=Yi(E.top,g),p=wa(E.right,p),y=wa(E.bottom,y),v=Yi(E.left,v)}return{width:p-v,height:y-g,x:v,y:g}}function UC(n){const{width:i,height:r}=lS(n);return{width:i,height:r}}function LC(n,i,r){const o=Rt(i),c=Xi(i),f=r==="fixed",d=cr(n,!0,f,i);let m={scrollLeft:0,scrollTop:0};const g=Vi(0);if((o||!f)&&(($t(i)!=="body"||hr(c))&&(m=nu(i)),o)){const S=cr(i,!0,f,i);g.x=S.x+i.clientLeft,g.y=S.y+i.clientTop}!o&&c&&(g.x=ru(c));const p=c&&!o&&!f?uS(c,m):Vi(0),y=d.left+m.scrollLeft-g.x-p.x,v=d.top+m.scrollTop-g.y-p.y;return{x:y,y:v,width:d.width,height:d.height}}function Ld(n){return zn(n).position==="static"}function Ib(n,i){if(!Rt(n)||zn(n).position==="fixed")return null;if(i)return i(n);let r=n.offsetParent;return Xi(n)===r&&(r=r.ownerDocument.body),r}function fS(n,i){const r=kt(n);if(tu(n))return r;if(!Rt(n)){let c=As(n);for(;c&&!Cs(c);){if(Je(c)&&!Ld(c))return c;c=As(c)}return r}let o=Ib(n,i);for(;o&&HR(o)&&Ld(o);)o=Ib(o,i);return o&&Cs(o)&&Ld(o)&&!kh(o)?r:o||VR(n)||r}const BC=async function(n){const i=this.getOffsetParent||fS,r=this.getDimensions,o=await r(n.floating);return{reference:LC(n.reference,await i(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function HC(n){return zn(n).direction==="rtl"}const qC={convertOffsetParentRelativeRectToViewportRelativeRect:AC,getDocumentElement:Xi,getClippingRect:jC,getOffsetParent:fS,getElementRects:BC,getClientRects:_C,getDimensions:UC,getScale:aa,isElement:Je,isRTL:HC};function dS(n,i){return n.x===i.x&&n.y===i.y&&n.width===i.width&&n.height===i.height}function YC(n,i,r){let o=null,c;const f=Xi(n);function d(){var y;clearTimeout(c),(y=o)==null||y.disconnect(),o=null}function m(y,v){y===void 0&&(y=!1),v===void 0&&(v=1),d();const S=n.getBoundingClientRect(),{left:E,top:x,width:w,height:_}=S;if(y||i(),!w||!_)return;const D=Ec(x),C=Ec(f.clientWidth-(E+w)),j=Ec(f.clientHeight-(x+_)),k=Ec(E),F={rootMargin:-D+"px "+-C+"px "+-j+"px "+-k+"px",threshold:Yi(0,wa(1,v))||1};let B=!0;function U(K){const se=K[0].intersectionRatio;if(!dS(S,n.getBoundingClientRect()))return m();if(se!==v){if(!B)return m();se?m(!1,se):c=setTimeout(()=>{m(!1,1e-7)},1e3)}B=!1}try{o=new IntersectionObserver(U,{...F,root:f.ownerDocument})}catch{o=new IntersectionObserver(U,F)}o.observe(n)}const g=kt(n),p=()=>m(r);return g.addEventListener("resize",p),m(!0),()=>{g.removeEventListener("resize",p),d()}}function Jb(n,i,r,o){o===void 0&&(o={});const{ancestorScroll:c=!0,ancestorResize:f=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:g=!1}=o,p=Fh(n),y=c||f?[...p?zo(p):[],...i?zo(i):[]]:[];y.forEach(D=>{c&&D.addEventListener("scroll",r),f&&D.addEventListener("resize",r)});const v=p&&m?YC(p,r,f):null;let S=-1,E=null;d&&(E=new ResizeObserver(D=>{let[C]=D;C&&C.target===p&&E&&i&&(E.unobserve(i),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var j;(j=E)==null||j.observe(i)})),r()}),p&&!g&&E.observe(p),i&&E.observe(i));let x,w=g?cr(n):null;g&&_();function _(){const D=cr(n);w&&!dS(w,D)&&r(),w=D,x=requestAnimationFrame(_)}return r(),()=>{var D;y.forEach(C=>{c&&C.removeEventListener("scroll",r),f&&C.removeEventListener("resize",r)}),v==null||v(),(D=E)==null||D.disconnect(),E=null,g&&cancelAnimationFrame(x)}}const VC=EC,GC=TC,QC=vC,XC=RC,FC=SC,KC=wC,ZC=(n,i,r)=>{const o=new Map,c=r??{},f={...qC,...c.platform,_c:o};return bC(n,i,{...c,platform:f})};var PC=typeof document<"u",IC=function(){},kc=PC?O.useLayoutEffect:IC;function Kc(n,i){if(n===i)return!0;if(typeof n!=typeof i)return!1;if(typeof n=="function"&&n.toString()===i.toString())return!0;let r,o,c;if(n&&i&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==i.length)return!1;for(o=r;o--!==0;)if(!Kc(n[o],i[o]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(i).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(i,c[o]))return!1;for(o=r;o--!==0;){const f=c[o];if(!(f==="_owner"&&n.$$typeof)&&!Kc(n[f],i[f]))return!1}return!0}return n!==n&&i!==i}function hS(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Wb(n,i){const r=hS(n);return Math.round(i*r)/r}function Bd(n){const i=O.useRef(n);return kc(()=>{i.current=n}),i}function JC(n){n===void 0&&(n={});const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:c,elements:{reference:f,floating:d}={},transform:m=!0,whileElementsMounted:g,open:p}=n,[y,v]=O.useState({x:0,y:0,strategy:r,placement:i,middlewareData:{},isPositioned:!1}),[S,E]=O.useState(o);Kc(S,o)||E(o);const[x,w]=O.useState(null),[_,D]=O.useState(null),C=O.useCallback(I=>{I!==F.current&&(F.current=I,w(I))},[]),j=O.useCallback(I=>{I!==B.current&&(B.current=I,D(I))},[]),k=f||x,q=d||_,F=O.useRef(null),B=O.useRef(null),U=O.useRef(y),K=g!=null,se=Bd(g),pe=Bd(c),ae=Bd(p),W=O.useCallback(()=>{if(!F.current||!B.current)return;const I={placement:i,strategy:r,middleware:S};pe.current&&(I.platform=pe.current),ZC(F.current,B.current,I).then(oe=>{const Y={...oe,isPositioned:ae.current!==!1};le.current&&!Kc(U.current,Y)&&(U.current=Y,Ms.flushSync(()=>{v(Y)}))})},[S,i,r,pe,ae]);kc(()=>{p===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,v(I=>({...I,isPositioned:!1})))},[p]);const le=O.useRef(!1);kc(()=>(le.current=!0,()=>{le.current=!1}),[]),kc(()=>{if(k&&(F.current=k),q&&(B.current=q),k&&q){if(se.current)return se.current(k,q,W);W()}},[k,q,W,se,K]);const ie=O.useMemo(()=>({reference:F,floating:B,setReference:C,setFloating:j}),[C,j]),N=O.useMemo(()=>({reference:k,floating:q}),[k,q]),Q=O.useMemo(()=>{const I={position:r,left:0,top:0};if(!N.floating)return I;const oe=Wb(N.floating,y.x),Y=Wb(N.floating,y.y);return m?{...I,transform:"translate("+oe+"px, "+Y+"px)",...hS(N.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:oe,top:Y}},[r,m,N.floating,y.x,y.y]);return O.useMemo(()=>({...y,update:W,refs:ie,elements:N,floatingStyles:Q}),[y,W,ie,N,Q])}const WC=(n,i)=>{const r=VC(n);return{name:r.name,fn:r.fn,options:[n,i]}},$C=(n,i)=>{const r=GC(n);return{name:r.name,fn:r.fn,options:[n,i]}},eA=(n,i)=>({fn:KC(n).fn,options:[n,i]}),tA=(n,i)=>{const r=QC(n);return{name:r.name,fn:r.fn,options:[n,i]}},nA=(n,i)=>{const r=XC(n);return{name:r.name,fn:r.fn,options:[n,i]}},iA=(n,i)=>{const r=FC(n);return{name:r.name,fn:r.fn,options:[n,i]}};function sA(n){const i=O.useRef(!0);i.current&&(i.current=!1,n())}const Ve=(n,i,r,o,c,f,...d)=>{if(d.length>0)throw new Error(ur(1));let m;if(n)m=n;else throw new Error("Missing arguments");return m};var Hd={exports:{}},qd={};/**
100
100
  * @license React
101
101
  * use-sync-external-store-shim.production.js
102
102
  *