prostgles-client 4.0.260 → 4.0.261
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 +1 -1
- package/dist/index.no-sync.js +1 -1
- package/package.json +2 -2
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]}}(this||window,(e=>(()=>{var t={515:(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.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)})),n=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=[],n=[];this.queue.forEach((async(e,s)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:s,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const s=n(316),r=n(476),i="DEBUG_SYNCEDTABLE",o="undefined"!=typeof window;t.debug=function(...e){o&&window[i]&&window[i](...e)};const a={array:"array",localStorage:"localStorage",object:"object"};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:d,skipFirstTrigger:h=!1,select:p="*",storageType:f="object",patchText:y=!1,patchJSON:m=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},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=[])=>{if(!this.isSynced)return;const t=[],n=[],s=[];if(e.map((({idObj:e,newItem:r,delta:i})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(i),s.push(e))})),this.onChange||this.multiSubscriptions.length){const e=[],s=[];if(this.getItems().map((r=>{e.push({...r});const i=t.findIndex((e=>this.matchesIdObj(r,e)));s.push(n[i])})),this.onChange)try{this.onChange(e,s)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,s)}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.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const s=this.getIdObj(e);return this.setItem(s,void 0,!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,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";const i=[];let o;const a=[];await Promise.all(e.map((async(e,n)=>{var r;const c={...e.idObj};let u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});const d=this.getItem(c),h=d.index,p=d.data;!t&&!(0,s.isEmpty)(u)||(0,s.isEmpty)(p)||(u=this.getDelta(p||{},u)),t||(u[this.synced_field]=Date.now());let f={...p,...u,...c};p&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(f=l({...p,...c},{...u})),o=p?p[this.synced_field]<f[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(f,h);const y={idObj:c,delta:u,oldItem:p,newItem:f,status:o,from_server:t};return t||a.push({initial:p,current:{...f}}),(0,s.isEmpty)(y.delta)||i.push(y),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(i.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=u(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(t))}else this.storageType===a.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},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 e=this.storageType===a.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});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 u(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=p,this.onChange=r,c&&(this.onDebug=t=>c({...t,type:"sync",tableName:e},this)),!a[f])throw"Invalid storage type. Expecting one of: "+Object.keys(a).join(", ");o||f!==a.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),f="object"),this.storageType=f,this.patchText=y,this.patchJSON=m;const b=d[e];if(!b)throw`${e} table not found in db`;this.db=d;const{id_fields:_,synced_field:v,throttle:O=100,batch_size:w=50}=b._syncInfo;if(!_||!v)throw"id_fields/synced_field missing";this.id_fields=_,this.synced_field=v,this.batch_size=w,this.throttle=O,this.skipFirstTrigger=h,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const S={id_fields:_,synced_field:v,throttle:O};b._sync(n,{select:p},{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({...S,batch_size:w,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({...S,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()})),b.getColumns&&b.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).data,$find:e=>this.getItem(e).data,$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 t;return t=this.storageType===a.localStorage?this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===a.array?this.items.find((t=>this.matchesIdObj(t,e))):{...this.itemsObj}[this.getIdStr(e)],{data:u(t),index:-1}}setItem(e,t,n=!1,s=!1){const r=u(e);if(this.storageType===a.localStorage){let e=this.getItems();s?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),o&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===a.array)s?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(s)delete this.itemsObj[this.getIdStr(r)];else{const e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function l(e,t){const n=e?u(e):e,r=t?u(t):t,i=Object.assign({},n);return(0,s.isObject)(n)&&(0,s.isObject)(r)&&Object.keys(r).forEach((e=>{(0,s.isObject)(r[e])?e in n?i[e]=l(n[e],r[e]):Object.assign(i,{[e]:r[e]}):Object.assign(i,{[e]:r[e]})})),i}function u(e){if(o&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>u(e)));if((0,s.isObject)(e)){const t={};return(0,s.getKeys)(e).map((n=>{t[n]=u(e[n])})),t}return e}t.SyncedTable=c,t.default=l,t.quickClone=u},476:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMultiSyncSubscription=void 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).data,s),$find:e=>r(this.getItem(e).data,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}}},886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const s=n(316),r=n(653);t.getAuthHandler=({authData:e,socket:n,onReload:o})=>{if((null==e?void 0:e.pathGuard)&&r.isClientSide){const e=e=>{(null==e?void 0:e.shouldReload)&&(o?o():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 a={loginType:null==e?void 0:e.loginType,login:void 0,preferredLogin:null==e?void 0:e.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,providers:null==e?void 0:e.providers};if(e){const{providers:n,signupWithEmailAndPassword:r,loginType:o}=e;a.loginWithProvider=(0,s.isEmpty)(n)?void 0:n&&Object.entries(n).reduce(((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e)),{}),a.login=o&&(async e=>(0,t.authRequest)(i("/login"),e)),a.signupWithEmailAndPassword=r&&(e=>(0,t.authRequest)(i(r.url),e))}return(null==e?void 0:e.user)?{isLoggedin:!0,user:e.user,logout:async()=>(0,t.authRequest)(i("/logout"),{},"POST"),...a}:{isLoggedin:!1,user:void 0,...a}};const i=e=>{const{search:t}=window.location;return e+t};t.authRequest=async(e,t,n)=>{const s=await fetch(e,{method:null!=n?n:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)}});if(!s.ok){const e=await s.json().catch((()=>s.text())).catch((()=>s.statusText));return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const r=await s.json().catch((async()=>({message:await s.text()}))).catch((()=>({message:s.statusText})));return s.redirected?{...r,success:!0,redirect_url:s.url}:r}},930:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDBO=void 0;const s=n(316),r=n(653),i=n(333),o=s.CHANNELS._preffix;t.getDBO=({schema:e,tableSchema:t,onDebug:n,syncedTable:a,syncHandler:c,subscriptionHandler:l,socket:u})=>{const d=(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"},h=["subscribe","subscribeOne"],p={},f=(0,i.quickClone)(e);return(0,s.getObjectEntries)(f).forEach((([e,i])=>{const f=(0,s.getKeys)(i);p[e]={};const y=p[e];f.sort(((e,t)=>h.includes(e)-h.includes(t))).forEach((f=>{if("sync"===f){if(y._syncInfo={...i[f]},a){y.getSync=async(t,s={})=>(await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{filter:t,params:s}})),a.create({name:e,onDebug:n,filter:t,db:p,...s}));const t=async(t={},r={},i)=>{const o=`${e}.${JSON.stringify(t)}.${JSON.stringify((0,s.omitKeys)(r,["handlesOnData"]))}`;return c.syncedTables[o]||(c.syncedTables[o]=await a.create({...r,onDebug:n,name:e,filter:t,db:p,onError:i})),c.syncedTables[o]},i=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}})),d(s,r,i,o);const a=await t(s,r,o);return await a.sync(i,r.handlesOnData)},o=async(s,r={handlesOnData:!0},i,o)=>{await(null==n?void 0:n({type:"table",command:"syncOne",tableName:e,data:{basicFilter:s,options:r}})),d(s,r,i,o);const a=await t(s,r,o);return await a.syncOne(s,i,r.handlesOnData)};y.sync=i,y.syncOne=o,y.useSync=(e,t,n)=>(0,r.useSync)(i,e,t,n),y.useSyncOne=(e,t,n)=>(0,r.useSync)(o,e,t,n)}y._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}})),c.addSync({tableName:e,command:f,param1:t,param2:s},r)}}else if(h.includes(f)){const t=async function(t={},s={},r,i){return await(null==n?void 0:n({type:"table",command:f,tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),d(t,s,r,i),l.addSub(p,{tableName:e,command:f,param1:t,param2:s},r,i)};y[f]=t;const s="subscribeOne",i="subscribe"===f?"useSubscribe":"subscribeOne"===f?"useSubscribeOne":void 0;i&&(y[i]=(e,n,i)=>(0,r.useSubscribe)(t,f===s,e,n,i)),f!==s&&h.includes(s)||(y[s]=async function(t,s,r,i){return await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),d(t,s,r,i),l.addSub(p,{tableName:e,command:f,param1:t,param2:s},(e=>{r(e[0])}),i)})}else{const s=async function(s,r,i){var a;if("getColumns"===f&&!s&&!r&&!i){const n=null===(a=null==t?void 0:t.find((t=>t.name===e)))||void 0===a?void 0:a.columns;if(n)return n}return await(null==n?void 0:n({type:"table",command:f,tableName:e,data:{param1:s,param2:r,param3:i}})),new Promise(((t,n)=>{u.emit(o,{tableName:e,command:f,param1:s,param2:r,param3:i},((e,s)=>{e?n(e):t(s)}))}))};y[f]=s;const i="findOne"===f?"useFindOne":"find"===f?"useFind":"count"===f?"useCount":"size"===f?"useSize":void 0;i&&(y[i]=(e,t,n)=>(0,r.useFetch)(s,[e,t],n))}}))})),{dbo:p}}},30:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const s=n(316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let r={};return JSON.parse(JSON.stringify(t)).map((t=>{const i="string"==typeof t,o=i?t:t.name,a=async function(...t){return await(null==e?void 0:e({type:"method",command:o,data:{params:t}})),new Promise(((e,r)=>{n.emit(s.CHANNELS.METHOD,{method:o,params:t},((t,n)=>{t?r(t):e(n)}))}))};r[o]=i?a:{...t,run:a}})),r=Object.freeze(r),{methodsObj:r}}},382:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const s=n(316);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(316),r=n(653),i=n(515),o=s.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a={},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[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),delete a[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,h){const p=(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)},f=Object.entries(a).find((([e,t])=>t.tableName===n&&t.command===r&&(0,s.isEqual)(t.param1||{},i||{})&&(0,s.isEqual)(t.param2||{},o||{})));if(f){const e=f[0];return f[1].handlers.push(d),f[1].errorHandlers.push(h),setTimeout((()=>{var t,n;(null===(t=a[e])||void 0===t?void 0:t.lastData)&&d(null===(n=a[e])||void 0===n?void 0:n.lastData)}),10),p(e,f[1].unsubChannel)}const{channelName:y,channelNameReady:m,channelNameUnsubscribe:g}=await u({tableName:n,command:r,param1:i,param2:o}),b=function(e){const t=a[y];t?e.data?(t.lastData=e.data,t.handlers.forEach((t=>{t(e.data)}))):e.err?t.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",y)},_=h||function(e){console.error(`Uncaught error within running subscription \n ${y}`,e)};return t.on(y,b),a[y]={lastData:void 0,tableName:n,command:r,param1:i,param2:o,onCall:b,unsubChannel:g,handlers:[d],errorHandlers:[_],reAttach:async()=>{await c(g).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()}),p(y,g)}),(([e,{tableName:t}])=>t));return{addSub:async(e,t,n,s)=>d.run([e,t,n,s]),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 Object.values(a))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),Object.values(e.errorHandlers).forEach((e=>null==e?void 0:e(t)))}await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},609:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandler=void 0;const s=n(316),r=n(515),i=n(653),o=s.CHANNELS._preffix;t.getSyncHandler=({socket:e,onDebug:t})=>{let n={},a={};function c({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 l=new r.FunctionQueuer((async function({tableName:t,command:n,param1:r,param2:o},l){const{onSyncRequest:u}=l;function d(t){return Object.freeze({unsync:function(){!function(t,n){(0,i.debug)("_unsync",{channelName:t,triggers:n}),new Promise(((s,r)=>{a[t]&&(a[t].triggers=a[t].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),a[t].triggers.length||(e.emit(t+"unsync",{},((e,t)=>{e?r(e):s(t)})),e.removeListener(t,a[t].onCall),delete a[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(a).find((e=>{const i=a[e];return i&&i.tableName===t&&i.command===n&&(0,s.isEqual)(i.param1,r)&&(0,s.isEqual)(i.param2,o)}));if(h)return a[h].triggers.push(l),d(h);{const s=await c({tableName:t,command:n,param1:r,param2:o},u),{channelName:i}=s,h=function(e,t){e&&a[i]&&a[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 a[i]={tableName:t,command:n,param1:r,param2:o,triggers:[l],syncInfo:s,onCall:h},e.on(i,h),d(i)}}),(([{tableName:e}])=>e));return{destroySyncs:async()=>{(0,i.debug)("destroySyncs",{syncedTables:n}),a={},Object.values(n).map((e=>{e&&e.destroy&&e.destroy()})),n={}},syncedTables:n,addSync:async function(e,t){return l.run([e,t])},reAttachAll:async()=>{let t=0;Object.entries(a).forEach((async([n,s])=>{const r=s.triggers[0];if(r)try{await c(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",a)}}}},653:function(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.prostgles=t.asName=t.debug=t.isClientSide=void 0;const i=n(316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return i.asName}});const o=n(886),a=n(930),c=n(30),l=n(382),u=n(395),d=n(609),h="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[h]&&window[h](...e)},r(n(512),t),r(n(641),t),t.prostgles=function(e,n){const{socket:s,onReady:r,onDisconnect:h,onReconnect:p,onSchemaChange:f,onReload:y,onDebug:m}=e;let g;(0,t.debug)("prostgles",{initOpts:e}),f&&(s.removeAllListeners(i.CHANNELS.SCHEMA_CHANGED),s.on(i.CHANNELS.SCHEMA_CHANGED,f));const b=(0,u.getSubscriptionHandler)(e),_=(0,d.getSyncHandler)(e),v=(0,l.getSqlHandler)(e);let O;return new Promise(((e,t)=>{s.removeAllListeners("connect_error"),s.on("connect_error",(e=>{t(e)})),s.removeAllListeners(i.CHANNELS.CONNECTION),s.on(i.CHANNELS.CONNECTION,(e=>(t(e),"ok"))),h&&s.on("disconnect",(()=>{O="disconnected",h()})),p&&s.on("connect",(()=>{"disconnected"===O&&(O="reconnected")})),s.on(i.CHANNELS.SCHEMA,(async l=>{await(null==m?void 0:m({type:"schemaChanged",data:l,state:O}));const{joinTables:u=[],...d}=l,{schema:h,methods:f,tableSchema:w,auth:S,rawSQL:k,err:T}=d;if((null==g?void 0:g.clientSchema)&&(0,i.isEqual)(g.clientSchema,d)||_.destroySyncs().catch((e=>console.error("Error while destroying syncs",e))),T&&console.error("Error on schema change:",T),"connected"!==O&&"reconnected"!==O||!p)g={origin:"onReady",date:new Date,clientSchema:d};else{if(p(s,T),T)return;g={origin:"onReconnect",date:new Date,clientSchema:d}}if(T)return void t(T);const E="reconnected"===O;O="connected";const C=(0,o.getAuthHandler)({authData:S,socket:s,onReload:y}),{methodsObj:j}=(0,c.getMethods)({onDebug:m,methods:f,socket:s}),{dbo:P}=(0,a.getDBO)({schema:h,onDebug:m,syncedTable:n,syncHandler:_,subscriptionHandler:b,socket:s,tableSchema:w});k&&(P.sql=v.sql),b.reAttachAll(),_.reAttachAll(),u.flat().map((e=>{var t,n,s,r;null!==(t=P.innerJoin)&&void 0!==t||(P.innerJoin={}),null!==(n=P.leftJoin)&&void 0!==n||(P.leftJoin={}),null!==(s=P.innerJoinOne)&&void 0!==s||(P.innerJoinOne={}),null!==(r=P.leftJoinOne)&&void 0!==r||(P.leftJoinOne={});const o=(0,i.getJoinHandlers)(e);P.leftJoin[e]=o.leftJoin,P.innerJoin[e]=o.innerJoin,P.leftJoinOne[e]=o.leftJoinOne,P.innerJoinOne[e]=o.innerJoinOne})),(async()=>{try{const e={dbo:P,methods:j,tableSchema:w,auth:C,isReconnect:E};await(null==m?void 0:m({type:"onReady.call",data:e,state:O})),await r(P,j,w,C,E)}catch(e){console.error("Prostgles: Error within onReady: \n",e),t(e)}e(P)})()}))}))}},512:(e,t,n)=>{"use strict";var s;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=t.getIO=t.getReact=void 0;const r=n(316);let i;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=i||(i=n(155))}catch(e){}if(e&&!i)throw new Error("Must install react");return i},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(s=i)&&void 0!==s?s:{};t.getIO=(e=!1)=>{try{return n(7)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useDeepCompareMemoize=e=>{const t=u();return(0,r.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>i.useMemo(e,null==n?void 0:n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{c(e,null==n?void 0:n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const s=u(),r=u(),i=async()=>{var e;if("resolved"===(null===(e=r.current)||void 0===e?void 0:e.state)){const{cleanup:e,effect:t}=r.current;r.current={state:"cleaning",effect:t},await e().catch(console.error),r.current=void 0}if(s.current&&!r.current){const e=s.current,{effect:t}=e;r.current={state:"resolving",effect:t};const n=await t().then((e=>async()=>{await(null==e?void 0:e())})).catch((e=>(console.error(e),async()=>{})));r.current={state:"resolved",effect:t,cleanup:n},e!==s.current&&i()}};(0,t.useEffectDeep)((()=>(s.current={effect:e,deps:n},i(),()=>{s.current=void 0,i()})),n)},t.useEffectAsync=(e,n)=>{const s=u({cleanup:void 0,effect:e,cleanupEffect:void 0});s.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(s.current.cleanup=t,s.current.cleanupEffect===e&&t())})),()=>{var t,n;s.current.cleanupEffect=e,null===(n=(t=s.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=()=>{const e=u(!0),t=l((()=>e.current),[]);return c((()=>(e.current=!0,()=>{e.current=!1})),[]),t},t.usePromise=(e,n=[])=>{const s=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},i=e=>{try{return(0,r.isObject)(e)&&!s(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const s of n){const n=e[s];try{t[s]="function"==typeof n?await n():await n}catch(e){console.error(e)}}return t},[a,c]=d(i(e)?{}:void 0),l=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{let t;try{if(i(e))t=await o(e);else{const n=await e();t=i(n)?await o(n):s(n)?await n():n}}catch(e){console.error(e)}l()&&c(t)}),n),a},t.useSubscribe=(e,n,s,i,o)=>{const{skip:a}=null!=o?o:{},c={data:void 0,error:void 0,isLoading:!0},[l,h]=d(c),p=u(l);p.current=l;const f=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(!f()||a)return;(0,r.isEqual)(p.current,c)||h(c);const t=e=>{f()&&h({data:void 0,error:e,isLoading:!1})};try{const r=await e(s,i,(e=>{f()&&h({data:n?e[0]:e,error:void 0,isLoading:!1})}),t);return()=>{r.unsubscribe()}}catch(e){t(e)}}),[e,s,i,a]),l},t.useSync=(e,n,s,r)=>{const{skip:i}=null!=r?r:{},[{data:o,error:a,isLoading:c},l]=d({data:void 0,error:void 0,isLoading:!0}),u=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(!u()||i)return;const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(n,s,(e=>{u()&&l({data:e,error:void 0,isLoading:!1})}),t)).$unsync}catch(e){t(e)}}),[e,n,s,i]),{data:o,error:a,isLoading:c}},t.useFetch=(e,n=[],s)=>{const{skip:r,deps:i=[]}=null!=s?s:{},o={data:void 0,error:void 0,isLoading:!0},[{data:a,error:c,isLoading:l},u]=d(o),h=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(h()&&!r){u(o);try{const t=await e(...n);if(!h())return;u({data:t,error:void 0,isLoading:!1})}catch(e){if(!h())return;u({data:void 0,error:e,isLoading:!1})}}}),[...n,...i]),{data:a,error:c,isLoading:l}},t.__prglReactInstalled=()=>Boolean(i&&u)},641:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=void 0;const s=n(316),r=n(333),i=n(653),o=n(512);t.useProstglesClient=({skip:e,socketOptions:t,...n}={})=>{const{useRef:a,useState:c}=(0,o.getReact)(!0),[l,u]=c({isLoading:!0}),d=(0,o.useIsMounted)(),h=a();return(0,o.useAsyncEffectQueue)((async()=>{var a;if(e)return;null===(a=h.current)||void 0===a||a.disconnect();const c=(0,o.getIO)(),l="string"==typeof t?{path:t}:t,p={reconnectionDelay:1e3,reconnection:!0,...(0,s.omitKeys)(null!=l?l:{},["uri"])},f="string"==typeof(null==l?void 0:l.uri)?c(l.uri,p):c(p);return h.current=f,await(0,i.prostgles)({socket:f,...n,onReady:(...e)=>{var t,s;const[r,i,o,a,c]=e,l={dbo:r,methods:i,tableSchema:o,auth:a,isReconnect:c,socket:f};d()?(null===(s=n.onDebug)||void 0===s||s.call(n,{type:"onReady",data:l}),u({...l,isLoading:!1})):null===(t=n.onDebug)||void 0===t||t.call(n,{type:"onReady.notMounted",data:l})}},r.SyncedTable).catch((e=>{d()&&u({isLoading:!1,error:e,hasError:!0})})),()=>{f.disconnect()}}),[n,t,e]),l}},833:(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")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$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){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}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.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),r=s.length;for(n=0;n<r;n++)s[n]&&("-"===(e=s[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,s;for(n=0,s=t.skips.length;n<s;n++)if(t.skips[n].test(e))return!1;for(n=0,s=t.names.length;n<s;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(585),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}},585: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))}},316:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={994:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,s){return(0,t.getJSONSchemaObject)(s,{id:`${e}.${n}`})};const s=n(472);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=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||"Lookup"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:i,arrayOf:o,arrayOfType:a,description:c,nullable:l,oneOf:u,oneOfType:d,title:h,record:p,...f}="string"==typeof e?{type:e}:e;let y={};const m={...(f.enum||f.allowedValues?.length&&("string"!=typeof i||!i.endsWith("[]")))&&{enum:f.allowedValues?.slice(0)??f.enum.slice(0)},...!!c&&{description:c},...!!h&&{title:h}};if(f.enum?.length){const e=typeof f.enum[0];m.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof i||o||a){if(i&&"string"!=typeof i)throw"Not expected";y=o||a||i?.endsWith("[]")?{type:"array",items:o||a?(0,t.getJSONSchemaObject)(o||{type:a}):i?.startsWith("any")?{type:void 0}:{type:r(i)?.type,...f.allowedValues&&{enum:f.allowedValues.slice(0)}}}:{type:r(i)?.type}}else(0,s.isObject)(i)?y={type:"object",required:(0,s.getKeys)(i).filter((e=>{const t=i[e];return"string"==typeof t||!t.optional})),properties:(0,s.getObjectEntries)(i).reduce(((e,[n,s])=>({...e,[n]:(0,t.getJSONSchemaObject)(s)})),{})}:u||d?y={oneOf:(u||d.map((e=>({type:e})))).map((e=>(0,t.getJSONSchemaObject)(e)))}:p&&(y={type:"object",...p.values&&!p.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(p.values)},...p.keysEnum&&{properties:p.keysEnum.reduce(((e,n)=>({...e,[n]:p.values?(0,t.getJSONSchemaObject)(p.values):{type:{}}})),{})}});if(l){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,...m,...y}}},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,Date:e=>"string"==typeof e,Lookup:()=>{throw new Error("Lookup type is not supported for validation")}},o=(0,s.getKeys)(i),a=(e,n,l=[])=>{const u=`${l.join(".")} is of invalid type. Expecting ${c(n).replaceAll("\n","")}`,d=(0,t.getFieldTypeObj)(n),{type:h,allowedValues:p,nullable:f,optional:y}=d;if(f&&null===e)return;if(y&&void 0===e)return;if(p)return`${l.join(".")} Allowed values are not supported for validation`;if(h){if((0,s.isObject)(h)){if(!(0,s.isObject)(e))return u;for(const t of(0,r.safeGetKeys)(h)){const n=(0,r.safeGetProperty)(h,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]);if(void 0!==i)return i}const t=(0,r.safeGetKeys)(e),n=(0,r.safeGetKeys)(h),i=t.filter((e=>!n.includes(e)));return i.length?`${l.join(".")} has extra properties: ${i.join(", ")}`:void 0}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}})(h);return t(e)?void 0:u}if(d.enum){const t=[];return d.nullable&&t.push(null),d.optional&&t.push(void 0),d.enum.includes(e)?void 0:u}const m=d.arrayOf??(d.arrayOfType?{type:d.arrayOfType}:void 0);if(m){if(!Array.isArray(e))return u+" an array";const t=e.map(((e,t)=>a(e,m,[...l,`${t}`]))).filter(s.isDefined)[0];return void 0!==t?`${u}. Error at index ${l.length>0?l.join(".")+".":""}\n\n${t}`:void 0}const g=d.oneOf??d.oneOfType?.map((e=>({type:e})));if(g){if(!g.length)return u+"to not be empty";let t;if(g.find((n=>{const s=a(e,n,l);return t??(t=s),void 0===s})))return;return u}if(!d.record)return`Could not validate field type. Some logic might be missing: ${JSON.stringify(d)}`;{const{keysEnum:t,partial:n,values:i}=d.record;if(!(0,s.isObject)(e))return u+"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`${u} to have key ${c}`;const h=t&&o.filter((e=>!t.includes(e)));if(h?.length)return`${u} has extra keys: ${h}`;if(i)for(const t of(0,r.safeGetKeys)(e)){const n=(0,r.safeGetProperty)(e,t),s=a(n,i,[...l,t]);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)=>{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 i=a(t,{type:e},[]);return i?{error:i}:{data:t}},t.getJSONBSchemaValidationError=(e,t)=>{const n=a(t,e);return n?{error:n}:{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)}},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")};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(994),t),r(n(472),t),r(n(618),t),r(n(897),t),r(n(394),t),r(n(778),t)},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.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getObjectEntries=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.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.getJoinHandlers=e=>{const t=(t,n)=>(n,s,i={})=>({[t?"$leftJoin":"$innerJoin"]:i.path??e,filter:n,...r(i,["path","select"]),select:s});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},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}},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 WeakSet,r)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e&&null!==e&&"object"==typeof t&&null!==t){if(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 i=Array.isArray(e),o=Array.isArray(t);if(i&&o){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(i!==o)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 a=Object.keys(e);if(a.length!==Object.keys(t).length)return!1;if(s.has(e)||s.has(t)){if("quiet"!==r&&console.trace("Circular reference detected in isEqual",e,t,s),"error"===r)throw new Error("Circular reference detected in isEqual");return!1}s.add(e),s.add(t);for(const i of a){if(!(i in t))return!1;{const o=e[i],a=t[i];if(!n(o,a,s,r))return!1}}return!0}return e!=e&&t!=t}},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()},155: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},110:(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},661:(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}},15:(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"]},624:(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"},956:(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(223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});var r=n(223);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(689);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(419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(15);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(71);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var h=n(71);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return h.XHR}});var p=n(716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return p.WS}});var f=n(716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var y=n(480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return y.WT}})},223:function(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(419),i=n(374),o=n(661),a=n(15),c=n(454),l=n(376),u=n(624),d=(0,s(n(833)).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 y 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=y,t.Socket=class extends y{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)}}},689:function(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(376),i=n(454),o=n(374),a=n(661),c=(0,s(n(833)).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&&Number(443!==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},419:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const s=n(71),r=n(716),i=n(480);t.transports={websocket:r.WS,webtransport:i.WT,polling:s.XHR}},209:(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},71:function(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(454),o=n(374),a=n(624),c=n(110),l=(0,s(n(833)).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=y({xdomain:!1});return e&&null!==e.responseType}();function y(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(y,this.uri(),e)}}},528:function(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(689),i=n(374),o=n(376),a=(0,s(n(833)).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},716:function(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(689),i=n(374),o=n(376),a=n(624),c=(0,s(n(833)).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)}}},480:function(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(689),i=n(624),o=n(376),a=(0,s(n(833)).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},374:(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((e.byteLength||e.size)*o)},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const s=n(624),r=s.globalThisShim.setTimeout,i=s.globalThisShim.clearTimeout,o=1.33},46:(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"}},745:(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}},662:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const s=n(46),r=n(745),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},686:(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(46),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},376:(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(686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return s.encodePacket}});const r=n(662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const i=n(46),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},743:(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}},7:function(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(894),i=n(776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return i.Manager}});const o=n(214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,s(n(833)).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(627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(956);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},776:function(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(956),c=n(214),l=i(n(627)),u=n(942),d=n(743),h=n(454),p=(0,o(n(833)).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},942:(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)}}},214:function(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(627),i=n(942),o=n(454),a=(0,s(n(833)).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)=>{if(n===this._queue[0])return 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.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){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},894:function(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(956),i=(0,s(n(833)).default)("socket.io-client:url")},926:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstructPacket=t.deconstructPacket=void 0;const s=n(133);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}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}},627:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0;const s=n(454),r=n(926),i=n(133),o=(0,n(833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;function l(e){return"[object Object]"===Object.prototype.toString.call(e)}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||(t.PacketType={})),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 u 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 d(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(!u.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 l(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||l(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=u;class d{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=[]}}},133:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;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}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}},454:(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=void 0;const t=s(653),n=s(333);e.prostgles=function(e){return(0,t.prostgles)(e,n.SyncedTable)}})(),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]}}(this||window,(e=>(()=>{var t={515:(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.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)})),n=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=[],n=[];this.queue.forEach((async(e,s)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:s,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const s=n(316),r=n(476),i="DEBUG_SYNCEDTABLE",o="undefined"!=typeof window;t.debug=function(...e){o&&window[i]&&window[i](...e)};const a={array:"array",localStorage:"localStorage",object:"object"};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:d,skipFirstTrigger:h=!1,select:p="*",storageType:f="object",patchText:y=!1,patchJSON:m=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},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=[])=>{if(!this.isSynced)return;const t=[],n=[],s=[];if(e.map((({idObj:e,newItem:r,delta:i})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(i),s.push(e))})),this.onChange||this.multiSubscriptions.length){const e=[],s=[];if(this.getItems().map((r=>{e.push({...r});const i=t.findIndex((e=>this.matchesIdObj(r,e)));s.push(n[i])})),this.onChange)try{this.onChange(e,s)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,s)}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.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const s=this.getIdObj(e);return this.setItem(s,void 0,!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,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";const i=[];let o;const a=[];await Promise.all(e.map((async(e,n)=>{var r;const c={...e.idObj};let u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});const d=this.getItem(c),h=d.index,p=d.data;!t&&!(0,s.isEmpty)(u)||(0,s.isEmpty)(p)||(u=this.getDelta(p||{},u)),t||(u[this.synced_field]=Date.now());let f={...p,...u,...c};p&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(f=l({...p,...c},{...u})),o=p?p[this.synced_field]<f[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(f,h);const y={idObj:c,delta:u,oldItem:p,newItem:f,status:o,from_server:t};return t||a.push({initial:p,current:{...f}}),(0,s.isEmpty)(y.delta)||i.push(y),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(i.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=u(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(t))}else this.storageType===a.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},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 e=this.storageType===a.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});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 u(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=p,this.onChange=r,c&&(this.onDebug=t=>c({...t,type:"sync",tableName:e},this)),!a[f])throw"Invalid storage type. Expecting one of: "+Object.keys(a).join(", ");o||f!==a.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),f="object"),this.storageType=f,this.patchText=y,this.patchJSON=m;const b=d[e];if(!b)throw`${e} table not found in db`;this.db=d;const{id_fields:_,synced_field:v,throttle:O=100,batch_size:w=50}=b._syncInfo;if(!_||!v)throw"id_fields/synced_field missing";this.id_fields=_,this.synced_field=v,this.batch_size=w,this.throttle=O,this.skipFirstTrigger=h,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const S={id_fields:_,synced_field:v,throttle:O};b._sync(n,{select:p},{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({...S,batch_size:w,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({...S,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()})),b.getColumns&&b.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).data,$find:e=>this.getItem(e).data,$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 t;return t=this.storageType===a.localStorage?this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===a.array?this.items.find((t=>this.matchesIdObj(t,e))):{...this.itemsObj}[this.getIdStr(e)],{data:u(t),index:-1}}setItem(e,t,n=!1,s=!1){const r=u(e);if(this.storageType===a.localStorage){let e=this.getItems();s?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),o&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===a.array)s?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(s)delete this.itemsObj[this.getIdStr(r)];else{const e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function l(e,t){const n=e?u(e):e,r=t?u(t):t,i=Object.assign({},n);return(0,s.isObject)(n)&&(0,s.isObject)(r)&&Object.keys(r).forEach((e=>{(0,s.isObject)(r[e])?e in n?i[e]=l(n[e],r[e]):Object.assign(i,{[e]:r[e]}):Object.assign(i,{[e]:r[e]})})),i}function u(e){if(o&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>u(e)));if((0,s.isObject)(e)){const t={};return(0,s.getKeys)(e).map((n=>{t[n]=u(e[n])})),t}return e}t.SyncedTable=c,t.default=l,t.quickClone=u},476:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMultiSyncSubscription=void 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).data,s),$find:e=>r(this.getItem(e).data,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}}},886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const s=n(316),r=n(653);t.getAuthHandler=({authData:e,socket:n,onReload:o})=>{if((null==e?void 0:e.pathGuard)&&r.isClientSide){const e=e=>{(null==e?void 0:e.shouldReload)&&(o?o():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 a={loginType:null==e?void 0:e.loginType,login:void 0,preferredLogin:null==e?void 0:e.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,providers:null==e?void 0:e.providers};if(e){const{providers:n,signupWithEmailAndPassword:r,loginType:o}=e;a.loginWithProvider=(0,s.isEmpty)(n)?void 0:n&&Object.entries(n).reduce(((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e)),{}),a.login=o&&(async e=>(0,t.authRequest)(i("/login"),e)),a.signupWithEmailAndPassword=r&&(e=>(0,t.authRequest)(i(r.url),e))}return(null==e?void 0:e.user)?{isLoggedin:!0,user:e.user,logout:async()=>(0,t.authRequest)(i("/logout"),{},"POST"),...a}:{isLoggedin:!1,user:void 0,...a}};const i=e=>{const{search:t}=window.location;return e+t};t.authRequest=async(e,t,n)=>{const s=await fetch(e,{method:null!=n?n:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)}});if(!s.ok){const e=await s.json().catch((()=>s.text())).catch((()=>s.statusText));return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const r=await s.json().catch((async()=>({message:await s.text()}))).catch((()=>({message:s.statusText})));return s.redirected?{...r,success:!0,redirect_url:s.url}:r}},930:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDBO=void 0;const s=n(316),r=n(653),i=n(333),o=s.CHANNELS._preffix;t.getDBO=({schema:e,tableSchema:t,onDebug:n,syncedTable:a,syncHandler:c,subscriptionHandler:l,socket:u})=>{const d=(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"},h=["subscribe","subscribeOne"],p={},f=(0,i.quickClone)(e);return(0,s.getObjectEntries)(f).forEach((([e,i])=>{const f=(0,s.getKeys)(i);p[e]={};const y=p[e];f.sort(((e,t)=>h.includes(e)-h.includes(t))).forEach((f=>{if("sync"===f){if(y._syncInfo={...i[f]},a){y.getSync=async(t,s={})=>(await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{filter:t,params:s}})),a.create({name:e,onDebug:n,filter:t,db:p,...s}));const t=async(t={},r={},i)=>{const o=`${e}.${JSON.stringify(t)}.${JSON.stringify((0,s.omitKeys)(r,["handlesOnData"]))}`;return c.syncedTables[o]||(c.syncedTables[o]=await a.create({...r,onDebug:n,name:e,filter:t,db:p,onError:i})),c.syncedTables[o]},i=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}})),d(s,r,i,o);const a=await t(s,r,o);return await a.sync(i,r.handlesOnData)},o=async(s,r={handlesOnData:!0},i,o)=>{await(null==n?void 0:n({type:"table",command:"syncOne",tableName:e,data:{basicFilter:s,options:r}})),d(s,r,i,o);const a=await t(s,r,o);return await a.syncOne(s,i,r.handlesOnData)};y.sync=i,y.syncOne=o,y.useSync=(e,t,n)=>(0,r.useSync)(i,e,t,n),y.useSyncOne=(e,t,n)=>(0,r.useSync)(o,e,t,n)}y._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}})),c.addSync({tableName:e,command:f,param1:t,param2:s},r)}}else if(h.includes(f)){const t=async function(t={},s={},r,i){return await(null==n?void 0:n({type:"table",command:f,tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),d(t,s,r,i),l.addSub(p,{tableName:e,command:f,param1:t,param2:s},r,i)};y[f]=t;const s="subscribeOne",i="subscribe"===f?"useSubscribe":"subscribeOne"===f?"useSubscribeOne":void 0;i&&(y[i]=(e,n,i)=>(0,r.useSubscribe)(t,f===s,e,n,i)),f!==s&&h.includes(s)||(y[s]=async function(t,s,r,i){return await(null==n?void 0:n({type:"table",command:"getSync",tableName:e,data:{param1:t,param2:s,onChange:r,onError:i}})),d(t,s,r,i),l.addSub(p,{tableName:e,command:f,param1:t,param2:s},(e=>{r(e[0])}),i)})}else{const s=async function(s,r,i){var a;if("getColumns"===f&&!s&&!r&&!i){const n=null===(a=null==t?void 0:t.find((t=>t.name===e)))||void 0===a?void 0:a.columns;if(n)return n}return await(null==n?void 0:n({type:"table",command:f,tableName:e,data:{param1:s,param2:r,param3:i}})),new Promise(((t,n)=>{u.emit(o,{tableName:e,command:f,param1:s,param2:r,param3:i},((e,s)=>{e?n(e):t(s)}))}))};y[f]=s;const i="findOne"===f?"useFindOne":"find"===f?"useFind":"count"===f?"useCount":"size"===f?"useSize":void 0;i&&(y[i]=(e,t,n)=>(0,r.useFetch)(s,[e,t],n))}}))})),{dbo:p}}},30:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const s=n(316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let r={};return JSON.parse(JSON.stringify(t)).map((t=>{const i="string"==typeof t,o=i?t:t.name,a=async function(...t){return await(null==e?void 0:e({type:"method",command:o,data:{params:t}})),new Promise(((e,r)=>{n.emit(s.CHANNELS.METHOD,{method:o,params:t},((t,n)=>{t?r(t):e(n)}))}))};r[o]=i?a:{...t,run:a}})),r=Object.freeze(r),{methodsObj:r}}},382:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const s=n(316);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(316),r=n(653),i=n(515),o=s.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a={},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[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),delete a[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,h){const p=(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)},f=Object.entries(a).find((([e,t])=>t.tableName===n&&t.command===r&&(0,s.isEqual)(t.param1||{},i||{})&&(0,s.isEqual)(t.param2||{},o||{})));if(f){const e=f[0];return f[1].handlers.push(d),f[1].errorHandlers.push(h),setTimeout((()=>{var t,n;(null===(t=a[e])||void 0===t?void 0:t.lastData)&&d(null===(n=a[e])||void 0===n?void 0:n.lastData)}),10),p(e,f[1].unsubChannel)}const{channelName:y,channelNameReady:m,channelNameUnsubscribe:g}=await u({tableName:n,command:r,param1:i,param2:o}),b=function(e){const t=a[y];t?e.data?(t.lastData=e.data,t.handlers.forEach((t=>{t(e.data)}))):e.err?t.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",y)},_=h||function(e){console.error(`Uncaught error within running subscription \n ${y}`,e)};return t.on(y,b),a[y]={lastData:void 0,tableName:n,command:r,param1:i,param2:o,onCall:b,unsubChannel:g,handlers:[d],errorHandlers:[_],reAttach:async()=>{await c(g).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()}),p(y,g)}),(([e,{tableName:t}])=>t));return{addSub:async(e,t,n,s)=>d.run([e,t,n,s]),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 Object.values(a))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),Object.values(e.errorHandlers).forEach((e=>null==e?void 0:e(t)))}await(null==n?void 0:n({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},609:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandler=void 0;const s=n(316),r=n(515),i=n(653),o=s.CHANNELS._preffix;t.getSyncHandler=({socket:e,onDebug:t})=>{let n={},a={};function c({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 l=new r.FunctionQueuer((async function({tableName:t,command:n,param1:r,param2:o},l){const{onSyncRequest:u}=l;function d(t){return Object.freeze({unsync:function(){!function(t,n){(0,i.debug)("_unsync",{channelName:t,triggers:n}),new Promise(((s,r)=>{a[t]&&(a[t].triggers=a[t].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),a[t].triggers.length||(e.emit(t+"unsync",{},((e,t)=>{e?r(e):s(t)})),e.removeListener(t,a[t].onCall),delete a[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(a).find((e=>{const i=a[e];return i&&i.tableName===t&&i.command===n&&(0,s.isEqual)(i.param1,r)&&(0,s.isEqual)(i.param2,o)}));if(h)return a[h].triggers.push(l),d(h);{const s=await c({tableName:t,command:n,param1:r,param2:o},u),{channelName:i}=s,h=function(e,t){e&&a[i]&&a[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 a[i]={tableName:t,command:n,param1:r,param2:o,triggers:[l],syncInfo:s,onCall:h},e.on(i,h),d(i)}}),(([{tableName:e}])=>e));return{destroySyncs:async()=>{(0,i.debug)("destroySyncs",{syncedTables:n}),a={},Object.values(n).map((e=>{e&&e.destroy&&e.destroy()})),n={}},syncedTables:n,addSync:async function(e,t){return l.run([e,t])},reAttachAll:async()=>{let t=0;Object.entries(a).forEach((async([n,s])=>{const r=s.triggers[0];if(r)try{await c(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",a)}}}},653:function(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.prostgles=t.asName=t.debug=t.isClientSide=void 0;const i=n(316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return i.asName}});const o=n(886),a=n(930),c=n(30),l=n(382),u=n(395),d=n(609),h="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[h]&&window[h](...e)},r(n(512),t),r(n(641),t),t.prostgles=function(e,n){const{socket:s,onReady:r,onDisconnect:h,onReconnect:p,onSchemaChange:f,onReload:y,onDebug:m}=e;let g;(0,t.debug)("prostgles",{initOpts:e}),f&&(s.removeAllListeners(i.CHANNELS.SCHEMA_CHANGED),s.on(i.CHANNELS.SCHEMA_CHANGED,f));const b=(0,u.getSubscriptionHandler)(e),_=(0,d.getSyncHandler)(e),v=(0,l.getSqlHandler)(e);let O;return new Promise(((e,t)=>{s.removeAllListeners("connect_error"),s.on("connect_error",(e=>{t(e)})),s.removeAllListeners(i.CHANNELS.CONNECTION),s.on(i.CHANNELS.CONNECTION,(e=>(t(e),"ok"))),h&&s.on("disconnect",(()=>{O="disconnected",h()})),p&&s.on("connect",(()=>{"disconnected"===O&&(O="reconnected")})),s.on(i.CHANNELS.SCHEMA,(async l=>{await(null==m?void 0:m({type:"schemaChanged",data:l,state:O}));const{joinTables:u=[],...d}=l,{schema:h,methods:f,tableSchema:w,auth:S,rawSQL:k,err:T}=d;if((null==g?void 0:g.clientSchema)&&(0,i.isEqual)(g.clientSchema,d)||_.destroySyncs().catch((e=>console.error("Error while destroying syncs",e))),T&&console.error("Error on schema change:",T),"connected"!==O&&"reconnected"!==O||!p)g={origin:"onReady",date:new Date,clientSchema:d};else{if(p(s,T),T)return;g={origin:"onReconnect",date:new Date,clientSchema:d}}if(T)return void t(T);const E="reconnected"===O;O="connected";const C=(0,o.getAuthHandler)({authData:S,socket:s,onReload:y}),{methodsObj:j}=(0,c.getMethods)({onDebug:m,methods:f,socket:s}),{dbo:P}=(0,a.getDBO)({schema:h,onDebug:m,syncedTable:n,syncHandler:_,subscriptionHandler:b,socket:s,tableSchema:w});k&&(P.sql=v.sql),b.reAttachAll(),_.reAttachAll(),u.flat().map((e=>{var t,n,s,r;null!==(t=P.innerJoin)&&void 0!==t||(P.innerJoin={}),null!==(n=P.leftJoin)&&void 0!==n||(P.leftJoin={}),null!==(s=P.innerJoinOne)&&void 0!==s||(P.innerJoinOne={}),null!==(r=P.leftJoinOne)&&void 0!==r||(P.leftJoinOne={});const o=(0,i.getJoinHandlers)(e);P.leftJoin[e]=o.leftJoin,P.innerJoin[e]=o.innerJoin,P.leftJoinOne[e]=o.leftJoinOne,P.innerJoinOne[e]=o.innerJoinOne})),(async()=>{try{const e={dbo:P,methods:j,tableSchema:w,auth:C,isReconnect:E};await(null==m?void 0:m({type:"onReady.call",data:e,state:O})),await r(P,j,w,C,E)}catch(e){console.error("Prostgles: Error within onReady: \n",e),t(e)}e(P)})()}))}))}},512:(e,t,n)=>{"use strict";var s;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=t.getIO=t.getReact=void 0;const r=n(316);let i;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=i||(i=n(155))}catch(e){}if(e&&!i)throw new Error("Must install react");return i},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(s=i)&&void 0!==s?s:{};t.getIO=(e=!1)=>{try{return n(7)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useDeepCompareMemoize=e=>{const t=u();return(0,r.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>i.useMemo(e,null==n?void 0:n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{c(e,null==n?void 0:n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const s=u(),r=u(),i=async()=>{var e;if("resolved"===(null===(e=r.current)||void 0===e?void 0:e.state)){const{cleanup:e,effect:t}=r.current;r.current={state:"cleaning",effect:t},await e().catch(console.error),r.current=void 0}if(s.current&&!r.current){const e=s.current,{effect:t}=e;r.current={state:"resolving",effect:t};const n=await t().then((e=>async()=>{await(null==e?void 0:e())})).catch((e=>(console.error(e),async()=>{})));r.current={state:"resolved",effect:t,cleanup:n},e!==s.current&&i()}};(0,t.useEffectDeep)((()=>(s.current={effect:e,deps:n},i(),()=>{s.current=void 0,i()})),n)},t.useEffectAsync=(e,n)=>{const s=u({cleanup:void 0,effect:e,cleanupEffect:void 0});s.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(s.current.cleanup=t,s.current.cleanupEffect===e&&t())})),()=>{var t,n;s.current.cleanupEffect=e,null===(n=(t=s.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=()=>{const e=u(!0),t=l((()=>e.current),[]);return c((()=>(e.current=!0,()=>{e.current=!1})),[]),t},t.usePromise=(e,n=[])=>{const s=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},i=e=>{try{return(0,r.isObject)(e)&&!s(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const s of n){const n=e[s];try{t[s]="function"==typeof n?await n():await n}catch(e){console.error(e)}}return t},[a,c]=d(i(e)?{}:void 0),l=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{let t;try{if(i(e))t=await o(e);else{const n=await e();t=i(n)?await o(n):s(n)?await n():n}}catch(e){console.error(e)}l()&&c(t)}),n),a},t.useSubscribe=(e,n,s,i,o)=>{const{skip:a}=null!=o?o:{},c={data:void 0,error:void 0,isLoading:!0},[l,h]=d(c),p=u(l);p.current=l;const f=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(!f()||a)return;(0,r.isEqual)(p.current,c)||h(c);const t=e=>{f()&&h({data:void 0,error:e,isLoading:!1})};try{const r=await e(s,i,(e=>{f()&&h({data:n?e[0]:e,error:void 0,isLoading:!1})}),t);return()=>{r.unsubscribe()}}catch(e){t(e)}}),[e,s,i,a]),l},t.useSync=(e,n,s,r)=>{const{skip:i}=null!=r?r:{},[{data:o,error:a,isLoading:c},l]=d({data:void 0,error:void 0,isLoading:!0}),u=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(!u()||i)return;const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(n,s,(e=>{u()&&l({data:e,error:void 0,isLoading:!1})}),t)).$unsync}catch(e){t(e)}}),[e,n,s,i]),{data:o,error:a,isLoading:c}},t.useFetch=(e,n=[],s)=>{const{skip:r,deps:i=[]}=null!=s?s:{},o={data:void 0,error:void 0,isLoading:!0},[{data:a,error:c,isLoading:l},u]=d(o),h=(0,t.useIsMounted)();return(0,t.useAsyncEffectQueue)((async()=>{if(h()&&!r){u(o);try{const t=await e(...n);if(!h())return;u({data:t,error:void 0,isLoading:!1})}catch(e){if(!h())return;u({data:void 0,error:e,isLoading:!1})}}}),[...n,...i]),{data:a,error:c,isLoading:l}},t.__prglReactInstalled=()=>Boolean(i&&u)},641:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=void 0;const s=n(316),r=n(333),i=n(653),o=n(512);t.useProstglesClient=({skip:e,socketOptions:t,...n}={})=>{const{useRef:a,useState:c}=(0,o.getReact)(!0),[l,u]=c({isLoading:!0}),d=(0,o.useIsMounted)(),h=a();return(0,o.useAsyncEffectQueue)((async()=>{var a;if(e)return;null===(a=h.current)||void 0===a||a.disconnect();const c=(0,o.getIO)(),l="string"==typeof t?{path:t}:t,p={reconnectionDelay:1e3,reconnection:!0,...(0,s.omitKeys)(null!=l?l:{},["uri"])},f="string"==typeof(null==l?void 0:l.uri)?c(l.uri,p):c(p);return h.current=f,await(0,i.prostgles)({socket:f,...n,onReady:(...e)=>{var t,s;const[r,i,o,a,c]=e,l={dbo:r,methods:i,tableSchema:o,auth:a,isReconnect:c,socket:f};d()?(null===(s=n.onDebug)||void 0===s||s.call(n,{type:"onReady",data:l}),u({...l,isLoading:!1})):null===(t=n.onDebug)||void 0===t||t.call(n,{type:"onReady.notMounted",data:l})}},r.SyncedTable).catch((e=>{d()&&u({isLoading:!1,error:e,hasError:!0})})),()=>{f.disconnect()}}),[n,t,e]),l}},833:(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")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$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){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}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.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),r=s.length;for(n=0;n<r;n++)s[n]&&("-"===(e=s[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,s;for(n=0,s=t.skips.length;n<s;n++)if(t.skips[n].test(e))return!1;for(n=0,s=t.names.length;n<s;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(585),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}},585: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))}},316:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={994:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,s){return(0,t.getJSONSchemaObject)(s,{id:`${e}.${n}`})};const s=n(472);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=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||"Lookup"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:i,arrayOf:o,arrayOfType:a,description:c,nullable:l,oneOf:u,oneOfType:d,title:h,record:p,...f}="string"==typeof e?{type:e}:e;let y={};const m={...(f.enum||f.allowedValues?.length&&("string"!=typeof i||!i.endsWith("[]")))&&{enum:f.allowedValues?.slice(0)??f.enum.slice(0)},...!!c&&{description:c},...!!h&&{title:h}};if(f.enum?.length){const e=typeof f.enum[0];m.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof i||o||a){if(i&&"string"!=typeof i)throw"Not expected";y=o||a||i?.endsWith("[]")?{type:"array",items:o||a?(0,t.getJSONSchemaObject)(o||{type:a}):i?.startsWith("any")?{type:void 0}:{type:r(i)?.type,...f.allowedValues&&{enum:f.allowedValues.slice(0)}}}:{type:r(i)?.type}}else(0,s.isObject)(i)?y={type:"object",required:(0,s.getKeys)(i).filter((e=>{const t=i[e];return"string"==typeof t||!t.optional})),properties:(0,s.getObjectEntries)(i).reduce(((e,[n,s])=>({...e,[n]:(0,t.getJSONSchemaObject)(s)})),{})}:u||d?y={oneOf:(u||d.map((e=>({type:e})))).map((e=>(0,t.getJSONSchemaObject)(e)))}:p&&(y={type:"object",...p.values&&!p.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(p.values)},...p.keysEnum&&{properties:p.keysEnum.reduce(((e,n)=>({...e,[n]:p.values?(0,t.getJSONSchemaObject)(p.values):{type:{}}})),{})}});if(l){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,...m,...y}}},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,Date:e=>"string"==typeof e,Lookup:()=>{throw new Error("Lookup type is not supported for validation")}},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:y,optional:m}=h;if(y&&null===e)return;if(m&&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)}},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")};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(994),t),r(n(472),t),r(n(618),t),r(n(897),t),r(n(394),t),r(n(778),t)},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.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=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.getJoinHandlers=e=>{const t=(t,n)=>(n,s,i={})=>({[t?"$leftJoin":"$innerJoin"]:i.path??e,filter:n,...r(i,["path","select"]),select:s});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},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}},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 WeakSet,r)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e&&null!==e&&"object"==typeof t&&null!==t){if(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 i=Array.isArray(e),o=Array.isArray(t);if(i&&o){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(i!==o)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 a=Object.keys(e);if(a.length!==Object.keys(t).length)return!1;if(s.has(e)||s.has(t)){if("quiet"!==r&&console.trace("Circular reference detected in isEqual",e,t,s),"error"===r)throw new Error("Circular reference detected in isEqual");return!1}s.add(e),s.add(t);for(const i of a){if(!(i in t))return!1;{const o=e[i],a=t[i];if(!n(o,a,s,r))return!1}}return!0}return e!=e&&t!=t}},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()},155: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},110:(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},661:(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}},15:(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"]},624:(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"},956:(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(223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});var r=n(223);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(689);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(419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(15);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(71);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var h=n(71);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return h.XHR}});var p=n(716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return p.WS}});var f=n(716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var y=n(480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return y.WT}})},223:function(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(419),i=n(374),o=n(661),a=n(15),c=n(454),l=n(376),u=n(624),d=(0,s(n(833)).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 y 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=y,t.Socket=class extends y{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)}}},689:function(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(376),i=n(454),o=n(374),a=n(661),c=(0,s(n(833)).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&&Number(443!==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},419:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const s=n(71),r=n(716),i=n(480);t.transports={websocket:r.WS,webtransport:i.WT,polling:s.XHR}},209:(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},71:function(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(454),o=n(374),a=n(624),c=n(110),l=(0,s(n(833)).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=y({xdomain:!1});return e&&null!==e.responseType}();function y(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(y,this.uri(),e)}}},528:function(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(689),i=n(374),o=n(376),a=(0,s(n(833)).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},716:function(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(689),i=n(374),o=n(376),a=n(624),c=(0,s(n(833)).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)}}},480:function(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(689),i=n(624),o=n(376),a=(0,s(n(833)).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},374:(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((e.byteLength||e.size)*o)},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const s=n(624),r=s.globalThisShim.setTimeout,i=s.globalThisShim.clearTimeout,o=1.33},46:(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"}},745:(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}},662:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const s=n(46),r=n(745),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},686:(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(46),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},376:(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(686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return s.encodePacket}});const r=n(662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const i=n(46),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},743:(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}},7:function(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(894),i=n(776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return i.Manager}});const o=n(214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,s(n(833)).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(627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(956);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},776:function(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(956),c=n(214),l=i(n(627)),u=n(942),d=n(743),h=n(454),p=(0,o(n(833)).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},942:(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)}}},214:function(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(627),i=n(942),o=n(454),a=(0,s(n(833)).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)=>{if(n===this._queue[0])return 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.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){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},894:function(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(956),i=(0,s(n(833)).default)("socket.io-client:url")},926:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstructPacket=t.deconstructPacket=void 0;const s=n(133);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}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}},627:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0;const s=n(454),r=n(926),i=n(133),o=(0,n(833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;function l(e){return"[object Object]"===Object.prototype.toString.call(e)}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||(t.PacketType={})),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 u 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 d(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(!u.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 l(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||l(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=u;class d{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=[]}}},133:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;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}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}},454:(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=void 0;const t=s(653),n=s(333);e.prostgles=function(e){return(0,t.prostgles)(e,n.SyncedTable)}})(),r})()));
|