prostgles-client 4.0.41 → 4.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>(()=>{var e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),s="DEBUG_SYNCEDTABLE",r="undefined"!=typeof window;t.debug=function(...e){r&&window[s]&&window[s](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{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:s,onReady:a,onDebug:u,db:d,skipFirstTrigger:h=!1,select:p="*",storageType:f="object",patchText:m=!1,patchJSON:y=!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 s=e.map((e=>e.current)),r=[],o=[];if(this.columns&&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){s=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map((async(e,a)=>{const{current:l,initial:c}={...e};let u;c&&(t.map((e=>{!n.includes(e.name)&&e.name in l&&(null!=u||(u={...l}),u[e.name]=(0,i.getTextPatch)(c[e.name],l[e.name]))})),u&&this.wal&&(o.push(u),r.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||s.push(l)})))}}if(r.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(r))}catch(e){console.log("failed to patch update",e),s=s.concat(o)}return s.filter((e=>e))},this._notifySubscribers=(e=[])=>{if(!this.isSynced)return;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:s,delta:r})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(s,r)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(s)&&(t.push(s),n.push(r),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((s=>{e.push({...s});const r=t.findIndex((e=>this.matchesIdObj(s,e)));i.push(n[r])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}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=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.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 i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&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,s;if(!(e&&e.length||t))throw"No data provided for upsert";let r,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var s;let c={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(c),h=d.index,p=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(p)||(u=this.getDelta(p||{},u)),t||(u[this.synced_field]=Date.now());let f={...p,...u,...c};p&&!t&&(null===(s=e.opts)||void 0===s?void 0:s.deepMerge)&&(f=l({...p,...c},{...u})),r=p?p[this.synced_field]<f[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(f,h);let m={idObj:c,delta:u,oldItem:p,newItem:f,status:r,from_server:t};return t||a.push({initial:p,current:{...f}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(s=this.wal)||void 0===s||s.addData(a))},this.setItems=e=>{const t=c(e);if(this.storageType===o.localStorage){if(!r)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!r)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!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,i.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 c(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={offset:0,limit:void 0})=>{let s=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||i)&&(s=s.splice(null!=n?n:0,i||s.length)),s},this.name=e,this.filter=n,this.select=p,this.onChange=s,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[f])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(r||f!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),f="object"),this.storageType=f,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:O=100,batch_size:S=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=S,this.throttle=O,this.skipFirstTrigger=h,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:O};d[this.name]._sync(n,{select:p},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,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;let 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){let 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 i.WAL({..._,batch_size:S,onSendStart:()=>{r&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{r&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,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}})))}}),a()})),d[this.name].getColumns&&d[this.name].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 a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let s=[...n],r=[...i];return t&&(s=s.map(((n,i)=>{const s=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>s(this.getItem(i).data,i),$find:e=>s(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),r=this.getIdObj(n);return s(n,r)}))),e(s,r)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{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:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),s={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,s)=>{let r={...e};return n&&(r.$get=i.$get,r.$find=i.$find,r.$update=i.$update,r.$delete=i.$delete,r.$unsync=i.$unsync,r.$cloneSync=i.$cloneSync),t(r,s)}};return this.singleSubscriptions.push(s),setTimeout((()=>{let e=i.$get();e&&s.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.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,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let s={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(s=n):s=n}return{...n,...s}}),{})}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 this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:c(t),index:-1}}setItem(e,t,n=!1,i=!1){const s=c(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,s))):void 0!==t&&e[t]?e[t]=n?{...s}:{...e[t],...s}:e.push(s),r&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?this.items=this.items.filter((e=>!this.matchesIdObj(e,s))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...s}:{...this.items[t],...s}):this.items.push(s);else if(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(s)];else{let e=this.itemsObj[this.getIdStr(s)]||{};this.itemsObj[this.getIdStr(s)]=n?{...s}:{...e,...s}}}}function l(e,t){const n=e?c(e):e,s=t?c(t):t;let r=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(s)&&Object.keys(s).forEach((e=>{(0,i.isObject)(s[e])?e in n?r[e]=l(n[e],s[e]):Object.assign(r,{[e]:s[e]}):Object.assign(r,{[e]:s[e]})})),r}function c(e){if(r&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>c(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=c(e[n])})),t}return e}t.SyncedTable=a,t.default=l,t.quickClone=c},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,s)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.asName=t.debug=void 0;const r=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return r.asName}});const o="DEBUG_SYNCEDTABLE",a="undefined"!=typeof window;t.debug=function(...e){a&&window[o]&&window[o](...e)},s(n(353),t),t.prostgles=function(e,n){const{socket:i,onReady:s,onDisconnect:o,onReconnect:c,onSchemaChange:u=!0,onReload:d,onDebug:h}=e;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(r.CHANNELS.SCHEMA_CHANGED),e&&i.on(r.CHANNELS.SCHEMA_CHANGED,e)}const p=r.CHANNELS._preffix;let f,m={},y={},g={},b={},v=!1,O=!1;function S(e,n,s){return(0,t.debug)("_unsubscribe",{channelName:e,handler:s}),new Promise(((t,r)=>{m[e]?(m[e].handlers=m[e].handlers.filter((e=>e!==s)),m[e].handlers.length||(i.emit(n,{},((e,t)=>{e&&console.error(e)})),i.removeListener(e,m[e].onCall),delete m[e]),t(!0)):t(!0)}))}function _({tableName:e,command:t,param1:n,param2:s},r){return new Promise(((o,a)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:s},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:s}=t;i.emit(s,{onSyncRequest:r({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:s})}}))}))}function w({tableName:e,command:t,param1:n,param2:s}){return new Promise(((r,o)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:s},((e,t)=>{e?(console.error(e),o(e)):t&&r(t)}))}))}const j=new l((async function({tableName:e,command:n,param1:s,param2:r},o){const{onPullRequest:a,onSyncRequest:l,onUpdates:c}=o;function u(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,s)=>{g[e]&&(g[e].triggers=g[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),g[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?s(e):t(n)})),i.removeListener(e,g[e].onCall),delete g[e]))}))}(e,o)},syncData:function(t,n,s){i.emit(e,{onSyncRequest:{...l({}),...{data:t}||{},...{deleted:n}||{}}},s?e=>{s(e)}:null)}})}const d=Object.keys(g).find((t=>{let i=g[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(s||{})&&JSON.stringify(i.param2||{})===JSON.stringify(r||{})}));if(d)return g[d].triggers.push(o),u(d);{const h=await _({tableName:e,command:n,param1:s,param2:r},l),{channelName:p,synced_field:f,id_fields:m}=h;function y(t,n){t&&g[p]&&g[p].triggers.map((({onUpdates:i,onSyncRequest:s,onPullRequest:r})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(s(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(r(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return g[p]={tableName:e,command:n,param1:s,param2:r,triggers:[o],syncInfo:h,onCall:y},i.on(p,y),u(p)}}),(([{tableName:e}])=>e)),N=new l((async function(e,{tableName:t,command:n,param1:s,param2:r},o,a){function l(n,i){let r={unsubscribe:function(){return S(n,i,o)},filter:{...s}};return e[t].update&&(r={...r,update:function(n,i){return e[t].update(s,n,i)}}),e[t].delete&&(r={...r,delete:function(n){return e[t].delete(s,n)}}),Object.freeze(r)}const c=Object.entries(m).find((([e])=>{let i=m[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(s||{})&&JSON.stringify(i.param2||{})===JSON.stringify(r||{})}));if(c){const e=c[0];return c[1].handlers.push(o),c[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==m?void 0:m[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==m?void 0:m[e])||void 0===n?void 0:n.lastData)}),10),l(e,c[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:h}=await w({tableName:t,command:n,param1:s,param2:r}),p=function(e,t){const n=m[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},f=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,p),m[u]={lastData:void 0,tableName:t,command:n,param1:s,param2:r,onCall:p,unsubChannel:h,handlers:[o],errorHandlers:[f],destroy:()=>{m[u]&&(Object.values(m[u]).map((e=>{e&&e.handlers&&e.handlers.map((e=>S(u,h,e)))})),delete m[u])}},i.emit(d,{now:Date.now()}),l(u,h)}),(([e,{tableName:t}])=>t));async function E(e,t,n,i){return N.run([e,t,n,i])}return new Promise(((e,l)=>{i.removeAllListeners(r.CHANNELS.CONNECTION),i.on(r.CHANNELS.CONNECTION,(e=>(l(e),"ok"))),o&&i.on("disconnect",(()=>{v=!1,O=!1,o()})),c&&i.on("connect",(()=>{O=!0})),i.on(r.CHANNELS.SCHEMA,(({schema:o,methods:u,tableSchema:S,auth:N,rawSQL:T,joinTables:x=[],err:C})=>{if((0,t.debug)("destroySyncs",{subscriptions:m,syncedTables:y}),Object.values(m).map((e=>e.destroy())),m={},g={},Object.values(y).map((e=>{e&&e.destroy&&e.destroy()})),y={},(v||O)&&c&&(c(i,C),C))return void console.error(C);if(C)throw l(C),C;v=!0;let P=JSON.parse(JSON.stringify(o)),I=JSON.parse(JSON.stringify(u)),k={},$={};if(N){if(N.pathGuard&&a){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(d?d():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(r.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(r.CHANNELS.AUTHGUARD),i.on(r.CHANNELS.AUTHGUARD,(t=>{e(t)}))}$={...N},[r.CHANNELS.LOGIN,r.CHANNELS.LOGOUT,r.CHANNELS.REGISTER].map((e=>{N[e]&&($[e]=function(t){return new Promise(((n,s)=>{i.emit(p+e,t,((e,t)=>{e?s(e):n(t)}))}))})}))}I.map((e=>{const t="string"==typeof e,n=t?e:e.name,s=async function(...e){return await(null==h?void 0:h({type:"method",command:n,data:{params:e}})),new Promise(((t,s)=>{i.emit(r.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?s(e):t(n)}))}))};k[n]=t?s:{...e,run:s}})),k=Object.freeze(k),T&&(P.sql=function(e,t,n){return new Promise(((s,o)=>{i.emit(r.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{f=f||{config:t,listeners:[]},f.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{f&&f.listeners&&f.listeners.length?f.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),f.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{f&&(f.listeners=f.listeners.filter((t=>t!==e)),!f.listeners.length&&f.config&&f.config.socketUnsubChannel&&i&&i.emit(f.config.socketUnsubChannel,{}))})(t)}),r={...e,addListener:n};s(r)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))s(t);else{const e=e=>(((e,t)=>{var n;b=b||{},b[t.notifChannel]?null===(n=b[t.notifChannel])||void 0===n||n.listeners.push(e):(b[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,s;(null===(n=b[t.notifChannel])||void 0===n?void 0:n.listeners.length)?b[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(s=b[t.notifChannel])||void 0===s?void 0:s.config.socketUnsubChannel,{})})))})(e,t),{...t,removeListener:()=>((e,t)=>{const n=b[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete b[t.notifChannel]))})(e,t)}),n={...t,addListener:e};s(n)}}))}))});const R=e=>"[object Object]"===Object.prototype.toString.call(e),D=(e,t,n,i)=>{if(!R(e)||!R(t)||"function"!=typeof n||i&&"function"!=typeof i)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},A=["subscribe","subscribeOne"];(0,r.getKeys)(P).forEach((e=>{Object.keys(P[e]).sort(((e,t)=>A.includes(e)-A.includes(t))).forEach((t=>{if(["find","findOne"].includes(t)&&(P[e].getJoinedTables=function(){return(x||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))}),"sync"===t){if(P[e]._syncInfo={...P[e][t]},n){P[e].getSync=async(t,i={})=>(await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:h,filter:t,db:P,...i}));const t=async(t={},i={},s)=>{const r=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return y[r]||(y[r]=await n.create({...i,onDebug:h,name:e,filter:t,db:P,onError:s})),y[r]};P[e].sync=async(n,i={handlesOnData:!0,select:"*"},s,r)=>{await(null==h?void 0:h({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),D(n,i,s,r);const o=await t(n,i,r);return await o.sync(s,i.handlesOnData)},P[e].syncOne=async(n,i={handlesOnData:!0},s,r)=>{await(null==h?void 0:h({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),D(n,i,s,r);const o=await t(n,i,r);return await o.syncOne(n,s,i.handlesOnData)}}P[e]._sync=async function(n,i,s){return await(null==h?void 0:h({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:s}})),async function(e,t){return j.run([e,t])}({tableName:e,command:t,param1:n,param2:i},s)}}else if(A.includes(t)){const n=async function(n,i,s,r){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:s,onError:r}})),D(n,i,s,r),E(P,{tableName:e,command:t,param1:n,param2:i},s,r)};P[e][t]=n;const i="subscribeOne";P[e][t+"Hook"]=function(e={},s={},r){return{start:o=>n(e,s,t!==i?o:e=>{o(e[0])},r),args:[e,s,r]}},t!==i&&A.includes(i)||(P[e][i]=async function(n,i,s,r){return await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:s,onError:r}})),D(n,i,s,r),E(P,{tableName:e,command:t,param1:n,param2:i},(e=>{s(e[0])}),r)})}else P[e][t]=async function(n,s,r){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:s,param3:r}})),new Promise(((o,a)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:s,param3:r},((e,t)=>{e?a(e):o(t)}))}))}}))})),m&&Object.keys(m).length&&Object.keys(m).map((async e=>{try{let t=m[e];await w(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),g&&Object.keys(g).length&&(0,r.getKeys)(g).filter((e=>{var t;return null===(t=g[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=g[e];await _(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),x.flat().map((e=>{P.innerJoin=P.innerJoin||{},P.leftJoin=P.leftJoin||{},P.innerJoinOne=P.innerJoinOne||{},P.leftJoinOne=P.leftJoinOne||{};const t=(0,r.getJoinHandlers)(e);P.leftJoin[e]=t.leftJoin,P.innerJoin[e]=t.innerJoin,P.leftJoinOne[e]=t.leftJoinOne,P.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await s(P,k,S,$,v)}catch(e){console.error("Prostgles: Error within onReady: \n",e),l(e)}e(P)})()}))}))};class l{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),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,i)=>{const s=this.groupBy(e.arguments);t.includes(s)||(t.push(s),n.push({index:i,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}}},353:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useSubscribeOne=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=void 0;const i=n(294),s=n(792),{useEffect:r,useCallback:o,useRef:a,useState:l}=null!=i?i:{};function c(){const e=a(!0),t=o((()=>e.current),[]);return r((()=>()=>{e.current=!1}),[]),t}t.useEffectAsync=(e,t)=>{const n=a({cleanup:void 0,effect:e,cleanupEffect:void 0});n.current.effect=e,r((()=>(e().then((t=>{"function"==typeof t&&(n.current.cleanup=t,n.current.cleanupEffect===e&&t())})),()=>{var t,i;n.current.cleanupEffect=e,null===(i=(t=n.current).cleanup)||void 0===i||i.call(t)})),t)},t.useIsMounted=c,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},r=e=>{try{return(0,s.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,s.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,u]=l(r(e)?{}:void 0),d=c();return(0,t.useEffectAsync)((async()=>{let t;if(r(e))t=await o(e);else{const n=await e();t=r(n)?await o(n):i(n)?await n():n}d()&&u(t)}),n),a},t.useSubscribe=e=>{const[n,i]=l(),s=c();return(0,t.useEffectAsync)((async()=>(await e.start((e=>{s()&&i(e)}))).unsubscribe),e.args.map((e=>JSON.stringify(e)))),n},t.useSubscribeOne=e=>{const[n,i]=l(),s=c();return(0,t.useEffectAsync)((async()=>(await e.start((e=>{s()&&i(e)}))).unsubscribe),[]),n},t.__prglReactInstalled=()=>Boolean(i&&a)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,s)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 r={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...r,"number[]":r.number.map((e=>`_${e}`)),"boolean[]":r.boolean.map((e=>`_${e}`)),"string[]":r.string.map((e=>`_${e}`)),"any[]":r.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},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"]},s(n(128),t),s(n(444),t);var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),s(n(929),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);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 s=(e,t)=>{const{type:n,arrayOf:r,arrayOfType:o,description:a,nullable:l,oneOf:c,oneOfType:u,title:d,record:h,...p}="string"==typeof e?{type:e}:e;let f={};const m={...(p.enum||p.allowedValues?.length)&&{enum:p.allowedValues?.slice(0)??p.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(p.enum?.length&&(m.type=typeof p.enum[0]),"string"==typeof n||r||o){if(n&&"string"!=typeof n)throw"Not expected";f=r||o||n?.endsWith("[]")?{type:"array",items:r||o?s(r||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...p.allowedValues&&{enum:p.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?f={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:s(n[t])})),{})}:c||u?f={oneOf:(c||u.map((e=>({type:e})))).map((e=>s(e)))}:h&&(f={type:"object",...h.values&&!h.keysEnum&&{additionalProperties:s(h.values)},...h.keysEnum&&{properties:h.keysEnum.reduce(((e,t)=>({...e,[t]:h.values?s(h.values):{type:{}}})),{})}});if(l){const e={type:"null"};f.oneOf?f.oneOf.push(e):f.enum&&!f.enum.includes(null)?f.enum.push(null):f={oneOf:[f,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...f}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return s(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],l=e[2],c=e[3];n=s(n,i,l,c,t[0],7,-680876936),c=s(c,n,i,l,t[1],12,-389564586),l=s(l,c,n,i,t[2],17,606105819),i=s(i,l,c,n,t[3],22,-1044525330),n=s(n,i,l,c,t[4],7,-176418897),c=s(c,n,i,l,t[5],12,1200080426),l=s(l,c,n,i,t[6],17,-1473231341),i=s(i,l,c,n,t[7],22,-45705983),n=s(n,i,l,c,t[8],7,1770035416),c=s(c,n,i,l,t[9],12,-1958414417),l=s(l,c,n,i,t[10],17,-42063),i=s(i,l,c,n,t[11],22,-1990404162),n=s(n,i,l,c,t[12],7,1804603682),c=s(c,n,i,l,t[13],12,-40341101),l=s(l,c,n,i,t[14],17,-1502002290),n=r(n,i=s(i,l,c,n,t[15],22,1236535329),l,c,t[1],5,-165796510),c=r(c,n,i,l,t[6],9,-1069501632),l=r(l,c,n,i,t[11],14,643717713),i=r(i,l,c,n,t[0],20,-373897302),n=r(n,i,l,c,t[5],5,-701558691),c=r(c,n,i,l,t[10],9,38016083),l=r(l,c,n,i,t[15],14,-660478335),i=r(i,l,c,n,t[4],20,-405537848),n=r(n,i,l,c,t[9],5,568446438),c=r(c,n,i,l,t[14],9,-1019803690),l=r(l,c,n,i,t[3],14,-187363961),i=r(i,l,c,n,t[8],20,1163531501),n=r(n,i,l,c,t[13],5,-1444681467),c=r(c,n,i,l,t[2],9,-51403784),l=r(l,c,n,i,t[7],14,1735328473),n=o(n,i=r(i,l,c,n,t[12],20,-1926607734),l,c,t[5],4,-378558),c=o(c,n,i,l,t[8],11,-2022574463),l=o(l,c,n,i,t[11],16,1839030562),i=o(i,l,c,n,t[14],23,-35309556),n=o(n,i,l,c,t[1],4,-1530992060),c=o(c,n,i,l,t[4],11,1272893353),l=o(l,c,n,i,t[7],16,-155497632),i=o(i,l,c,n,t[10],23,-1094730640),n=o(n,i,l,c,t[13],4,681279174),c=o(c,n,i,l,t[0],11,-358537222),l=o(l,c,n,i,t[3],16,-722521979),i=o(i,l,c,n,t[6],23,76029189),n=o(n,i,l,c,t[9],4,-640364487),c=o(c,n,i,l,t[12],11,-421815835),l=o(l,c,n,i,t[15],16,530742520),n=a(n,i=o(i,l,c,n,t[2],23,-995338651),l,c,t[0],6,-198630844),c=a(c,n,i,l,t[7],10,1126891415),l=a(l,c,n,i,t[14],15,-1416354905),i=a(i,l,c,n,t[5],21,-57434055),n=a(n,i,l,c,t[12],6,1700485571),c=a(c,n,i,l,t[3],10,-1894986606),l=a(l,c,n,i,t[10],15,-1051523),i=a(i,l,c,n,t[1],21,-2054922799),n=a(n,i,l,c,t[8],6,1873313359),c=a(c,n,i,l,t[15],10,-30611744),l=a(l,c,n,i,t[6],15,-1560198380),i=a(i,l,c,n,t[13],21,1309151649),n=a(n,i,l,c,t[4],6,-145523070),c=a(c,n,i,l,t[11],10,-1120210379),l=a(l,c,n,i,t[2],15,718787259),i=a(i,l,c,n,t[9],21,-343485551),e[0]=h(n,e[0]),e[1]=h(i,e[1]),e[2]=h(l,e[2]),e[3]=h(c,e[3])}function i(e,t,n,i,s,r){return t=h(h(t,e),h(i,r)),h(t<<s|t>>>32-s,n)}function s(e,t,n,s,r,o,a){return i(t&n|~t&s,e,t,r,o,a)}function r(e,t,n,s,r,o,a){return i(t&s|n&~s,e,t,r,o,a)}function o(e,t,n,s,r,o,a){return i(t^n^s,e,t,r,o,a)}function a(e,t,n,s,r,o,a){return i(n^(t|~s),e,t,r,o,a)}function l(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.md5=t.md5cycle=void 0,t.md5cycle=n;var c="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=c[e>>8*n+4&15]+c[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,i=e.length,s=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(s,l(e.substring(t-64,t)));e=e.substring(t-64);var r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(n(s,r),t=0;t<16;t++)r[t]=0;return r[14]=8*i,n(s,r),s}(e))}function h(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function s(e,t=[],n=!1){let i=t;if(!i.length)return{};if(e&&i.length){let t={};return i.forEach((i=>{n&&void 0===e[i]||(t[i]=e[i])})),t}return e}function r(e,t){return s(e,c(e).filter((e=>!t.includes(e))))}function o(e,t){return e.filter((e=>Object.entries(t).every((([t,n])=>e[t]===n))))}function a(e){for(var t in e)return!1;return!0}function l(e){return null!=e}function c(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=s,t.omitKeys=r,t.filter=o,t.find=function(e,t){return o(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,s=t.cmp&&(n=t.cmp,function(e){return function(t,i){var s={key:t,value:e[t]},r={key:i,value:e[i]};return n(s,r)}}),r=[];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!==r.indexOf(t)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=r.push(t)-1,l=Object.keys(t).sort(s&&s(t));for(o="",n=0;n<l.length;n++){var c=l[n],u=e(t[c]);u&&(o&&(o+=","),o+=JSON.stringify(c)+":"+u)}return r.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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,s=!1;for(;!s&&Math.abs(i)<=t.length;){const r=n<1?[i]:[0,i];e.slice(...r)!==t.slice(...r)?s=!0:i+=1*Math.sign(n)}return i}let s=n()-1,r=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:s,to:r,text:t.slice(s,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:s,text:r,md5:o}=t;if(null===r||null===e)return r;let a=e.slice(0,n)+r+e.slice(s);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],s=n.asc?t[n.fieldName]:e[n.fieldName],r=+i-+s,o=i<s?-1:i==s?0:1;return"number"===n.tsDataType&&Number.isFinite(r)?r: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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{a(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:s}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const r=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[r]??(t[r]={initial:n,current:i,delta:s}),this.changed[r].current={...this.changed[r].current,...i},this.changed[r].delta={...this.changed[r].delta,...s}})),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:i,throttle:s,historyAgeSeconds:r=2}=this.options;if(this.isSendingTimeout||this.sending&&!a(this.sending))return;if(!this.changed||a(this.changed))return;let o,l=[],c=[],u={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,i).map((e=>{let t={...this.changed[e]};this.sending[e]={...t},c.push({...t}),u[e]={...t.current},delete this.changed[e]})),l=c.map((e=>{let t={};return Object.keys(e.current).map((n=>{const i=e.initial?.[n],s=e.current[n];var r,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((r=i)===(o=s)||(["number","string","boolean"].includes(typeof r)?r===o:JSON.stringify(r)===JSON.stringify(o)))||(t[n]=s)})),t})),e&&console.log(this.options.id," SENDING lr->",l[l.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,a(this.changed)||this.sendItems()}),s)),this.isOnSending=!0;try{await t(l,c),r&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*r)))}catch(e){o=e,console.error("WAL onSend failed:",e,l,c)}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(o)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",l[l.length-1]),a(this.changed)?n&&n(l,c,o):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||!(a(this.sending)&&a(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.isEmpty=a,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=l,t.getKeys=c,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:n,...r(s,["path","select"]),select:i});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 i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const s=i[n+1];if(s)return{table:e.table,on:(0,t.reverseJoinOn)(s.on)}})).filter(l).reverse()}}},t={};return function n(i){var s=t[i];if(void 0!==s)return s.exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,n),r.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator,f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||f}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||f}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var O=v.prototype=new b;O.constructor=v,m(O,g.prototype),O.isPureReactComponent=!0;var S=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function N(e,t,i){var s,r={},o=null,a=null;if(null!=t)for(s in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,s)&&!j.hasOwnProperty(s)&&(r[s]=t[s]);var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}if(e&&e.defaultProps)for(s in l=e.defaultProps)void 0===r[s]&&(r[s]=l[s]);return{$$typeof:n,type:e,key:o,ref:a,props:r,_owner:w.current}}function E(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var T=/\/+/g;function x(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function C(e,t,s,r,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var l=!1;if(null===e)l=!0;else switch(a){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case n:case i:l=!0}}if(l)return o=o(l=e),e=""===r?"."+x(l,0):r,S(o)?(s="",null!=e&&(s=e.replace(T,"$&/")+"/"),C(o,t,s,"",(function(e){return e}))):null!=o&&(E(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,s+(!o.key||l&&l.key===o.key?"":(""+o.key).replace(T,"$&/")+"/")+e)),t.push(o)),1;if(l=0,r=""===r?".":r+":",S(e))for(var c=0;c<e.length;c++){var u=r+x(a=e[c],c);l+=C(a,t,s,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),c=0;!(a=e.next()).done;)l+=C(a=a.value,t,s,u=r+x(a,c++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function P(e,t,n){if(null==e)return e;var i=[],s=0;return C(e,i,"","",(function(e){return t.call(n,e,s++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},R={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=s,t.Profiler=o,t.PureComponent=v,t.StrictMode=r,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=R,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var s=m({},e.props),r=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(r=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)_.call(t,c)&&!j.hasOwnProperty(c)&&(s[c]=void 0===t[c]&&void 0!==l?l[c]:t[c])}var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}return{$$typeof:n,type:e.type,key:r,ref:o,props:s,_owner:a}},t.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=N,t.createFactory=function(e){var t=N.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=E,t.lazy=function(e){return{$$typeof:h,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,n),r.exports}var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=void 0;const t=n(274),s=n(133);e.prostgles=function(e){return(0,t.prostgles)(e,s.SyncedTable)}})(),i})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>(()=>{var e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),r="DEBUG_SYNCEDTABLE",s="undefined"!=typeof window;t.debug=function(...e){s&&window[r]&&window[r](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{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:a,onDebug:u,db:d,skipFirstTrigger:f=!1,select:p="*",storageType:h="object",patchText:m=!1,patchJSON:y=!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)),s=[],o=[];if(this.columns&&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,i.getTextPatch)(l[e.name],c[e.name]))})),u&&this.wal&&(o.push(u),s.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)})))}}if(s.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(s))}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;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:r,delta:s})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,s)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(s),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((r=>{e.push({...r});const s=t.findIndex((e=>this.matchesIdObj(r,e)));i.push(n[s])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}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=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.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 i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&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";let s,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var r;let l={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(l),f=d.index,p=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(p)||(u=this.getDelta(p||{},u)),t||(u[this.synced_field]=Date.now());let h={...p,...u,...l};p&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(h=c({...p,...l},{...u})),s=p?p[this.synced_field]<h[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(h,f);let m={idObj:l,delta:u,oldItem:p,newItem:h,status:s,from_server:t};return t||a.push({initial:p,current:{...h}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.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=l(e);if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!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,i.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 l(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={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||i)&&(r=r.splice(null!=n?n:0,i||r.length)),r},this.name=e,this.filter=n,this.select=p,this.onChange=r,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[h])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(s||h!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),h="object"),this.storageType=h,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:O=100,batch_size:S=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=S,this.throttle=O,this.skipFirstTrigger=f,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:O};d[this.name]._sync(n,{select:p},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,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;let 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){let 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 i.WAL({..._,batch_size:S,onSendStart:()=>{s&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{s&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,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}})))}}),a()})),d[this.name].getColumns&&d[this.name].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 a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let r=[...n],s=[...i];return t&&(r=r.map(((n,i)=>{const r=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>r(this.getItem(i).data,i),$find:e=>r(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),s=this.getIdObj(n);return r(n,s)}))),e(r,s)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{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:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,r)=>{let s={...e};return n&&(s.$get=i.$get,s.$find=i.$find,s.$update=i.$update,s.$delete=i.$delete,s.$unsync=i.$unsync,s.$cloneSync=i.$cloneSync),t(s,r)}};return this.singleSubscriptions.push(r),setTimeout((()=>{let e=i.$get();e&&r.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.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,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let r={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(r=n):r=n}return{...n,...r}}),{})}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 this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:l(t),index:-1}}setItem(e,t,n=!1,i=!1){const r=l(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),s&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?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(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(r)];else{let e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function c(e,t){const n=e?l(e):e,r=t?l(t):t;let s=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(r)&&Object.keys(r).forEach((e=>{(0,i.isObject)(r[e])?e in n?s[e]=c(n[e],r[e]):Object.assign(s,{[e]:r[e]}):Object.assign(s,{[e]:r[e]})})),s}function l(e){if(s&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>l(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=l(e[n])})),t}return e}t.SyncedTable=a,t.default=c,t.quickClone=l},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=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,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.asName=t.debug=void 0;const s=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o="DEBUG_SYNCEDTABLE",a="undefined"!=typeof window;t.debug=function(...e){a&&window[o]&&window[o](...e)},r(n(353),t),t.prostgles=function(e,n){const{socket:i,onReady:r,onDisconnect:o,onReconnect:l,onSchemaChange:u=!0,onReload:d,onDebug:f}=e;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),e&&i.on(s.CHANNELS.SCHEMA_CHANGED,e)}const p=s.CHANNELS._preffix;let h,m,y={},g={},b={},v={};function O(e,n,r){return(0,t.debug)("_unsubscribe",{channelName:e,handler:r}),new Promise(((t,s)=>{y[e]?(y[e].handlers=y[e].handlers.filter((e=>e!==r)),y[e].handlers.length||(i.emit(n,{},((e,t)=>{e&&console.error(e)})),i.removeListener(e,y[e].onCall),delete y[e]),t(!0)):t(!0)}))}function S({tableName:e,command:t,param1:n,param2:r},s){return new Promise(((o,a)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:r}=t;i.emit(r,{onSyncRequest:s({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:r})}}))}))}function _({tableName:e,command:t,param1:n,param2:r}){return new Promise(((s,o)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{e?(console.error(e),o(e)):t&&s(t)}))}))}const w=new c((async function({tableName:e,command:n,param1:r,param2:s},o){const{onPullRequest:a,onSyncRequest:c,onUpdates:l}=o;function u(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,r)=>{b[e]&&(b[e].triggers=b[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),b[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?r(e):t(n)})),i.removeListener(e,b[e].onCall),delete b[e]))}))}(e,o)},syncData:function(t,n,r){i.emit(e,{onSyncRequest:{...c({}),...{data:t}||{},...{deleted:n}||{}}},r?e=>{r(e)}:null)}})}const d=Object.keys(b).find((t=>{let i=b[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(d)return b[d].triggers.push(o),u(d);{const f=await S({tableName:e,command:n,param1:r,param2:s},c),{channelName:p,synced_field:h,id_fields:m}=f;function y(t,n){t&&b[p]&&b[p].triggers.map((({onUpdates:i,onSyncRequest:r,onPullRequest:s})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(r(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(s(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return b[p]={tableName:e,command:n,param1:r,param2:s,triggers:[o],syncInfo:f,onCall:y},i.on(p,y),u(p)}}),(([{tableName:e}])=>e)),j=new c((async function(e,{tableName:t,command:n,param1:r,param2:s},o,a){function c(n,i){let s={unsubscribe:function(){return O(n,i,o)},filter:{...r}};return e[t].update&&(s={...s,update:function(n,i){return e[t].update(r,n,i)}}),e[t].delete&&(s={...s,delete:function(n){return e[t].delete(r,n)}}),Object.freeze(s)}const l=Object.entries(y).find((([e])=>{let i=y[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l){const e=l[0];return l[1].handlers.push(o),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==y?void 0:y[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==y?void 0:y[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:f}=await _({tableName:t,command:n,param1:r,param2:s}),p=function(e,t){const n=y[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},h=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,p),y[u]={lastData:void 0,tableName:t,command:n,param1:r,param2:s,onCall:p,unsubChannel:f,handlers:[o],errorHandlers:[h],destroy:()=>{y[u]&&(Object.values(y[u]).map((e=>{e&&e.handlers&&e.handlers.map((e=>O(u,f,e)))})),delete y[u])}},i.emit(d,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function E(e,t,n,i){return j.run([e,t,n,i])}return new Promise(((e,c)=>{i.removeAllListeners(s.CHANNELS.CONNECTION),i.on(s.CHANNELS.CONNECTION,(e=>(c(e),"ok"))),o&&i.on("disconnect",(()=>{m="disconnected",o()})),l&&i.on("connect",(()=>{"disconnected"===m&&(m="reconnected")})),i.on(s.CHANNELS.SCHEMA,(({schema:o,methods:u,tableSchema:O,auth:j,rawSQL:N,joinTables:C=[],err:T})=>{if((0,t.debug)("destroySyncs",{subscriptions:y,syncedTables:g}),Object.values(y).map((e=>e.destroy())),y={},b={},Object.values(g).map((e=>{e&&e.destroy&&e.destroy()})),g={},("connected"===m||"reconnected"===m)&&l&&(l(i,T),T))return void console.error(T);if(T)throw c(T),T;const x="reconnected"===m;m="connected";let P=JSON.parse(JSON.stringify(o)),I=JSON.parse(JSON.stringify(u)),k={},$={};if(j){if(j.pathGuard&&a){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(d?d():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(s.CHANNELS.AUTHGUARD),i.on(s.CHANNELS.AUTHGUARD,(t=>{e(t)}))}$={...j},[s.CHANNELS.LOGIN,s.CHANNELS.LOGOUT,s.CHANNELS.REGISTER].map((e=>{j[e]&&($[e]=function(t){return new Promise(((n,r)=>{i.emit(p+e,t,((e,t)=>{e?r(e):n(t)}))}))})}))}I.map((e=>{const t="string"==typeof e,n=t?e:e.name,r=async function(...e){return await(null==f?void 0:f({type:"method",command:n,data:{params:e}})),new Promise(((t,r)=>{i.emit(s.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?r(e):t(n)}))}))};k[n]=t?r:{...e,run:r}})),k=Object.freeze(k),N&&(P.sql=function(e,t,n){return new Promise(((r,o)=>{i.emit(s.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{h=h||{config:t,listeners:[]},h.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{h&&h.listeners&&h.listeners.length?h.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),h.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{h&&(h.listeners=h.listeners.filter((t=>t!==e)),!h.listeners.length&&h.config&&h.config.socketUnsubChannel&&i&&i.emit(h.config.socketUnsubChannel,{}))})(t)}),s={...e,addListener:n};r(s)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))r(t);else{const e=e=>(((e,t)=>{var n;v=v||{},v[t.notifChannel]?null===(n=v[t.notifChannel])||void 0===n||n.listeners.push(e):(v[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,r;(null===(n=v[t.notifChannel])||void 0===n?void 0:n.listeners.length)?v[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(r=v[t.notifChannel])||void 0===r?void 0:r.config.socketUnsubChannel,{})})))})(e,t),{...t,removeListener:()=>((e,t)=>{const n=v[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete v[t.notifChannel]))})(e,t)}),n={...t,addListener:e};r(n)}}))}))});const D=e=>"[object Object]"===Object.prototype.toString.call(e),R=(e,t,n,i)=>{if(!D(e)||!D(t)||"function"!=typeof n||i&&"function"!=typeof i)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},A=["subscribe","subscribeOne"];(0,s.getKeys)(P).forEach((e=>{Object.keys(P[e]).sort(((e,t)=>A.includes(e)-A.includes(t))).forEach((t=>{if(["find","findOne"].includes(t)&&(P[e].getJoinedTables=function(){return(C||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))}),"sync"===t){if(P[e]._syncInfo={...P[e][t]},n){P[e].getSync=async(t,i={})=>(await(null==f?void 0:f({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:f,filter:t,db:P,...i}));const t=async(t={},i={},r)=>{const s=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return g[s]||(g[s]=await n.create({...i,onDebug:f,name:e,filter:t,db:P,onError:r})),g[s]};P[e].sync=async(n,i={handlesOnData:!0,select:"*"},r,s)=>{await(null==f?void 0:f({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),R(n,i,r,s);const o=await t(n,i,s);return await o.sync(r,i.handlesOnData)},P[e].syncOne=async(n,i={handlesOnData:!0},r,s)=>{await(null==f?void 0:f({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),R(n,i,r,s);const o=await t(n,i,s);return await o.syncOne(n,r,i.handlesOnData)}}P[e]._sync=async function(n,i,r){return await(null==f?void 0:f({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:r}})),async function(e,t){return w.run([e,t])}({tableName:e,command:t,param1:n,param2:i},r)}}else if(A.includes(t)){const n=async function(n,i,r,s){return await(null==f?void 0:f({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),R(n,i,r,s),E(P,{tableName:e,command:t,param1:n,param2:i},r,s)};P[e][t]=n;const i="subscribeOne";P[e][t+"Hook"]=function(e={},r={},s){return{start:o=>n(e,r,t!==i?o:e=>{o(e[0])},s),args:[e,r,s]}},t!==i&&A.includes(i)||(P[e][i]=async function(n,i,r,s){return await(null==f?void 0:f({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),R(n,i,r,s),E(P,{tableName:e,command:t,param1:n,param2:i},(e=>{r(e[0])}),s)})}else P[e][t]=async function(n,r,s){return await(null==f?void 0:f({type:"table",command:t,tableName:e,data:{param1:n,param2:r,param3:s}})),new Promise(((o,a)=>{i.emit(p,{tableName:e,command:t,param1:n,param2:r,param3:s},((e,t)=>{e?a(e):o(t)}))}))}}))})),y&&Object.keys(y).length&&Object.keys(y).map((async e=>{try{let t=y[e];await _(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),b&&Object.keys(b).length&&(0,s.getKeys)(b).filter((e=>{var t;return null===(t=b[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=b[e];await S(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),C.flat().map((e=>{P.innerJoin=P.innerJoin||{},P.leftJoin=P.leftJoin||{},P.innerJoinOne=P.innerJoinOne||{},P.leftJoinOne=P.leftJoinOne||{};const t=(0,s.getJoinHandlers)(e);P.leftJoin[e]=t.leftJoin,P.innerJoin[e]=t.innerJoin,P.leftJoinOne[e]=t.leftJoinOne,P.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await r(P,k,O,$,x)}catch(e){console.error("Prostgles: Error within onReady: \n",e),c(e)}e(P)})()}))}))};class c{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),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,i)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:i,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}}},353:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useSubscribeOne=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=void 0;const i=n(294),r=n(792),{useEffect:s,useCallback:o,useRef:a,useState:c}=null!=i?i:{};function l(){const e=a(!0),t=o((()=>e.current),[]);return s((()=>()=>{e.current=!1}),[]),t}t.isEqual=(e,n)=>{const i=Object.keys,r=typeof e;return e&&n&&"object"===r&&r===typeof n?i(e).length===i(n).length&&i(e).every((i=>(0,t.isEqual)(e[i],n[i]))):e===n},t.useDeepCompareMemoize=e=>{const n=a();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{s(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,t)=>{const n={effect:e,deps:t,didCleanup:!1},i=a({activeEffect:void 0,latestEffect:n});i.current.latestEffect=n;const r=async e=>{e.current.latestEffect&&!e.current.activeEffect&&(e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,e.current.activeEffect.resolvedCleanup={run:await e.current.activeEffect.effect()},e.current.activeEffect.didCleanup&&o())},o=async()=>{var e,t,n;(null===(e=i.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)&&(await(null===(n=(t=i.current.activeEffect.resolvedCleanup).run)||void 0===n?void 0:n.call(t)),i.current.activeEffect=void 0,r(i))};s((()=>(r(i),()=>{var t,n;(null===(t=i.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(i.current.activeEffect.didCleanup=!0,i.current.activeEffect.resolvedCleanup&&o()),(null===(n=i.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(i.current.latestEffect.didCleanup=!0)})),t)},t.useEffectAsync=(e,t)=>{const n=a({cleanup:void 0,effect:e,cleanupEffect:void 0});n.current.effect=e,s((()=>(e().then((t=>{"function"==typeof t&&(n.current.cleanup=t,n.current.cleanupEffect===e&&t())})),()=>{var t,i;n.current.cleanupEffect=e,null===(i=(t=n.current).cleanup)||void 0===i||i.call(t)})),t)},t.useIsMounted=l,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},s=e=>{try{return(0,r.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,u]=c(s(e)?{}:void 0),d=l();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(s(e))t=await o(e);else{const n=await e();t=s(n)?await o(n):i(n)?await n():n}d()&&u(t)}),n),a},t.useSubscribe=e=>{const[n,i]=c(),r=l();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{r()&&i(e)}))).unsubscribe),e.args.map((e=>JSON.stringify(e)))),n},t.useSubscribeOne=e=>{const[n,i]=c(),r=l();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{r()&&i(e)}))).unsubscribe),[]),n},t.__prglReactInstalled=()=>Boolean(i&&a)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=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,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 s={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},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"]},r(n(128),t),r(n(444),t);var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(n(929),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);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,t)=>{const{type:n,arrayOf:s,arrayOfType:o,description:a,nullable:c,oneOf:l,oneOfType:u,title:d,record:f,...p}="string"==typeof e?{type:e}:e;let h={};const m={...(p.enum||p.allowedValues?.length)&&{enum:p.allowedValues?.slice(0)??p.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(p.enum?.length&&(m.type=typeof p.enum[0]),"string"==typeof n||s||o){if(n&&"string"!=typeof n)throw"Not expected";h=s||o||n?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...p.allowedValues&&{enum:p.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?h={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:r(n[t])})),{})}:l||u?h={oneOf:(l||u.map((e=>({type:e})))).map((e=>r(e)))}:f&&(h={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:r(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?r(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};h.oneOf?h.oneOf.push(e):h.enum&&!h.enum.includes(null)?h.enum.push(null):h={oneOf:[h,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...h}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return r(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],c=e[2],l=e[3];n=r(n,i,c,l,t[0],7,-680876936),l=r(l,n,i,c,t[1],12,-389564586),c=r(c,l,n,i,t[2],17,606105819),i=r(i,c,l,n,t[3],22,-1044525330),n=r(n,i,c,l,t[4],7,-176418897),l=r(l,n,i,c,t[5],12,1200080426),c=r(c,l,n,i,t[6],17,-1473231341),i=r(i,c,l,n,t[7],22,-45705983),n=r(n,i,c,l,t[8],7,1770035416),l=r(l,n,i,c,t[9],12,-1958414417),c=r(c,l,n,i,t[10],17,-42063),i=r(i,c,l,n,t[11],22,-1990404162),n=r(n,i,c,l,t[12],7,1804603682),l=r(l,n,i,c,t[13],12,-40341101),c=r(c,l,n,i,t[14],17,-1502002290),n=s(n,i=r(i,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,i,c,t[6],9,-1069501632),c=s(c,l,n,i,t[11],14,643717713),i=s(i,c,l,n,t[0],20,-373897302),n=s(n,i,c,l,t[5],5,-701558691),l=s(l,n,i,c,t[10],9,38016083),c=s(c,l,n,i,t[15],14,-660478335),i=s(i,c,l,n,t[4],20,-405537848),n=s(n,i,c,l,t[9],5,568446438),l=s(l,n,i,c,t[14],9,-1019803690),c=s(c,l,n,i,t[3],14,-187363961),i=s(i,c,l,n,t[8],20,1163531501),n=s(n,i,c,l,t[13],5,-1444681467),l=s(l,n,i,c,t[2],9,-51403784),c=s(c,l,n,i,t[7],14,1735328473),n=o(n,i=s(i,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,i,c,t[8],11,-2022574463),c=o(c,l,n,i,t[11],16,1839030562),i=o(i,c,l,n,t[14],23,-35309556),n=o(n,i,c,l,t[1],4,-1530992060),l=o(l,n,i,c,t[4],11,1272893353),c=o(c,l,n,i,t[7],16,-155497632),i=o(i,c,l,n,t[10],23,-1094730640),n=o(n,i,c,l,t[13],4,681279174),l=o(l,n,i,c,t[0],11,-358537222),c=o(c,l,n,i,t[3],16,-722521979),i=o(i,c,l,n,t[6],23,76029189),n=o(n,i,c,l,t[9],4,-640364487),l=o(l,n,i,c,t[12],11,-421815835),c=o(c,l,n,i,t[15],16,530742520),n=a(n,i=o(i,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,i,c,t[7],10,1126891415),c=a(c,l,n,i,t[14],15,-1416354905),i=a(i,c,l,n,t[5],21,-57434055),n=a(n,i,c,l,t[12],6,1700485571),l=a(l,n,i,c,t[3],10,-1894986606),c=a(c,l,n,i,t[10],15,-1051523),i=a(i,c,l,n,t[1],21,-2054922799),n=a(n,i,c,l,t[8],6,1873313359),l=a(l,n,i,c,t[15],10,-30611744),c=a(c,l,n,i,t[6],15,-1560198380),i=a(i,c,l,n,t[13],21,1309151649),n=a(n,i,c,l,t[4],6,-145523070),l=a(l,n,i,c,t[11],10,-1120210379),c=a(c,l,n,i,t[2],15,718787259),i=a(i,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(i,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function i(e,t,n,i,r,s){return t=f(f(t,e),f(i,s)),f(t<<r|t>>>32-r,n)}function r(e,t,n,r,s,o,a){return i(t&n|~t&r,e,t,s,o,a)}function s(e,t,n,r,s,o,a){return i(t&r|n&~r,e,t,s,o,a)}function o(e,t,n,r,s,o,a){return i(t^n^r,e,t,s,o,a)}function a(e,t,n,r,s,o,a){return i(n^(t|~r),e,t,s,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.md5=t.md5cycle=void 0,t.md5cycle=n;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,i=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 s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*i,n(r,s),r}(e))}function f(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function r(e,t=[],n=!1){let i=t;if(!i.length)return{};if(e&&i.length){let t={};return i.forEach((i=>{n&&void 0===e[i]||(t[i]=e[i])})),t}return e}function s(e,t){return r(e,l(e).filter((e=>!t.includes(e))))}function o(e,t){return e.filter((e=>Object.entries(t).every((([t,n])=>e[t]===n))))}function a(e){for(var t in e)return!1;return!0}function c(e){return null!=e}function l(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=r,t.omitKeys=s,t.filter=o,t.find=function(e,t){return o(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},s={key:i,value:e[i]};return n(r,s)}}),s=[];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!==s.indexOf(t)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.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 s.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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,r=!1;for(;!r&&Math.abs(i)<=t.length;){const s=n<1?[i]:[0,i];e.slice(...s)!==t.slice(...s)?r=!0:i+=1*Math.sign(n)}return i}let r=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(r);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],s=+i-+r,o=i<r?-1:i==r?0:1;return"number"===n.tsDataType&&Number.isFinite(s)?s: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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{a(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:r}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:i,delta:r}),this.changed[s].current={...this.changed[s].current,...i},this.changed[s].delta={...this.changed[s].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:i,throttle:r,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!a(this.sending))return;if(!this.changed||a(this.changed))return;let o,c=[],l=[],u={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,i).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 i=e.initial?.[n],r=e.current[n];var s,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((s=i)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===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,a(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}catch(e){o=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(o)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),a(this.changed)?n&&n(c,l,o):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||!(a(this.sending)&&a(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.isEmpty=a,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=c,t.getKeys=l,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,r={})=>({[t?"$leftJoin":"$innerJoin"]:r.path??e,filter:n,...s(r,["path","select"]),select:i});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 i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const r=i[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(c).reverse()}}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator,h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||h}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||h}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var O=v.prototype=new b;O.constructor=v,m(O,g.prototype),O.isPureReactComponent=!0;var S=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,i){var r,s={},o=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,r)&&!j.hasOwnProperty(r)&&(s[r]=t[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:n,type:e,key:o,ref:a,props:s,_owner:w.current}}function N(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var C=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(e,t,r,s,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case i:c=!0}}if(c)return o=o(c=e),e=""===s?"."+T(c,0):s,S(o)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),x(o,t,r,"",(function(e){return e}))):null!=o&&(N(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(C,"$&/")+"/")+e)),t.push(o)),1;if(c=0,s=""===s?".":s+":",S(e))for(var l=0;l<e.length;l++){var u=s+T(a=e[l],l);c+=x(a,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=x(a=a.value,t,r,u=s+T(a,l++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var i=[],r=0;return x(e,i,"","",(function(e){return t.call(n,e,r++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},D={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=r,t.Profiler=o,t.PureComponent=v,t.StrictMode=s,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m({},e.props),s=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!j.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:n,type:e.type,key:s,ref:o,props:r,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=N,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=void 0;const t=n(274),r=n(133);e.prostgles=function(e){return(0,t.prostgles)(e,r.SyncedTable)}})(),i})()));
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.no-sync.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this||window,(()=>{return e={274:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.asName=t.debug=void 0;const o=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return o.asName}});const s="DEBUG_SYNCEDTABLE",a="undefined"!=typeof window;t.debug=function(...e){a&&window[s]&&window[s](...e)},i(n(353),t),t.prostgles=function(e,n){const{socket:r,onReady:i,onDisconnect:s,onReconnect:l,onSchemaChange:u=!0,onReload:p,onDebug:f}=e;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),r.removeAllListeners(o.CHANNELS.SCHEMA_CHANGED),e&&r.on(o.CHANNELS.SCHEMA_CHANGED,e)}const d=o.CHANNELS._preffix;let m,h={},y={},g={},b={},v=!1,_=!1;function O(e,n,i){return(0,t.debug)("_unsubscribe",{channelName:e,handler:i}),new Promise(((t,o)=>{h[e]?(h[e].handlers=h[e].handlers.filter((e=>e!==i)),h[e].handlers.length||(r.emit(n,{},((e,t)=>{e&&console.error(e)})),r.removeListener(e,h[e].onCall),delete h[e]),t(!0)):t(!0)}))}function S({tableName:e,command:t,param1:n,param2:i},o){return new Promise(((s,a)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:i}=t;r.emit(i,{onSyncRequest:o({})},(e=>{console.log(e)})),s({id_fields:e,synced_field:n,channelName:i})}}))}))}function N({tableName:e,command:t,param1:n,param2:i}){return new Promise(((o,s)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i},((e,t)=>{e?(console.error(e),s(e)):t&&o(t)}))}))}const E=new c((async function({tableName:e,command:n,param1:i,param2:o},s){const{onPullRequest:a,onSyncRequest:c,onUpdates:l}=s;function u(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,i)=>{g[e]&&(g[e].triggers=g[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),g[e].triggers.length||(r.emit(e+"unsync",{},((e,n)=>{e?i(e):t(n)})),r.removeListener(e,g[e].onCall),delete g[e]))}))}(e,s)},syncData:function(t,n,i){r.emit(e,{onSyncRequest:{...c({}),...{data:t}||{},...{deleted:n}||{}}},i?e=>{i(e)}:null)}})}const p=Object.keys(g).find((t=>{let r=g[t];return r&&r.tableName===e&&r.command===n&&JSON.stringify(r.param1||{})===JSON.stringify(i||{})&&JSON.stringify(r.param2||{})===JSON.stringify(o||{})}));if(p)return g[p].triggers.push(s),u(p);{const f=await S({tableName:e,command:n,param1:i,param2:o},c),{channelName:d,synced_field:m,id_fields:h}=f;function y(t,n){t&&g[d]&&g[d].triggers.map((({onUpdates:r,onSyncRequest:i,onPullRequest:o})=>{t.data?Promise.resolve(r(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(i(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(o(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return g[d]={tableName:e,command:n,param1:i,param2:o,triggers:[s],syncInfo:f,onCall:y},r.on(d,y),u(d)}}),(([{tableName:e}])=>e)),w=new c((async function(e,{tableName:t,command:n,param1:i,param2:o},s,a){function c(n,r){let o={unsubscribe:function(){return O(n,r,s)},filter:{...i}};return e[t].update&&(o={...o,update:function(n,r){return e[t].update(i,n,r)}}),e[t].delete&&(o={...o,delete:function(n){return e[t].delete(i,n)}}),Object.freeze(o)}const l=Object.entries(h).find((([e])=>{let r=h[e];return r&&r.tableName===t&&r.command===n&&JSON.stringify(r.param1||{})===JSON.stringify(i||{})&&JSON.stringify(r.param2||{})===JSON.stringify(o||{})}));if(l){const e=l[0];return l[1].handlers.push(s),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;s&&(null===(t=null==h?void 0:h[e])||void 0===t?void 0:t.lastData)&&s(null===(n=null==h?void 0:h[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:p,channelNameUnsubscribe:f}=await N({tableName:t,command:n,param1:i,param2:o}),d=function(e,t){const n=h[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},m=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return r.on(u,d),h[u]={lastData:void 0,tableName:t,command:n,param1:i,param2:o,onCall:d,unsubChannel:f,handlers:[s],errorHandlers:[m],destroy:()=>{h[u]&&(Object.values(h[u]).map((e=>{e&&e.handlers&&e.handlers.map((e=>O(u,f,e)))})),delete h[u])}},r.emit(p,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function x(e,t,n,r){return w.run([e,t,n,r])}return new Promise(((e,c)=>{r.removeAllListeners(o.CHANNELS.CONNECTION),r.on(o.CHANNELS.CONNECTION,(e=>(c(e),"ok"))),s&&r.on("disconnect",(()=>{v=!1,_=!1,s()})),l&&r.on("connect",(()=>{_=!0})),r.on(o.CHANNELS.SCHEMA,(({schema:s,methods:u,tableSchema:O,auth:w,rawSQL:j,joinTables:T=[],err:C})=>{if((0,t.debug)("destroySyncs",{subscriptions:h,syncedTables:y}),Object.values(h).map((e=>e.destroy())),h={},g={},Object.values(y).map((e=>{e&&e.destroy&&e.destroy()})),y={},(v||_)&&l&&(l(r,C),C))return void console.error(C);if(C)throw c(C),C;v=!0;let P=JSON.parse(JSON.stringify(s)),k=JSON.parse(JSON.stringify(u)),R={},A={};if(w){if(w.pathGuard&&a){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(p?p():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};r.emit(o.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),r.removeAllListeners(o.CHANNELS.AUTHGUARD),r.on(o.CHANNELS.AUTHGUARD,(t=>{e(t)}))}A={...w},[o.CHANNELS.LOGIN,o.CHANNELS.LOGOUT,o.CHANNELS.REGISTER].map((e=>{w[e]&&(A[e]=function(t){return new Promise(((n,i)=>{r.emit(d+e,t,((e,t)=>{e?i(e):n(t)}))}))})}))}k.map((e=>{const t="string"==typeof e,n=t?e:e.name,i=async function(...e){return await(null==f?void 0:f({type:"method",command:n,data:{params:e}})),new Promise(((t,i)=>{r.emit(o.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?i(e):t(n)}))}))};R[n]=t?i:{...e,run:i}})),R=Object.freeze(R),j&&(P.sql=function(e,t,n){return new Promise(((i,s)=>{r.emit(o.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)s(e);else if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{m=m||{config:t,listeners:[]},m.listeners.length||(r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,(e=>{m&&m.listeners&&m.listeners.length?m.listeners.map((t=>{t(e)})):r.emit(t.socketUnsubChannel,{})}))),m.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{m&&(m.listeners=m.listeners.filter((t=>t!==e)),!m.listeners.length&&m.config&&m.config.socketUnsubChannel&&r&&r.emit(m.config.socketUnsubChannel,{}))})(t)}),o={...e,addListener:n};i(o)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))i(t);else{const e=e=>(((e,t)=>{var n;b=b||{},b[t.notifChannel]?null===(n=b[t.notifChannel])||void 0===n||n.listeners.push(e):(b[t.notifChannel]={config:t,listeners:[e]},r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,(e=>{var n,i;(null===(n=b[t.notifChannel])||void 0===n?void 0:n.listeners.length)?b[t.notifChannel].listeners.map((t=>{t(e)})):r.emit(null===(i=b[t.notifChannel])||void 0===i?void 0:i.config.socketUnsubChannel,{})})))})(e,t),{...t,removeListener:()=>((e,t)=>{const n=b[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&r&&(r.emit(n.config.socketUnsubChannel,{}),delete b[t.notifChannel]))})(e,t)}),n={...t,addListener:e};i(n)}}))}))});const J=e=>"[object Object]"===Object.prototype.toString.call(e),$=(e,t,n,r)=>{if(!J(e)||!J(t)||"function"!=typeof n||r&&"function"!=typeof r)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},D=["subscribe","subscribeOne"];(0,o.getKeys)(P).forEach((e=>{Object.keys(P[e]).sort(((e,t)=>D.includes(e)-D.includes(t))).forEach((t=>{if(["find","findOne"].includes(t)&&(P[e].getJoinedTables=function(){return(T||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))}),"sync"===t){if(P[e]._syncInfo={...P[e][t]},n){P[e].getSync=async(t,r={})=>(await(null==f?void 0:f({type:"table",command:"getSync",tableName:e,data:{filter:t,params:r}})),n.create({name:e,onDebug:f,filter:t,db:P,...r}));const t=async(t={},r={},i)=>{const o=`${e}.${JSON.stringify(t)}.${JSON.stringify(r)}`;return y[o]||(y[o]=await n.create({...r,onDebug:f,name:e,filter:t,db:P,onError:i})),y[o]};P[e].sync=async(n,r={handlesOnData:!0,select:"*"},i,o)=>{await(null==f?void 0:f({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:r}})),$(n,r,i,o);const s=await t(n,r,o);return await s.sync(i,r.handlesOnData)},P[e].syncOne=async(n,r={handlesOnData:!0},i,o)=>{await(null==f?void 0:f({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:r}})),$(n,r,i,o);const s=await t(n,r,o);return await s.syncOne(n,i,r.handlesOnData)}}P[e]._sync=async function(n,r,i){return await(null==f?void 0:f({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:r,syncHandles:i}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:r},i)}}else if(D.includes(t)){const n=async function(n,r,i,o){return await(null==f?void 0:f({type:"table",command:t,tableName:e,data:{param1:n,param2:r,onChange:i,onError:o}})),$(n,r,i,o),x(P,{tableName:e,command:t,param1:n,param2:r},i,o)};P[e][t]=n;const r="subscribeOne";P[e][t+"Hook"]=function(e={},i={},o){return{start:s=>n(e,i,t!==r?s:e=>{s(e[0])},o),args:[e,i,o]}},t!==r&&D.includes(r)||(P[e][r]=async function(n,r,i,o){return await(null==f?void 0:f({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:r,onChange:i,onError:o}})),$(n,r,i,o),x(P,{tableName:e,command:t,param1:n,param2:r},(e=>{i(e[0])}),o)})}else P[e][t]=async function(n,i,o){return await(null==f?void 0:f({type:"table",command:t,tableName:e,data:{param1:n,param2:i,param3:o}})),new Promise(((s,a)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i,param3:o},((e,t)=>{e?a(e):s(t)}))}))}}))})),h&&Object.keys(h).length&&Object.keys(h).map((async e=>{try{let t=h[e];await N(t),r.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),g&&Object.keys(g).length&&(0,o.getKeys)(g).filter((e=>{var t;return null===(t=g[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=g[e];await S(t,t.triggers[0].onSyncRequest),r.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),T.flat().map((e=>{P.innerJoin=P.innerJoin||{},P.leftJoin=P.leftJoin||{},P.innerJoinOne=P.innerJoinOne||{},P.leftJoinOne=P.leftJoinOne||{};const t=(0,o.getJoinHandlers)(e);P.leftJoin[e]=t.leftJoin,P.innerJoin[e]=t.innerJoin,P.leftJoinOne[e]=t.leftJoinOne,P.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await i(P,R,O,A,v)}catch(e){console.error("Prostgles: Error within onReady: \n",e),c(e)}e(P)})()}))}))};class c{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const r={arguments:e,onResult:t,onFail:n};this.queue.push(r)})),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,r)=>{const i=this.groupBy(e.arguments);t.includes(i)||(t.push(i),n.push({index:r,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}}},353:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useSubscribeOne=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=void 0;const r=n(294),i=n(792),{useEffect:o,useCallback:s,useRef:a,useState:c}=null!=r?r:{};function l(){const e=a(!0),t=s((()=>e.current),[]);return o((()=>()=>{e.current=!1}),[]),t}t.useEffectAsync=(e,t)=>{const n=a({cleanup:void 0,effect:e,cleanupEffect:void 0});n.current.effect=e,o((()=>(e().then((t=>{"function"==typeof t&&(n.current.cleanup=t,n.current.cleanupEffect===e&&t())})),()=>{var t,r;n.current.cleanupEffect=e,null===(r=(t=n.current).cleanup)||void 0===r||r.call(t)})),t)},t.useIsMounted=l,t.usePromise=(e,n=[])=>{const r=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},o=e=>{try{return(0,i.isObject)(e)&&!r(e)}catch(e){console.error(e)}return!1},s=async e=>{const t={},n=(0,i.getKeys)(e);for await(const r of n){const n=e[r];t[r]="function"==typeof n?await n():await n}return t},[a,u]=c(o(e)?{}:void 0),p=l();return(0,t.useEffectAsync)((async()=>{let t;if(o(e))t=await s(e);else{const n=await e();t=o(n)?await s(n):r(n)?await n():n}p()&&u(t)}),n),a},t.useSubscribe=e=>{const[n,r]=c(),i=l();return(0,t.useEffectAsync)((async()=>(await e.start((e=>{i()&&r(e)}))).unsubscribe),e.args.map((e=>JSON.stringify(e)))),n},t.useSubscribeOne=e=>{const[n,r]=c(),i=l();return(0,t.useEffectAsync)((async()=>(await e.start((e=>{i()&&r(e)}))).unsubscribe),[]),n},t.__prglReactInstalled=()=>Boolean(r&&a)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,r.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 o={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...o,"number[]":o.number.map((e=>`_${e}`)),"boolean[]":o.boolean.map((e=>`_${e}`)),"string[]":o.string.map((e=>`_${e}`)),"any[]":o.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const s="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:s+"schema-changed",SCHEMA:s+"schema",DEFAULT:s,SQL:`${s}sql`,METHOD:`${s}method`,NOTICE_EV:`${s}notice`,LISTEN_EV:`${s}listen`,REGISTER:`${s}register`,LOGIN:`${s}login`,LOGOUT:`${s}logout`,AUTHGUARD:`${s}authguard`,CONNECTION:`${s}connection`,_preffix:s},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"]},i(n(128),t),i(n(444),t);var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),i(n(929),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const r=n(128);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 i=(e,t)=>{const{type:n,arrayOf:o,arrayOfType:s,description:a,nullable:c,oneOf:l,oneOfType:u,title:p,record:f,...d}="string"==typeof e?{type:e}:e;let m={};const h={...(d.enum||d.allowedValues?.length)&&{enum:d.allowedValues?.slice(0)??d.enum.slice(0)},...!!a&&{description:a},...!!p&&{title:p}};if(d.enum?.length&&(h.type=typeof d.enum[0]),"string"==typeof n||o||s){if(n&&"string"!=typeof n)throw"Not expected";m=o||s||n?.endsWith("[]")?{type:"array",items:o||s?i(o||{type:s}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...d.allowedValues&&{enum:d.allowedValues.slice(0)}}}:{type:n}}else(0,r.isObject)(n)?m={type:"object",required:(0,r.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,r.getKeys)(n).reduce(((e,t)=>({...e,[t]:i(n[t])})),{})}:l||u?m={oneOf:(l||u.map((e=>({type:e})))).map((e=>i(e)))}:f&&(m={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:i(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?i(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...h,...m}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return i(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=o(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=o(l,n,r,c,t[6],9,-1069501632),c=o(c,l,n,r,t[11],14,643717713),r=o(r,c,l,n,t[0],20,-373897302),n=o(n,r,c,l,t[5],5,-701558691),l=o(l,n,r,c,t[10],9,38016083),c=o(c,l,n,r,t[15],14,-660478335),r=o(r,c,l,n,t[4],20,-405537848),n=o(n,r,c,l,t[9],5,568446438),l=o(l,n,r,c,t[14],9,-1019803690),c=o(c,l,n,r,t[3],14,-187363961),r=o(r,c,l,n,t[8],20,1163531501),n=o(n,r,c,l,t[13],5,-1444681467),l=o(l,n,r,c,t[2],9,-51403784),c=o(c,l,n,r,t[7],14,1735328473),n=s(n,r=o(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=s(l,n,r,c,t[8],11,-2022574463),c=s(c,l,n,r,t[11],16,1839030562),r=s(r,c,l,n,t[14],23,-35309556),n=s(n,r,c,l,t[1],4,-1530992060),l=s(l,n,r,c,t[4],11,1272893353),c=s(c,l,n,r,t[7],16,-155497632),r=s(r,c,l,n,t[10],23,-1094730640),n=s(n,r,c,l,t[13],4,681279174),l=s(l,n,r,c,t[0],11,-358537222),c=s(c,l,n,r,t[3],16,-722521979),r=s(r,c,l,n,t[6],23,76029189),n=s(n,r,c,l,t[9],4,-640364487),l=s(l,n,r,c,t[12],11,-421815835),c=s(c,l,n,r,t[15],16,530742520),n=a(n,r=s(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function r(e,t,n,r,i,o){return t=f(f(t,e),f(r,o)),f(t<<i|t>>>32-i,n)}function i(e,t,n,i,o,s,a){return r(t&n|~t&i,e,t,o,s,a)}function o(e,t,n,i,o,s,a){return r(t&i|n&~i,e,t,o,s,a)}function s(e,t,n,i,o,s,a){return r(t^n^i,e,t,o,s,a)}function a(e,t,n,i,o,s,a){return r(n^(t|~i),e,t,o,s,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.md5=t.md5cycle=void 0,t.md5cycle=n;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 p(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(i,o),t=0;t<16;t++)o[t]=0;return o[14]=8*r,n(i,o),i}(e))}function f(e,t){return e+t&4294967295}t.md5=p,p("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const r=n(899);function i(e,t=[],n=!1){let r=t;if(!r.length)return{};if(e&&r.length){let t={};return r.forEach((r=>{n&&void 0===e[r]||(t[r]=e[r])})),t}return e}function o(e,t){return i(e,l(e).filter((e=>!t.includes(e))))}function s(e,t){return e.filter((e=>Object.entries(t).every((([t,n])=>e[t]===n))))}function a(e){for(var t in e)return!1;return!0}function c(e){return null!=e}function l(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=i,t.omitKeys=o,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];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,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(s="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(s&&(s+=","),s+=JSON.stringify(l)+":"+u)}return o.splice(a,1),"{"+s+"}"}}(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,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const o=n<1?[r]:[0,r];e.slice(...o)!==t.slice(...o)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,o=e.length+n(-1)+1,s=t.length+n(-1)+1;return{from:i,to:o,text:t.slice(i,s),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:o,md5:s}=t;if(null===o||null===e)return o;let a=e.slice(0,n)+o+e.slice(i);if(s&&(0,r.md5)(a)!==s)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],o=+r-+i,s=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(o)?o:s})).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)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r==+t)return!0}return!1},this.addData=e=>{a(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const o=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[o]??(t[o]={initial:n,current:r,delta:i}),this.changed[o].current={...this.changed[o].current,...r},this.changed[o].delta={...this.changed[o].delta,...i}})),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:r,throttle:i,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!a(this.sending))return;if(!this.changed||a(this.changed))return;let s,c=[],l=[],u={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,r).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 r=e.initial?.[n],i=e.current[n];var o,s;![this.options.synced_field,...this.options.id_fields].includes(n)&&((o=r)===(s=i)||(["number","string","boolean"].includes(typeof o)?o===s:JSON.stringify(o)===JSON.stringify(s)))||(t[n]=i)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,a(this.changed)||this.sendItems()}),i)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*o)))}catch(e){s=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(s)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),a(this.changed)?n&&n(c,l,s):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||!(a(this.sending)&&a(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.isEmpty=a,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=c,t.getKeys=l,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,r,i={})=>({[t?"$leftJoin":"$innerJoin"]:i.path??e,filter:n,...o(i,["path","select"]),select:r});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 r=[{table:n,on:[{}]},...e??[]];return r.map(((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}})).filter(c).reverse()}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),d=Symbol.iterator,m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||m}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||m}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var _=v.prototype=new b;_.constructor=v,h(_,g.prototype),_.isPureReactComponent=!0;var O=Array.isArray,S=Object.prototype.hasOwnProperty,N={current:null},E={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,r){var i,o={},s=null,a=null;if(null!=t)for(i in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(s=""+t.key),t)S.call(t,i)&&!E.hasOwnProperty(i)&&(o[i]=t[i]);var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];o.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps)void 0===o[i]&&(o[i]=c[i]);return{$$typeof:n,type:e,key:s,ref:a,props:o,_owner:N.current}}function x(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var j=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function C(e,t,i,o,s){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case r:c=!0}}if(c)return s=s(c=e),e=""===o?"."+T(c,0):o,O(s)?(i="",null!=e&&(i=e.replace(j,"$&/")+"/"),C(s,t,i,"",(function(e){return e}))):null!=s&&(x(s)&&(s=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(s,i+(!s.key||c&&c.key===s.key?"":(""+s.key).replace(j,"$&/")+"/")+e)),t.push(s)),1;if(c=0,o=""===o?".":o+":",O(e))for(var l=0;l<e.length;l++){var u=o+T(a=e[l],l);c+=C(a,t,i,u,s)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=d&&e[d]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=C(a=a.value,t,i,u=o+T(a,l++),s);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var r=[],i=0;return C(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function k(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var R={current:null},A={transition:null},J={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:A,ReactCurrentOwner:N};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!x(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=i,t.Profiler=s,t.PureComponent=v,t.StrictMode=o,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=J,t.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var i=h({},e.props),o=e.key,s=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,a=N.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)S.call(t,l)&&!E.hasOwnProperty(l)&&(i[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:n,type:e.type,key:o,ref:s,props:i,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=w,t.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=x,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:k}},t.memo=function(e,t){return{$$typeof:p,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=A.transition;A.transition={};try{e()}finally{A.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return R.current.useCallback(e,t)},t.useContext=function(e){return R.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return R.current.useDeferredValue(e)},t.useEffect=function(e,t){return R.current.useEffect(e,t)},t.useId=function(){return R.current.useId()},t.useImperativeHandle=function(e,t,n){return R.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return R.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return R.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return R.current.useMemo(e,t)},t.useReducer=function(e,t,n){return R.current.useReducer(e,t,n)},t.useRef=function(e){return R.current.useRef(e)},t.useState=function(e){return R.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return R.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return R.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={},function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(274);var e,t}));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this||window,(()=>{return e={274:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.asName=t.debug=void 0;const o=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return o.asName}});const s="DEBUG_SYNCEDTABLE",a="undefined"!=typeof window;t.debug=function(...e){a&&window[s]&&window[s](...e)},i(n(353),t),t.prostgles=function(e,n){const{socket:r,onReady:i,onDisconnect:s,onReconnect:l,onSchemaChange:u=!0,onReload:f,onDebug:p}=e;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),r.removeAllListeners(o.CHANNELS.SCHEMA_CHANGED),e&&r.on(o.CHANNELS.SCHEMA_CHANGED,e)}const d=o.CHANNELS._preffix;let m,h,y={},g={},b={},v={};function _(e,n,i){return(0,t.debug)("_unsubscribe",{channelName:e,handler:i}),new Promise(((t,o)=>{y[e]?(y[e].handlers=y[e].handlers.filter((e=>e!==i)),y[e].handlers.length||(r.emit(n,{},((e,t)=>{e&&console.error(e)})),r.removeListener(e,y[e].onCall),delete y[e]),t(!0)):t(!0)}))}function O({tableName:e,command:t,param1:n,param2:i},o){return new Promise(((s,a)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:i}=t;r.emit(i,{onSyncRequest:o({})},(e=>{console.log(e)})),s({id_fields:e,synced_field:n,channelName:i})}}))}))}function S({tableName:e,command:t,param1:n,param2:i}){return new Promise(((o,s)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i},((e,t)=>{e?(console.error(e),s(e)):t&&o(t)}))}))}const E=new c((async function({tableName:e,command:n,param1:i,param2:o},s){const{onPullRequest:a,onSyncRequest:c,onUpdates:l}=s;function u(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,i)=>{b[e]&&(b[e].triggers=b[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),b[e].triggers.length||(r.emit(e+"unsync",{},((e,n)=>{e?i(e):t(n)})),r.removeListener(e,b[e].onCall),delete b[e]))}))}(e,s)},syncData:function(t,n,i){r.emit(e,{onSyncRequest:{...c({}),...{data:t}||{},...{deleted:n}||{}}},i?e=>{i(e)}:null)}})}const f=Object.keys(b).find((t=>{let r=b[t];return r&&r.tableName===e&&r.command===n&&JSON.stringify(r.param1||{})===JSON.stringify(i||{})&&JSON.stringify(r.param2||{})===JSON.stringify(o||{})}));if(f)return b[f].triggers.push(s),u(f);{const p=await O({tableName:e,command:n,param1:i,param2:o},c),{channelName:d,synced_field:m,id_fields:h}=p;function y(t,n){t&&b[d]&&b[d].triggers.map((({onUpdates:r,onSyncRequest:i,onPullRequest:o})=>{t.data?Promise.resolve(r(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(i(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(o(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return b[d]={tableName:e,command:n,param1:i,param2:o,triggers:[s],syncInfo:p,onCall:y},r.on(d,y),u(d)}}),(([{tableName:e}])=>e)),N=new c((async function(e,{tableName:t,command:n,param1:i,param2:o},s,a){function c(n,r){let o={unsubscribe:function(){return _(n,r,s)},filter:{...i}};return e[t].update&&(o={...o,update:function(n,r){return e[t].update(i,n,r)}}),e[t].delete&&(o={...o,delete:function(n){return e[t].delete(i,n)}}),Object.freeze(o)}const l=Object.entries(y).find((([e])=>{let r=y[e];return r&&r.tableName===t&&r.command===n&&JSON.stringify(r.param1||{})===JSON.stringify(i||{})&&JSON.stringify(r.param2||{})===JSON.stringify(o||{})}));if(l){const e=l[0];return l[1].handlers.push(s),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;s&&(null===(t=null==y?void 0:y[e])||void 0===t?void 0:t.lastData)&&s(null===(n=null==y?void 0:y[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:f,channelNameUnsubscribe:p}=await S({tableName:t,command:n,param1:i,param2:o}),d=function(e,t){const n=y[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},m=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return r.on(u,d),y[u]={lastData:void 0,tableName:t,command:n,param1:i,param2:o,onCall:d,unsubChannel:p,handlers:[s],errorHandlers:[m],destroy:()=>{y[u]&&(Object.values(y[u]).map((e=>{e&&e.handlers&&e.handlers.map((e=>_(u,p,e)))})),delete y[u])}},r.emit(f,{now:Date.now()}),c(u,p)}),(([e,{tableName:t}])=>t));async function w(e,t,n,r){return N.run([e,t,n,r])}return new Promise(((e,c)=>{r.removeAllListeners(o.CHANNELS.CONNECTION),r.on(o.CHANNELS.CONNECTION,(e=>(c(e),"ok"))),s&&r.on("disconnect",(()=>{h="disconnected",s()})),l&&r.on("connect",(()=>{"disconnected"===h&&(h="reconnected")})),r.on(o.CHANNELS.SCHEMA,(({schema:s,methods:u,tableSchema:_,auth:N,rawSQL:x,joinTables:j=[],err:C})=>{if((0,t.debug)("destroySyncs",{subscriptions:y,syncedTables:g}),Object.values(y).map((e=>e.destroy())),y={},b={},Object.values(g).map((e=>{e&&e.destroy&&e.destroy()})),g={},("connected"===h||"reconnected"===h)&&l&&(l(r,C),C))return void console.error(C);if(C)throw c(C),C;const T="reconnected"===h;h="connected";let P=JSON.parse(JSON.stringify(s)),k=JSON.parse(JSON.stringify(u)),R={},A={};if(N){if(N.pathGuard&&a){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(f?f():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};r.emit(o.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),r.removeAllListeners(o.CHANNELS.AUTHGUARD),r.on(o.CHANNELS.AUTHGUARD,(t=>{e(t)}))}A={...N},[o.CHANNELS.LOGIN,o.CHANNELS.LOGOUT,o.CHANNELS.REGISTER].map((e=>{N[e]&&(A[e]=function(t){return new Promise(((n,i)=>{r.emit(d+e,t,((e,t)=>{e?i(e):n(t)}))}))})}))}k.map((e=>{const t="string"==typeof e,n=t?e:e.name,i=async function(...e){return await(null==p?void 0:p({type:"method",command:n,data:{params:e}})),new Promise(((t,i)=>{r.emit(o.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?i(e):t(n)}))}))};R[n]=t?i:{...e,run:i}})),R=Object.freeze(R),x&&(P.sql=function(e,t,n){return new Promise(((i,s)=>{r.emit(o.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)s(e);else if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{m=m||{config:t,listeners:[]},m.listeners.length||(r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,(e=>{m&&m.listeners&&m.listeners.length?m.listeners.map((t=>{t(e)})):r.emit(t.socketUnsubChannel,{})}))),m.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{m&&(m.listeners=m.listeners.filter((t=>t!==e)),!m.listeners.length&&m.config&&m.config.socketUnsubChannel&&r&&r.emit(m.config.socketUnsubChannel,{}))})(t)}),o={...e,addListener:n};i(o)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))i(t);else{const e=e=>(((e,t)=>{var n;v=v||{},v[t.notifChannel]?null===(n=v[t.notifChannel])||void 0===n||n.listeners.push(e):(v[t.notifChannel]={config:t,listeners:[e]},r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,(e=>{var n,i;(null===(n=v[t.notifChannel])||void 0===n?void 0:n.listeners.length)?v[t.notifChannel].listeners.map((t=>{t(e)})):r.emit(null===(i=v[t.notifChannel])||void 0===i?void 0:i.config.socketUnsubChannel,{})})))})(e,t),{...t,removeListener:()=>((e,t)=>{const n=v[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&r&&(r.emit(n.config.socketUnsubChannel,{}),delete v[t.notifChannel]))})(e,t)}),n={...t,addListener:e};i(n)}}))}))});const J=e=>"[object Object]"===Object.prototype.toString.call(e),D=(e,t,n,r)=>{if(!J(e)||!J(t)||"function"!=typeof n||r&&"function"!=typeof r)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},$=["subscribe","subscribeOne"];(0,o.getKeys)(P).forEach((e=>{Object.keys(P[e]).sort(((e,t)=>$.includes(e)-$.includes(t))).forEach((t=>{if(["find","findOne"].includes(t)&&(P[e].getJoinedTables=function(){return(j||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))}),"sync"===t){if(P[e]._syncInfo={...P[e][t]},n){P[e].getSync=async(t,r={})=>(await(null==p?void 0:p({type:"table",command:"getSync",tableName:e,data:{filter:t,params:r}})),n.create({name:e,onDebug:p,filter:t,db:P,...r}));const t=async(t={},r={},i)=>{const o=`${e}.${JSON.stringify(t)}.${JSON.stringify(r)}`;return g[o]||(g[o]=await n.create({...r,onDebug:p,name:e,filter:t,db:P,onError:i})),g[o]};P[e].sync=async(n,r={handlesOnData:!0,select:"*"},i,o)=>{await(null==p?void 0:p({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:r}})),D(n,r,i,o);const s=await t(n,r,o);return await s.sync(i,r.handlesOnData)},P[e].syncOne=async(n,r={handlesOnData:!0},i,o)=>{await(null==p?void 0:p({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:r}})),D(n,r,i,o);const s=await t(n,r,o);return await s.syncOne(n,i,r.handlesOnData)}}P[e]._sync=async function(n,r,i){return await(null==p?void 0:p({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:r,syncHandles:i}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:r},i)}}else if($.includes(t)){const n=async function(n,r,i,o){return await(null==p?void 0:p({type:"table",command:t,tableName:e,data:{param1:n,param2:r,onChange:i,onError:o}})),D(n,r,i,o),w(P,{tableName:e,command:t,param1:n,param2:r},i,o)};P[e][t]=n;const r="subscribeOne";P[e][t+"Hook"]=function(e={},i={},o){return{start:s=>n(e,i,t!==r?s:e=>{s(e[0])},o),args:[e,i,o]}},t!==r&&$.includes(r)||(P[e][r]=async function(n,r,i,o){return await(null==p?void 0:p({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:r,onChange:i,onError:o}})),D(n,r,i,o),w(P,{tableName:e,command:t,param1:n,param2:r},(e=>{i(e[0])}),o)})}else P[e][t]=async function(n,i,o){return await(null==p?void 0:p({type:"table",command:t,tableName:e,data:{param1:n,param2:i,param3:o}})),new Promise(((s,a)=>{r.emit(d,{tableName:e,command:t,param1:n,param2:i,param3:o},((e,t)=>{e?a(e):s(t)}))}))}}))})),y&&Object.keys(y).length&&Object.keys(y).map((async e=>{try{let t=y[e];await S(t),r.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),b&&Object.keys(b).length&&(0,o.getKeys)(b).filter((e=>{var t;return null===(t=b[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=b[e];await O(t,t.triggers[0].onSyncRequest),r.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),j.flat().map((e=>{P.innerJoin=P.innerJoin||{},P.leftJoin=P.leftJoin||{},P.innerJoinOne=P.innerJoinOne||{},P.leftJoinOne=P.leftJoinOne||{};const t=(0,o.getJoinHandlers)(e);P.leftJoin[e]=t.leftJoin,P.innerJoin[e]=t.innerJoin,P.leftJoinOne[e]=t.leftJoinOne,P.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await i(P,R,_,A,T)}catch(e){console.error("Prostgles: Error within onReady: \n",e),c(e)}e(P)})()}))}))};class c{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const r={arguments:e,onResult:t,onFail:n};this.queue.push(r)})),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,r)=>{const i=this.groupBy(e.arguments);t.includes(i)||(t.push(i),n.push({index:r,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}}},353:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useSubscribeOne=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=void 0;const r=n(294),i=n(792),{useEffect:o,useCallback:s,useRef:a,useState:c}=null!=r?r:{};function l(){const e=a(!0),t=s((()=>e.current),[]);return o((()=>()=>{e.current=!1}),[]),t}t.isEqual=(e,n)=>{const r=Object.keys,i=typeof e;return e&&n&&"object"===i&&i===typeof n?r(e).length===r(n).length&&r(e).every((r=>(0,t.isEqual)(e[r],n[r]))):e===n},t.useDeepCompareMemoize=e=>{const n=a();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{o(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,t)=>{const n={effect:e,deps:t,didCleanup:!1},r=a({activeEffect:void 0,latestEffect:n});r.current.latestEffect=n;const i=async e=>{e.current.latestEffect&&!e.current.activeEffect&&(e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,e.current.activeEffect.resolvedCleanup={run:await e.current.activeEffect.effect()},e.current.activeEffect.didCleanup&&s())},s=async()=>{var e,t,n;(null===(e=r.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)&&(await(null===(n=(t=r.current.activeEffect.resolvedCleanup).run)||void 0===n?void 0:n.call(t)),r.current.activeEffect=void 0,i(r))};o((()=>(i(r),()=>{var t,n;(null===(t=r.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(r.current.activeEffect.didCleanup=!0,r.current.activeEffect.resolvedCleanup&&s()),(null===(n=r.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(r.current.latestEffect.didCleanup=!0)})),t)},t.useEffectAsync=(e,t)=>{const n=a({cleanup:void 0,effect:e,cleanupEffect:void 0});n.current.effect=e,o((()=>(e().then((t=>{"function"==typeof t&&(n.current.cleanup=t,n.current.cleanupEffect===e&&t())})),()=>{var t,r;n.current.cleanupEffect=e,null===(r=(t=n.current).cleanup)||void 0===r||r.call(t)})),t)},t.useIsMounted=l,t.usePromise=(e,n=[])=>{const r=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},o=e=>{try{return(0,i.isObject)(e)&&!r(e)}catch(e){console.error(e)}return!1},s=async e=>{const t={},n=(0,i.getKeys)(e);for await(const r of n){const n=e[r];t[r]="function"==typeof n?await n():await n}return t},[a,u]=c(o(e)?{}:void 0),f=l();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(o(e))t=await s(e);else{const n=await e();t=o(n)?await s(n):r(n)?await n():n}f()&&u(t)}),n),a},t.useSubscribe=e=>{const[n,r]=c(),i=l();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{i()&&r(e)}))).unsubscribe),e.args.map((e=>JSON.stringify(e)))),n},t.useSubscribeOne=e=>{const[n,r]=c(),i=l();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{i()&&r(e)}))).unsubscribe),[]),n},t.__prglReactInstalled=()=>Boolean(r&&a)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,r.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 o={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...o,"number[]":o.number.map((e=>`_${e}`)),"boolean[]":o.boolean.map((e=>`_${e}`)),"string[]":o.string.map((e=>`_${e}`)),"any[]":o.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const s="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:s+"schema-changed",SCHEMA:s+"schema",DEFAULT:s,SQL:`${s}sql`,METHOD:`${s}method`,NOTICE_EV:`${s}notice`,LISTEN_EV:`${s}listen`,REGISTER:`${s}register`,LOGIN:`${s}login`,LOGOUT:`${s}logout`,AUTHGUARD:`${s}authguard`,CONNECTION:`${s}connection`,_preffix:s},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"]},i(n(128),t),i(n(444),t);var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),i(n(929),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const r=n(128);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 i=(e,t)=>{const{type:n,arrayOf:o,arrayOfType:s,description:a,nullable:c,oneOf:l,oneOfType:u,title:f,record:p,...d}="string"==typeof e?{type:e}:e;let m={};const h={...(d.enum||d.allowedValues?.length)&&{enum:d.allowedValues?.slice(0)??d.enum.slice(0)},...!!a&&{description:a},...!!f&&{title:f}};if(d.enum?.length&&(h.type=typeof d.enum[0]),"string"==typeof n||o||s){if(n&&"string"!=typeof n)throw"Not expected";m=o||s||n?.endsWith("[]")?{type:"array",items:o||s?i(o||{type:s}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...d.allowedValues&&{enum:d.allowedValues.slice(0)}}}:{type:n}}else(0,r.isObject)(n)?m={type:"object",required:(0,r.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,r.getKeys)(n).reduce(((e,t)=>({...e,[t]:i(n[t])})),{})}:l||u?m={oneOf:(l||u.map((e=>({type:e})))).map((e=>i(e)))}:p&&(m={type:"object",...p.values&&!p.keysEnum&&{additionalProperties:i(p.values)},...p.keysEnum&&{properties:p.keysEnum.reduce(((e,t)=>({...e,[t]:p.values?i(p.values):{type:{}}})),{})}});if(c){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...h,...m}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return i(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=o(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=o(l,n,r,c,t[6],9,-1069501632),c=o(c,l,n,r,t[11],14,643717713),r=o(r,c,l,n,t[0],20,-373897302),n=o(n,r,c,l,t[5],5,-701558691),l=o(l,n,r,c,t[10],9,38016083),c=o(c,l,n,r,t[15],14,-660478335),r=o(r,c,l,n,t[4],20,-405537848),n=o(n,r,c,l,t[9],5,568446438),l=o(l,n,r,c,t[14],9,-1019803690),c=o(c,l,n,r,t[3],14,-187363961),r=o(r,c,l,n,t[8],20,1163531501),n=o(n,r,c,l,t[13],5,-1444681467),l=o(l,n,r,c,t[2],9,-51403784),c=o(c,l,n,r,t[7],14,1735328473),n=s(n,r=o(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=s(l,n,r,c,t[8],11,-2022574463),c=s(c,l,n,r,t[11],16,1839030562),r=s(r,c,l,n,t[14],23,-35309556),n=s(n,r,c,l,t[1],4,-1530992060),l=s(l,n,r,c,t[4],11,1272893353),c=s(c,l,n,r,t[7],16,-155497632),r=s(r,c,l,n,t[10],23,-1094730640),n=s(n,r,c,l,t[13],4,681279174),l=s(l,n,r,c,t[0],11,-358537222),c=s(c,l,n,r,t[3],16,-722521979),r=s(r,c,l,n,t[6],23,76029189),n=s(n,r,c,l,t[9],4,-640364487),l=s(l,n,r,c,t[12],11,-421815835),c=s(c,l,n,r,t[15],16,530742520),n=a(n,r=s(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=p(n,e[0]),e[1]=p(r,e[1]),e[2]=p(c,e[2]),e[3]=p(l,e[3])}function r(e,t,n,r,i,o){return t=p(p(t,e),p(r,o)),p(t<<i|t>>>32-i,n)}function i(e,t,n,i,o,s,a){return r(t&n|~t&i,e,t,o,s,a)}function o(e,t,n,i,o,s,a){return r(t&i|n&~i,e,t,o,s,a)}function s(e,t,n,i,o,s,a){return r(t^n^i,e,t,o,s,a)}function a(e,t,n,i,o,s,a){return r(n^(t|~i),e,t,o,s,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.md5=t.md5cycle=void 0,t.md5cycle=n;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 f(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(i,o),t=0;t<16;t++)o[t]=0;return o[14]=8*r,n(i,o),i}(e))}function p(e,t){return e+t&4294967295}t.md5=f,f("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const r=n(899);function i(e,t=[],n=!1){let r=t;if(!r.length)return{};if(e&&r.length){let t={};return r.forEach((r=>{n&&void 0===e[r]||(t[r]=e[r])})),t}return e}function o(e,t){return i(e,l(e).filter((e=>!t.includes(e))))}function s(e,t){return e.filter((e=>Object.entries(t).every((([t,n])=>e[t]===n))))}function a(e){for(var t in e)return!1;return!0}function c(e){return null!=e}function l(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=i,t.omitKeys=o,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];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,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(s="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(s&&(s+=","),s+=JSON.stringify(l)+":"+u)}return o.splice(a,1),"{"+s+"}"}}(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,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const o=n<1?[r]:[0,r];e.slice(...o)!==t.slice(...o)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,o=e.length+n(-1)+1,s=t.length+n(-1)+1;return{from:i,to:o,text:t.slice(i,s),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:o,md5:s}=t;if(null===o||null===e)return o;let a=e.slice(0,n)+o+e.slice(i);if(s&&(0,r.md5)(a)!==s)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],o=+r-+i,s=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(o)?o:s})).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)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r==+t)return!0}return!1},this.addData=e=>{a(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const o=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[o]??(t[o]={initial:n,current:r,delta:i}),this.changed[o].current={...this.changed[o].current,...r},this.changed[o].delta={...this.changed[o].delta,...i}})),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:r,throttle:i,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!a(this.sending))return;if(!this.changed||a(this.changed))return;let s,c=[],l=[],u={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,r).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 r=e.initial?.[n],i=e.current[n];var o,s;![this.options.synced_field,...this.options.id_fields].includes(n)&&((o=r)===(s=i)||(["number","string","boolean"].includes(typeof o)?o===s:JSON.stringify(o)===JSON.stringify(s)))||(t[n]=i)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,a(this.changed)||this.sendItems()}),i)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*o)))}catch(e){s=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(s)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),a(this.changed)?n&&n(c,l,s):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||!(a(this.sending)&&a(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.isEmpty=a,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=c,t.getKeys=l,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,r,i={})=>({[t?"$leftJoin":"$innerJoin"]:i.path??e,filter:n,...o(i,["path","select"]),select:r});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 r=[{table:n,on:[{}]},...e??[]];return r.map(((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}})).filter(c).reverse()}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),d=Symbol.iterator,m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||m}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||m}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var _=v.prototype=new b;_.constructor=v,h(_,g.prototype),_.isPureReactComponent=!0;var O=Array.isArray,S=Object.prototype.hasOwnProperty,E={current:null},N={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,r){var i,o={},s=null,a=null;if(null!=t)for(i in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(s=""+t.key),t)S.call(t,i)&&!N.hasOwnProperty(i)&&(o[i]=t[i]);var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];o.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps)void 0===o[i]&&(o[i]=c[i]);return{$$typeof:n,type:e,key:s,ref:a,props:o,_owner:E.current}}function x(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var j=/\/+/g;function C(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function T(e,t,i,o,s){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case r:c=!0}}if(c)return s=s(c=e),e=""===o?"."+C(c,0):o,O(s)?(i="",null!=e&&(i=e.replace(j,"$&/")+"/"),T(s,t,i,"",(function(e){return e}))):null!=s&&(x(s)&&(s=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(s,i+(!s.key||c&&c.key===s.key?"":(""+s.key).replace(j,"$&/")+"/")+e)),t.push(s)),1;if(c=0,o=""===o?".":o+":",O(e))for(var l=0;l<e.length;l++){var u=o+C(a=e[l],l);c+=T(a,t,i,u,s)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=d&&e[d]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=T(a=a.value,t,i,u=o+C(a,l++),s);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var r=[],i=0;return T(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function k(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var R={current:null},A={transition:null},J={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:A,ReactCurrentOwner:E};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!x(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=i,t.Profiler=s,t.PureComponent=v,t.StrictMode=o,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=J,t.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var i=h({},e.props),o=e.key,s=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,a=E.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)S.call(t,l)&&!N.hasOwnProperty(l)&&(i[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:n,type:e.type,key:o,ref:s,props:i,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=w,t.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=x,t.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:k}},t.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=A.transition;A.transition={};try{e()}finally{A.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return R.current.useCallback(e,t)},t.useContext=function(e){return R.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return R.current.useDeferredValue(e)},t.useEffect=function(e,t){return R.current.useEffect(e,t)},t.useId=function(){return R.current.useId()},t.useImperativeHandle=function(e,t,n){return R.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return R.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return R.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return R.current.useMemo(e,t)},t.useReducer=function(e,t,n){return R.current.useReducer(e,t,n)},t.useRef=function(e){return R.current.useRef(e)},t.useState=function(e){return R.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return R.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return R.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={},function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(274);var e,t}));
@@ -1 +1 @@
1
- {"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAAE,WAAW,EAET,SAAS,EAAE,mBAAmB,EAC9C,UAAU,EAAqC,aAAa,EACjC,aAAa,EAAE,iBAAiB,EAA4C,SAAS,EAAE,QAAQ,EAAE,WAAW,EACvI,MAAM,EAEN,UAAU,EACV,eAAe,EACf,OAAO,EACP,mBAAmB,EAGpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAe,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIhE,eAAO,MAAM,KAAK,EAAE,GAInB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAE5C,cAAc,eAAe,CAAC;AAE9B,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACrH,eAAe,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,aAAa,EAAE,CAAC,SAAS,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EACrD,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,OAAO,KACd;QACH,KAAK,EAAE,CAAC,CACN,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,KACpE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAA;QAClC,IAAI,EAAE;YACJ,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,EAAE,OAAO;SAClB,CAAA;KACF,CAAC;IACF,gBAAgB,EAAE,CAAC,SAAS,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EACxD,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAC5B,OAAO,CAAC,EAAE,OAAO,KACd;QACH,KAAK,EAAE,CACL,QAAQ,EAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,KAAK,GAAG,KAC9E,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAClC,IAAI,EAAE;YACJ,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,EAAE,OAAO;SAClB,CAAA;KACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,IAAI,IAAI,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACjJ,eAAe,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAA;AAGD,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,SAAS,QAAQ,GAAG;KACrE,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,GAClE,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,GACtD,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CACxD,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAC5C,GAAG;IACF,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB,GAAG,WAAW,CAAC;AAEhB,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,iBAAiB,CAAC;IACjC,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AACF,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,kBAAkB,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG,cAAc,CAAC;AAEnB,MAAM,MAAM,WAAW,CAAC,QAAQ,GAAG,IAAI,IAAI;IACzC,MAAM,EAAE,GAAG,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACtC,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,EAAE,OAAO,KAAK,GAAG,CAAC;IAE7K;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IAEzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;CACtC,CAAA;AAuBD,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAA;AAQnE,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AASD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,oBAwuBpF"}
1
+ {"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAAE,WAAW,EAET,SAAS,EAAE,mBAAmB,EAC9C,UAAU,EAAqC,aAAa,EACjC,aAAa,EAAE,iBAAiB,EAA4C,SAAS,EAAE,QAAQ,EAAE,WAAW,EACvI,MAAM,EAEN,UAAU,EACV,eAAe,EACf,OAAO,EACP,mBAAmB,EAGpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAe,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIhE,eAAO,MAAM,KAAK,EAAE,GAInB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAE5C,cAAc,eAAe,CAAC;AAE9B,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACrH,eAAe,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,aAAa,EAAE,CAAC,SAAS,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EACrD,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,OAAO,KACd;QACH,KAAK,EAAE,CAAC,CACN,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,KACpE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAA;QAClC,IAAI,EAAE;YACJ,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,EAAE,OAAO;SAClB,CAAA;KACF,CAAC;IACF,gBAAgB,EAAE,CAAC,SAAS,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EACxD,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAC5B,OAAO,CAAC,EAAE,OAAO,KACd;QACH,KAAK,EAAE,CACL,QAAQ,EAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,KAAK,GAAG,KAC9E,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAClC,IAAI,EAAE;YACJ,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,EAAE,OAAO;SAClB,CAAA;KACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,IAAI,IAAI,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACjJ,eAAe,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAA;AAGD,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,SAAS,QAAQ,GAAG;KACrE,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,GAClE,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,GACtD,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CACxD,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAC5C,GAAG;IACF,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB,GAAG,WAAW,CAAC;AAEhB,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,iBAAiB,CAAC;IACjC,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AACF,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,kBAAkB,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG,cAAc,CAAC;AAEnB,MAAM,MAAM,WAAW,CAAC,QAAQ,GAAG,IAAI,IAAI;IACzC,MAAM,EAAE,GAAG,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACtC,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,EAAE,OAAO,KAAK,GAAG,CAAC;IAE7K;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IAEzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;CACtC,CAAA;AAuBD,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAA;AAQnE,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AASD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,oBAyuBpF"}
package/dist/prostgles.js CHANGED
@@ -113,8 +113,7 @@ function prostgles(initOpts, syncedTable) {
113
113
  }
114
114
  noticeSubs.listeners.push(listener);
115
115
  };
116
- let connected = false;
117
- let reconnected = false;
116
+ let state;
118
117
  const destroySyncs = () => {
119
118
  (0, exports.debug)("destroySyncs", { subscriptions, syncedTables });
120
119
  Object.values(subscriptions).map(s => s.destroy());
@@ -442,21 +441,22 @@ function prostgles(initOpts, syncedTable) {
442
441
  });
443
442
  if (onDisconnect) {
444
443
  socket.on("disconnect", () => {
445
- connected = false;
446
- reconnected = false;
444
+ state = "disconnected";
447
445
  onDisconnect();
448
446
  });
449
447
  }
450
448
  if (onReconnect) {
451
449
  /** A reconnect will happen after the server is ready and pushed the schema */
452
450
  socket.on("connect", () => {
453
- reconnected = true;
451
+ if (state === "disconnected") {
452
+ state = "reconnected";
453
+ }
454
454
  });
455
455
  }
456
456
  /* Schema = published schema */
457
457
  socket.on(prostgles_types_1.CHANNELS.SCHEMA, ({ schema, methods, tableSchema, auth, rawSQL, joinTables = [], err }) => {
458
458
  destroySyncs();
459
- if ((connected || reconnected) && onReconnect) {
459
+ if ((state === "connected" || state === "reconnected") && onReconnect) {
460
460
  onReconnect(socket, err);
461
461
  if (err) {
462
462
  console.error(err);
@@ -467,7 +467,8 @@ function prostgles(initOpts, syncedTable) {
467
467
  reject(err);
468
468
  throw err;
469
469
  }
470
- connected = true;
470
+ const isReconnect = state === "reconnected";
471
+ state = "connected";
471
472
  let dbo = JSON.parse(JSON.stringify(schema));
472
473
  let _methods = JSON.parse(JSON.stringify(methods)), methodsObj = {}, _auth = {};
473
474
  if (auth) {
@@ -717,7 +718,7 @@ function prostgles(initOpts, syncedTable) {
717
718
  });
718
719
  (async () => {
719
720
  try {
720
- await onReady(dbo, methodsObj, tableSchema, _auth, connected);
721
+ await onReady(dbo, methodsObj, tableSchema, _auth, isReconnect);
721
722
  }
722
723
  catch (err) {
723
724
  console.error("Prostgles: Error within onReady: \n", err);
@@ -1,3 +1,7 @@
1
+ export declare const isEqual: (x: any, y: any) => any;
2
+ export declare const useDeepCompareMemoize: (value: any) => undefined;
3
+ export declare const useEffectDeep: (callback: any, deps: any) => void;
4
+ export declare const useAsyncEffectQueue: (effect: () => Promise<void | (() => void)>, deps: any[]) => void;
1
5
  export declare const useEffectAsync: (effect: () => Promise<void | (() => void)>, inputs: any[]) => void;
2
6
  export declare function useIsMounted(): () => boolean;
3
7
  type PromiseFunc = () => Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,UAAU,GAAG,EAAE,SAsBvF,CAAA;AAED,wBAAgB,YAAY,kBAS3B;AAED,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;AACrC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,gEAAgE,GAAG,EAAE,wMA6C3F,CAAA;AAID,eAAO,MAAM,YAAY;;;iFAgBxB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;QAC9B,WAAW,EAAE,YAAY,CAAC;KAC3B,CAAC,CAAC,CAAC,CAAC;CACN,CAAC;AACF,eAAO,MAAM,eAAe,4FAgB3B,CAAA;AAED,eAAO,MAAM,oBAAoB,eAAiC,CAAC"}
1
+ {"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,yBAMnB,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,GAAG,cAQ/C,CAAA;AAED,eAAO,MAAM,aAAa,oCAKzB,CAAA;AAeD,eAAO,MAAM,mBAAmB,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,GAAG,EAAE,SAwC1F,CAAA;AACD,eAAO,MAAM,cAAc,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,UAAU,GAAG,EAAE,SAsBvF,CAAA;AAED,wBAAgB,YAAY,kBAS3B;AAED,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;AACrC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,gEAAgE,GAAG,EAAE,wMA6C3F,CAAA;AAID,eAAO,MAAM,YAAY;;;iFAgBxB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;QAC9B,WAAW,EAAE,YAAY,CAAC;KAC3B,CAAC,CAAC,CAAC,CAAC;CACN,CAAC;AACF,eAAO,MAAM,eAAe,4FAgB3B,CAAA;AAED,eAAO,MAAM,oBAAoB,eAAiC,CAAC"}
@@ -1,9 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__prglReactInstalled = exports.useSubscribeOne = exports.useSubscribe = exports.usePromise = exports.useIsMounted = exports.useEffectAsync = void 0;
3
+ exports.__prglReactInstalled = exports.useSubscribeOne = exports.useSubscribe = exports.usePromise = exports.useIsMounted = exports.useEffectAsync = exports.useAsyncEffectQueue = exports.useEffectDeep = exports.useDeepCompareMemoize = exports.isEqual = void 0;
4
4
  const React = require("react");
5
5
  const prostgles_types_1 = require("prostgles-types");
6
6
  const { useEffect, useCallback, useRef, useState } = React !== null && React !== void 0 ? React : {};
7
+ const isEqual = (x, y) => {
8
+ const keys = Object.keys, tx = typeof x, ty = typeof y;
9
+ return x && y && tx === 'object' && tx === ty ? (keys(x).length === keys(y).length &&
10
+ keys(x).every(key => (0, exports.isEqual)(x[key], y[key]))) : (x === y);
11
+ };
12
+ exports.isEqual = isEqual;
13
+ const useDeepCompareMemoize = (value) => {
14
+ const ref = useRef();
15
+ if (!(0, exports.isEqual)(value, ref.current)) {
16
+ ref.current = value;
17
+ }
18
+ return ref.current;
19
+ };
20
+ exports.useDeepCompareMemoize = useDeepCompareMemoize;
21
+ const useEffectDeep = (callback, deps) => {
22
+ useEffect(callback, deps.map(exports.useDeepCompareMemoize));
23
+ };
24
+ exports.useEffectDeep = useEffectDeep;
25
+ const useAsyncEffectQueue = (effect, deps) => {
26
+ const latestEffect = { effect, deps, didCleanup: false };
27
+ const queue = useRef({
28
+ activeEffect: undefined,
29
+ latestEffect
30
+ });
31
+ queue.current.latestEffect = latestEffect;
32
+ const runAsyncEffect = async (queue) => {
33
+ if (queue.current.latestEffect && !queue.current.activeEffect) {
34
+ queue.current.activeEffect = queue.current.latestEffect;
35
+ queue.current.latestEffect = undefined;
36
+ queue.current.activeEffect.resolvedCleanup = { run: await queue.current.activeEffect.effect() };
37
+ if (queue.current.activeEffect.didCleanup) {
38
+ cleanup();
39
+ }
40
+ }
41
+ };
42
+ const cleanup = async () => {
43
+ var _a, _b, _c;
44
+ if (!((_a = queue.current.activeEffect) === null || _a === void 0 ? void 0 : _a.resolvedCleanup))
45
+ return;
46
+ await ((_c = (_b = queue.current.activeEffect.resolvedCleanup).run) === null || _c === void 0 ? void 0 : _c.call(_b));
47
+ queue.current.activeEffect = undefined;
48
+ runAsyncEffect(queue);
49
+ };
50
+ useEffect(() => {
51
+ runAsyncEffect(queue);
52
+ return () => {
53
+ var _a, _b;
54
+ if (((_a = queue.current.activeEffect) === null || _a === void 0 ? void 0 : _a.effect) === effect) {
55
+ queue.current.activeEffect.didCleanup = true;
56
+ if (queue.current.activeEffect.resolvedCleanup) {
57
+ cleanup();
58
+ }
59
+ }
60
+ if (((_b = queue.current.latestEffect) === null || _b === void 0 ? void 0 : _b.effect) === effect) {
61
+ queue.current.latestEffect.didCleanup = true;
62
+ }
63
+ };
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ }, deps);
66
+ };
67
+ exports.useAsyncEffectQueue = useAsyncEffectQueue;
7
68
  const useEffectAsync = (effect, inputs) => {
8
69
  const onCleanup = useRef({
9
70
  cleanup: undefined,
@@ -68,7 +129,7 @@ const usePromise = (f, dependencyArray = []) => {
68
129
  };
69
130
  const [result, setResult] = useState(isNamedObj(f) ? {} : undefined);
70
131
  const getIsMounted = useIsMounted();
71
- (0, exports.useEffectAsync)(async () => {
132
+ (0, exports.useAsyncEffectQueue)(async () => {
72
133
  let newD;
73
134
  if (isNamedObj(f)) {
74
135
  newD = await getNamedObjResults(f);
@@ -89,7 +150,7 @@ exports.usePromise = usePromise;
89
150
  const useSubscribe = (subHok) => {
90
151
  const [data, setData] = useState();
91
152
  const getIsMounted = useIsMounted();
92
- (0, exports.useEffectAsync)(async () => {
153
+ (0, exports.useAsyncEffectQueue)(async () => {
93
154
  const sub = await subHok.start(newData => {
94
155
  if (!getIsMounted())
95
156
  return;
@@ -103,7 +164,7 @@ exports.useSubscribe = useSubscribe;
103
164
  const useSubscribeOne = (subHook) => {
104
165
  const [data, setData] = useState();
105
166
  const getIsMounted = useIsMounted();
106
- (0, exports.useEffectAsync)(async () => {
167
+ (0, exports.useAsyncEffectQueue)(async () => {
107
168
  const sub = await subHook.start(newData => {
108
169
  if (!getIsMounted())
109
170
  return;
package/lib/prostgles.ts CHANGED
@@ -278,8 +278,7 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
278
278
  noticeSubs.listeners.push(listener);
279
279
  };
280
280
 
281
- let connected = false;
282
- let reconnected = false;
281
+ let state: undefined | "connected" | "disconnected" | "reconnected";
283
282
 
284
283
  const destroySyncs = () => {
285
284
  debug("destroySyncs", { subscriptions, syncedTables })
@@ -626,15 +625,16 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
626
625
 
627
626
  if (onDisconnect) {
628
627
  socket.on("disconnect", () => {
629
- connected = false;
630
- reconnected = false;
628
+ state = "disconnected"
631
629
  onDisconnect();
632
630
  });
633
631
  }
634
632
  if(onReconnect){
635
633
  /** A reconnect will happen after the server is ready and pushed the schema */
636
634
  socket.on("connect", () => {
637
- reconnected = true;
635
+ if(state === "disconnected"){
636
+ state = "reconnected"
637
+ }
638
638
  });
639
639
  }
640
640
 
@@ -642,7 +642,7 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
642
642
  socket.on(CHANNELS.SCHEMA, ({ schema, methods, tableSchema, auth, rawSQL, joinTables = [], err }: ClientSchema) => {
643
643
 
644
644
  destroySyncs();
645
- if ((connected || reconnected) && onReconnect) {
645
+ if ((state === "connected" || state === "reconnected") && onReconnect) {
646
646
  onReconnect(socket, err);
647
647
  if (err) {
648
648
  console.error(err)
@@ -655,7 +655,8 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
655
655
  throw err;
656
656
  }
657
657
 
658
- connected = true;
658
+ const isReconnect = state === "reconnected";
659
+ state = "connected";
659
660
 
660
661
  let dbo: DBHandlerClient = JSON.parse(JSON.stringify(schema));
661
662
  let _methods: typeof methods = JSON.parse(JSON.stringify(methods)),
@@ -915,7 +916,7 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
915
916
 
916
917
  (async () => {
917
918
  try {
918
- await onReady(dbo as DBHandlerClient<DBSchema>, methodsObj, tableSchema, _auth, connected);
919
+ await onReady(dbo as DBHandlerClient<DBSchema>, methodsObj, tableSchema, _auth, isReconnect);
919
920
  } catch (err) {
920
921
  console.error("Prostgles: Error within onReady: \n", err);
921
922
  reject(err);
@@ -4,6 +4,85 @@ import { ViewHandlerClient } from "./prostgles";
4
4
 
5
5
  const { useEffect, useCallback, useRef, useState } = React ?? {};
6
6
 
7
+ export const isEqual = (x, y) => {
8
+ const keys = Object.keys, tx = typeof x, ty = typeof y;
9
+ return x && y && tx === 'object' && tx === ty ? (
10
+ keys(x).length === keys(y).length &&
11
+ keys(x).every(key => isEqual(x[key], y[key]))
12
+ ) : (x === y);
13
+ }
14
+
15
+ export const useDeepCompareMemoize = (value: any) => {
16
+ const ref = useRef();
17
+
18
+ if (!isEqual(value, ref.current)) {
19
+ ref.current = value
20
+ }
21
+
22
+ return ref.current
23
+ }
24
+
25
+ export const useEffectDeep = (callback, deps) => {
26
+ useEffect(
27
+ callback,
28
+ deps.map(useDeepCompareMemoize)
29
+ )
30
+ }
31
+
32
+ type AsyncCleanup = void | (() => void | Promise<void>)
33
+ type AsyncActiveEffect = {
34
+ effect: () => Promise<AsyncCleanup>;
35
+ deps: any[];
36
+ didCleanup: boolean;
37
+ resolvedCleanup?: {
38
+ run: AsyncCleanup;
39
+ };
40
+ };
41
+ type AsyncEffectQueue = {
42
+ latestEffect: undefined | AsyncActiveEffect;
43
+ activeEffect: undefined | AsyncActiveEffect;
44
+ }
45
+ export const useAsyncEffectQueue = (effect: () => Promise<void | (() => void)>, deps: any[]) => {
46
+ const latestEffect = { effect, deps, didCleanup: false }
47
+ const queue = useRef<AsyncEffectQueue>({
48
+ activeEffect: undefined,
49
+ latestEffect
50
+ });
51
+ queue.current.latestEffect = latestEffect;
52
+
53
+ const runAsyncEffect = async (queue: React.MutableRefObject<AsyncEffectQueue>) => {
54
+ if(queue.current.latestEffect && !queue.current.activeEffect){
55
+ queue.current.activeEffect = queue.current.latestEffect;
56
+ queue.current.latestEffect = undefined;
57
+ queue.current.activeEffect.resolvedCleanup = { run: await queue.current.activeEffect.effect() };
58
+ if(queue.current.activeEffect.didCleanup){
59
+ cleanup();
60
+ }
61
+ }
62
+ }
63
+ const cleanup = async () => {
64
+ if(!queue.current.activeEffect?.resolvedCleanup) return;
65
+ await queue.current.activeEffect.resolvedCleanup.run?.();
66
+ queue.current.activeEffect = undefined;
67
+ runAsyncEffect(queue)
68
+ }
69
+
70
+ useEffect(() => {
71
+ runAsyncEffect(queue);
72
+ return () => {
73
+ if(queue.current.activeEffect?.effect === effect){
74
+ queue.current.activeEffect.didCleanup = true;
75
+ if(queue.current.activeEffect.resolvedCleanup){
76
+ cleanup()
77
+ }
78
+ }
79
+ if(queue.current.latestEffect?.effect === effect){
80
+ queue.current.latestEffect.didCleanup = true;
81
+ }
82
+ };
83
+ // eslint-disable-next-line react-hooks/exhaustive-deps
84
+ }, deps);
85
+ }
7
86
  export const useEffectAsync = (effect: () => Promise<void | (() => void)>, inputs: any[]) => {
8
87
  const onCleanup = useRef({
9
88
  cleanup: undefined as undefined | (() => void),
@@ -73,7 +152,7 @@ export const usePromise = <F extends PromiseFunc | NamedResult>(f: F, dependency
73
152
  }
74
153
  const [result, setResult] = useState(isNamedObj(f) ? {} : undefined);
75
154
  const getIsMounted = useIsMounted();
76
- useEffectAsync(async () => {
155
+ useAsyncEffectQueue(async () => {
77
156
  let newD
78
157
  if (isNamedObj(f)) {
79
158
  newD = await getNamedObjResults(f);
@@ -97,7 +176,7 @@ export const useSubscribe = <SubHook extends ReturnType<SubHooks>>(
97
176
  const [data, setData] = useState<undefined | Parameters<Parameters<SubHook["start"]>[0]>[0]>();
98
177
 
99
178
  const getIsMounted = useIsMounted();
100
- useEffectAsync(async () => {
179
+ useAsyncEffectQueue(async () => {
101
180
  const sub = await subHok.start(newData => {
102
181
  if (!getIsMounted()) return;
103
182
  setData(newData);
@@ -120,7 +199,7 @@ export const useSubscribeOne = <S extends SubOneHook>(
120
199
  const [data, setData] = useState<undefined | Parameters<Parameters<S["start"]>[0]>[0]>();
121
200
 
122
201
  const getIsMounted = useIsMounted();
123
- useEffectAsync(async () => {
202
+ useAsyncEffectQueue(async () => {
124
203
  const sub = await subHook.start(newData => {
125
204
  if (!getIsMounted()) return;
126
205
  setData(newData);
@@ -132,4 +211,5 @@ export const useSubscribeOne = <S extends SubOneHook>(
132
211
  return data;
133
212
  }
134
213
 
135
- export const __prglReactInstalled = () => Boolean(React && useRef);
214
+ export const __prglReactInstalled = () => Boolean(React && useRef);
215
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-client",
3
- "version": "4.0.41",
3
+ "version": "4.0.43",
4
4
  "description": "Reactive client for Postgres",
5
5
  "main": "dist/prostgles-full.js",
6
6
  "types": "dist/prostgles-full.d.ts",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "..": {
19
19
  "name": "prostgles-client",
20
- "version": "4.0.40",
20
+ "version": "4.0.42",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "prostgles-types": "^4.0.49"