prostgles-client 4.0.322 → 4.0.324

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(function(){try{return require("react")}catch(e){}}());else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(function(){try{return require("react")}catch(e){}}()):t(e.react);for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(Object(this||window),e=>(()=>{var t={9515(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionQueuer=void 0,t.FunctionQueuer=class{constructor(e,t){this.queue=[],this.isRunning=!1,this.startQueueJob=async()=>{if(this.isRunning)return;this.isRunning=!0;const e=async e=>{if(e)try{const t=await this.func(...e.arguments);e.onResult(t)}catch(t){e.onFail(t)}};if(this.groupBy){const t=new Set,n=[];this.queue.forEach(e=>{const s=this.groupBy(e.arguments);t.has(s)||(t.add(s),n.push(e))}),n.slice(0).reverse().forEach(e=>{this.queue.splice(this.queue.indexOf(e),1)}),await Promise.all(n.map(t=>e(t)))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&this.startQueueJob()},this.func=e,this.groupBy=t}async run(e){const t=new Promise((t,n)=>{const s={arguments:e,onResult:t,onFail:n};this.queue.push(s)});return this.startQueueJob(),t}}},3333(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.mergeDeep=t.SyncedTable=t.debug=void 0;const s=n(3316),r=n(4476),i="DEBUG_SYNCEDTABLE",o="undefined"!=typeof window;t.debug=function(...e){o&&window[i]&&window[i](...e)};const a={map:"map",localStorage:"localStorage"};class c{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:i,onDebug:c,db:l,skipFirstTrigger:u=!1,select:d="*",storageType:h="map",patchText:p=!1,patchJSON:f=!1,onError:m}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.itemsMap=new Map,this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map(e=>e.current);const i=[],o=[];if(this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter(e=>"text"===e.data_type);if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map(async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map(e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,s.getTextPatch)(l[e.name],c[e.name]))}),u&&this.wal&&(o.push(u),i.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)}))}}if(i.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(i))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter(e=>e)},this._notifySubscribers=(e=[])=>{var t,n;if(!this.isSynced)return void(null===(t=this.onDebug)||void 0===t||t.call(this,{command:"notifySubscribers",data:[],info:"not synced yet"}));null===(n=this.onDebug)||void 0===n||n.call(this,{command:"notifySubscribers",data:e});const s=[],r=[],i=[];if(e.map(({idObj:e,newItem:t,delta:n})=>{this.singleSubscriptions.filter(t=>this.matchesIdObj(t.idObj,e)).map(async e=>{try{await e.notify(t,n)}catch(e){console.error("SyncedTable failed to notify: ",e)}}),this.matchesFilter(t)&&(s.push(t),r.push(n),i.push(e))}),this.onChange||this.multiSubscriptions.length){const e=[],t=[];if(this.getItems().map(n=>{e.push({...n});const i=s.findIndex(e=>this.matchesIdObj(n,e));t.push(r[i])}),this.onChange)try{this.onChange(e,t)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map(async n=>{try{await n.notify(e,t)}catch(e){console.error("SyncedTable failed to notify: ",e)}})}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter(t=>t._onChange!==e),this.multiSubscriptions=this.multiSubscriptions.filter(t=>t._onChange!==e),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{var e;null===(e=this.dbSync)||void 0===e||e.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsMap.clear(),this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const s=this.getIdObj(e);return this.setItem(s,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(s),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns.length){const t=Object.keys({...e}).filter(e=>!this.columns.find(t=>t.name===e));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,n=!1)=>{var r,i;if(!(e&&e.length||n))throw"No data provided for upsert";const o=[];let a;const c=[];await Promise.all(e.map(async(e,r)=>{var i;const l={...e.idObj};let u={...e.delta};Object.keys(u).map(e=>{void 0===u[e]&&(u[e]=null)}),n||this.checkItemCols({...e.delta,...e.idObj});const d=this.getItem(l);!n&&!(0,s.isEmpty)(u)||(0,s.isEmpty)(d)||(u=this.getDelta(d||{},u)),n||(u[this.synced_field]=Date.now());let h={...d,...u,...l};d&&!n&&(null===(i=e.opts)||void 0===i?void 0:i.deepMerge)&&(h=(0,t.mergeDeep)({...d,...l},{...u})),a=d?d[this.synced_field]<h[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(h);const p={idObj:l,delta:u,oldItem:d,newItem:h,status:a,from_server:n};return n||c.push({initial:d,current:{...h}}),(0,s.isEmpty)(p.delta)||o.push(p),!0})).catch(e=>{console.error("SyncedTable failed upsert: ",e)}),null===(r=this.notifyWal)||void 0===r||r.addData(o.map(e=>({initial:e.oldItem,current:e.newItem}))),!n&&c.length&&(null===(i=this.wal)||void 0===i||i.addData(c))},this.setItems=e=>{const n=(0,t.quickClone)(e);if(this.storageType===a.localStorage){if(!o)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(n))}else this.storageType===a.map&&(this.itemsMap=new Map(n.map(e=>[this.getIdStr(e),{...e}])))},this.getItems=()=>{let e=[];if(this.storageType===a.localStorage){if(!o)throw"Cannot access window object. Choose another storage method (array OR object)";const t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else this.storageType===a.map&&(e=Array.from(this.itemsMap.values()).map(e=>({...e})));if(!this.id_fields.length||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter(e=>!this.filter||!(0,s.getKeys)(this.filter).find(t=>e[t]!==this.filter[t])).sort((e,n)=>t.map(t=>e[t]<n[t]?-1:e[t]>n[t]?1:0).find(e=>e))}return(0,t.quickClone)(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:s}={offset:0,limit:void 0})=>{let r=this.getItems().map(e=>({...e})).filter(n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t));return(n||s)&&(r=r.splice(null!=n?n:0,s||r.length)),r},this.name=e,this.filter=n,this.select=d,this.onChange=r,c&&(this.onDebug=t=>c({...t,type:"sync",tableName:e},this)),!a[h])throw"Invalid storage type. Expecting one of: "+Object.keys(a).join(", ");o||h!==a.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to map"),h="map"),this.storageType=h,this.patchText=p,this.patchJSON=f;const y=l[e];if(!y)throw`${e} table not found in db`;this.db=l;const{id_fields:g,synced_field:b,throttle:_=100,batch_size:v=50}=y._syncInfo;if(!g||!b)throw"id_fields/synced_field missing";this.id_fields=g,this.synced_field=b,this.batch_size=v,this.throttle=_,this.skipFirstTrigger=u,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=m||function(e){console.error("Sync internal error: ",e)};const O={id_fields:g,synced_field:b,throttle:_};y._sync(n,{select:d},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0};const s=this.getBatch(e);return s.length&&(n={c_fr:this.getRowSyncObj(s[0]),c_lr:this.getRowSyncObj(s[s.length-1]),c_count:s.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:s,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;const t=this.getItems().map(e=>({...e}));this.setItems([]);const n=t.map(e=>({idObj:this.getIdObj(e),delta:{...e}}));await this.upsert(n,!0)}else if("data"in e){const t=e.data.map(e=>({idObj:this.getIdObj(e),delta:e}));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then(e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new s.WAL({...O,batch_size:v,onSendStart:()=>{o&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{o&&(window.onbeforeunload=null)}}),this.notifyWal=new s.WAL({...O,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map(e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}}))}}),i()}),y.getColumns&&y.getColumns().then(e=>{this.columns=e}),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise((t,n)=>{try{const n=new c({...e,onReady:()=>{setTimeout(()=>{t(n)},0)}})}catch(e){n(e)}})}sync(e,t=!0){const{sub:n,handles:s}=r.getMultiSyncSubscription.bind(this)({onChange:e,handlesOnData:t});return this.multiSubscriptions.push(n),this.skipFirstTrigger||setTimeout(()=>{const e=this.getItems();n.notify(e,e)},0),Object.freeze({...s})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const s={$get:()=>this.getItem(e),$find:e=>this.getItem(e),$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,s)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:s}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return s}syncOne(e,t,n=!0){const s=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:s,notify:(e,r)=>{const i={...e};return n&&(i.$get=s.$get,i.$find=s.$find,i.$update=s.$update,i.$delete=s.$delete,i.$unsync=s.$unsync,i.$cloneSync=s.$cloneSync),t(i,r)}};return this.singleSubscriptions.push(r),setTimeout(()=>{const e=s.$get();e&&r.notify(e,e)},0),Object.freeze({...s})}getIdStr(e){return this.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){const t={};return this.id_fields.sort().map(n=>{t[n]=e[n]}),t}getRowSyncObj(e){const t={};return[this.synced_field,...this.id_fields].sort().map(n=>{t[n]=e[n]}),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,s.isEmpty)(this.filter)||!Object.keys(this.filter).find(t=>this.filter[t]!==e[t])))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find(n=>e[n]!==t[n]))}getDelta(e,t){return(0,s.isEmpty)(e)?{...t}:Object.fromEntries(Object.entries({...t}).filter(([e])=>!this.id_fields.includes(e)).map(([t,n])=>{if(!(0,s.isEqual)(n,e[t]))return[t,(0,s.isObject)(n)?{...n}:Array.isArray(n)?n.slice(0):n]}).filter(s.isDefined))}deleteAll(){this.getItems().map(e=>this.delete(e))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let n;return n=this.storageType===a.localStorage?this.getItems().find(t=>this.matchesIdObj(t,e)):this.itemsMap.get(this.getIdStr(e)),(0,t.quickClone)(n)}setItem(e,n=!1,s=!1){var r;const i=(0,t.quickClone)(e);if(this.storageType===a.localStorage){let e=this.getItems();if(s)e=e.filter(e=>!this.matchesIdObj(e,i));else{let t=!1;e=e.map(e=>this.matchesIdObj(e,i)?(t=!0,n?{...i}:{...e,...i}):e),t||e.push(i)}o&&window.localStorage.setItem(this.name,JSON.stringify(e))}else{const e=this.getIdStr(i);if(s)this.itemsMap.delete(e);else{const t=null!==(r=this.itemsMap.get(e))&&void 0!==r?r:{};this.itemsMap.set(e,n?{...i}:{...t,...i})}}}}t.SyncedTable=c,t.mergeDeep=(e,n)=>{const r=e?(0,t.quickClone)(e):e,i=n?(0,t.quickClone)(n):n,o=(0,s.isObject)(r)?{...r}:{};return(0,s.isObject)(r)&&(0,s.isObject)(i)&&Object.keys(i).forEach(e=>{const n=i[e],a=r[e];(0,s.isObject)(n)&&(0,s.isObject)(a)?o[e]=(0,t.mergeDeep)(a,n):o[e]=(0,t.quickClone)(n)}),o},t.quickClone=e=>{if(o&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map(e=>(0,t.quickClone)(e));if((0,s.isObject)(e)){const n={};return(0,s.getKeys)(e).map(s=>{n[s]=(0,t.quickClone)(e[s])}),n}return e}},4476(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMultiSyncSubscription=function({onChange:e,handlesOnData:t}){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(!e)throw"No data provided for upsert";const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map(e=>t(e))):this.upsert([t(e)])}};return{sub:{_onChange:e,handlesOnData:t,handles:n,notify:(n,s)=>{let r=[...n];const i=[...s];return t&&(r=r.map((n,s)=>{const r=(n,s)=>({...n,...this.makeSingleSyncHandles(s,e),$get:()=>r(this.getItem(s),s),$find:e=>r(this.getItem(e),e),$update:(e,t)=>this.upsert([{idObj:s,delta:e,opts:t}]).then(e=>!0),$delete:async()=>this.delete(s),$cloneMultiSync:e=>this.sync(e,t)}),i=this.getIdObj(n);return r(n,i)})),e(r,i)}},handles:n}}},2886(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const s=n(3316),r=n(9653);t.getAuthHandler=({authData:e,socket:n,onReload:i,endpoint:o,...a})=>{var c;const l=e=>{const{search:t}=window.location;let n=e+t;return o&&(n=`${o}${n}`),n};if((null==e?void 0:e.pathGuard)&&r.isClientSide){const e=e=>{(null==e?void 0:e.shouldReload)&&(i?i():r.isClientSide&&(console.log("prostgles page reload due to authguard",e),setTimeout(()=>{window.location.reload()},200)))};n.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),(t,n)=>{e(n)}),n.removeAllListeners(s.CHANNELS.AUTHGUARD),n.on(s.CHANNELS.AUTHGUARD,t=>{e(t)})}const u={loginType:null===(c=null==e?void 0:e.login)||void 0===c?void 0:c.mode,login:void 0,preferredLogin:null==e?void 0:e.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,confirmEmail:void 0,providers:null==e?void 0:e.providers};if(e){const{providers:n,signupWithEmailAndPassword:r,login:i}=e;u.loginWithProvider=(0,s.isEmpty)(n)?void 0:n&&Object.entries(n).reduce((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e),{}),u.login=i&&(async e=>(0,t.authRequest)(l(i.loginRoute),e,"POST",a)),u.signupWithEmailAndPassword=r&&(e=>(0,t.authRequest)(l(r.url),e,"POST",a)),u.confirmEmail=r&&(e=>(0,t.authRequest)(l(r.emailConfirmationRoute),e,"POST",a))}return(null==e?void 0:e.user)?{isLoggedin:!0,user:e.user,logout:async()=>{var n;const{logoutRoute:s}=null!==(n=e.login)&&void 0!==n?n:{};if(!s)throw new Error("Unexpected");return(0,t.authRequest)(l(s),{},"POST",a)},...u}:{isLoggedin:!1,user:void 0,...u}},t.authRequest=async(e,t,n,{credentials:s,redirect:r})=>{const i=await fetch(e,{method:n,headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)},credentials:s,redirect:r});if(!i.ok){const e=await i.json().catch(()=>i.text()).catch(()=>i.statusText);return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const o=await i.json().catch(async()=>({message:await i.text()})).catch(()=>({message:i.statusText}));return i.redirected?{...o,success:!0,redirect_url:i.url}:o}},9930(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDB=void 0;const s=n(3316),r=n(3333),i=n(1632),o=n(6469),a=n(8552),c=s.CHANNELS._preffix;t.getDB=({schema:e,tableSchema:t,onDebug:n,syncedTable:l,syncHandler:u,subscriptionHandler:d,socket:h})=>{const p=(e,t,n,r)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.isObject)(t)||"function"!=typeof n||void 0!==r&&"function"!=typeof r)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},f=["subscribe","subscribeOne"],m={},y=(0,r.quickClone)(e);return(0,s.getObjectEntries)(y).forEach(([e,r])=>{const y=(0,s.getKeys)(r);m[e]={};const g=m[e];y.sort((e,t)=>Number((0,s.includes)(f,e))-Number((0,s.includes)(f,t))).forEach(y=>{if("sync"===y){if(g._syncInfo={...r[y]},l){g.getSync=async(t,s={})=>(await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{filter:t,params:s}})),l.create({name:e,onDebug:n,filter:t,db:m,...s}));const t=async(t={},r={},i)=>{var o;const a=`${e}.${JSON.stringify(t)}.${JSON.stringify((0,s.omitKeys)(r,["handlesOnData"]))}`,c=null!==(o=u.syncedTables[a])&&void 0!==o?o:await l.create({...r,onDebug:n,name:e,filter:t,db:m,onError:i});return u.syncedTables[a]=c,c},r=async(s,r={handlesOnData:!0,select:"*"},i,o)=>{await(null==n?void 0:n({type:"table",command:"sync",tableName:e,data:{basicFilter:s,options:r}})),p(s,r,i,o);const a=await t(s,r,o);return await a.sync(i,r.handlesOnData)},i=async(s,r={handlesOnData:!0},i,o)=>{await(null==n?void 0:n({type:"table",command:"syncOne",tableName:e,data:{basicFilter:s,options:r}})),p(s,r,i,o);const a=await t(s,r,o);return await a.syncOne(s,i,r.handlesOnData)};g.sync=r,g.syncOne=i,g.useSync=(e,t,n)=>(0,o.useSync)(r,e,t,n),g.useSyncOne=(e,t,n)=>(0,o.useSync)(i,e,t,n)}g._sync=async function(t,s,r){return await(null==n?void 0:n({type:"table",command:"_sync",tableName:e,data:{param1:t,param2:s,syncHandles:r}})),u.addSync({tableName:e,command:y,param1:t,param2:s},r)}}else if(f.includes(y)){const t=async function(t={},s={},r,i){return await(null==n?void 0:n({type:"table",command:y,tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),p(t,s,r,i),d.addSub(m,{tableName:e,command:y,param1:t,param2:s},r,i)};g[y]=t;const s="subscribeOne",r="subscribe"===y?"useSubscribe":"subscribeOne"===y?"useSubscribeOne":void 0;r&&(g[r]=(e,n,r)=>(0,i.useSubscribe)(t,y===s,e,n,r)),y!==s&&f.includes(s)||(g[s]=async function(t,s,r){return await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{param1:t,param2:s,onChange:r}})),p(t,s,r),d.addSub(m,{tableName:e,command:y,param1:t,param2:s},e=>{r(e[0])})})}else{const s=async function(s,r,i){var o;if("getColumns"===y&&!s&&!r&&!i){const n=null===(o=null==t?void 0:t.find(t=>t.name===e))||void 0===o?void 0:o.columns;if(n)return n}return await(null==n?void 0:n({type:"table",command:y,tableName:e,data:{param1:s,param2:r,param3:i}})),new Promise((t,n)=>{h.emit(c,{tableName:e,command:y,param1:s,param2:r,param3:i},(e,s)=>{e?n(e):t(s)})})};g[y]=s;const r="findOne"===y?"useFindOne":"find"===y?"useFind":"count"===y?"useCount":"size"===y?"useSize":void 0;r&&(g[r]=(e,t,n)=>(0,a.useFetch)(s,[e,t],n))}})}),{db:m}}},7030(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const s=n(3316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let r={};const i={};return JSON.parse(JSON.stringify(t)).map(({name:t,description:o,input:a,output:c})=>{const l=async function(r){return await(null==e?void 0:e({type:"method",command:t,data:{params:r}})),new Promise((e,i)=>{n.emit(s.CHANNELS.METHOD,{name:t,input:r},(t,n)=>{t?i(t):e(n)})})};r[t]={description:o,input:a,output:c,run:l},i[t]=l}),r=Object.freeze(r),{methodSchema:r,methodHandlers:i}}},3382(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const s=n(3316);t.getSqlHandler=({socket:e})=>{let t;const n={};return{sql:function(r,i,o){return new Promise((a,c)=>{e.emit(s.CHANNELS.SQL,{query:r,params:i,options:o},(s,r)=>{if(s)return c(s);if("stream"===(null==o?void 0:o.returnType)){const{channel:t,unsubChannel:n}=r,s=s=>new Promise((r,i)=>{e.on(t,s),e.emit(t,{},(s,o)=>{o?(i(o),e.removeAllListeners(t)):r({pid:s,run:(n,s)=>new Promise((r,i)=>{e.emit(t,{query:n,params:s},(e,t)=>{t?i(t):r(e)})}),stop:t=>new Promise((s,r)=>{e.emit(n,{terminate:t},(e,t)=>{t?r(t):s(e)})})})})});return a({channel:t,unsubChannel:n,start:s})}if(o&&"noticeSubscription"===o.returnType&&r&&Object.keys(r).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(r).find(e=>"string"!=typeof e)){const n=r,s=s=>(((e,n,s)=>{null!=t||(t={config:n,listeners:[]}),t.listeners.length||(s.removeAllListeners(n.socketChannel),s.on(n.socketChannel,e=>{t&&t.listeners.length?t.listeners.map(t=>{t(e)}):s.emit(n.socketUnsubChannel,{})})),t.listeners.push(e)})(s,n,e),{...n,removeListener:()=>((e,n)=>{t&&(t.listeners=t.listeners.filter(t=>t!==e),!t.listeners.length&&t.config.socketUnsubChannel&&n&&n.emit(t.config.socketUnsubChannel,{}))})(s,e)}),i={...n,addListener:s};a(i)}else if(o&&o.returnType&&"statement"===o.returnType||!r||Object.keys(r).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(r).find(e=>"string"!=typeof e))a(r);else{const t=r,s=s=>(((e,t,s)=>{var r;n[t.notifChannel]?null===(r=n[t.notifChannel])||void 0===r||r.listeners.push(e):(n[t.notifChannel]={config:t,listeners:[e]},s.removeAllListeners(t.socketChannel),s.on(t.socketChannel,e=>{var r,i;(null===(r=n[t.notifChannel])||void 0===r?void 0:r.listeners.length)?n[t.notifChannel].listeners.map(t=>{t(e)}):s.emit(null===(i=n[t.notifChannel])||void 0===i?void 0:i.config.socketUnsubChannel,{})}))})(s,t,e),{...r,removeListener:()=>((e,t,s)=>{const r=n[t.notifChannel];r&&(r.listeners=r.listeners.filter(t=>t!==e),!r.listeners.length&&r.config.socketUnsubChannel&&s&&(s.emit(r.config.socketUnsubChannel,{}),delete n[t.notifChannel]))})(s,t,e)}),i={...r,addListener:s};a(i)}})})}}}},395(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriptionHandler=void 0;const s=n(3316),r=n(9653),i=n(9515),o=s.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a=new Map,c=e=>new Promise((n,s)=>{t.emit(e,{},(e,t)=>{e?(console.error(e),s(e)):n(t)})});function l(e,s,i){return(0,r.debug)("_unsubscribe",{channelName:e,handler:i}),new Promise(r=>{const o=a.get(e);o?(o.handlers=o.handlers.filter(e=>e!==i),null==n||n({type:"table",command:"unsubscribe",tableName:o.tableName,unsubChannel:s,handlers:o.handlers}),o.handlers.length||(c(s),t.removeListener(e,o.onCall),a.delete(e)),r(!0)):r(!0)})}function u({tableName:e,command:n,param1:s,param2:r}){return new Promise((i,a)=>{t.emit(o,{tableName:e,command:n,param1:s,param2:r},(e,t)=>{e?(console.error(e),a(e)):t&&i(t)})})}const d=new i.FunctionQueuer(async function(e,{tableName:n,command:r,param1:i,param2:o},d){const h=(t,s)=>{let r={unsubscribe:function(){return l(t,s,d)},filter:{...i}};return e[n].update&&(r={...r,update:function(t,s){return e[n].update(i,t,s)}}),e[n].delete&&(r={...r,delete:function(t){return e[n].delete(i,t)}}),Object.freeze(r)},p=Array.from(a.entries()).find(([e,t])=>t.tableName===n&&t.command===r&&(0,s.isEqual)(t.param1||{},i||{})&&(0,s.isEqual)(t.param2||{},o||{}));if(p){const[e,t]=p;return t.handlers.push(d),setTimeout(()=>{const t=a.get(e);(null==t?void 0:t.lastData)&&d(t.lastData)},10),h(e,t.unsubChannel)}const{channelName:f,channelNameReady:m,channelNameUnsubscribe:y}=await u({tableName:n,command:r,param1:i,param2:o}),g=function(e){const t=a.get(f),{data:n,err:s}=e;t?void 0!==n||void 0!==s?(t.lastData=n,t.handlers.forEach(e=>{void 0!==s&&console.error(`Error within running subscription \n ${f}`,s),e(null!=n?n:[],s)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",f)};return t.on(f,g),a.set(f,{lastData:void 0,tableName:n,command:r,param1:i,param2:o,onCall:g,unsubChannel:y,handlers:[d],reAttach:async()=>{await c(y).catch(console.error),await u({tableName:n,command:r,param1:i,param2:o}),t.emit(m,{now:Date.now()})}}),t.emit(m,{now:Date.now()}),h(f,y)},([e,{tableName:t}])=>t);return{addSub:async(e,t,n,s)=>d.run([e,t,n]),subscriptions:a,addServerSub:u,_unsubscribe:l,reAttachAll:async()=>{await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.start",subscriptions:a}));for await(const e of Array.from(a.values()))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),e.onCall({data:[],err:t})}await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},9609(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandler=void 0;const s=n(3316),r=n(9515),i=n(9653),o=s.CHANNELS._preffix;t.getSyncHandler=({socket:e})=>{let t={},n={};function a({tableName:t,command:n,param1:s,param2:r},i){return new Promise((a,c)=>{e.emit(o,{tableName:t,command:n,param1:s,param2:r},(t,n)=>{if(t)console.error(t),c(t);else if(n){const{id_fields:t,synced_field:s,channelName:r}=n;e.emit(r,{onSyncRequest:i({})},e=>{console.log(e)}),a({id_fields:t,synced_field:s,channelName:r})}})})}const c=new r.FunctionQueuer(async function({tableName:t,command:r,param1:o,param2:c},l){const{onSyncRequest:u}=l;function d(t){return Object.freeze({unsync:function(){!function(t,s){(0,i.debug)("_unsync",{channelName:t,triggers:s}),new Promise((r,i)=>{n[t]&&(n[t].triggers=n[t].triggers.filter(e=>e.onPullRequest!==s.onPullRequest&&e.onSyncRequest!==s.onSyncRequest&&e.onUpdates!==s.onUpdates),n[t].triggers.length||(e.emit(t+"unsync",{},(e,t)=>{e?i(e):r(t)}),e.removeListener(t,n[t].onCall),delete n[t]))})}(t,l)},syncData:function(n,s,r){e.emit(t,{onSyncRequest:{...u({}),data:n,deleted:s}},r?e=>{r(e)}:null)}})}const h=Object.keys(n).find(e=>{const i=n[e];return i&&i.tableName===t&&i.command===r&&(0,s.isEqual)(i.param1,o)&&(0,s.isEqual)(i.param2,c)});if(h)return n[h].triggers.push(l),d(h);{const s=await a({tableName:t,command:r,param1:o,param2:c},u),{channelName:i}=s,h=function(e,t){e&&n[i]&&n[i].triggers.map(({onUpdates:n,onSyncRequest:s,onPullRequest:r})=>{e.data?Promise.resolve(n(e)).then(()=>{t({ok:!0})}).catch(e=>{t({err:e})}):e.onSyncRequest?Promise.resolve(s(e.onSyncRequest)).then(e=>t({onSyncRequest:e})).catch(e=>{t({err:e})}):e.onPullRequest?Promise.resolve(r(e.onPullRequest)).then(e=>{t({data:e})}).catch(e=>{t({err:e})}):console.log("unexpected response")})};return n[i]={tableName:t,command:r,param1:o,param2:c,triggers:[l],syncInfo:s,onCall:h},e.on(i,h),d(i)}},([{tableName:e}])=>e);return{destroySyncs:async()=>{(0,i.debug)("destroySyncs",{syncedTables:t}),n={},Object.values(t).forEach(e=>{e.destroy()}),t={}},syncedTables:t,addSync:async function(e,t){return c.run([e,t])},reAttachAll:async()=>{let t=0;Object.entries(n).forEach(async([n,s])=>{const r=s.triggers[0];if(r)try{await a(s,r.onSyncRequest),e.on(n,s.onCall),t++}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}}),t&&console.log("reAttached",t," syncs",n)}}}},4926(e,t,n){"use strict";var s;let r;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.reactImports=t.getReact=void 0;const i=(...e)=>{throw"Must install react"},o=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=r||(r=n(9155))}catch(e){}if(e&&!r)throw new Error("Must install react");return r},(0,t.getReact)();const{useEffect:a=i,useCallback:c=i,useRef:l,useState:u=o}=null!==(s=r)&&void 0!==s?s:{},d={useEffect:a,useCallback:c,useRef:l,useState:u,getReact:()=>r};t.reactImports=d,t.__prglReactInstalled=()=>Boolean(r&&l)},7566(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useAsyncEffectQueue=void 0;const s=n(9501),r=n(4926),{useRef:i}=r.reactImports;t.useAsyncEffectQueue=(e,t,n)=>{const r=i(0),o=i(!0),a=i(),c=i(),l=async()=>{var e,t;if("resolved"===(null===(e=c.current)||void 0===e?void 0:e.state)){const{cleanup:e,effect:t,id:n}=c.current;c.current={id:n,state:"cleaning",effect:t},await e().catch(console.error),c.current={id:n,state:"cleaned",effect:t}}if(a.current&&(!c.current||"cleaned"===c.current.state)&&(null===(t=c.current)||void 0===t?void 0:t.id)!==a.current.id){const e=a.current,{effect:t,id:n}=e;c.current={id:n,state:"resolving",effect:t};const s=await t().then(e=>async()=>{await(null==e?void 0:e())}).catch(e=>(console.error(e),async()=>{}));c.current={id:n,state:"resolved",effect:t,cleanup:s},o.current&&e===a.current&&c.current.id===a.current.id||l()}},u=i(null),d=()=>{n?(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l()},n)):l()};(0,s.useEffectDeep)(()=>(o.current=!0,a.current={effect:e,deps:t,id:++r.current},d(),()=>{o.current=!1,d()}),t)}},9501(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=void 0;const s=n(3316),r=n(4926),{getReact:i,useEffect:o,useRef:a}=r.reactImports,c=i();t.useDeepCompareMemoize=e=>{const t=a();return(0,s.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>c.useMemo(e,n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{o(e,null==n?void 0:n.map(t.useDeepCompareMemoize))}},8552(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useFetch=void 0;const s=n(4926),{useState:r}=s.reactImports,i=n(7566),o=n(6912);t.useFetch=(e,t=[],n)=>{const{skip:s,deps:a=[]}=null!=n?n:{},c={data:void 0,error:void 0,isLoading:!0},[{data:l,error:u,isLoading:d},h]=r(c),p=(0,o.useIsMounted)();return(0,i.useAsyncEffectQueue)(async()=>{if(p()&&!s){h(c);try{const n=await e(...t);if(!p())return;h({data:n,error:void 0,isLoading:!1})}catch(e){if(!p())return;h({data:void 0,error:e,isLoading:!1})}}},[e,...t,...a]),{data:l,error:u,isLoading:d}}},6912(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsMounted=void 0;const s=n(4926),{useEffect:r,useRef:i,useCallback:o}=s.reactImports;t.useIsMounted=()=>{const e=i(!0),t=o(()=>e.current,[]);return r(()=>(e.current=!0,()=>{e.current=!1}),[]),t}},1044(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=t.getIO=void 0;const s=n(9653),r=n(3333),i=n(4926),o=n(7566),a=n(6912);t.getIO=(e=!1)=>{try{return n(8007)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useProstglesClient=({skip:e,socketOptions:n,endpoint:c,token:l,...u}={})=>{const{useRef:d,useState:h}=(0,i.getReact)(!0),[p,f]=h({isLoading:!0,hasError:!1}),m=(0,a.useIsMounted)(),y=d();return(0,o.useAsyncEffectQueue)(async()=>{var i,o;if(e)return;null===(i=y.current)||void 0===i||i.disconnect();const a=(0,t.getIO)(),d="string"==typeof n?{path:n}:n,h={withCredentials:u.credentials&&"omit"!==u.credentials,...d,reconnectionDelay:1e3,reconnection:!0};null!==(o=h.path)&&void 0!==o||(h.path="/ws-api"),l&&(h.auth={token:l});const p=c?a(c,h):a(h);return y.current=p,await(0,s.prostgles)({socket:p,endpoint:c,...u,onReady:e=>{var t,n;m()?(null===(n=u.onDebug)||void 0===n||n.call(u,{type:"onReady",data:e}),f({...e,hasError:!1,isLoading:!1})):null===(t=u.onDebug)||void 0===t||t.call(u,{type:"onReady.notMounted",data:e})}},r.SyncedTable).catch(e=>{m()&&f({isLoading:!1,error:e,hasError:!0})}),()=>{p.disconnect(),p.emit=()=>{throw"Socket disconnected"}}},[u,n,e],80),p}},1632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSubscribe=void 0;const s=n(3316),r=n(4926),{useRef:i,useState:o}=r.reactImports,a=n(6912),c=n(7566);t.useSubscribe=(e,t,n,r,l)=>{const{skip:u}=null!=l?l:{},d={data:void 0,error:void 0,isLoading:!0},[h,p]=o(d),f=i(h);f.current=h;const m=(0,a.useIsMounted)();return(0,c.useAsyncEffectQueue)(async()=>{if(!m()||u)return;(0,s.isEqual)(f.current,d)||p(d);const i=e=>{m()&&p({data:void 0,error:e,isLoading:!1})};try{const s=await e(n,r,e=>{m()&&p({data:t?e[0]:e,error:void 0,isLoading:!1})},i);return()=>{s.unsubscribe()}}catch(e){i(e)}},[e,n,r,u]),h}},6469(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSync=void 0;const s=n(4926),{useState:r}=s.reactImports,i=n(7566),o=n(6912);t.useSync=(e,t,n,s)=>{const{skip:a}=null!=s?s:{},[{data:c,error:l,isLoading:u},d]=r({data:void 0,error:void 0,isLoading:!0}),h=(0,o.useIsMounted)();return(0,i.useAsyncEffectQueue)(async()=>{if(!h()||a)return;const s=e=>{h()&&d({data:void 0,error:e,isLoading:!1})};try{return(await e(t,n,e=>{h()&&d({data:e,error:void 0,isLoading:!1})},s)).$unsync}catch(e){s(e)}},[e,t,n,a]),{data:c,error:l,isLoading:u}}},9653(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.asName=t.debug=t.isClientSide=void 0,t.prostgles=function(e,n){const{endpoint:s,socket:r,onReady:h,onDisconnect:p,onReconnect:f,onSchemaChange:m,onReload:y,onDebug:g,credentials:b,redirect:_}=e;let v;(0,t.debug)("prostgles",{initOpts:e}),m&&(r.removeAllListeners(i.CHANNELS.SCHEMA_CHANGED),r.on(i.CHANNELS.SCHEMA_CHANGED,m));const O=(0,u.getSubscriptionHandler)(e),w=(0,d.getSyncHandler)(e);let S;return(0,l.getSqlHandler)(e),new Promise((t,u)=>{r.removeAllListeners("connect_error"),r.on("connect_error",e=>{u(e)}),r.removeAllListeners(i.CHANNELS.CONNECTION),r.on(i.CHANNELS.CONNECTION,e=>(u(e),"ok")),p&&r.on("disconnect",()=>{S="disconnected",p()}),f&&r.on("connect",()=>{"disconnected"===S&&(S="reconnected")}),r.on(i.CHANNELS.SCHEMA,async d=>{await(null==g?void 0:g({type:"schemaChanged",data:d,state:S}));const{joinTables:p=[],...m}=d,{schema:k,methods:T,tableSchema:C,auth:E,rawSQL:j,err:P}=m;if((null==v?void 0:v.clientSchema)&&(0,i.isEqual)(v.clientSchema,m)||w.destroySyncs().catch(e=>console.error("Error while destroying syncs",e)),P&&console.error("Error on schema change:",P),"connected"!==S&&"reconnected"!==S||!f)v={origin:"onReady",date:new Date,clientSchema:m};else{if(f(r,P),P)return;v={origin:"onReconnect",date:new Date,clientSchema:m}}if(P)return void u(P);const N="reconnected"===S;S="connected";const A=(0,o.getAuthHandler)({authData:E,socket:r,onReload:y,endpoint:s,credentials:b,redirect:_}),{methodHandlers:x,methodSchema:R}=(0,c.getMethods)({onDebug:g,methods:T,socket:r}),{db:F}=(0,a.getDB)({schema:k,onDebug:g,syncedTable:n,syncHandler:w,subscriptionHandler:O,socket:r,tableSchema:C}),D=j?(0,l.getSqlHandler)(e).sql:void 0;O.reAttachAll(),w.reAttachAll(),(async()=>{try{const e={db:F,sql:D,methods:x,methodSchema:R,tableSchema:C,auth:A,socket:r,isReconnect:N};await(null==g?void 0:g({type:"onReady.call",data:e,state:S})),await h(e)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}t(F)})()})})};const i=n(3316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return i.asName}});const o=n(2886),a=n(9930),c=n(7030),l=n(3382),u=n(395),d=n(9609),h="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[h]&&window[h](...e)},r(n(9501),t),r(n(1044),t)},7833(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let s=0,r=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(s++,"%c"===e&&(r=s))}),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(736)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736(e,t,n){e.exports=function(e){function t(e){let n,r,i,o=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),i=r-(n||r);s.diff=i,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,r)=>{if("%%"===n)return"%";o++;const i=t.formatters[r];if("function"==typeof i){const t=e[o];n=i.call(s,t),e.splice(o,1),o--}return n}),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==t.namespaces&&(r=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function r(e,t){let n=0,s=0,r=-1,i=0;for(;n<e.length;)if(s<t.length&&(t[s]===e[n]||"*"===t[s]))"*"===t[s]?(r=s,i=n,s++):(n++,s++);else{if(-1===r)return!1;s=r+1,i++,n=i}for(;s<t.length&&"*"===t[s];)s++;return s===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=n(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},6585(e){var t=1e3,n=60*t,s=60*n,r=24*s,i=7*r;function o(e,t,n,s){var r=t>=1.5*n;return Math.round(e/n)+" "+s+(r?"s":"")}e.exports=function(e,a){a=a||{};var c,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*s;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&isFinite(e))return a.long?(c=e,(l=Math.abs(c))>=r?o(c,l,r,"day"):l>=s?o(c,l,s,"hour"):l>=n?o(c,l,n,"minute"):l>=t?o(c,l,t,"second"):c+" ms"):function(e){var i=Math.abs(e);return i>=r?Math.round(e/r)+"d":i>=s?Math.round(e/s)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},3316(e){var t;this||window,t=()=>(()=>{"use strict";var e={994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0,t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","Blob","any","unknown"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const s=n(472),r=n(704);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const i={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:()=>{throw new Error("Lookup type is not supported for validation")},Blob:e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},o=(0,s.getKeys)(i),a=(e,n,l=[],u)=>{const d=`${l.join(".")} is of invalid type. Expecting ${c(n).replaceAll("\n","")}`,h=(0,t.getFieldTypeObj)(n),{type:p,allowedValues:f,nullable:m,optional:y}=h;if(m&&null===e)return;if(y&&void 0===e)return;if(f)return`${l.join(".")} Allowed values are not supported for validation`;if(p){if((0,s.isObject)(p)){if(!(0,s.isObject)(e))return d;for(const t of(0,r.safeGetKeys)(p)){const n=(0,r.safeGetProperty)(p,t);if(!((0,s.isObject)(n)&&n.optional||(0,r.safeHasOwn)(e,t)))return`${[...l,t].join(".")} is missing but required`;const i=a((0,r.safeGetProperty)(e,t),n,[...l,t],u);if(void 0!==i)return i}if(!u?.allowExtraProperties){const t=(0,r.safeGetKeys)(e),n=(0,r.safeGetKeys)(p),s=t.filter(e=>!n.includes(e));if(s.length)return`${l.join(".")} has extra properties: ${s.join(", ")}`}return}const{validator:t}=(e=>{const t=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!o.includes(t))throw new Error(`Unknown array field type ${e}`);return t}})(e);if(t){const e=i[t];return{isArray:!0,validator:t=>Array.isArray(t)&&t.every(t=>e(t))}}const n=i[e];if(!n)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:n}})(p);return t(e)?void 0:d}if(h.enum){const t=[];return h.nullable&&t.push(null),h.optional&&t.push(void 0),h.enum.includes(e)?void 0:d}const g=h.arrayOf??(h.arrayOfType?{type:h.arrayOfType}:void 0);if(g){if(!Array.isArray(e))return d+" an array";const t=e.map((e,t)=>a(e,g,[...l,`${t}`],u)).filter(s.isDefined)[0];return void 0!==t?`${d}. Error at index ${l.length>0?l.join(".")+".":""}\n\n${t}`:void 0}const b=h.oneOf??h.oneOfType?.map(e=>({type:e}));if(b){if(!b.length)return d+"to not be empty";let t;if(b.find(n=>{const s=a(e,n,l,u);return t??(t=s),void 0===s}))return;return d}if(!h.record)return`Could not validate field type. Some logic might be missing: ${JSON.stringify(h)}`;{const{keysEnum:t,partial:n,values:i}=h.record;if(!(0,s.isObject)(e))return d+"object";if(n&&(0,s.isEmpty)(e))return;const o=(0,s.getKeys)(e),c=n?void 0:t?.find(e=>!o.includes(e));if(void 0!==c)return`${d} to have key ${c}`;const p=t&&o.filter(e=>!t.includes(e));if(p?.length)return`${d} has extra keys: ${p}`;if(i)for(const t of(0,r.safeGetKeys)(e)){const n=(0,r.safeGetProperty)(e,t),s=a(n,i,[...l,t],u);if(void 0!==s)return`${s}`}}},c=e=>{const n=(0,t.getFieldTypeObj)(e),{type:r,nullable:i,optional:o,record:a}=n,l=n.oneOf??n.oneOfType?.map(e=>({type:e})),u=[];if(i&&u.push("null"),o&&u.push("undefined"),"string"==typeof r)u.push(r);else if(r&&(0,s.isObject)(r)){const e=[];Object.entries(r).forEach(([t,n])=>{e.push(`${t}: ${c(n)}`)}),u.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?u.push("null"):void 0===e?u.push("undefined"):"string"==typeof e?u.push(JSON.stringify(e)):u.push(e)}),l?.forEach(e=>{const t=c(e);u.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,s=t?"?":"",r=n?c(n):"any";e?u.push(`{ [${e.join(" | ")}]${s}: ${r} }`):u.push(`{ [key: string]${s}: ${r} }`)}return u.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",r=!1,i)=>{if(void 0===t&&!r)return{error:`Expecting ${n} to be defined`};if(!(0,s.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=a(t,{type:e},[],i);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const s=a(t,e,void 0,n);return s?{error:s}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,s,r=!1)=>{const{error:i}=(0,t.getJSONBObjectSchemaValidationError)(e,n,s,r);return void 0===i},t.assertJSONBObjectAgainstSchema=(e,n,s,r=!1)=>{const{error:i}=(0,t.getJSONBObjectSchemaValidationError)(e,n,s,r);if(i)throw new Error(i)}},699:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,s){return(0,t.getJSONSchemaObject)(s,{id:`${e}.${n}`})};const s=n(472),r=n(704),i=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:h,title:p,record:f,...m}="string"==typeof e?{type:e}:e;let y={};const g={...(m.enum||m.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!l&&{description:l},...!!p&&{title:p}};if(m.enum?.length){const e=typeof m.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";y=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:i(o)?.type,...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:i(o)?.type}}else(0,s.isObject)(o)?y={type:"object",required:(0,r.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,s.getObjectEntries)(o).reduce((e,[n,s])=>({...e,[n]:(0,t.getJSONSchemaObject)(s)}),{})}:d||h?y={oneOf:(d||h.map(e=>({type:e}))).map(e=>(0,t.getJSONSchemaObject)(e))}:f&&(y={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};y.oneOf?y.oneOf.push(e):y.enum&&!y.enum.includes(null)?y.enum.push(null):y={oneOf:[y,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...y}}},394:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,s="",r){return(0,t.getJSONBTSTypes)(r,{...e,nullable:n.nullable},void 0,s)};const s=n(806),r=n(897),i=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,r.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const r="schema"===n.type;let i=r?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!r){const t=e.find(e=>e.name===n.table)?.columns;i=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,s.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,s.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${i}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("Date","string");return u.allowedValues&&u.type.endsWith("[]")?d+` (${u.allowedValues.map(e=>JSON.stringify(e)).join(" | ")})[]`:d+e}if((0,s.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:i}=u,c=a?" ":" ";let h=` {${c}`+(0,s.getObjectEntries)(i).map(([s,i])=>{const a=(0,r.getFieldTypeObj)(i),u=o(s)?s:JSON.stringify(s);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(h=n(h)),a&&(h=h.split("\n").join("")),d+h}if(u.enum)return d+u.enum.map(e=>i(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:s,partial:r}=u.record,o=e=>r?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>i(e)).join(" | ")??"string"}, ${s?(0,t.getJSONBTSTypes)(e,s,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const s=Object.keys(e);for(const r of n)(0,t.safeHasOwn)(e,r)&&!s.includes(r)&&s.push(r);return s}},618:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const s=n(472);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,s.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806:function(e,t,n){var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const i=n(472),o=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,i.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const c="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:c+"schema-changed",SCHEMA:c+"schema",DEFAULT:c,SQL:`${c}sql`,SQL_STREAM:`${c}sql-stream`,METHOD:`${c}method`,NOTICE_EV:`${c}notice`,LISTEN_EV:`${c}listen`,REGISTER:`${c}register`,LOGIN:`${c}login`,LOGOUT:`${c}logout`,AUTHGUARD:`${c}authguard`,CONNECTION:`${c}connection`,_preffix:c},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const s=(e.references??[]).map(e=>{const{ftable:n,fcols:s}=e,r=t.find(e=>e.name===n);if(!r)return;const i=r.columns.filter(e=>s.includes(e.name));return i.length?{ref:e,fcolsInfo:i}:void 0}).filter(i.isDefined),[r,...o]=s??[];if(!o.length)return r?.ref;const[a,...c]=s.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},r(n(618),t);var l=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return l.CONTENT_TYPE_TO_EXT}}),r(n(209),t),r(n(319),t),r(n(699),t),r(n(394),t),r(n(994),t),r(n(897),t),r(n(472),t),r(n(778),t)},319:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const s=n(472),r=(e="$leftJoin")=>(t,n,r,i={})=>({[e]:i.path??t,filter:n,...(0,s.omitKeys)(i,["path","select"]),select:r});t.innerJoin=r("$innerJoin"),t.leftJoin=r("$leftJoin")},666:(e,t)=>{function n(e,t){var n=e[0],s=e[1],c=e[2],l=e[3];n=r(n,s,c,l,t[0],7,-680876936),l=r(l,n,s,c,t[1],12,-389564586),c=r(c,l,n,s,t[2],17,606105819),s=r(s,c,l,n,t[3],22,-1044525330),n=r(n,s,c,l,t[4],7,-176418897),l=r(l,n,s,c,t[5],12,1200080426),c=r(c,l,n,s,t[6],17,-1473231341),s=r(s,c,l,n,t[7],22,-45705983),n=r(n,s,c,l,t[8],7,1770035416),l=r(l,n,s,c,t[9],12,-1958414417),c=r(c,l,n,s,t[10],17,-42063),s=r(s,c,l,n,t[11],22,-1990404162),n=r(n,s,c,l,t[12],7,1804603682),l=r(l,n,s,c,t[13],12,-40341101),c=r(c,l,n,s,t[14],17,-1502002290),n=i(n,s=r(s,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=i(l,n,s,c,t[6],9,-1069501632),c=i(c,l,n,s,t[11],14,643717713),s=i(s,c,l,n,t[0],20,-373897302),n=i(n,s,c,l,t[5],5,-701558691),l=i(l,n,s,c,t[10],9,38016083),c=i(c,l,n,s,t[15],14,-660478335),s=i(s,c,l,n,t[4],20,-405537848),n=i(n,s,c,l,t[9],5,568446438),l=i(l,n,s,c,t[14],9,-1019803690),c=i(c,l,n,s,t[3],14,-187363961),s=i(s,c,l,n,t[8],20,1163531501),n=i(n,s,c,l,t[13],5,-1444681467),l=i(l,n,s,c,t[2],9,-51403784),c=i(c,l,n,s,t[7],14,1735328473),n=o(n,s=i(s,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,s,c,t[8],11,-2022574463),c=o(c,l,n,s,t[11],16,1839030562),s=o(s,c,l,n,t[14],23,-35309556),n=o(n,s,c,l,t[1],4,-1530992060),l=o(l,n,s,c,t[4],11,1272893353),c=o(c,l,n,s,t[7],16,-155497632),s=o(s,c,l,n,t[10],23,-1094730640),n=o(n,s,c,l,t[13],4,681279174),l=o(l,n,s,c,t[0],11,-358537222),c=o(c,l,n,s,t[3],16,-722521979),s=o(s,c,l,n,t[6],23,76029189),n=o(n,s,c,l,t[9],4,-640364487),l=o(l,n,s,c,t[12],11,-421815835),c=o(c,l,n,s,t[15],16,530742520),n=a(n,s=o(s,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,s,c,t[7],10,1126891415),c=a(c,l,n,s,t[14],15,-1416354905),s=a(s,c,l,n,t[5],21,-57434055),n=a(n,s,c,l,t[12],6,1700485571),l=a(l,n,s,c,t[3],10,-1894986606),c=a(c,l,n,s,t[10],15,-1051523),s=a(s,c,l,n,t[1],21,-2054922799),n=a(n,s,c,l,t[8],6,1873313359),l=a(l,n,s,c,t[15],10,-30611744),c=a(c,l,n,s,t[6],15,-1560198380),s=a(s,c,l,n,t[13],21,1309151649),n=a(n,s,c,l,t[4],6,-145523070),l=a(l,n,s,c,t[11],10,-1120210379),c=a(c,l,n,s,t[2],15,718787259),s=a(s,c,l,n,t[9],21,-343485551),e[0]=h(n,e[0]),e[1]=h(s,e[1]),e[2]=h(c,e[2]),e[3]=h(l,e[3])}function s(e,t,n,s,r,i){return t=h(h(t,e),h(s,i)),h(t<<r|t>>>32-r,n)}function r(e,t,n,r,i,o,a){return s(t&n|~t&r,e,t,i,o,a)}function i(e,t,n,r,i,o,a){return s(t&r|n&~r,e,t,i,o,a)}function o(e,t,n,r,i,o,a){return s(t^n^r,e,t,i,o,a)}function a(e,t,n,r,i,o,a){return s(n^(t|~r),e,t,i,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.md5cycle=n,t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,s=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,c(e.substring(t-64,t)));e=e.substring(t-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(n(r,i),t=0;t<16;t++)i[t]=0;return i[14]=8*s,n(r,i),r}(e))}function h(e,t){return e+t&4294967295}d("hello")},472:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.WAL=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=r,t.filter=i,t.find=function(e,t){return i(e,t)[0]},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,s="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,s){var r={key:t,value:e[t]},i={key:s,value:e[s]};return n(r,i)}}),i=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==i.indexOf(t)){if(s)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=i.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return i.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,s.md5)(t)};function n(n=1){let s=n<1?-1:0,r=!1;for(;!r&&Math.abs(s)<=t.length;){const i=n<1?[s]:[0,s];e.slice(...i)!==t.slice(...i)?r=!0:s+=1*Math.sign(n)}return s}let r=n()-1,i=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:i,text:t.slice(r,o),md5:(0,s.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:i,md5:o}=t;if(null===i||null===e)return i;let a=e.slice(0,n)+i+e.slice(r);if(o&&(0,s.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,s=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,s)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const s=n(666);function r(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function i(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let s={};return t.forEach(t=>{n&&void 0===e[t]||(s[t]=e[t])}),s}return e},t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let s=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],i=+s-+r,o=s<r?-1:s==r?0:1;return"number"===n.tsDataType&&Number.isFinite(i)?i:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],s=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+s))throw"Provided historic item Synced field value is missing/invalid";if(+s==+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:s,delta:r}={...e};if(!s)throw"Expecting { current: object, initial?: object }";const i=this.getIdStr(s);this.changed??(this.changed={}),(t=this.changed)[i]??(t[i]={initial:n,current:s,delta:r}),this.changed[i].current={...this.changed[i].current,...s},this.changed[i].delta={...this.changed[i].delta,...r}}),this.sendItems()},this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:s,throttle:r,historyAgeSeconds:i=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,s).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const s=e.initial?.[n],r=e.current[n];var i,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((i=s)===(o=r)||(["number","string","boolean"].includes(typeof i)?i===o:JSON.stringify(i)===JSON.stringify(o)))||(t[n]=r)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()},r)),this.isOnSending=!0;try{await t(c,l),i&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*i)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),o(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!(o(this.sending)&&o(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const s=[{table:n,on:[{}]},...e??[]];return s.map((e,n)=>{const r=s[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const s=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),i=JSON.parse((0,t.safeStringify)(s));return n?i:r(i,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]}},441:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778:function(e,t,n){var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(102),t),r(n(436),t),r(n(441),t)},102:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,s="trace")=>n(e,t,void 0,s);const n=(e,t,s=new WeakMap,r)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let i=s.get(e);if(i?.has(t)){if("quiet"!==r&&console.trace("Circular reference detected in isEqual",e,t),"error"===r)throw new Error("Circular reference detected in isEqual");return"return-true"===r}if(i||(i=new WeakSet,s.set(e,i)),i.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i],s,r))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),s=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const i of c){if(!(i in t))return!1;{const o=e[i],a=t[i];if(!n(o,a,s,r))return!1}}return!0}},436:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,s)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,n),i.exports}(806)})(),e.exports=t()},9155(t){"use strict";if(void 0===e){var n=new Error("Cannot find module 'react'");throw n.code="MODULE_NOT_FOUND",n}t.exports=e},4110(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},8661(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,s=n.length;e<s;e++){let s=n[e].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}},1015(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),i=e.indexOf("]");-1!=r&&-1!=i&&(e=e.substring(0,r)+e.substring(r,i).replace(/:/g,";")+e.substring(i,e.length));let o=n.exec(e||""),a={},c=14;for(;c--;)a[s[c]]=o[c]||"";return-1!=r&&-1!=i&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,s){t&&(n[t]=s)}),n}(0,a.query),a};const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},4624(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.globalThisShim=t.nextTick=void 0,t.createCookieJar=function(){},t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),t.defaultBinaryType="arraybuffer"},4956(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.SocketWithUpgrade=t.SocketWithoutUpgrade=t.Socket=void 0;const s=n(8223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});var r=n(8223);Object.defineProperty(t,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return r.SocketWithoutUpgrade}}),Object.defineProperty(t,"SocketWithUpgrade",{enumerable:!0,get:function(){return r.SocketWithUpgrade}}),t.protocol=s.Socket.protocol;var i=n(4689);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return i.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return i.TransportError}});var o=n(9419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(5374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(1015);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(4624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(8209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(2071);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var h=n(2071);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return h.XHR}});var p=n(8716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return p.WS}});var f=n(8716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var m=n(4480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return m.WT}})},8223(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const r=n(9419),i=n(5374),o=n(8661),a=n(1015),c=n(4454),l=n(6376),u=n(4624),d=(0,s(n(7833)).default)("engine.io-client:socket"),h="function"==typeof addEventListener&&"function"==typeof removeEventListener,p=[];h&&addEventListener("offline",()=>{d("closing %d connection(s) because the network was lost",p.length),p.forEach(e=>e())},!1);class f extends c.Emitter{constructor(e,t){if(super(),this.binaryType=u.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=(0,a.parse)(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,i.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),h&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(d("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},p.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,u.createCookieJar)()),this._open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",n),new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){d("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=(0,i.byteLength)(n)),t>0&&e>this._maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(d("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,u.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if("function"==typeof t&&(s=t,t=void 0),"function"==typeof n&&(s=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this._onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(d("socket error %j",e),f.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return d("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),h&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=p.indexOf(this._offlineEventListener);-1!==e&&(d("removing listener for the 'offline' event"),p.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=f,f.protocol=l.protocol;class m extends f{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),n=!1;f.priorWebsocketSuccess=!1;const s=()=>{n||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",s=>{if(!n)if("pong"===s.type&&"probe"===s.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{d('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}}))};function r(){n||(n=!0,l(),t.close(),t=null)}const i=n=>{const s=new Error("probe error: "+n);s.transport=t.name,r(),d('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",s)};function o(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),r())}const l=()=>{t.removeListener("open",s),t.removeListener("error",i),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",s),t.once("error",i),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}t.SocketWithUpgrade=m,t.Socket=class extends m{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>r.transports[e]).filter(e=>!!e)),super(e,n)}}},4689(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const r=n(6376),i=n(4454),o=n(5374),a=n(8661),c=(0,s(n(7833)).default)("engine.io-client:transport");class l extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}t.TransportError=l;class u extends i.Emitter{constructor(e){super(),this.writable=!1,(0,o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new l(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):c("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,r.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,a.encode)(e);return t.length?"?"+t:""}}t.Transport=u},9419(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const s=n(2071),r=n(8716),i=n(4480);t.transports={websocket:r.WS,webtransport:i.WT,polling:s.XHR}},8209(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const s=n(528);class r extends s.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(e=>this.onData(e))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()}).catch(e=>{this.onError("fetch write error",e)})}_fetch(e){var t;const n=void 0!==e,s=new Headers(this.opts.extraHeaders);return n&&s.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(s),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:s,credentials:this.opts.withCredentials?"include":"omit"}).then(e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e})}}t.Fetch=r},2071(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const r=n(528),i=n(4454),o=n(5374),a=n(4624),c=n(4110),l=(0,s(n(7833)).default)("engine.io-client:polling");function u(){}class d extends r.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){l("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}t.BaseXHR=d;class h extends i.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{l("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},l("xhr data %s",this._data),n.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=h.requestsCount++,h.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=u,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete h.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=h,h.requestsCount=0,h.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",p);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,p,!1)}function p(){for(let e in h.requests)h.requests.hasOwnProperty(e)&&h.requests[e].abort()}const f=function(){const e=m({xdomain:!1});return e&&null!==e.responseType}();function m(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||c.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends d{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new h(m,this.uri(),e)}}},528(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;const r=n(4689),i=n(5374),o=n(6376),a=(0,s(n(7833)).default)("engine.io-client:polling");class c extends r.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{a("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(a("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){a("pre-pause polling complete"),--e||t()})),this.writable||(a("we are currently writing - waiting to pause"),e++,this.once("drain",function(){a("pre-pause writing complete"),--e||t()}))}else t()}_poll(){a("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){a("polling got data %s",e),(0,o.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this._poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),e()):(a("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}t.Polling=c},8716(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=t.BaseWS=void 0;const r=n(4689),i=n(5374),o=n(6376),a=n(4624),c=(0,s(n(7833)).default)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class u extends r.Transport{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=l?{}:(0,i.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],s=t===e.length-1;(0,o.encodePacket)(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){c("websocket closed before onclose event")}s&&(0,a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}t.BaseWS=u;const d=a.globalThisShim.WebSocket||a.globalThisShim.MozWebSocket;t.WS=class extends u{createSocket(e,t,n){return l?new d(e,t,n):t?new d(e,t):new d(e)}doWrite(e,t){this.ws.send(t)}}},4480(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const r=n(4689),i=n(4624),o=n(6376),a=(0,s(n(7833)).default)("engine.io-client:webtransport");class c extends r.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{a("transport closed gracefully"),this.onClose()}).catch(e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=(0,o.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=(0,o.createPacketEncoderStream)();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();const r=()=>{n.read().then(({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),r())}).catch(e=>{a("an error occurred while reading: %s",e)})};r();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&(0,i.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}}t.WT=c},5374(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=r.bind(s.globalThisShim),e.clearTimeoutFn=i.bind(s.globalThisShim)):(e.setTimeoutFn=s.globalThisShim.setTimeout.bind(s.globalThisShim),e.clearTimeoutFn=s.globalThisShim.clearTimeout.bind(s.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const s=n(4624),r=s.globalThisShim.setTimeout,i=s.globalThisShim.clearTimeout},2046(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const s=Object.create(null);t.PACKET_TYPES_REVERSE=s,Object.keys(n).forEach(e=>{s[n[e]]=e}),t.ERROR_PACKET={type:"error",data:"parser error"}},2745(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)s[n.charCodeAt(e)]=e;t.encode=e=>{let t,s=new Uint8Array(e),r=s.length,i="";for(t=0;t<r;t+=3)i+=n[s[t]>>2],i+=n[(3&s[t])<<4|s[t+1]>>4],i+=n[(15&s[t+1])<<2|s[t+2]>>6],i+=n[63&s[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i},t.decode=e=>{let t,n,r,i,o,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const u=new ArrayBuffer(a),d=new Uint8Array(u);for(t=0;t<c;t+=4)n=s[e.charCodeAt(t)],r=s[e.charCodeAt(t+1)],i=s[e.charCodeAt(t+2)],o=s[e.charCodeAt(t+3)],d[l++]=n<<2|r>>4,d[l++]=(15&r)<<4|i>>2,d[l++]=(3&i)<<6|63&o;return u}},2662(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const s=n(2046),r=n(2745),i="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:o(e.substring(1),t)}:s.PACKET_TYPES_REVERSE[n]?e.length>1?{type:s.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:s.PACKET_TYPES_REVERSE[n]}:s.ERROR_PACKET};const o=(e,t)=>{if(i){const n=(0,r.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},2686(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=void 0,t.encodePacketToBinary=function(e,t){return r&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):i&&(e.data instanceof ArrayBuffer||o(e.data))?t(l(e.data)):void a(e,!1,e=>{u||(u=new TextEncoder),t(u.encode(e))})};const s=n(2046),r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>r&&t instanceof Blob?n?a(t):c(t,a):i&&(t instanceof ArrayBuffer||o(t))?n?a(t):c(new Blob([t]),a):a(s.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u},6376(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=void 0,t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,s.encodePacketToBinary)(e,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,s)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(s))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)})}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let s=0,o=-1,u=!1;return new TransformStream({transform(d,h){for(n.push(d);;){if(0===s){if(c(n)<1)break;const e=l(n,1);u=!(128&~e[0]),o=127&e[0],s=o<126?3:126===o?1:2}else if(1===s){if(c(n)<2)break;const e=l(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),s=3}else if(2===s){if(c(n)<8)break;const e=l(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){h.enqueue(i.ERROR_PACKET);break}o=r*Math.pow(2,32)+t.getUint32(4),s=3}else{if(c(n)<o)break;const e=l(n,o);h.enqueue((0,r.decodePacket)(u?e:a.decode(e),t)),s=0}if(0===o||o>e){h.enqueue(i.ERROR_PACKET);break}}}})};const s=n(2686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return s.encodePacket}});const r=n(2662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const i=n(2046),o=String.fromCharCode(30);let a;function c(e){return e.reduce((e,t)=>e+t.length,0)}function l(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)n[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),n}t.encodePayload=(e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach((e,a)=>{(0,s.encodePacket)(e,!1,e=>{r[a]=e,++i===n&&t(r.join(o))})})},t.decodePayload=(e,t)=>{const n=e.split(o),s=[];for(let e=0;e<n.length;e++){const i=(0,r.decodePacket)(n[e],t);if(s.push(i),"error"===i.type)break}return s},t.protocol=4},7743(e,t){"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=l,t.connect=l,t.default=l;const r=n(6894),i=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return i.Manager}});const o=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,s(n(7833)).default)("socket.io-client"),c={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=(0,r.url)(e,t.path||"/socket.io"),s=n.source,o=n.id,l=n.path,u=c[o]&&l in c[o].nsps;let d;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(a("ignoring socket cache for %s",s),d=new i.Manager(s,t)):(c[o]||(a("new io instance for %s",s),c[o]=new i.Manager(s,t)),d=c[o]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(l,{Manager:i.Manager,Socket:o.Socket,io:l,connect:l});var u=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(4956);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return d.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return d.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return d.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return d.WebTransport}}),e.exports=l},3776(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&s(t,e,n);return r(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),l=i(n(4627)),u=n(5942),d=n(7743),h=n(4454),p=(0,o(n(7833)).default)("socket.io-client:manager");class f extends h.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,(0,a.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new d.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||l;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=(0,u.on)(t,"open",function(){n.onopen(),e&&e()}),r=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=(0,u.on)(t,"error",r);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const n=this.setTimeoutFn(()=>{p("connect attempt timed out after %d",e),s(),r(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push((0,u.on)(e,"ping",this.onping.bind(this)),(0,u.on)(e,"data",this.ondata.bind(this)),(0,u.on)(e,"error",this.onerror.bind(this)),(0,u.on)(e,"close",this.onclose.bind(this)),(0,u.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){(0,a.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){p("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){p("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;p("closed due to %s",e),this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();p("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(p("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(p("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(p("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=f},5942(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},6214(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const r=n(4627),i=n(5942),o=n(4454),a=(0,s(n(7833)).default)("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class l extends o.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,i.on)(e,"open",this.onopen.bind(this)),(0,i.on)(e,"packet",this.onpacket.bind(this)),(0,i.on)(e,"error",this.onerror.bind(this)),(0,i.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,i;if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:r.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const n=t.pop();this._registerAckCallback(e,n),o.id=e}const l=null===(s=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===s?void 0:s.writable,u=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!l?a("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var n;const s=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===s)return void(this.acks[e]=t);const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,s)=>{const r=(e,t)=>e?s(e):n(t);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...s)=>n!==this._queue[0]?a("packet [%d] already acknowledged",n.id):(null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...s)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:r.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...s){n||(n=!0,a("sending ack %j",s),t.packet({type:r.PacketType.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:r.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}t.Socket=l},6894(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=function(e,t="",n){let s=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(i("protocol-less url %s",e),e=void 0!==n?n.protocol+"//"+e:"https://"+e),i("parse %s",e),s=(0,r.parse)(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const o=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+o+":"+s.port+t,s.href=s.protocol+"://"+o+(n&&n.port===s.port?"":":"+s.port),s};const r=n(4956),i=(0,s(n(7833)).default)("socket.io-client:url")},2545(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deconstructPacket=function(e){const t=[],n=e.data,s=e;return s.data=r(n,t),s.attachments=t.length,{packet:s,buffers:t}},t.reconstructPacket=function(e,t){return e.data=i(e.data,t),delete e.attachments,e};const s=n(9133);function r(e,t){if(!e)return e;if((0,s.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let s=0;s<e.length;s++)n[s]=r(e[s],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=r(e[s],t));return n}return e}function i(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=i(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=i(e[n],t));return e}},4627(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0,t.isPacketValid=function(e){return"string"==typeof e.nsp&&(void 0===(t=e.id)||d(t))&&function(e,t){switch(e){case c.CONNECT:return void 0===t||h(t);case c.DISCONNECT:return void 0===t;case c.EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:return Array.isArray(t);case c.CONNECT_ERROR:return"string"==typeof t||h(t);default:return!1}}(e.type,e.data);var t};const s=n(4454),r=n(2545),i=n(9133),o=(0,n(7833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c||(t.PacketType=c={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return o("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,i.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),o("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,r.deconstructPacket)(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}};class l extends s.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new u(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,i.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const s=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(s,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const s=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(s,t)}else n.nsp="/";const s=e.charAt(t+1);if(""!==s&&Number(s)==s){const s=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){const s=this.tryParse(e.substr(t));if(!l.isPayloadValid(n.type,s))throw new Error("invalid payload");n.data=s}return o("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return h(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||h(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=l;class u{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,r.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function h(e){return"[object Object]"===Object.prototype.toString.call(e)}},9133(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBinary=o,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(e(t[n]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1};const n="function"==typeof ArrayBuffer,s=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),i="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);function o(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||r&&e instanceof Blob||i&&e instanceof File}},4454(e,t,n){"use strict";function s(e){if(e)return function(e){for(var t in s.prototype)e[t]=s.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>s}),s.prototype.on=s.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},s.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},s.prototype.off=s.prototype.removeListener=s.prototype.removeAllListeners=s.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<s.length;r++)if((n=s[r])===t||n.fn===t){s.splice(r,1);break}return 0===s.length&&delete this._callbacks["$"+e],this},s.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(n){s=0;for(var r=(n=n.slice(0)).length;s<r;++s)n[s].apply(this,t)}return this},s.prototype.emitReserved=s.prototype.emit,s.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},s.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},n={};function s(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e].call(i.exports,i,i.exports,s),i.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=function(e){return(0,t.prostgles)(e,n.SyncedTable)};const t=s(9653),n=s(3333)})(),r})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(function(){try{return require("react")}catch(e){}}());else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(function(){try{return require("react")}catch(e){}}()):t(e.react);for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(Object(this||window),e=>(()=>{var t={9515(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionQueuer=void 0,t.FunctionQueuer=class{constructor(e,t){this.queue=[],this.isRunning=!1,this.startQueueJob=async()=>{if(this.isRunning)return;this.isRunning=!0;const e=async e=>{if(e)try{const t=await this.func(...e.arguments);e.onResult(t)}catch(t){e.onFail(t)}};if(this.groupBy){const t=new Set,n=[];this.queue.forEach(e=>{const s=this.groupBy(e.arguments);t.has(s)||(t.add(s),n.push(e))}),n.slice(0).reverse().forEach(e=>{this.queue.splice(this.queue.indexOf(e),1)}),await Promise.all(n.map(t=>e(t)))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&this.startQueueJob()},this.func=e,this.groupBy=t}async run(e){const t=new Promise((t,n)=>{const s={arguments:e,onResult:t,onFail:n};this.queue.push(s)});return this.startQueueJob(),t}}},3333(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.mergeDeep=t.SyncedTable=t.debug=void 0;const s=n(3316),r=n(4476),i="DEBUG_SYNCEDTABLE",o="undefined"!=typeof window;t.debug=function(...e){o&&window[i]&&window[i](...e)};const a={map:"map",localStorage:"localStorage"};class c{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:i,onDebug:c,db:l,skipFirstTrigger:u=!1,select:d="*",storageType:h="map",patchText:p=!1,patchJSON:f=!1,onError:m}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.itemsMap=new Map,this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map(e=>e.current);const i=[],o=[];if(this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter(e=>"text"===e.data_type);if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map(async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map(e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,s.getTextPatch)(l[e.name],c[e.name]))}),u&&this.wal&&(o.push(u),i.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)}))}}if(i.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(i))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter(e=>e)},this._notifySubscribers=(e=[])=>{var t,n;if(!this.isSynced)return void(null===(t=this.onDebug)||void 0===t||t.call(this,{command:"notifySubscribers",data:[],info:"not synced yet"}));null===(n=this.onDebug)||void 0===n||n.call(this,{command:"notifySubscribers",data:e});const s=[],r=[],i=[];if(e.map(({idObj:e,newItem:t,delta:n})=>{this.singleSubscriptions.filter(t=>this.matchesIdObj(t.idObj,e)).map(async e=>{try{await e.notify(t,n)}catch(e){console.error("SyncedTable failed to notify: ",e)}}),this.matchesFilter(t)&&(s.push(t),r.push(n),i.push(e))}),this.onChange||this.multiSubscriptions.length){const e=[],t=[];if(this.getItems().map(n=>{e.push({...n});const i=s.findIndex(e=>this.matchesIdObj(n,e));t.push(r[i])}),this.onChange)try{this.onChange(e,t)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map(async n=>{try{await n.notify(e,t)}catch(e){console.error("SyncedTable failed to notify: ",e)}})}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter(t=>t._onChange!==e),this.multiSubscriptions=this.multiSubscriptions.filter(t=>t._onChange!==e),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{var e;null===(e=this.dbSync)||void 0===e||e.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsMap.clear(),this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const s=this.getIdObj(e);return this.setItem(s,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(s),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns.length){const t=Object.keys({...e}).filter(e=>!this.columns.find(t=>t.name===e));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,n=!1)=>{var r,i;if(!(e&&e.length||n))throw"No data provided for upsert";const o=[];let a;const c=[];await Promise.all(e.map(async(e,r)=>{var i;const l={...e.idObj};let u={...e.delta};Object.keys(u).map(e=>{void 0===u[e]&&(u[e]=null)}),n||this.checkItemCols({...e.delta,...e.idObj});const d=this.getItem(l);!n&&!(0,s.isEmpty)(u)||(0,s.isEmpty)(d)||(u=this.getDelta(d||{},u)),n||(u[this.synced_field]=Date.now());let h={...d,...u,...l};d&&!n&&(null===(i=e.opts)||void 0===i?void 0:i.deepMerge)&&(h=(0,t.mergeDeep)({...d,...l},{...u})),a=d?d[this.synced_field]<h[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(h);const p={idObj:l,delta:u,oldItem:d,newItem:h,status:a,from_server:n};return n||c.push({initial:d,current:{...h}}),(0,s.isEmpty)(p.delta)||o.push(p),!0})).catch(e=>{console.error("SyncedTable failed upsert: ",e)}),null===(r=this.notifyWal)||void 0===r||r.addData(o.map(e=>({initial:e.oldItem,current:e.newItem}))),!n&&c.length&&(null===(i=this.wal)||void 0===i||i.addData(c))},this.setItems=e=>{const n=(0,t.quickClone)(e);if(this.storageType===a.localStorage){if(!o)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(n))}else this.storageType===a.map&&(this.itemsMap=new Map(n.map(e=>[this.getIdStr(e),{...e}])))},this.getItems=()=>{let e=[];if(this.storageType===a.localStorage){if(!o)throw"Cannot access window object. Choose another storage method (array OR object)";const t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else this.storageType===a.map&&(e=Array.from(this.itemsMap.values()).map(e=>({...e})));if(!this.id_fields.length||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter(e=>!this.filter||!(0,s.getKeys)(this.filter).find(t=>e[t]!==this.filter[t])).sort((e,n)=>t.map(t=>e[t]<n[t]?-1:e[t]>n[t]?1:0).find(e=>e))}return(0,t.quickClone)(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:s}={offset:0,limit:void 0})=>{let r=this.getItems().map(e=>({...e})).filter(n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t));return(n||s)&&(r=r.splice(null!=n?n:0,s||r.length)),r},this.name=e,this.filter=n,this.select=d,this.onChange=r,c&&(this.onDebug=t=>c({...t,type:"sync",tableName:e},this)),!a[h])throw"Invalid storage type. Expecting one of: "+Object.keys(a).join(", ");o||h!==a.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to map"),h="map"),this.storageType=h,this.patchText=p,this.patchJSON=f;const y=l[e];if(!y)throw`${e} table not found in db`;this.db=l;const{id_fields:g,synced_field:b,throttle:_=100,batch_size:v=50}=y._syncInfo;if(!g||!b)throw"id_fields/synced_field missing";this.id_fields=g,this.synced_field=b,this.batch_size=v,this.throttle=_,this.skipFirstTrigger=u,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=m||function(e){console.error("Sync internal error: ",e)};const O={id_fields:g,synced_field:b,throttle:_};y._sync(n,{select:d},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0};const s=this.getBatch(e);return s.length&&(n={c_fr:this.getRowSyncObj(s[0]),c_lr:this.getRowSyncObj(s[s.length-1]),c_count:s.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:s,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;const t=this.getItems().map(e=>({...e}));this.setItems([]);const n=t.map(e=>({idObj:this.getIdObj(e),delta:{...e}}));await this.upsert(n,!0)}else if("data"in e){const t=e.data.map(e=>({idObj:this.getIdObj(e),delta:e}));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then(e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new s.WAL({...O,batch_size:v,onSendStart:()=>{o&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{o&&(window.onbeforeunload=null)}}),this.notifyWal=new s.WAL({...O,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map(e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}}))}}),i()}),y.getColumns&&y.getColumns().then(e=>{this.columns=e}),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise((t,n)=>{try{const n=new c({...e,onReady:()=>{setTimeout(()=>{t(n)},0)}})}catch(e){n(e)}})}sync(e,t=!0){const{sub:n,handles:s}=r.getMultiSyncSubscription.bind(this)({onChange:e,handlesOnData:t});return this.multiSubscriptions.push(n),this.skipFirstTrigger||setTimeout(()=>{const e=this.getItems();n.notify(e,e)},0),Object.freeze({...s})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const s={$get:()=>this.getItem(e),$find:e=>this.getItem(e),$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,s)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:s}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return s}syncOne(e,t,n=!0){const s=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:s,notify:(e,r)=>{const i={...e};return n&&(i.$get=s.$get,i.$find=s.$find,i.$update=s.$update,i.$delete=s.$delete,i.$unsync=s.$unsync,i.$cloneSync=s.$cloneSync),t(i,r)}};return this.singleSubscriptions.push(r),setTimeout(()=>{const e=s.$get();e&&r.notify(e,e)},0),Object.freeze({...s})}getIdStr(e){return this.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){const t={};return this.id_fields.sort().map(n=>{t[n]=e[n]}),t}getRowSyncObj(e){const t={};return[this.synced_field,...this.id_fields].sort().map(n=>{t[n]=e[n]}),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,s.isEmpty)(this.filter)||!Object.keys(this.filter).find(t=>this.filter[t]!==e[t])))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find(n=>e[n]!==t[n]))}getDelta(e,t){return(0,s.isEmpty)(e)?{...t}:Object.fromEntries(Object.entries({...t}).filter(([e])=>!this.id_fields.includes(e)).map(([t,n])=>{if(!(0,s.isEqual)(n,e[t]))return[t,(0,s.isObject)(n)?{...n}:Array.isArray(n)?n.slice(0):n]}).filter(s.isDefined))}deleteAll(){this.getItems().map(e=>this.delete(e))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let n;return n=this.storageType===a.localStorage?this.getItems().find(t=>this.matchesIdObj(t,e)):this.itemsMap.get(this.getIdStr(e)),(0,t.quickClone)(n)}setItem(e,n=!1,s=!1){var r;const i=(0,t.quickClone)(e);if(this.storageType===a.localStorage){let e=this.getItems();if(s)e=e.filter(e=>!this.matchesIdObj(e,i));else{let t=!1;e=e.map(e=>this.matchesIdObj(e,i)?(t=!0,n?{...i}:{...e,...i}):e),t||e.push(i)}o&&window.localStorage.setItem(this.name,JSON.stringify(e))}else{const e=this.getIdStr(i);if(s)this.itemsMap.delete(e);else{const t=null!==(r=this.itemsMap.get(e))&&void 0!==r?r:{};this.itemsMap.set(e,n?{...i}:{...t,...i})}}}}t.SyncedTable=c,t.mergeDeep=(e,n)=>{const r=e?(0,t.quickClone)(e):e,i=n?(0,t.quickClone)(n):n,o=(0,s.isObject)(r)?{...r}:{};return(0,s.isObject)(r)&&(0,s.isObject)(i)&&Object.keys(i).forEach(e=>{const n=i[e],a=r[e];(0,s.isObject)(n)&&(0,s.isObject)(a)?o[e]=(0,t.mergeDeep)(a,n):o[e]=(0,t.quickClone)(n)}),o},t.quickClone=e=>{if(o&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map(e=>(0,t.quickClone)(e));if((0,s.isObject)(e)){const n={};return(0,s.getKeys)(e).map(s=>{n[s]=(0,t.quickClone)(e[s])}),n}return e}},4476(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMultiSyncSubscription=function({onChange:e,handlesOnData:t}){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(!e)throw"No data provided for upsert";const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map(e=>t(e))):this.upsert([t(e)])}};return{sub:{_onChange:e,handlesOnData:t,handles:n,notify:(n,s)=>{let r=[...n];const i=[...s];return t&&(r=r.map((n,s)=>{const r=(n,s)=>({...n,...this.makeSingleSyncHandles(s,e),$get:()=>r(this.getItem(s),s),$find:e=>r(this.getItem(e),e),$update:(e,t)=>this.upsert([{idObj:s,delta:e,opts:t}]).then(e=>!0),$delete:async()=>this.delete(s),$cloneMultiSync:e=>this.sync(e,t)}),i=this.getIdObj(n);return r(n,i)})),e(r,i)}},handles:n}}},2886(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const s=n(3316),r=n(9653);t.getAuthHandler=({authData:e,socket:n,onReload:i,endpoint:o,...a})=>{var c;const l=e=>{const{search:t}=window.location;let n=e+t;return o&&(n=`${o}${n}`),n};if((null==e?void 0:e.pathGuard)&&r.isClientSide){const e=e=>{(null==e?void 0:e.shouldReload)&&(i?i():r.isClientSide&&(console.log("prostgles page reload due to authguard",e),setTimeout(()=>{window.location.reload()},200)))};n.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),(t,n)=>{e(n)}),n.removeAllListeners(s.CHANNELS.AUTHGUARD),n.on(s.CHANNELS.AUTHGUARD,t=>{e(t)})}const u={loginType:null===(c=null==e?void 0:e.login)||void 0===c?void 0:c.mode,login:void 0,preferredLogin:null==e?void 0:e.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,confirmEmail:void 0,providers:null==e?void 0:e.providers};if(e){const{providers:n,signupWithEmailAndPassword:r,login:i}=e;u.loginWithProvider=(0,s.isEmpty)(n)?void 0:n&&Object.entries(n).reduce((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e),{}),u.login=i&&(async e=>(0,t.authRequest)(l(i.loginRoute),e,"POST",a)),u.signupWithEmailAndPassword=r&&(e=>(0,t.authRequest)(l(r.url),e,"POST",a)),u.confirmEmail=r&&(e=>(0,t.authRequest)(l(r.emailConfirmationRoute),e,"POST",a))}return(null==e?void 0:e.user)?{isLoggedin:!0,user:e.user,logout:async()=>{var n;const{logoutRoute:s}=null!==(n=e.login)&&void 0!==n?n:{};if(!s)throw new Error("Unexpected");return(0,t.authRequest)(l(s),{},"POST",a)},...u}:{isLoggedin:!1,user:void 0,...u}},t.authRequest=async(e,t,n,{credentials:s,redirect:r})=>{const i=await fetch(e,{method:n,headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)},credentials:s,redirect:r});if(!i.ok){const e=await i.json().catch(()=>i.text()).catch(()=>i.statusText);return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const o=await i.json().catch(async()=>({message:await i.text()})).catch(()=>({message:i.statusText}));return i.redirected?{...o,success:!0,redirect_url:i.url}:o}},9930(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDB=void 0;const s=n(3316),r=n(3333),i=n(1632),o=n(6469),a=n(8552),c=s.CHANNELS._preffix;t.getDB=({schema:e,tableSchema:t,onDebug:n,syncedTable:l,syncHandler:u,subscriptionHandler:d,socket:h})=>{const p=(e,t,n,r)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.isObject)(t)||"function"!=typeof n||void 0!==r&&"function"!=typeof r)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},f=["subscribe","subscribeOne"],m={},y=(0,r.quickClone)(e);return(0,s.getObjectEntries)(y).forEach(([e,r])=>{const y=(0,s.getKeys)(r);m[e]={};const g=m[e];y.sort((e,t)=>Number((0,s.includes)(f,e))-Number((0,s.includes)(f,t))).forEach(y=>{if("sync"===y){if(g._syncInfo={...r[y]},l){g.getSync=async(t,s={})=>(await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{filter:t,params:s}})),l.create({name:e,onDebug:n,filter:t,db:m,...s}));const t=async(t={},r={},i)=>{var o;const a=`${e}.${JSON.stringify(t)}.${JSON.stringify((0,s.omitKeys)(r,["handlesOnData"]))}`,c=null!==(o=u.syncedTables[a])&&void 0!==o?o:await l.create({...r,onDebug:n,name:e,filter:t,db:m,onError:i});return u.syncedTables[a]=c,c},r=async(s,r={handlesOnData:!0,select:"*"},i,o)=>{await(null==n?void 0:n({type:"table",command:"sync",tableName:e,data:{basicFilter:s,options:r}})),p(s,r,i,o);const a=await t(s,r,o);return await a.sync(i,r.handlesOnData)},i=async(s,r={handlesOnData:!0},i,o)=>{await(null==n?void 0:n({type:"table",command:"syncOne",tableName:e,data:{basicFilter:s,options:r}})),p(s,r,i,o);const a=await t(s,r,o);return await a.syncOne(s,i,r.handlesOnData)};g.sync=r,g.syncOne=i,g.useSync=(e,t,n)=>(0,o.useSync)(r,e,t,n),g.useSyncOne=(e,t,n)=>(0,o.useSync)(i,e,t,n)}g._sync=async function(t,s,r){return await(null==n?void 0:n({type:"table",command:"_sync",tableName:e,data:{param1:t,param2:s,syncHandles:r}})),u.addSync({tableName:e,command:y,param1:t,param2:s},r)}}else if(f.includes(y)){const t=async function(t={},s={},r,i){return await(null==n?void 0:n({type:"table",command:y,tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),p(t,s,r,i),d.addSub(m,{tableName:e,command:y,param1:t,param2:s},r,i)};g[y]=t;const s="subscribeOne",r="subscribe"===y?"useSubscribe":"subscribeOne"===y?"useSubscribeOne":void 0;r&&(g[r]=(e,n,r)=>(0,i.useSubscribe)(t,y===s,e,n,r)),y!==s&&f.includes(s)||(g[s]=async function(t,s,r){return await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{param1:t,param2:s,onChange:r}})),p(t,s,r),d.addSub(m,{tableName:e,command:y,param1:t,param2:s},e=>{r(e[0])})})}else{const s=async function(s,r,i){var o;if("getColumns"===y&&!s&&!r&&!i){const n=null===(o=null==t?void 0:t.find(t=>t.name===e))||void 0===o?void 0:o.columns;if(n)return n}return await(null==n?void 0:n({type:"table",command:y,tableName:e,data:{param1:s,param2:r,param3:i}})),new Promise((t,n)=>{h.emit(c,{tableName:e,command:y,param1:s,param2:r,param3:i},(e,s)=>{e?n(e):t(s)})})};g[y]=s;const r="findOne"===y?"useFindOne":"find"===y?"useFind":"count"===y?"useCount":"size"===y?"useSize":void 0;r&&(g[r]=(e,t,n)=>(0,a.useFetch)(s,[e,t],n))}})}),{db:m}}},7030(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const s=n(3316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let r={};const i={};return JSON.parse(JSON.stringify(t)).map(({name:t,description:o,input:a,output:c})=>{const l=async function(r){return await(null==e?void 0:e({type:"method",command:t,data:{params:r}})),new Promise((e,i)=>{n.emit(s.CHANNELS.METHOD,{name:t,input:r},(t,n)=>{t?i(t):e(n)})})};r[t]={description:o,input:a,output:c,run:l},i[t]=l}),r=Object.freeze(r),{methodSchema:r,methodHandlers:i}}},3382(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const s=n(3316);t.getSqlHandler=({socket:e})=>{let t;const n={};return{sql:function(r,i,o){return new Promise((a,c)=>{e.emit(s.CHANNELS.SQL,{query:r,params:i,options:o},(s,r)=>{if(s)return c(s);if("stream"===(null==o?void 0:o.returnType)){const{channel:t,unsubChannel:n}=r,s=s=>new Promise((r,i)=>{e.on(t,s),e.emit(t,{},(s,o)=>{o?(i(o),e.removeAllListeners(t)):r({pid:s,run:(n,s)=>new Promise((r,i)=>{e.emit(t,{query:n,params:s},(e,t)=>{t?i(t):r(e)})}),stop:t=>new Promise((s,r)=>{e.emit(n,{terminate:t},(e,t)=>{t?r(t):s(e)})})})})});return a({channel:t,unsubChannel:n,start:s})}if(o&&"noticeSubscription"===o.returnType&&r&&Object.keys(r).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(r).find(e=>"string"!=typeof e)){const n=r,s=s=>(((e,n,s)=>{null!=t||(t={config:n,listeners:[]}),t.listeners.length||(s.removeAllListeners(n.socketChannel),s.on(n.socketChannel,e=>{t&&t.listeners.length?t.listeners.map(t=>{t(e)}):s.emit(n.socketUnsubChannel,{})})),t.listeners.push(e)})(s,n,e),{...n,removeListener:()=>((e,n)=>{t&&(t.listeners=t.listeners.filter(t=>t!==e),!t.listeners.length&&t.config.socketUnsubChannel&&n&&n.emit(t.config.socketUnsubChannel,{}))})(s,e)}),i={...n,addListener:s};a(i)}else if(o&&o.returnType&&"statement"===o.returnType||!r||Object.keys(r).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(r).find(e=>"string"!=typeof e))a(r);else{const t=r,s=s=>(((e,t,s)=>{var r;n[t.notifChannel]?null===(r=n[t.notifChannel])||void 0===r||r.listeners.push(e):(n[t.notifChannel]={config:t,listeners:[e]},s.removeAllListeners(t.socketChannel),s.on(t.socketChannel,e=>{var r,i;(null===(r=n[t.notifChannel])||void 0===r?void 0:r.listeners.length)?n[t.notifChannel].listeners.map(t=>{t(e)}):s.emit(null===(i=n[t.notifChannel])||void 0===i?void 0:i.config.socketUnsubChannel,{})}))})(s,t,e),{...r,removeListener:()=>((e,t,s)=>{const r=n[t.notifChannel];r&&(r.listeners=r.listeners.filter(t=>t!==e),!r.listeners.length&&r.config.socketUnsubChannel&&s&&(s.emit(r.config.socketUnsubChannel,{}),delete n[t.notifChannel]))})(s,t,e)}),i={...r,addListener:s};a(i)}})})}}}},395(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriptionHandler=void 0;const s=n(3316),r=n(9653),i=n(9515),o=s.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a=new Map,c=e=>new Promise((n,s)=>{t.emit(e,{},(e,t)=>{e?(console.error(e),s(e)):n(t)})});function l(e,s,i){return(0,r.debug)("_unsubscribe",{channelName:e,handler:i}),new Promise(r=>{const o=a.get(e);o?(o.handlers=o.handlers.filter(e=>e!==i),null==n||n({type:"table",command:"unsubscribe",tableName:o.tableName,unsubChannel:s,handlers:o.handlers}),o.handlers.length||(c(s),t.removeListener(e,o.onCall),a.delete(e)),r(!0)):r(!0)})}function u({tableName:e,command:n,param1:s,param2:r}){return new Promise((i,a)=>{t.emit(o,{tableName:e,command:n,param1:s,param2:r},(e,t)=>{e?(console.error(e),a(e)):t&&i(t)})})}const d=new i.FunctionQueuer(async function(e,{tableName:n,command:r,param1:i,param2:o},d){const h=(t,s)=>{let r={unsubscribe:function(){return l(t,s,d)},filter:{...i}};return e[n].update&&(r={...r,update:function(t,s){return e[n].update(i,t,s)}}),e[n].delete&&(r={...r,delete:function(t){return e[n].delete(i,t)}}),Object.freeze(r)},p=Array.from(a.entries()).find(([e,t])=>t.tableName===n&&t.command===r&&(0,s.isEqual)(t.param1||{},i||{})&&(0,s.isEqual)(t.param2||{},o||{}));if(p){const[e,t]=p;return t.handlers.push(d),setTimeout(()=>{const t=a.get(e);(null==t?void 0:t.lastData)&&d(t.lastData)},10),h(e,t.unsubChannel)}const{channelName:f,channelNameReady:m,channelNameUnsubscribe:y}=await u({tableName:n,command:r,param1:i,param2:o}),g=function(e){const t=a.get(f),{data:n,err:s}=e;t?void 0!==n||void 0!==s?(t.lastData=n,t.handlers.forEach(e=>{void 0!==s&&console.error(`Error within running subscription \n ${f}`,s),e(null!=n?n:[],s)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",f)};return t.on(f,g),a.set(f,{lastData:void 0,tableName:n,command:r,param1:i,param2:o,onCall:g,unsubChannel:y,handlers:[d],reAttach:async()=>{await c(y).catch(console.error),await u({tableName:n,command:r,param1:i,param2:o}),t.emit(m,{now:Date.now()})}}),t.emit(m,{now:Date.now()}),h(f,y)},([e,{tableName:t}])=>t);return{addSub:async(e,t,n,s)=>d.run([e,t,n]),subscriptions:a,addServerSub:u,_unsubscribe:l,reAttachAll:async()=>{await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.start",subscriptions:a}));for await(const e of Array.from(a.values()))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),e.onCall({data:[],err:t})}await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},9609(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandler=void 0;const s=n(3316),r=n(9515),i=n(9653),o=s.CHANNELS._preffix;t.getSyncHandler=({socket:e})=>{let t={},n={};function a({tableName:t,command:n,param1:s,param2:r},i){return new Promise((a,c)=>{e.emit(o,{tableName:t,command:n,param1:s,param2:r},(t,n)=>{if(t)console.error(t),c(t);else if(n){const{id_fields:t,synced_field:s,channelName:r}=n;e.emit(r,{onSyncRequest:i({})},e=>{console.log(e)}),a({id_fields:t,synced_field:s,channelName:r})}})})}const c=new r.FunctionQueuer(async function({tableName:t,command:r,param1:o,param2:c},l){const{onSyncRequest:u}=l;function d(t){return Object.freeze({unsync:function(){!function(t,s){(0,i.debug)("_unsync",{channelName:t,triggers:s}),new Promise((r,i)=>{n[t]&&(n[t].triggers=n[t].triggers.filter(e=>e.onPullRequest!==s.onPullRequest&&e.onSyncRequest!==s.onSyncRequest&&e.onUpdates!==s.onUpdates),n[t].triggers.length||(e.emit(t+"unsync",{},(e,t)=>{e?i(e):r(t)}),e.removeListener(t,n[t].onCall),delete n[t]))})}(t,l)},syncData:function(n,s,r){e.emit(t,{onSyncRequest:{...u({}),data:n,deleted:s}},r?e=>{r(e)}:null)}})}const h=Object.keys(n).find(e=>{const i=n[e];return i&&i.tableName===t&&i.command===r&&(0,s.isEqual)(i.param1,o)&&(0,s.isEqual)(i.param2,c)});if(h)return n[h].triggers.push(l),d(h);{const s=await a({tableName:t,command:r,param1:o,param2:c},u),{channelName:i}=s,h=function(e,t){e&&n[i]&&n[i].triggers.map(({onUpdates:n,onSyncRequest:s,onPullRequest:r})=>{e.data?Promise.resolve(n(e)).then(()=>{t({ok:!0})}).catch(e=>{t({err:e})}):e.onSyncRequest?Promise.resolve(s(e.onSyncRequest)).then(e=>t({onSyncRequest:e})).catch(e=>{t({err:e})}):e.onPullRequest?Promise.resolve(r(e.onPullRequest)).then(e=>{t({data:e})}).catch(e=>{t({err:e})}):console.log("unexpected response")})};return n[i]={tableName:t,command:r,param1:o,param2:c,triggers:[l],syncInfo:s,onCall:h},e.on(i,h),d(i)}},([{tableName:e}])=>e);return{destroySyncs:async()=>{(0,i.debug)("destroySyncs",{syncedTables:t}),n={},Object.values(t).forEach(e=>{e.destroy()}),t={}},syncedTables:t,addSync:async function(e,t){return c.run([e,t])},reAttachAll:async()=>{let t=0;Object.entries(n).forEach(async([n,s])=>{const r=s.triggers[0];if(r)try{await a(s,r.onSyncRequest),e.on(n,s.onCall),t++}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}}),t&&console.log("reAttached",t," syncs",n)}}}},4926(e,t,n){"use strict";var s;let r;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.reactImports=t.getReact=void 0;const i=(...e)=>{throw"Must install react"},o=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=r||(r=n(9155))}catch(e){}if(e&&!r)throw new Error("Must install react");return r},(0,t.getReact)();const{useEffect:a=i,useCallback:c=i,useRef:l,useState:u=o}=null!==(s=r)&&void 0!==s?s:{},d={useEffect:a,useCallback:c,useRef:l,useState:u,getReact:()=>r};t.reactImports=d,t.__prglReactInstalled=()=>Boolean(r&&l)},7566(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useAsyncEffectQueue=void 0;const s=n(9501),r=n(4926),{useRef:i}=r.reactImports;t.useAsyncEffectQueue=(e,t,n)=>{const r=i(0),o=i(!0),a=i(),c=i(),l=async()=>{var e,t;if("resolved"===(null===(e=c.current)||void 0===e?void 0:e.state)){const{cleanup:e,effect:t,id:n}=c.current;c.current={id:n,state:"cleaning",effect:t},await e().catch(console.error),c.current={id:n,state:"cleaned",effect:t}}if(a.current&&(!c.current||"cleaned"===c.current.state)&&(null===(t=c.current)||void 0===t?void 0:t.id)!==a.current.id){const e=a.current,{effect:t,id:n}=e;c.current={id:n,state:"resolving",effect:t};const s=await t().then(e=>async()=>{await(null==e?void 0:e())}).catch(e=>(console.error(e),async()=>{}));c.current={id:n,state:"resolved",effect:t,cleanup:s},o.current&&e===a.current&&c.current.id===a.current.id||l()}},u=i(null),d=()=>{n?(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l()},n)):l()};(0,s.useEffectDeep)(()=>(o.current=!0,a.current={effect:e,deps:t,id:++r.current},d(),()=>{o.current=!1,d()}),t)}},9501(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=void 0;const s=n(3316),r=n(4926),{getReact:i,useEffect:o,useRef:a}=r.reactImports,c=i();t.useDeepCompareMemoize=e=>{const t=a();return(0,s.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>c.useMemo(e,n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{o(e,null==n?void 0:n.map(t.useDeepCompareMemoize))}},8552(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useFetch=void 0;const s=n(4926),{useState:r}=s.reactImports,i=n(7566),o=n(6912);t.useFetch=(e,t=[],n)=>{const{skip:s,deps:a=[]}=null!=n?n:{},c={data:void 0,error:void 0,isLoading:!0},[{data:l,error:u,isLoading:d},h]=r(c),p=(0,o.useIsMounted)();return(0,i.useAsyncEffectQueue)(async()=>{if(p()&&!s){h(c);try{const n=await e(...t);if(!p())return;h({data:n,error:void 0,isLoading:!1})}catch(e){if(!p())return;h({data:void 0,error:e,isLoading:!1})}}},[e,...t,...a]),{data:l,error:u,isLoading:d}}},6912(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsMounted=void 0;const s=n(4926),{useEffect:r,useRef:i,useCallback:o}=s.reactImports;t.useIsMounted=()=>{const e=i(!0),t=o(()=>e.current,[]);return r(()=>(e.current=!0,()=>{e.current=!1}),[]),t}},1044(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=t.getIO=void 0;const s=n(9653),r=n(3333),i=n(4926),o=n(7566),a=n(6912);t.getIO=(e=!1)=>{try{return n(8007)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useProstglesClient=({skip:e,socketOptions:n,endpoint:c,token:l,...u}={})=>{const{useRef:d,useState:h}=(0,i.getReact)(!0),[p,f]=h({isLoading:!0,hasError:!1}),m=(0,a.useIsMounted)(),y=d();return(0,o.useAsyncEffectQueue)(async()=>{var i,o;if(e)return;null===(i=y.current)||void 0===i||i.disconnect();const a=(0,t.getIO)(),d="string"==typeof n?{path:n}:n,h={withCredentials:u.credentials&&"omit"!==u.credentials,...d,reconnectionDelay:1e3,reconnection:!0};null!==(o=h.path)&&void 0!==o||(h.path="/ws-api"),l&&(h.auth={token:l});const p=c?a(c,h):a(h);return y.current=p,await(0,s.prostgles)({socket:p,endpoint:c,...u,onReady:e=>{var t,n;m()?(null===(n=u.onDebug)||void 0===n||n.call(u,{type:"onReady",data:e}),f({...e,hasError:!1,isLoading:!1})):null===(t=u.onDebug)||void 0===t||t.call(u,{type:"onReady.notMounted",data:e})}},r.SyncedTable).catch(e=>{m()&&f({isLoading:!1,error:e,hasError:!0})}),()=>{p.disconnect(),p.emit=()=>{throw"Socket disconnected"}}},[u,n,e],80),p}},1632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSubscribe=void 0;const s=n(3316),r=n(4926),{useRef:i,useState:o}=r.reactImports,a=n(6912),c=n(7566);t.useSubscribe=(e,t,n,r,l)=>{const{skip:u}=null!=l?l:{},d={data:void 0,error:void 0,isLoading:!0},[h,p]=o(d),f=i(h);f.current=h;const m=(0,a.useIsMounted)();return(0,c.useAsyncEffectQueue)(async()=>{if(!m()||u)return;(0,s.isEqual)(f.current,d)||p(d);const i=e=>{m()&&p({data:void 0,error:e,isLoading:!1})};try{const s=await e(n,r,e=>{m()&&p({data:t?e[0]:e,error:void 0,isLoading:!1})},i);return()=>{s.unsubscribe()}}catch(e){i(e)}},[e,n,r,u]),h}},6469(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSync=void 0;const s=n(4926),{useState:r}=s.reactImports,i=n(7566),o=n(6912);t.useSync=(e,t,n,s)=>{const{skip:a}=null!=s?s:{},[{data:c,error:l,isLoading:u},d]=r({data:void 0,error:void 0,isLoading:!0}),h=(0,o.useIsMounted)();return(0,i.useAsyncEffectQueue)(async()=>{if(!h()||a)return;const s=e=>{h()&&d({data:void 0,error:e,isLoading:!1})};try{return(await e(t,n,e=>{h()&&d({data:e,error:void 0,isLoading:!1})},s)).$unsync}catch(e){s(e)}},[e,t,n,a]),{data:c,error:l,isLoading:u}}},9653(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.asName=t.debug=t.isClientSide=void 0,t.prostgles=function(e,n){const{endpoint:s,socket:r,onReady:h,onDisconnect:p,onReconnect:f,onSchemaChange:m,onReload:y,onDebug:g,credentials:b,redirect:_}=e;let v;(0,t.debug)("prostgles",{initOpts:e}),m&&(r.removeAllListeners(i.CHANNELS.SCHEMA_CHANGED),r.on(i.CHANNELS.SCHEMA_CHANGED,m));const O=(0,u.getSubscriptionHandler)(e),w=(0,d.getSyncHandler)(e);let S;return(0,l.getSqlHandler)(e),new Promise((t,u)=>{r.removeAllListeners("connect_error"),r.on("connect_error",e=>{u(e)}),r.removeAllListeners(i.CHANNELS.CONNECTION),r.on(i.CHANNELS.CONNECTION,e=>(u(e),"ok")),p&&r.on("disconnect",()=>{S="disconnected",p()}),f&&r.on("connect",()=>{"disconnected"===S&&(S="reconnected")}),r.on(i.CHANNELS.SCHEMA,async d=>{await(null==g?void 0:g({type:"schemaChanged",data:d,state:S}));const{joinTables:p=[],...m}=d,{schema:k,methods:T,tableSchema:C,auth:E,rawSQL:j,err:P}=m;if((null==v?void 0:v.clientSchema)&&(0,i.isEqual)(v.clientSchema,m)||w.destroySyncs().catch(e=>console.error("Error while destroying syncs",e)),P&&console.error("Error on schema change:",P),"connected"!==S&&"reconnected"!==S||!f)v={origin:"onReady",date:new Date,clientSchema:m};else{if(f(r,P),P)return;v={origin:"onReconnect",date:new Date,clientSchema:m}}if(P)return void u(P);const N="reconnected"===S;S="connected";const A=(0,o.getAuthHandler)({authData:E,socket:r,onReload:y,endpoint:s,credentials:b,redirect:_}),{methodHandlers:x,methodSchema:R}=(0,c.getMethods)({onDebug:g,methods:T,socket:r}),{db:F}=(0,a.getDB)({schema:k,onDebug:g,syncedTable:n,syncHandler:w,subscriptionHandler:O,socket:r,tableSchema:C}),D=j?(0,l.getSqlHandler)(e).sql:void 0;O.reAttachAll(),w.reAttachAll(),(async()=>{try{const e={db:F,sql:D,methods:x,methodSchema:R,tableSchema:C,auth:A,socket:r,isReconnect:N};await(null==g?void 0:g({type:"onReady.call",data:e,state:S})),await h(e)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}t(F)})()})})};const i=n(3316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return i.asName}});const o=n(2886),a=n(9930),c=n(7030),l=n(3382),u=n(395),d=n(9609),h="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[h]&&window[h](...e)},r(n(9501),t),r(n(1044),t)},7833(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let s=0,r=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(s++,"%c"===e&&(r=s))}),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(736)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736(e,t,n){e.exports=function(e){function t(e){let n,r,i,o=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),i=r-(n||r);s.diff=i,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,r)=>{if("%%"===n)return"%";o++;const i=t.formatters[r];if("function"==typeof i){const t=e[o];n=i.call(s,t),e.splice(o,1),o--}return n}),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==t.namespaces&&(r=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function r(e,t){let n=0,s=0,r=-1,i=0;for(;n<e.length;)if(s<t.length&&(t[s]===e[n]||"*"===t[s]))"*"===t[s]?(r=s,i=n,s++):(n++,s++);else{if(-1===r)return!1;s=r+1,i++,n=i}for(;s<t.length&&"*"===t[s];)s++;return s===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=n(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},6585(e){var t=1e3,n=60*t,s=60*n,r=24*s,i=7*r;function o(e,t,n,s){var r=t>=1.5*n;return Math.round(e/n)+" "+s+(r?"s":"")}e.exports=function(e,a){a=a||{};var c,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*s;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&isFinite(e))return a.long?(c=e,(l=Math.abs(c))>=r?o(c,l,r,"day"):l>=s?o(c,l,s,"hour"):l>=n?o(c,l,n,"minute"):l>=t?o(c,l,t,"second"):c+" ms"):function(e){var i=Math.abs(e);return i>=r?Math.round(e/r)+"d":i>=s?Math.round(e/s)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},3316(e){var t;Object(this||window),t=()=>(()=>{"use strict";var e={994(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const s=n(472);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,s.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const s=n(472),r=n(704),i=n(441);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const o=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:o,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,s.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&o(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},c=(0,s.getKeys)(a),l=(e,n,o=[],d)=>{const h=`${o.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,p=(0,t.getFieldTypeObj)(n),{type:f,allowedValues:m,nullable:y,optional:g}=p;if(y&&null===e)return;if(g&&void 0===e)return;if(m)return`${o.join(".")} Allowed values are not supported for validation`;if(f){if((0,s.isObject)(f)){if(!(0,s.isObject)(e))return h;for(const t of(0,r.safeGetKeys)(f)){const n=(0,r.safeGetProperty)(f,t);if(!((0,s.isObject)(n)&&n.optional||(0,r.safeHasOwn)(e,t)))return`${[...o,t].join(".")} is missing but required`;const i=l((0,r.safeGetProperty)(e,t),n,[...o,t],d);if(void 0!==i)return i}if(!d?.allowExtraProperties){const t=(0,r.safeGetKeys)(e),n=(0,r.safeGetKeys)(f),s=t.filter(e=>!n.includes(e));if(s.length)return`${o.join(".")} has extra properties: ${s.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,i.includes)(c,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const s=a[e];if(!s)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:s}})(f,p);return t(e,p)?void 0:h}if(p.enum){const t=[];return p.nullable&&t.push(null),p.optional&&t.push(void 0),p.enum.includes(e)?void 0:h}const b=p.arrayOf??(p.arrayOfType?{type:p.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return h+" an array";const t=e.map((e,t)=>l(e,b,[...o,`${t}`],d)).filter(s.isDefined)[0];return void 0!==t?`${h}. Error at index ${o.length>0?o.join(".")+".":""}\n\n${t}`:void 0}const _=p.oneOf??p.oneOfType?.map(e=>({type:e}));if(_){if(!_.length)return h+"to not be empty";let t;if(_.find(n=>{const s=l(e,n,o,d);return t??(t=s),void 0===s}))return;return h}if(p.record){const{keysEnum:t,partial:n,values:i}=p.record;if(!(0,s.isObject)(e))return h+"object";if(n&&(0,s.isEmpty)(e))return;const a=(0,s.getKeys)(e),c=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==c)return`${h} to have key ${c}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${h} has extra keys: ${u}`;if(i)for(const t of(0,r.safeGetKeys)(e)){const n=(0,r.safeGetProperty)(e,t),s=l(n,i,[...o,t],d);if(void 0!==s)return`${s}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(p)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:r,nullable:i,optional:o,record:a}=n,c=n.oneOf??n.oneOfType?.map(e=>({type:e})),l=[];if(i&&l.push("null"),o&&l.push("undefined"),"string"==typeof r)l.push(r);else if(r&&(0,s.isObject)(r)){const e=[];Object.entries(r).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),l.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?l.push("null"):void 0===e?l.push("undefined"):"string"==typeof e?l.push(JSON.stringify(e)):l.push(e)}),c?.forEach(e=>{const t=u(e);l.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,s=t?"?":"",r=n?u(n):"any";e?l.push(`{ [${e.join(" | ")}]${s}: ${r} }`):l.push(`{ [key: string]${s}: ${r} }`)}return l.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",r=!1,i)=>{if(void 0===t&&!r)return{error:`Expecting ${n} to be defined`};if(!(0,s.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=l(t,{type:e},[],i);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const s=l(t,e,void 0,n);return s?{error:s}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,s,r=!1)=>{const{error:i}=(0,t.getJSONBObjectSchemaValidationError)(e,n,s,r);return void 0===i},t.assertJSONBObjectAgainstSchema=(e,n,s,r=!1)=>{const{error:i}=(0,t.getJSONBObjectSchemaValidationError)(e,n,s,r);if(i)throw new Error(i)}},699(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,s){return(0,t.getJSONSchemaObject)(s,{id:`${e}.${n}`})};const s=n(472),r=n(704),i=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:h,title:p,record:f,...m}="string"==typeof e?{type:e}:e;let y={};const g={...(m.enum||m.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!l&&{description:l},...!!p&&{title:p}};if(m.enum?.length){const e=typeof m.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";y=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:i(o)?.type,...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:i(o)?.type}}else(0,s.isObject)(o)?y={type:"object",required:(0,r.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,s.getObjectEntries)(o).reduce((e,[n,s])=>({...e,[n]:(0,t.getJSONSchemaObject)(s)}),{})}:d||h?y={oneOf:(d||h.map(e=>({type:e}))).map(e=>(0,t.getJSONSchemaObject)(e))}:f&&(y={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};y.oneOf?y.oneOf.push(e):y.enum&&!y.enum.includes(null)?y.enum.push(null):y={oneOf:[y,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...y}}},394(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,s="",r){return(0,t.getJSONBTSTypes)(r,{...e,nullable:n.nullable},void 0,s)};const s=n(806),r=n(897),i=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,r.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const r="schema"===n.type;let i=r?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!r){const t=e.find(e=>e.name===n.table)?.columns;i=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,s.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,s.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${i}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("Date","string");return u.allowedValues&&u.type.endsWith("[]")?d+` (${u.allowedValues.map(e=>JSON.stringify(e)).join(" | ")})[]`:d+e}if((0,s.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:i}=u,c=a?" ":" ";let h=` {${c}`+(0,s.getObjectEntries)(i).map(([s,i])=>{const a=(0,r.getFieldTypeObj)(i),u=o(s)?s:JSON.stringify(s);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(h=n(h)),a&&(h=h.split("\n").join("")),d+h}if(u.enum)return d+u.enum.map(e=>i(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:s,partial:r}=u.record,o=e=>r?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>i(e)).join(" | ")??"string"}, ${s?(0,t.getJSONBTSTypes)(e,s,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const s=Object.keys(e);for(const r of n)(0,t.safeHasOwn)(e,r)&&!s.includes(r)&&s.push(r);return s}},618(e,t){Object.defineProperty(t,"__esModule",{value:!0})},521(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const s=n(472);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,s.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806(e,t,n){var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const i=n(472),o=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,i.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const c="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:c+"schema-changed",SCHEMA:c+"schema",DEFAULT:c,SQL:`${c}sql`,SQL_STREAM:`${c}sql-stream`,METHOD:`${c}method`,NOTICE_EV:`${c}notice`,LISTEN_EV:`${c}listen`,REGISTER:`${c}register`,LOGIN:`${c}login`,LOGOUT:`${c}logout`,AUTHGUARD:`${c}authguard`,CONNECTION:`${c}connection`,_preffix:c},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const s=(e.references??[]).map(e=>{const{ftable:n,fcols:s}=e,r=t.find(e=>e.name===n);if(!r)return;const i=r.columns.filter(e=>s.includes(e.name));return i.length?{ref:e,fcolsInfo:i}:void 0}).filter(i.isDefined),[r,...o]=s??[];if(!o.length)return r?.ref;const[a,...c]=s.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},r(n(618),t);var l=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return l.CONTENT_TYPE_TO_EXT}}),r(n(209),t),r(n(319),t),r(n(699),t),r(n(394),t),r(n(994),t),r(n(897),t),r(n(472),t),r(n(778),t)},319(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const s=n(472),r=(e="$leftJoin")=>(t,n,r,i={})=>({[e]:i.path??t,filter:n,...(0,s.omitKeys)(i,["path","select"]),select:r});t.innerJoin=r("$innerJoin"),t.leftJoin=r("$leftJoin")},666(e,t){function n(e,t){var n=e[0],s=e[1],c=e[2],l=e[3];n=r(n,s,c,l,t[0],7,-680876936),l=r(l,n,s,c,t[1],12,-389564586),c=r(c,l,n,s,t[2],17,606105819),s=r(s,c,l,n,t[3],22,-1044525330),n=r(n,s,c,l,t[4],7,-176418897),l=r(l,n,s,c,t[5],12,1200080426),c=r(c,l,n,s,t[6],17,-1473231341),s=r(s,c,l,n,t[7],22,-45705983),n=r(n,s,c,l,t[8],7,1770035416),l=r(l,n,s,c,t[9],12,-1958414417),c=r(c,l,n,s,t[10],17,-42063),s=r(s,c,l,n,t[11],22,-1990404162),n=r(n,s,c,l,t[12],7,1804603682),l=r(l,n,s,c,t[13],12,-40341101),c=r(c,l,n,s,t[14],17,-1502002290),n=i(n,s=r(s,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=i(l,n,s,c,t[6],9,-1069501632),c=i(c,l,n,s,t[11],14,643717713),s=i(s,c,l,n,t[0],20,-373897302),n=i(n,s,c,l,t[5],5,-701558691),l=i(l,n,s,c,t[10],9,38016083),c=i(c,l,n,s,t[15],14,-660478335),s=i(s,c,l,n,t[4],20,-405537848),n=i(n,s,c,l,t[9],5,568446438),l=i(l,n,s,c,t[14],9,-1019803690),c=i(c,l,n,s,t[3],14,-187363961),s=i(s,c,l,n,t[8],20,1163531501),n=i(n,s,c,l,t[13],5,-1444681467),l=i(l,n,s,c,t[2],9,-51403784),c=i(c,l,n,s,t[7],14,1735328473),n=o(n,s=i(s,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,s,c,t[8],11,-2022574463),c=o(c,l,n,s,t[11],16,1839030562),s=o(s,c,l,n,t[14],23,-35309556),n=o(n,s,c,l,t[1],4,-1530992060),l=o(l,n,s,c,t[4],11,1272893353),c=o(c,l,n,s,t[7],16,-155497632),s=o(s,c,l,n,t[10],23,-1094730640),n=o(n,s,c,l,t[13],4,681279174),l=o(l,n,s,c,t[0],11,-358537222),c=o(c,l,n,s,t[3],16,-722521979),s=o(s,c,l,n,t[6],23,76029189),n=o(n,s,c,l,t[9],4,-640364487),l=o(l,n,s,c,t[12],11,-421815835),c=o(c,l,n,s,t[15],16,530742520),n=a(n,s=o(s,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,s,c,t[7],10,1126891415),c=a(c,l,n,s,t[14],15,-1416354905),s=a(s,c,l,n,t[5],21,-57434055),n=a(n,s,c,l,t[12],6,1700485571),l=a(l,n,s,c,t[3],10,-1894986606),c=a(c,l,n,s,t[10],15,-1051523),s=a(s,c,l,n,t[1],21,-2054922799),n=a(n,s,c,l,t[8],6,1873313359),l=a(l,n,s,c,t[15],10,-30611744),c=a(c,l,n,s,t[6],15,-1560198380),s=a(s,c,l,n,t[13],21,1309151649),n=a(n,s,c,l,t[4],6,-145523070),l=a(l,n,s,c,t[11],10,-1120210379),c=a(c,l,n,s,t[2],15,718787259),s=a(s,c,l,n,t[9],21,-343485551),e[0]=h(n,e[0]),e[1]=h(s,e[1]),e[2]=h(c,e[2]),e[3]=h(l,e[3])}function s(e,t,n,s,r,i){return t=h(h(t,e),h(s,i)),h(t<<r|t>>>32-r,n)}function r(e,t,n,r,i,o,a){return s(t&n|~t&r,e,t,i,o,a)}function i(e,t,n,r,i,o,a){return s(t&r|n&~r,e,t,i,o,a)}function o(e,t,n,r,i,o,a){return s(t^n^r,e,t,i,o,a)}function a(e,t,n,r,i,o,a){return s(n^(t|~r),e,t,i,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.md5cycle=n,t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,s=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,c(e.substring(t-64,t)));e=e.substring(t-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(n(r,i),t=0;t<16;t++)i[t]=0;return i[14]=8*s,n(r,i),r}(e))}function h(e,t){return e+t&4294967295}d("hello")},472(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.WAL=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=r,t.filter=i,t.find=function(e,t){return i(e,t)[0]},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,s="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,s){var r={key:t,value:e[t]},i={key:s,value:e[s]};return n(r,i)}}),i=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==i.indexOf(t)){if(s)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=i.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return i.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,s.md5)(t)};function n(n=1){let s=n<1?-1:0,r=!1;for(;!r&&Math.abs(s)<=t.length;){const i=n<1?[s]:[0,s];e.slice(...i)!==t.slice(...i)?r=!0:s+=1*Math.sign(n)}return s}let r=n()-1,i=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:i,text:t.slice(r,o),md5:(0,s.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:i,md5:o}=t;if(null===i||null===e)return i;let a=e.slice(0,n)+i+e.slice(r);if(o&&(0,s.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,s=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,s)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const s=n(666);function r(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function i(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let s={};return t.forEach(t=>{n&&void 0===e[t]||(s[t]=e[t])}),s}return e},t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let s=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],i=+s-+r,o=s<r?-1:s==r?0:1;return"number"===n.tsDataType&&Number.isFinite(i)?i:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],s=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+s))throw"Provided historic item Synced field value is missing/invalid";if(+s===+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:s,delta:r}={...e};if(!s)throw"Expecting { current: object, initial?: object }";const i=this.getIdStr(s);this.changed??(this.changed={}),(t=this.changed)[i]??(t[i]={initial:n,current:s,delta:r}),this.changed[i].current={...this.changed[i].current,...s},this.changed[i].delta={...this.changed[i].delta,...r}}),this.sendItems()},this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:s,throttle:r,historyAgeSeconds:i=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,s).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const s=e.initial?.[n],r=e.current[n];var i,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((i=s)===(o=r)||(["number","string","boolean"].includes(typeof i)?i===o:JSON.stringify(i)===JSON.stringify(o)))||(t[n]=r)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()},r)),this.isOnSending=!0;try{await t(c,l),i&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*i)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),o(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!(o(this.sending)&&o(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const s=[{table:n,on:[{}]},...e??[]];return s.map((e,n)=>{const r=s[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const s=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),i=JSON.parse((0,t.safeStringify)(s));return n?i:r(i,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]}},441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778(e,t,n){var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(102),t),r(n(436),t),r(n(441),t)},102(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,s="trace")=>n(e,t,void 0,s);const n=(e,t,s=new WeakMap,r)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let i=s.get(e);if(i?.has(t)){if("quiet"!==r&&console.trace("Circular reference detected in isEqual",e,t),"error"===r)throw new Error("Circular reference detected in isEqual");return"return-true"===r}if(i||(i=new WeakSet,s.set(e,i)),i.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i],s,r))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),s=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const i of c){if(!(i in t))return!1;{const o=e[i],a=t[i];if(!n(o,a,s,r))return!1}}return!0}},436(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,s)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,n),i.exports}(806)})(),e.exports=t()},9155(t){"use strict";if(void 0===e){var n=new Error("Cannot find module 'react'");throw n.code="MODULE_NOT_FOUND",n}t.exports=e},4110(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},8661(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,s=n.length;e<s;e++){let s=n[e].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}},1015(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),i=e.indexOf("]");-1!=r&&-1!=i&&(e=e.substring(0,r)+e.substring(r,i).replace(/:/g,";")+e.substring(i,e.length));let o=n.exec(e||""),a={},c=14;for(;c--;)a[s[c]]=o[c]||"";return-1!=r&&-1!=i&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,s){t&&(n[t]=s)}),n}(0,a.query),a};const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},4624(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.globalThisShim=t.nextTick=void 0,t.createCookieJar=function(){},t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),t.defaultBinaryType="arraybuffer"},4956(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.SocketWithUpgrade=t.SocketWithoutUpgrade=t.Socket=void 0;const s=n(8223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});var r=n(8223);Object.defineProperty(t,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return r.SocketWithoutUpgrade}}),Object.defineProperty(t,"SocketWithUpgrade",{enumerable:!0,get:function(){return r.SocketWithUpgrade}}),t.protocol=s.Socket.protocol;var i=n(4689);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return i.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return i.TransportError}});var o=n(9419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(5374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(1015);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(4624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(8209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(2071);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var h=n(2071);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return h.XHR}});var p=n(8716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return p.WS}});var f=n(8716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var m=n(4480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return m.WT}})},8223(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const r=n(9419),i=n(5374),o=n(8661),a=n(1015),c=n(4454),l=n(6376),u=n(4624),d=(0,s(n(7833)).default)("engine.io-client:socket"),h="function"==typeof addEventListener&&"function"==typeof removeEventListener,p=[];h&&addEventListener("offline",()=>{d("closing %d connection(s) because the network was lost",p.length),p.forEach(e=>e())},!1);class f extends c.Emitter{constructor(e,t){if(super(),this.binaryType=u.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=(0,a.parse)(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,i.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),h&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(d("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},p.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,u.createCookieJar)()),this._open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",n),new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){d("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=(0,i.byteLength)(n)),t>0&&e>this._maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(d("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,u.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if("function"==typeof t&&(s=t,t=void 0),"function"==typeof n&&(s=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this._onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(d("socket error %j",e),f.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return d("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),h&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=p.indexOf(this._offlineEventListener);-1!==e&&(d("removing listener for the 'offline' event"),p.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=f,f.protocol=l.protocol;class m extends f{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),n=!1;f.priorWebsocketSuccess=!1;const s=()=>{n||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",s=>{if(!n)if("pong"===s.type&&"probe"===s.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{d('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}}))};function r(){n||(n=!0,l(),t.close(),t=null)}const i=n=>{const s=new Error("probe error: "+n);s.transport=t.name,r(),d('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",s)};function o(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),r())}const l=()=>{t.removeListener("open",s),t.removeListener("error",i),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",s),t.once("error",i),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}t.SocketWithUpgrade=m,t.Socket=class extends m{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>r.transports[e]).filter(e=>!!e)),super(e,n)}}},4689(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const r=n(6376),i=n(4454),o=n(5374),a=n(8661),c=(0,s(n(7833)).default)("engine.io-client:transport");class l extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}t.TransportError=l;class u extends i.Emitter{constructor(e){super(),this.writable=!1,(0,o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new l(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):c("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,r.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,a.encode)(e);return t.length?"?"+t:""}}t.Transport=u},9419(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const s=n(2071),r=n(8716),i=n(4480);t.transports={websocket:r.WS,webtransport:i.WT,polling:s.XHR}},8209(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const s=n(528);class r extends s.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(e=>this.onData(e))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()}).catch(e=>{this.onError("fetch write error",e)})}_fetch(e){var t;const n=void 0!==e,s=new Headers(this.opts.extraHeaders);return n&&s.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(s),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:s,credentials:this.opts.withCredentials?"include":"omit"}).then(e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e})}}t.Fetch=r},2071(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const r=n(528),i=n(4454),o=n(5374),a=n(4624),c=n(4110),l=(0,s(n(7833)).default)("engine.io-client:polling");function u(){}class d extends r.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){l("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}t.BaseXHR=d;class h extends i.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{l("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},l("xhr data %s",this._data),n.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=h.requestsCount++,h.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=u,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete h.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=h,h.requestsCount=0,h.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",p);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,p,!1)}function p(){for(let e in h.requests)h.requests.hasOwnProperty(e)&&h.requests[e].abort()}const f=function(){const e=m({xdomain:!1});return e&&null!==e.responseType}();function m(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||c.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends d{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new h(m,this.uri(),e)}}},528(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;const r=n(4689),i=n(5374),o=n(6376),a=(0,s(n(7833)).default)("engine.io-client:polling");class c extends r.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{a("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(a("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){a("pre-pause polling complete"),--e||t()})),this.writable||(a("we are currently writing - waiting to pause"),e++,this.once("drain",function(){a("pre-pause writing complete"),--e||t()}))}else t()}_poll(){a("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){a("polling got data %s",e),(0,o.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this._poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),e()):(a("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}t.Polling=c},8716(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=t.BaseWS=void 0;const r=n(4689),i=n(5374),o=n(6376),a=n(4624),c=(0,s(n(7833)).default)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class u extends r.Transport{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=l?{}:(0,i.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],s=t===e.length-1;(0,o.encodePacket)(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){c("websocket closed before onclose event")}s&&(0,a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}t.BaseWS=u;const d=a.globalThisShim.WebSocket||a.globalThisShim.MozWebSocket;t.WS=class extends u{createSocket(e,t,n){return l?new d(e,t,n):t?new d(e,t):new d(e)}doWrite(e,t){this.ws.send(t)}}},4480(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const r=n(4689),i=n(4624),o=n(6376),a=(0,s(n(7833)).default)("engine.io-client:webtransport");class c extends r.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{a("transport closed gracefully"),this.onClose()}).catch(e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=(0,o.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=(0,o.createPacketEncoderStream)();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();const r=()=>{n.read().then(({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),r())}).catch(e=>{a("an error occurred while reading: %s",e)})};r();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&(0,i.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}}t.WT=c},5374(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=r.bind(s.globalThisShim),e.clearTimeoutFn=i.bind(s.globalThisShim)):(e.setTimeoutFn=s.globalThisShim.setTimeout.bind(s.globalThisShim),e.clearTimeoutFn=s.globalThisShim.clearTimeout.bind(s.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const s=n(4624),r=s.globalThisShim.setTimeout,i=s.globalThisShim.clearTimeout},2046(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const s=Object.create(null);t.PACKET_TYPES_REVERSE=s,Object.keys(n).forEach(e=>{s[n[e]]=e}),t.ERROR_PACKET={type:"error",data:"parser error"}},2745(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)s[n.charCodeAt(e)]=e;t.encode=e=>{let t,s=new Uint8Array(e),r=s.length,i="";for(t=0;t<r;t+=3)i+=n[s[t]>>2],i+=n[(3&s[t])<<4|s[t+1]>>4],i+=n[(15&s[t+1])<<2|s[t+2]>>6],i+=n[63&s[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i},t.decode=e=>{let t,n,r,i,o,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const u=new ArrayBuffer(a),d=new Uint8Array(u);for(t=0;t<c;t+=4)n=s[e.charCodeAt(t)],r=s[e.charCodeAt(t+1)],i=s[e.charCodeAt(t+2)],o=s[e.charCodeAt(t+3)],d[l++]=n<<2|r>>4,d[l++]=(15&r)<<4|i>>2,d[l++]=(3&i)<<6|63&o;return u}},2662(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const s=n(2046),r=n(2745),i="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:o(e.substring(1),t)}:s.PACKET_TYPES_REVERSE[n]?e.length>1?{type:s.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:s.PACKET_TYPES_REVERSE[n]}:s.ERROR_PACKET};const o=(e,t)=>{if(i){const n=(0,r.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},2686(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=void 0,t.encodePacketToBinary=function(e,t){return r&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):i&&(e.data instanceof ArrayBuffer||o(e.data))?t(l(e.data)):void a(e,!1,e=>{u||(u=new TextEncoder),t(u.encode(e))})};const s=n(2046),r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>r&&t instanceof Blob?n?a(t):c(t,a):i&&(t instanceof ArrayBuffer||o(t))?n?a(t):c(new Blob([t]),a):a(s.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u},6376(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=void 0,t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,s.encodePacketToBinary)(e,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,s)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(s))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)})}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let s=0,o=-1,u=!1;return new TransformStream({transform(d,h){for(n.push(d);;){if(0===s){if(c(n)<1)break;const e=l(n,1);u=!(128&~e[0]),o=127&e[0],s=o<126?3:126===o?1:2}else if(1===s){if(c(n)<2)break;const e=l(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),s=3}else if(2===s){if(c(n)<8)break;const e=l(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){h.enqueue(i.ERROR_PACKET);break}o=r*Math.pow(2,32)+t.getUint32(4),s=3}else{if(c(n)<o)break;const e=l(n,o);h.enqueue((0,r.decodePacket)(u?e:a.decode(e),t)),s=0}if(0===o||o>e){h.enqueue(i.ERROR_PACKET);break}}}})};const s=n(2686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return s.encodePacket}});const r=n(2662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const i=n(2046),o=String.fromCharCode(30);let a;function c(e){return e.reduce((e,t)=>e+t.length,0)}function l(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)n[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),n}t.encodePayload=(e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach((e,a)=>{(0,s.encodePacket)(e,!1,e=>{r[a]=e,++i===n&&t(r.join(o))})})},t.decodePayload=(e,t)=>{const n=e.split(o),s=[];for(let e=0;e<n.length;e++){const i=(0,r.decodePacket)(n[e],t);if(s.push(i),"error"===i.type)break}return s},t.protocol=4},7743(e,t){"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=l,t.connect=l,t.default=l;const r=n(6894),i=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return i.Manager}});const o=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,s(n(7833)).default)("socket.io-client"),c={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=(0,r.url)(e,t.path||"/socket.io"),s=n.source,o=n.id,l=n.path,u=c[o]&&l in c[o].nsps;let d;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(a("ignoring socket cache for %s",s),d=new i.Manager(s,t)):(c[o]||(a("new io instance for %s",s),c[o]=new i.Manager(s,t)),d=c[o]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(l,{Manager:i.Manager,Socket:o.Socket,io:l,connect:l});var u=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(4956);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return d.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return d.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return d.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return d.WebTransport}}),e.exports=l},3776(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,r)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&s(t,e,n);return r(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),l=i(n(4627)),u=n(5942),d=n(7743),h=n(4454),p=(0,o(n(7833)).default)("socket.io-client:manager");class f extends h.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,(0,a.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new d.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||l;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=(0,u.on)(t,"open",function(){n.onopen(),e&&e()}),r=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=(0,u.on)(t,"error",r);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const n=this.setTimeoutFn(()=>{p("connect attempt timed out after %d",e),s(),r(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push((0,u.on)(e,"ping",this.onping.bind(this)),(0,u.on)(e,"data",this.ondata.bind(this)),(0,u.on)(e,"error",this.onerror.bind(this)),(0,u.on)(e,"close",this.onclose.bind(this)),(0,u.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){(0,a.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){p("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){p("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;p("closed due to %s",e),this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();p("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(p("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(p("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(p("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=f},5942(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},6214(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const r=n(4627),i=n(5942),o=n(4454),a=(0,s(n(7833)).default)("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class l extends o.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,i.on)(e,"open",this.onopen.bind(this)),(0,i.on)(e,"packet",this.onpacket.bind(this)),(0,i.on)(e,"error",this.onerror.bind(this)),(0,i.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,i;if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:r.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const n=t.pop();this._registerAckCallback(e,n),o.id=e}const l=null===(s=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===s?void 0:s.writable,u=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!l?a("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var n;const s=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===s)return void(this.acks[e]=t);const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,s)=>{const r=(e,t)=>e?s(e):n(t);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...s)=>n!==this._queue[0]?a("packet [%d] already acknowledged",n.id):(null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...s)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:r.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...s){n||(n=!0,a("sending ack %j",s),t.packet({type:r.PacketType.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:r.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}t.Socket=l},6894(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=function(e,t="",n){let s=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(i("protocol-less url %s",e),e=void 0!==n?n.protocol+"//"+e:"https://"+e),i("parse %s",e),s=(0,r.parse)(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const o=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+o+":"+s.port+t,s.href=s.protocol+"://"+o+(n&&n.port===s.port?"":":"+s.port),s};const r=n(4956),i=(0,s(n(7833)).default)("socket.io-client:url")},2545(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deconstructPacket=function(e){const t=[],n=e.data,s=e;return s.data=r(n,t),s.attachments=t.length,{packet:s,buffers:t}},t.reconstructPacket=function(e,t){return e.data=i(e.data,t),delete e.attachments,e};const s=n(9133);function r(e,t){if(!e)return e;if((0,s.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let s=0;s<e.length;s++)n[s]=r(e[s],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=r(e[s],t));return n}return e}function i(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=i(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=i(e[n],t));return e}},4627(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0,t.isPacketValid=function(e){return"string"==typeof e.nsp&&(void 0===(t=e.id)||d(t))&&function(e,t){switch(e){case c.CONNECT:return void 0===t||h(t);case c.DISCONNECT:return void 0===t;case c.EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:return Array.isArray(t);case c.CONNECT_ERROR:return"string"==typeof t||h(t);default:return!1}}(e.type,e.data);var t};const s=n(4454),r=n(2545),i=n(9133),o=(0,n(7833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c||(t.PacketType=c={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return o("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,i.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),o("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,r.deconstructPacket)(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}};class l extends s.Emitter{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},"function"==typeof e?{reviver:e}:e)}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new u(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,i.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const s=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(s,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");const i=Number(r);if(!d(i)||i<0)throw new Error("Illegal attachments");if(i>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=i}if("/"===e.charAt(t+1)){const s=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(s,t)}else n.nsp="/";const s=e.charAt(t+1);if(""!==s&&Number(s)==s){const s=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){const s=this.tryParse(e.substr(t));if(!l.isPayloadValid(n.type,s))throw new Error("invalid payload");n.data=s}return o("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return h(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||h(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=l;class u{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,r.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function h(e){return"[object Object]"===Object.prototype.toString.call(e)}},9133(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBinary=o,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(e(t[n]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1};const n="function"==typeof ArrayBuffer,s=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),i="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);function o(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||r&&e instanceof Blob||i&&e instanceof File}},4454(e,t,n){"use strict";function s(e){if(e)return function(e){for(var t in s.prototype)e[t]=s.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>s}),s.prototype.on=s.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},s.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},s.prototype.off=s.prototype.removeListener=s.prototype.removeAllListeners=s.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<s.length;r++)if((n=s[r])===t||n.fn===t){s.splice(r,1);break}return 0===s.length&&delete this._callbacks["$"+e],this},s.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(n){s=0;for(var r=(n=n.slice(0)).length;s<r;++s)n[s].apply(this,t)}return this},s.prototype.emitReserved=s.prototype.emit,s.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},s.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},n={};function s(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e].call(i.exports,i,i.exports,s),i.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=function(e){return(0,t.prostgles)(e,n.SyncedTable)};const t=s(9653),n=s(3333)})(),r})());