!function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,a=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&s(e,r,t[r]);if(n)for(var r of n(t))o.call(t,r)&&s(e,r,t[r]);return e},u=(e,n)=>t(e,r(n)),c=(e,t,r)=>(s(e,"symbol"!=typeof t?t+"":t,r),r);const l={CONNECT_TIMEOUT:{code:-32300,message:"Connect timeout"},APPLICATION_ERROR:{code:-32500,message:"Application error"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"}};const f=class{constructor(e){c(this,"_event"),c(this,"_methods",{}),c(this,"_timeout",0),c(this,"_$connect",null),this._event=e.event,this._timeout=e.timeout||0,e.methods&&Object.entries(e.methods).forEach((([e,t])=>{this.registerMethod(e,t)})),this._event.onerror=e=>{const{code:t,message:r,data:n}=e;if(n.event&&Array.isArray(n.args)&&n.args.length){const e=n.args[0],i=this._getAckEventName(e.method),o={jsonrpc:"2.0",id:null==e?void 0:e.id,error:{code:t,message:r,data:e}};this._event.emit(i,o)}else console.error(e)},this.connect()}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}_getSynEventName(e){return`${f.EVENT.SYN_SIGN}${e}`}_getAckEventName(e){return`${f.EVENT.ACK_SIGN}${e}`}connect(e){return this._$connect||(this._$connect=new Promise(((t,r)=>{const n=e||this._timeout;let i;n&&(i=setTimeout((()=>{const e=u(a({},l.TIMEOUT),{data:{timeout:n}});r(e)}),n));const o=f.EVENT.CONNECT,s=this._getAckEventName(o),c=this._getSynEventName(o),h=()=>{clearTimeout(i),t()};this._event.on(s,h);this._event.on(c,(()=>{this._event.emit(s),h()})),this._event.emit(c)}))),this._$connect}registerMethod(e,t){if(this._methods[e])throw new Error(`${e} already registered`);this._methods[e]=t;const r=this._getSynEventName(e);this._event.on(r,(r=>{const n=this._getAckEventName(e);r.id?Promise.resolve(t(...r.params)).then((e=>{const t={jsonrpc:"2.0",result:e,id:r.id};this._event.emit(n,t)})).catch((e=>{const t={jsonrpc:"2.0",id:r.id,error:{code:(null==e?void 0:e.code)||l.APPLICATION_ERROR.code,message:(null==e?void 0:e.message)||l.APPLICATION_ERROR.message,data:null}};this._event.emit(n,t)})):t(...r.params)}))}removeMethod(e){this._methods[e]||delete this._methods[e];const t=this._getSynEventName(e);this._event.off(t)}invoke(e,...t){return new Promise(((r,n)=>{const i=t[t.length-1],o=i&&"object"==typeof i&&(Reflect.has(i,"isNotify")||Reflect.has(i,"timeout")),s=o?i:{isNotify:!1,timeout:0},c=o?t.slice(0,-1):t,h=this._getSynEventName(e),d=f.uuid(),p={jsonrpc:"2.0",method:e,params:c,id:d};if(this._event.emit(h,p),s.isNotify)r(void 0);else{const t=this._getAckEventName(e),i=s.timeout||this._timeout;let o;i&&(o=setTimeout((()=>{const e=u(a({},l.CONNECT_TIMEOUT),{data:{timeout:i}});n(e)}),i));const c=e=>{e.id===d&&(clearTimeout(o),this._event.off(t,c),e.error?n(e.error):r(e.result))};this._event.on(t,c)}}))}destroy(){Object.entries(this._methods).forEach((([e])=>{const t=this._getSynEventName(e);this._event.off(t)}));const e=this._getAckEventName(f.EVENT.CONNECT),t=this._getSynEventName(f.EVENT.CONNECT);this._event.off(t),this._event.off(e),this._event.destroy&&this._event.destroy()}};let h=f;c(h,"CODES",l),c(h,"EVENT",{SYN_SIGN:"syn:",ACK_SIGN:"ack:",CONNECT:"__rpc_connect_event",SYNC_METHODS:"__rpc_sync_methods_event"});const d={ErrorInit:10001,ErrorNoRecord:10002,ErrorDBTimeout:10003};var p;!function(e){e.Login="Login",e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvMessageRevoked="OnRecvMessageRevoked",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerStart="OnSyncServerStart",e.OnTotalUnreadMessageCountChanged="OnTotalUnreadMessageCountChanged",e.OnBlackAdded="OnBlackAdded",e.OnBlackDeleted="OnBlackDeleted",e.OnFriendApplicationAccepted="OnFriendApplicationAccepted",e.OnFriendApplicationAdded="OnFriendApplicationAdded",e.OnFriendApplicationDeleted="OnFriendApplicationDeleted",e.OnFriendApplicationRejected="OnFriendApplicationRejected",e.OnFriendInfoChanged="OnFriendInfoChanged",e.OnFriendAdded="OnFriendAdded",e.OnFriendDeleted="OnFriendDeleted",e.OnJoinedGroupAdded="OnJoinedGroupAdded",e.OnJoinedGroupDeleted="OnJoinedGroupDeleted",e.OnGroupDismissed="OnGroupDismissed",e.OnGroupMemberAdded="OnGroupMemberAdded",e.OnGroupMemberDeleted="OnGroupMemberDeleted",e.OnGroupApplicationAdded="OnGroupApplicationAdded",e.OnGroupApplicationDeleted="OnGroupApplicationDeleted",e.OnGroupInfoChanged="OnGroupInfoChanged",e.OnGroupMemberInfoChanged="OnGroupMemberInfoChanged",e.OnGroupApplicationAccepted="OnGroupApplicationAccepted",e.OnGroupApplicationRejected="OnGroupApplicationRejected",e.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnReceiveNewInvitation="OnReceiveNewInvitation",e.OnInviteeAccepted="OnInviteeAccepted",e.OnInviteeRejected="OnInviteeRejected",e.OnInvitationCancelled="OnInvitationCancelled",e.OnHangUp="OnHangUp",e.OnInvitationTimeout="OnInvitationTimeout",e.OnInviteeAcceptedByOtherDevice="OnInviteeAcceptedByOtherDevice",e.OnInviteeRejectedByOtherDevice="OnInviteeRejectedByOtherDevice",e.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal"}(p||(p={}));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var m={exports:{}};m.exports=function(){var e=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0},t=function(){function e(e,t){for(var r=0;r1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:null,p={isSquelBuilder:function(e){return e&&!!e._toParamString}},_=function(e){return!p.isSquelBuilder(e)||!e.options.rawNesting};p.DefaultQueryBuilderOptions={autoQuoteTableNames:!1,autoQuoteFieldNames:!1,autoQuoteAliasNames:!0,useAsForTableAliasNames:!1,nameQuoteCharacter:"`",tableAliasQuoteCharacter:"`",fieldAliasQuoteCharacter:'"',valueHandlers:[],parameterCharacter:"?",numberedParameters:!1,numberedParametersPrefix:"$",numberedParametersStartAt:1,replaceSingleQuotes:!1,singleQuoteReplacement:"''",separator:" ",stringFormatter:null,rawNesting:!1},p.globalValueHandlers=[],p.registerValueHandler=function(e,t){f(p.globalValueHandlers,e,t)},p.Cloneable=function(){function e(){o(this,e)}return t(e,[{key:"clone",value:function(){return a(new this.constructor,l(a({},this)))}}]),e}(),p.BaseBuilder=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this)),r=JSON.parse(JSON.stringify(p.DefaultQueryBuilderOptions));return["stringFormatter"].forEach((function(e){r[e]=p.DefaultQueryBuilderOptions[e]})),t.options=a({},r,e),t}return i(s,e),t(s,[{key:"registerValueHandler",value:function(e,t){return f(this.options.valueHandlers,e,t),this}},{key:"_sanitizeExpression",value:function(e){if(!p.isSquelBuilder(e)&&"string"!=typeof e)throw new Error("expression must be a stringĀ or builder instance");return e}},{key:"_sanitizeName",value:function(e,t){if("string"!=typeof e)throw new Error(t+" must be a string");return e}},{key:"_sanitizeField",value:function(e){return p.isSquelBuilder(e)||(e=this._sanitizeName(e,"field name")),e}},{key:"_sanitizeBaseBuilder",value:function(e){if(p.isSquelBuilder(e))return e;throw new Error("must be a builder instance")}},{key:"_sanitizeTable",value:function(e){if("string"!=typeof e)try{e=this._sanitizeBaseBuilder(e)}catch(e){throw new Error("table name must be a string or a builder")}else e=this._sanitizeName(e,"table");return e}},{key:"_sanitizeTableAlias",value:function(e){return this._sanitizeName(e,"table alias")}},{key:"_sanitizeFieldAlias",value:function(e){return this._sanitizeName(e,"field alias")}},{key:"_sanitizeLimitOffset",value:function(e){if(0>(e=parseInt(e))||isNaN(e))throw new Error("limit/offset must be >= 0");return e}},{key:"_sanitizeValue",value:function(e){var t=void 0===e?"undefined":r(e);if(null===e);else if("string"===t||"number"===t||"boolean"===t);else if(p.isSquelBuilder(e));else if(!h(e,this.options.valueHandlers,p.globalValueHandlers))throw new Error("field value must be a string, number, boolean, null or one of the registered custom value types");return e}},{key:"_escapeValue",value:function(e){return this.options.replaceSingleQuotes&&e?e.replace(/\'/g,this.options.singleQuoteReplacement):e}},{key:"_formatTableName",value:function(e){if(this.options.autoQuoteTableNames){var t=this.options.nameQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatFieldAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.fieldAliasQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatTableAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.tableAliasQuoteCharacter;e=""+t+e+t}return this.options.useAsForTableAliasNames?"AS "+e:e}},{key:"_formatFieldName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options.autoQuoteFieldNames){var r=this.options.nameQuoteCharacter;e=t.ignorePeriodsForFieldNameQuotes?""+r+e+r:e.split(".").map((function(e){return"*"===e?e:""+r+e+r})).join(".")}return e}},{key:"_formatCustomValue",value:function(e,t,r){var n=h(e,this.options.valueHandlers,p.globalValueHandlers);return n&&(e=n(e,t,r))&&e.rawNesting?{formatted:!0,rawNesting:!0,value:e.value}:{formatted:!!n,value:e}}},{key:"_formatValueForParamArray",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e)?e.map((function(e){return t._formatValueForParamArray(e,r)})):this._formatCustomValue(e,!0,r).value}},{key:"_formatValueForQueryString",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this._formatCustomValue(e,!1,n),o=i.rawNesting,s=i.formatted,a=i.value;if(s)return o?a:this._applyNestingFormatting(a,_(e));if(c(a))a=a.map((function(e){return t._formatValueForQueryString(e)})),a=this._applyNestingFormatting(a.join(", "),_(a));else{var u=void 0===a?"undefined":r(a);if(null===a)a="NULL";else if("boolean"===u)a=a?"TRUE":"FALSE";else if(p.isSquelBuilder(a))a=this._applyNestingFormatting(a.toString(),_(a));else if("number"!==u){if("string"===u&&this.options.stringFormatter)return this.options.stringFormatter(a);a=n.dontQuote?""+a:"'"+this._escapeValue(a)+"'"}}return a}},{key:"_applyNestingFormatting",value:function(e){if(e&&"string"==typeof e&&(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!this.options.rawNesting){var t="("===e.charAt(0)&&")"===e.charAt(e.length-1);if(t)for(var r=0,n=1;e.length-1>++r;){var i=e.charAt(r);if("("===i)n++;else if(")"===i&&1>--n){t=!1;break}}t||(e="("+e+")")}return e}},{key:"_buildString",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.nested,i=r.buildParameterized,o=r.formattingOptions;t=t||[],e=e||"";for(var s="",a=-1,u=[],l=this.options.parameterCharacter,f=0;e.length>f;)if(e.substr(f,l.length)===l){var h=t[++a];if(i)if(p.isSquelBuilder(h)){var d=h._toParamString({buildParameterized:i,nested:!0});s+=d.text,d.values.forEach((function(e){return u.push(e)}))}else c(h=this._formatValueForParamArray(h,o))?(s+="("+h.map((function(){return l})).join(", ")+")",h.forEach((function(e){return u.push(e)}))):(s+=l,u.push(h));else s+=this._formatValueForQueryString(h,o);f+=l.length}else s+=e.charAt(f),f++;return{text:this._applyNestingFormatting(s,!!n),values:u}}},{key:"_buildManyStrings",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[],i=[],o=0;e.length>o;++o){var s=e[o],a=t[o],u=this._buildString(s,a,{buildParameterized:r.buildParameterized,nested:!1}),c=u.text,l=u.values;n.push(c),l.forEach((function(e){return i.push(e)}))}return{text:(n=n.join(this.options.separator)).length?this._applyNestingFormatting(n,!!r.nested):"",values:i}}},{key:"_toParamString",value:function(e){throw new Error("Not yet implemented")}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(e).text}},{key:"toParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(a({},e,{buildParameterized:!0}))}}]),s}(p.Cloneable),p.Expression=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._nodes=[],t}return i(r,e),t(r,[{key:"and",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._nodes[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.type,l=u.expr,f=u.para,h=p.isSquelBuilder(l)?l._toParamString({buildParameterized:e.buildParameterized,nested:!0}):this._buildString(l,f,{buildParameterized:e.buildParameterized}),d=h.text,_=h.values;t.length&&t.push(c),t.push(d),_.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t=t.join(" "),{text:this._applyNestingFormatting(t,!!e.nested),values:r}}}]),r}(p.BaseBuilder),p.Case=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t));return u(e)&&(t=e,e=null),e&&(i._fieldName=i._sanitizeField(e)),i.options=a({},p.DefaultQueryBuilderOptions,t),i._cases=[],i._elseValue=null,i}return i(r,e),t(r,[{key:"when",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._cases[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.expression,f=c.values,h=c.result;t=s(t," ");var d=this._buildString(l,f,{buildParameterized:e.buildParameterized,nested:!0});t+="WHEN "+d.text+" THEN "+this._formatValueForQueryString(h),d.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return t.length?(t+=" ELSE "+this._formatValueForQueryString(this._elseValue)+" END",this._fieldName&&(t=this._fieldName+" "+t),t="CASE "+t):t=this._formatValueForQueryString(this._elseValue),{text:t,values:r}}}]),r}(p.BaseBuilder),p.Block=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return i(r,e),t(r,[{key:"exposedMethods",value:function(){for(var e={},t=this;t;)Object.getOwnPropertyNames(t).forEach((function(r){"constructor"===r||"function"!=typeof t[r]||"_"===r.charAt(0)||p.Block.prototype[r]||(e[r]=t[r])})),t=Object.getPrototypeOf(t);return e}}]),r}(p.BaseBuilder),p.StringBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._str=t,i}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._str,values:[]}}}]),r}(p.Block),p.FunctionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._strings=[],t._values=[],t}return i(r,e),t(r,[{key:"function",value:function(e){this._strings.push(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{};return this._buildManyStrings(this._strings,this._values,e)}}]),r}(p.Block),p.registerValueHandler(p.FunctionBlock,(function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.toParam():e.toString()})),p.AbstractTableBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._tables=[],i}return i(r,e),t(r,[{key:"_table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t?this._sanitizeTableAlias(t):t,e=this._sanitizeTable(e),this.options.singleTable&&(this._tables=[]),this._tables.push({table:e,alias:t})}},{key:"_hasTable",value:function(){return 00&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._hasTable()){var n=!0,i=!1,o=void 0;try{for(var a,u=this._tables[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.table,f=c.alias;t=s(t,", ");var h=void 0;if(p.isSquelBuilder(l)){var d=l._toParamString({buildParameterized:e.buildParameterized,nested:!0}),_=d.text,g=d.values;h=_,g.forEach((function(e){return r.push(e)}))}else h=this._formatTableName(l);f&&(h+=" "+this._formatTableAlias(f)),t+=h}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}this.options.prefix&&(t=this.options.prefix+" "+t)}return{text:t,values:r}}}]),r}(p.Block),p.TargetTableBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"target",value:function(e){this._table(e)}}]),r}(p.AbstractTableBlock),p.UpdateTableBlock=function(r){function s(){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return i(s,r),t(s,[{key:"table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("table() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(p.AbstractTableBlock),p.FromTableBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{prefix:"FROM"})))}return i(r,e),t(r,[{key:"from",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}}]),r}(p.AbstractTableBlock),p.IntoTableBlock=function(r){function s(e){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,a({},e,{prefix:"INTO",singleTable:!0})))}return i(s,r),t(s,[{key:"into",value:function(e){this._table(e)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("into() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(p.AbstractTableBlock),p.GetFieldBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"fields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(e)){var r=!0,n=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var a=o.value;this.field(a,null,t)}}catch(e){n=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}}else for(var u in e){var l=e[u];this.field(u,l,t)}}},{key:"field",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.queryBuilder,r=e.buildParameterized,n="",i=[],o=!0,a=!1,u=void 0;try{for(var c,l=this._fields[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;n=s(n,", ");var h=f.name,d=f.alias,_=f.options;if("string"==typeof h)n+=this._formatFieldName(h,_);else{var g=h._toParamString({nested:!0,buildParameterized:r});n+=g.text,g.values.forEach((function(e){return i.push(e)}))}d&&(n+=" AS "+this._formatFieldAlias(d))}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}if(!n.length){var m=t&&t.getBlock(p.FromTableBlock);m&&m._hasTable()&&(n="*")}return{text:n,values:i}}}]),r}(p.Block),p.AbstractSetFieldBlock=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._reset(),t}return i(s,e),t(s,[{key:"_reset",value:function(){this._fields=[],this._values=[[]],this._valueOptions=[[]]}},{key:"_set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._values.length>1)throw new Error("Cannot set multiple rows of fields this way.");void 0!==t&&(t=this._sanitizeValue(t)),e=this._sanitizeField(e);var n=this._fields.indexOf(e);-1===n&&(this._fields.push(e),n=this._fields.length-1),this._values[0][n]=t,this._valueOptions[0][n]=r}},{key:"_setFields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===e?"undefined":r(e)))throw new Error("Expected an object but got "+(void 0===e?"undefined":r(e)));for(var n in e)this._set(n,e[n],t)}},{key:"_setFieldsRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(e))throw new Error("Expected an array of objects but got "+(void 0===e?"undefined":r(e)));this._reset();for(var n=0;e.length>n;++n){var i=e[n];for(var o in i){var s=i[o];o=this._sanitizeField(o),s=this._sanitizeValue(s);var a=this._fields.indexOf(o);if(00&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized;if(0>=this._fields.length)throw new Error("set() needs to be called");for(var t="",r=[],n=0;ni.indexOf("=")&&(i=i+" = "+this.options.parameterCharacter);var a=this._buildString(i,[o],{buildParameterized:e,formattingOptions:this._valueOptions[0][n]});t+=a.text,a.values.forEach((function(e){return r.push(e)}))}return{text:"SET "+t,values:r}}}]),r}(p.AbstractSetFieldBlock),p.InsertFieldValueBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"setFieldsRows",value:function(e,t){this._setFieldsRows(e,t)}},{key:"_toParamString",value:function(){for(var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized,r=this._fields.map((function(t){return e._formatFieldName(t)})).join(", "),n=[],i=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._fields.length&&this._query){var n=this._query._toParamString({buildParameterized:e.buildParameterized,nested:!0}),i=n.text,o=n.values;t="("+this._fields.join(", ")+") "+this._applyNestingFormatting(i),r=o}return{text:t,values:r}}}]),r}(p.Block),p.DistinctBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"distinct",value:function(){this._useDistinct=!0}},{key:"_toParamString",value:function(){return{text:this._useDistinct?"DISTINCT":"",values:[]}}}]),r}(p.Block),p.GroupByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._groups=[],t}return i(r,e),t(r,[{key:"group",value:function(e){this._groups.push(this._sanitizeField(e))}},{key:"_toParamString",value:function(){return{text:this._groups.length?"GROUP BY "+this._groups.join(", "):"",values:[]}}}]),r}(p.Block),p.AbstractVerbSingleValueBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._value=null,t}return i(r,e),t(r,[{key:"_setValue",value:function(e){this._value=null!==e?this._sanitizeLimitOffset(e):e}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=null!==this._value?this.options.verb+" "+this.options.parameterCharacter:"",r=null!==this._value?[this._value]:[];return this._buildString(t,r,e)}}]),r}(p.Block),p.OffsetBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"OFFSET"})))}return i(r,e),t(r,[{key:"offset",value:function(e){this._setValue(e)}}]),r}(p.AbstractVerbSingleValueBlock),p.LimitBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"LIMIT"})))}return i(r,e),t(r,[{key:"limit",value:function(e){this._setValue(e)}}]),r}(p.AbstractVerbSingleValueBlock),p.AbstractConditionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._conditions=[],t}return i(r,e),t(r,[{key:"_condition",value:function(e){e=this._sanitizeExpression(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._conditions[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.expr,l=u.values,f=p.isSquelBuilder(c)?c._toParamString({buildParameterized:e.buildParameterized}):this._buildString(c,l,{buildParameterized:e.buildParameterized});f.text.length&&t.push(f.text),f.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t.length&&(t=t.join(") AND (")),{text:t.length?this.options.verb+" ("+t+")":"",values:r}}}]),r}(p.Block),p.WhereBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"WHERE"})))}return i(r,e),t(r,[{key:"where",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n2?r-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._orders[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,f=l.field,h=l.dir,d=l.values;t=s(t,", ");var p=this._buildString(f,d,{buildParameterized:e.buildParameterized});t+=p.text,c(p.values)&&p.values.forEach((function(e){return r.push(e)})),null!==h&&(t+=" "+h)}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t.length?"ORDER BY "+t:"",values:r}}}]),r}(p.Block),p.JoinBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._joins=[],t}return i(r,e),t(r,[{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"INNER";e=this._sanitizeTable(e,!0),t=t?this._sanitizeTableAlias(t):t,r=r?this._sanitizeExpression(r):r,this._joins.push({type:n,table:e,alias:t,condition:r})}},{key:"left_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT")}},{key:"right_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"RIGHT")}},{key:"outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"OUTER")}},{key:"left_outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT OUTER")}},{key:"full_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"FULL")}},{key:"cross_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"CROSS")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._joins[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table,h=c.alias,d=c.condition;t=s(t,this.options.separator);var _=void 0;if(p.isSquelBuilder(f)){var g=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});g.values.forEach((function(e){return r.push(e)})),_=g.text}else _=this._formatTableName(f);if(t+=l+" JOIN "+_,h&&(t+=" "+this._formatTableAlias(h)),d){t+=" ON ";var m=void 0;m=p.isSquelBuilder(d)?d._toParamString({buildParameterized:e.buildParameterized}):this._buildString(d,[],{buildParameterized:e.buildParameterized}),t+=this._applyNestingFormatting(m.text),m.values.forEach((function(e){return r.push(e)}))}}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(p.Block),p.UnionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._unions=[],t}return i(r,e),t(r,[{key:"union",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UNION";e=this._sanitizeTable(e),this._unions.push({type:t,table:e})}},{key:"union_all",value:function(e){this.union(e,"UNION ALL")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._unions[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table;t=s(t,this.options.separator);var h=void 0;if(f instanceof p.BaseBuilder){var d=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});h=d.text,d.values.forEach((function(e){return r.push(e)}))}else t=this._formatTableName(f);t+=l+" "+h}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(p.Block),p.QueryBuilder=function(r){function s(e,t){o(this,s);var r=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));r.blocks=t||[];var i=!0,a=!1,u=void 0;try{for(var c,l=r.blocks[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value,h=f.exposedMethods();for(var d in h){var p=h[d];if(void 0!==r[d])throw new Error("Builder already has a builder method called: "+d);!function(e,t,n){r[t]=function(){for(var t=arguments.length,i=Array(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:{};t=a({},this.options,t);var r=this.blocks.map((function(r){return r._toParamString({buildParameterized:t.buildParameterized,queryBuilder:e})})),n=r.map((function(e){return e.text})),i=r.map((function(e){return e.values})),o=n.filter((function(e){return 01&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new p.StringBlock(e,"SELECT"),new p.FunctionBlock(e),new p.DistinctBlock(e),new p.GetFieldBlock(e),new p.FromTableBlock(e),new p.JoinBlock(e),new p.WhereBlock(e),new p.GroupByBlock(e),new p.HavingBlock(e),new p.OrderByBlock(e),new p.LimitBlock(e),new p.OffsetBlock(e),new p.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(p.QueryBuilder),p.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new p.StringBlock(e,"UPDATE"),new p.UpdateTableBlock(e),new p.SetFieldBlock(e),new p.WhereBlock(e),new p.OrderByBlock(e),new p.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(p.QueryBuilder),p.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new p.StringBlock(e,"DELETE"),new p.TargetTableBlock(e),new p.FromTableBlock(a({},e,{singleTable:!0})),new p.JoinBlock(e),new p.WhereBlock(e),new p.OrderByBlock(e),new p.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(p.QueryBuilder),p.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new p.StringBlock(e,"INSERT"),new p.IntoTableBlock(e),new p.InsertFieldValueBlock(e),new p.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(p.QueryBuilder);var g={VERSION:"5.13.0",flavour:d,expr:function(e){return new p.Expression(e)},case:function(e,t){return new p.Case(e,t)},select:function(e,t){return new p.Select(e,t)},update:function(e,t){return new p.Update(e,t)},insert:function(e,t){return new p.Insert(e,t)},delete:function(e,t){return new p.Delete(e,t)},str:function(){var e=new p.FunctionBlock;return e.function.apply(e,arguments),e},rstr:function(){var e=new p.FunctionBlock({rawNesting:!0});return e.function.apply(e,arguments),e},registerValueHandler:p.registerValueHandler};return g.remove=g.delete,g.cls=p,g}var _=p();return _.flavours={},_.useFlavour=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return _;if(_.flavours[e]instanceof Function){var t=p(e);return _.flavours[e].call(null,t),t.flavours=_.flavours,t.useFlavour=_.useFlavour,t}throw new Error("Flavour not available: "+e)},_.flavours.mssql=function(r){var u=r.cls;u.DefaultQueryBuilderOptions.replaceSingleQuotes=!0,u.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,u.DefaultQueryBuilderOptions.numberedParametersPrefix="@",r.registerValueHandler(Date,(function(e){return"'"+e.getUTCFullYear()+"-"+(e.getUTCMonth()+1)+"-"+e.getUTCDate()+" "+e.getUTCHours()+":"+e.getUTCMinutes()+":"+e.getUTCSeconds()+"'"})),u.MssqlLimitOffsetTopBlock=function(e){function r(e){o(this,r);var s=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));s._limits=null,s._offsets=null;var a=function(e){e=this._sanitizeLimitOffset(e),this._parent._limits=e};return s.ParentBlock=function(e){function t(e){o(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.options));return r._parent=e,r}return i(t,e),t}(u.Block),s.LimitBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.limit=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&this._parent._offsets&&(e="FETCH NEXT "+this._parent._limits+" ROWS ONLY"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.TopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.top=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&!this._parent._offsets&&(e="TOP ("+this._parent._limits+")"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.OffsetBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"offset",value:function(e){this._parent._offsets=this._sanitizeLimitOffset(e)}},{key:"_toParamString",value:function(){var e="";return this._parent._offsets&&(e="OFFSET "+this._parent._offsets+" ROWS"),{text:e,values:[]}}}]),r}(s.ParentBlock),s}return i(r,e),t(r,[{key:"LIMIT",value:function(){return new this.LimitBlock(this)}},{key:"TOP",value:function(){return new this.TopBlock(this)}},{key:"OFFSET",value:function(){return new this.OffsetBlock(this)}}]),r}(u.Block),u.MssqlUpdateTopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._limits=null,t.limit=t.top=function(e){t._limits=t._sanitizeLimitOffset(e)},t}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._limits?"TOP ("+this._limits+")":"",values:[]}}}]),r}(u.Block),u.MssqlInsertFieldValueBlock=function(r){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._outputs=[],t}return i(s,r),t(s,[{key:"output",value:function(e){var t=this;"string"==typeof e?this._outputs.push("INSERTED."+this._sanitizeField(e)):e.forEach((function(e){t._outputs.push("INSERTED."+t._sanitizeField(e))}))}},{key:"_toParamString",value:function(t){var r=e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t);if(r.text.length&&01&&void 0!==arguments[1]?arguments[1]:null;e=this._sanitizeField(e),t=t?this._sanitizeFieldAlias(t):t,this._outputs.push({name:this.options.forDelete?"DELETED."+e:"INSERTED."+e,alias:t})}},{key:"_toParamString",value:function(e){var t="";if(this._outputs.length){var r=!0,n=!1,i=void 0;try{for(var o,a=this._outputs[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;t=s(t,", "),t+=u.name,u.alias&&(t+=" AS "+this._formatFieldAlias(u.alias))}}catch(e){n=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}t="OUTPUT "+t}return{text:t,values:[]}}}]),r}(u.Block),u.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t);var i=new u.MssqlLimitOffsetTopBlock(e);return r=r||[new u.StringBlock(e,"SELECT"),new u.DistinctBlock(e),i.TOP(),new u.GetFieldBlock(e),new u.FromTableBlock(e),new u.JoinBlock(e),new u.WhereBlock(e),new u.GroupByBlock(e),new u.OrderByBlock(e),i.OFFSET(),i.LIMIT(),new u.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"UPDATE"),new u.MssqlUpdateTopBlock(e),new u.UpdateTableBlock(e),new u.SetFieldBlock(e),new u.MssqlUpdateDeleteOutputBlock(e),new u.WhereBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"DELETE"),new u.TargetTableBlock(e),new u.FromTableBlock(a({},e,{singleTable:!0})),new u.JoinBlock(e),new u.MssqlUpdateDeleteOutputBlock(a({},e,{forDelete:!0})),new u.WhereBlock(e),new u.OrderByBlock(e),new u.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"INSERT"),new u.IntoTableBlock(e),new u.MssqlInsertFieldValueBlock(e),new u.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder)},_.flavours.mysql=function(e){var r=e.cls;r.MysqlOnDuplicateKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onDupUpdate",value:function(e,t,r){this._set(e,t,r)}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.MysqlOnDuplicateKeyUpdateBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Replace=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"REPLACE"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),e.replace=function(e,t){return new r.Replace(e,t)}},_.flavours.postgres=function(e){var r=e.cls;r.DefaultQueryBuilderOptions.numberedParameters=!0,r.DefaultQueryBuilderOptions.numberedParametersStartAt=1,r.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,r.DefaultQueryBuilderOptions.useAsForTableAliasNames=!0,r.PostgresOnConflictKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onConflict",value:function(e,t){var r=this;this._onConflict=!0,e&&(c(e)||(e=[e]),this._dupFields=e.map(this._sanitizeField.bind(this)),t&&Object.keys(t).forEach((function(e){r._set(e,t[e])})))}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.queryBuilder;var t=e.buildParameterized,r="",n=[],i=!0,o=!1,a=void 0;try{for(var u,c=this._fields[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;r=s(r,", ");var f=l.name,h=l.alias,d=l.options;if("string"==typeof f)r+=this._formatFieldName(f,d);else{var p=f._toParamString({nested:!0,buildParameterized:t});r+=p.text,p.values.forEach((function(e){return n.push(e)}))}h&&(r+=" AS "+this._formatFieldAlias(h))}}catch(e){o=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(o)throw a}}return{text:r.length>0?"RETURNING "+r:"",values:n}}}]),r}(r.Block),r.WithBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._tables=[],t}return i(r,e),t(r,[{key:"with",value:function(e,t){this._tables.push({alias:e,table:t})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._tables[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.alias,l=u.table._toParamString({buildParameterized:e.buildParameterized,nested:!0});t.push(c+" AS "+l.text),l.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return{text:t.length?"WITH "+t.join(", "):"",values:r}}}]),r}(r.Block),r.DistinctOnBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._distinctFields=[],t}return i(r,e),t(r,[{key:"distinct",value:function(){var e=this;this._useDistinct=!0;for(var t=arguments.length,r=Array(t),n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"SELECT"),new r.FunctionBlock(e),new r.DistinctOnBlock(e),new r.GetFieldBlock(e),new r.FromTableBlock(e),new r.JoinBlock(e),new r.WhereBlock(e),new r.GroupByBlock(e),new r.HavingBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.OffsetBlock(e),new r.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.PostgresOnConflictKeyUpdateBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Update=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"UPDATE"),new r.UpdateTableBlock(e),new r.SetFieldBlock(e),new r.FromTableBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Delete=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"DELETE"),new r.TargetTableBlock(e),new r.FromTableBlock(a({},e,{singleTable:!0})),new r.JoinBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder)},_}();var v=_(m.exports);function y(e,t){!function(e,t){e.exec(`\n create table if not exists 'chat_logs_${t}' (\n 'client_msg_id' char(32),\n 'server_msg_id' char(32),\n 'send_id' char(32),\n 'recv_id' char(32),\n 'sender_platform_id' smallint,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' smallint,\n 'msg_from' smallint,\n 'content_type' smallint,\n 'content' varchar(1000),\n 'is_read' tinyint(1),\n 'status' smallint,\n 'seq' int DEFAULT 0,\n 'send_time' int,\n 'create_time' int,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'local_ex' varchar(1024),\n 'is_react' tinyint(1),\n 'is_external_extensions' tinyint(1),\n 'msg_first_modify_time' int,\n PRIMARY KEY ('client_msg_id')\n );\n `)}(e,t)}function b(e){return e.exec("\n select * from local_super_groups;\n ")}function w(e){return e.exec("\n SELECT * FROM local_groups\n ")}function E(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_stranger\n WHERE user_id = (${r.join(",")})\n `)}function O(e,t,r){let n=e;return"object"==typeof e&&(n=JSON.stringify(e)),{data:void 0!==e?n:"{}",errCode:t||0,errMsg:r||""}}const k=[["user_id","userID"],["group_id","groupID"],["client_msg_id","clientMsgID"],["server_msg_id","serverMsgID"],["send_id","sendID"],["recv_id","recvID"],["sender_platform_id","senderPlatformID"],["sender_nick_name","senderNickname"],["sender_face_url","senderFaceURL"],["session_type","sessionType"],["msg_from","msgFrom"],["content_type","contentType"],["content","content"],["is_read","isRead"],["is_react","isReact"],["is_external_extensions","isExternalExtensions"],["msg_first_modify_time","msgFirstModifyTime"],["status","status"],["seq","seq"],["send_time","sendTime"],["create_time","createTime"],["attached_info","attachedInfo"],["ex","ex"],["face_url","faceURL"],["creator_user_id","creatorUserID"],["conversation_id","conversationID"],["owner_user_id","ownerUserID"],["notification_user_id","notificationUserID"],["operator_user_id","operatorUserID"],["from_face_url","fromFaceURL"],["from_user_id","fromUserID"],["from_gender","fromGender"],["from_nickname","fromNickname"],["to_user_id","toUserID"],["to_nickname","toNickname"],["to_face_url","toFaceURL"],["to_gender","toGender"],["req_msg","reqMsg"],["handle_msg","handleMsg"],["handle_time","handleTime"],["handle_result","handleResult"],["handler_user_id","handlerUserID"],["handle_user_id","handleUserID"],["inviter_user_id","inviterUserID"],["mute_end_time","muteEndTime"],["role_level","roleLevel"],["join_time","joinTime"],["join_source","joinSource"],["friend_user_id","friendUserID"],["recv_msg_opt","recvMsgOpt"],["group_at_type","groupAtType"],["latest_msg_send_time","latestMsgSendTime"],["draft_text_time","draftTextTime"],["is_private_chat","isPrivateChat"],["is_not_in_group","isNotInGroup"],["update_unread_count_time","updateUnreadCountTime"],["is_msg_destruct","isMsgDestruct"],["msg_destruct_time","msgDestructTime"],["part_hash","partHash"],["upload_id","uploadID"],["upload_info","uploadInfo"],["expire_time","expireTime"]];function S(e){const t=function(e){const t=k.find((t=>t[0]===e));if(t)return t[1]}(e);if(t)return t;const r=[];let n=-2;for(let t=0;tt[1]===e));if(t)return t[0]}(e);if(t)return t;const r=[];for(let t=0;t{const o={};i.forEach(((i,s)=>{let a=i,u=e[s];"CamelCase"===t&&(a=S(i)),"SnakeCase"===t&&(a=R(i)),r.find((e=>e===a))&&(u=!!u),a=n[i]||a,o[a]=u})),s.push(o)})),s}function A(e,t=!0){const r={};return Object.keys(e).forEach((n=>{let i=e[n];t&&function(e){return"string"==typeof e}(i)&&(i=function(e,t={backslashSupported:!1}){if(null==e)throw new Error("Need to pass a valid string");if(!(t=t||{}).backslashSupported)return"'"+e.replace(/'/g,"''")+"'";const r=N,n=M;let i,o=r.lastIndex=0,s="";for(;i=r.exec(e);)s+=e.slice(o,i.index)+n[i[0]],o=r.lastIndex;return 0===o?"'"+e+"'":o{const i=t[n]||n;r[i]=e[n]})),r}var I="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function C(){throw new Error("setTimeout has not been defined")}function F(){throw new Error("clearTimeout has not been defined")}var B=C,P=F;function D(e){if(B===setTimeout)return setTimeout(e,0);if((B===C||!B)&&setTimeout)return B=setTimeout,setTimeout(e,0);try{return B(e,0)}catch(t){try{return B.call(null,e,0)}catch(t){return B.call(this,e,0)}}}"function"==typeof I.setTimeout&&(B=setTimeout),"function"==typeof I.clearTimeout&&(P=clearTimeout);var $,L=[],U=!1,q=-1;function j(){U&&$&&(U=!1,$.length?L=$.concat(L):q=-1,L.length&&J())}function J(){if(!U){var e=D(j);U=!0;for(var t=L.length;t;){for($=L,L=[];++q1)for(var r=1;r>18&63]+ne[i>>12&63]+ne[i>>6&63]+ne[63&i]);return o.join("")}function ce(e){var t;se||ae();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=ne[t>>2],i+=ne[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ne[t>>10],i+=ne[t>>4&63],i+=ne[t<<2&63],i+="="),o.push(i),o.join("")}function le(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,h=r?-1:1,d=e[t+f];for(f+=h,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)}function fe(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*_}var he={}.toString,de=Array.isArray||function(e){return"[object Array]"==he.call(e)};function pe(){return ge.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _e(e,t){if(pe()=pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+pe().toString(16)+" bytes");return 0|e}function Ee(e){return!(null==e||!e._isBuffer)}function Oe(e,t){if(Ee(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Qe(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ke(e).length;default:if(n)return Qe(e).length;t=(""+t).toLowerCase(),n=!0}}function ke(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Le(this,t,r);case"utf8":case"utf-8":return Be(this,t,r);case"ascii":return De(this,t,r);case"latin1":case"binary":return $e(this,t,r);case"base64":return Fe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ue(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Se(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Re(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=ge.from(t,n)),Ee(t))return 0===t.length?-1:Ne(e,t,r,n,i);if("number"==typeof t)return t&=255,ge.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Ne(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Ne(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var f=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function Fe(e,t,r){return 0===t&&r===e.length?ce(e):ce(e.slice(t,r))}function Be(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=Pe)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},ge.prototype.compare=function(e,t,r,n,i){if(!Ee(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Me(this,e,t,r);case"utf8":case"utf-8":return xe(this,e,t,r);case"ascii":return Ae(this,e,t,r);case"latin1":case"binary":return Te(this,e,t,r);case"base64":return Ie(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ge.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Pe=4096;function De(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function je(e,t,r,n,i,o){if(!Ee(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Je(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ze(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function We(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ge(e,t,r,n,i){return i||We(e,0,r,4),fe(e,t,r,n,23,4),r+4}function He(e,t,r,n,i){return i||We(e,0,r,8),fe(e,t,r,n,52,8),r+8}ge.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},ge.prototype.readUInt8=function(e,t){return t||qe(e,1,this.length),this[e]},ge.prototype.readUInt16LE=function(e,t){return t||qe(e,2,this.length),this[e]|this[e+1]<<8},ge.prototype.readUInt16BE=function(e,t){return t||qe(e,2,this.length),this[e]<<8|this[e+1]},ge.prototype.readUInt32LE=function(e,t){return t||qe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ge.prototype.readUInt32BE=function(e,t){return t||qe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ge.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||qe(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ge.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||qe(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},ge.prototype.readInt8=function(e,t){return t||qe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ge.prototype.readInt16LE=function(e,t){t||qe(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ge.prototype.readInt16BE=function(e,t){t||qe(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ge.prototype.readInt32LE=function(e,t){return t||qe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ge.prototype.readInt32BE=function(e,t){return t||qe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ge.prototype.readFloatLE=function(e,t){return t||qe(e,4,this.length),le(this,e,!0,23,4)},ge.prototype.readFloatBE=function(e,t){return t||qe(e,4,this.length),le(this,e,!1,23,4)},ge.prototype.readDoubleLE=function(e,t){return t||qe(e,8,this.length),le(this,e,!0,52,8)},ge.prototype.readDoubleBE=function(e,t){return t||qe(e,8,this.length),le(this,e,!1,52,8)},ge.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||je(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},ge.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,1,255,0),ge.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ge.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,2,65535,0),ge.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Je(this,e,t,!0),t+2},ge.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,2,65535,0),ge.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Je(this,e,t,!1),t+2},ge.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,4,4294967295,0),ge.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ze(this,e,t,!0),t+4},ge.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,4,4294967295,0),ge.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ze(this,e,t,!1),t+4},ge.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);je(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},ge.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);je(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},ge.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,1,127,-128),ge.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ge.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,2,32767,-32768),ge.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Je(this,e,t,!0),t+2},ge.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,2,32767,-32768),ge.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Je(this,e,t,!1),t+2},ge.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,4,2147483647,-2147483648),ge.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ze(this,e,t,!0),t+4},ge.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||je(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ge.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ze(this,e,t,!1),t+4},ge.prototype.writeFloatLE=function(e,t,r){return Ge(this,e,t,!0,r)},ge.prototype.writeFloatBE=function(e,t,r){return Ge(this,e,t,!1,r)},ge.prototype.writeDoubleLE=function(e,t,r){return He(this,e,t,!0,r)},ge.prototype.writeDoubleBE=function(e,t,r){return He(this,e,t,!1,r)},ge.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!ge.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ke(e){return function(e){var t,r,n,i,o,s;se||ae();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new oe(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=ie[e.charCodeAt(t)]<<2|ie[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=ie[e.charCodeAt(t)]<<10|ie[e.charCodeAt(t+1)]<<4|ie[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ye,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Xe(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ze(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var et={exports:{}};function tt(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var rt=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,nt=function(e){return rt.exec(e).slice(1)};function it(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=tt(dt(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function ot(e){var t=st(e),r="/"===pt(e,-1);return(e=tt(dt(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function st(e){return"/"===e.charAt(0)}function at(){return ot(dt(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function ut(e,t){function r(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=it(e).substr(1),t=it(t).substr(1);for(var n=r(e.split("/")),i=r(t.split("/")),o=Math.min(n.length,i.length),s=o,a=0;a>>0),this.Xc=!0,null!=e&&Re.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(s(this.filename,n)),this.db=R(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Ye(4),o=i.cwrap,s=o("sqlite3_open","number",["string","number"]),a=o("sqlite3_close_v2","number",["number"]),u=o("sqlite3_exec","number",["number","string","number","number","number"]),c=o("sqlite3_changes","number",["number"]),l=o("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=o("sqlite3_sql","string",["number"]),h=o("sqlite3_normalized_sql","string",["number"]),d=o("sqlite3_prepare_v2","number",["number","number","number","number","number"]),p=o("sqlite3_bind_text","number",["number","number","number","number","number"]),_=o("sqlite3_bind_blob","number",["number","number","number","number","number"]),g=o("sqlite3_bind_double","number",["number","number","number"]),m=o("sqlite3_bind_int","number",["number","number","number"]),v=o("sqlite3_bind_parameter_index","number",["number","string"]),y=o("sqlite3_step","number",["number"]),b=o("sqlite3_errmsg","string",["number"]),w=o("sqlite3_column_count","number",["number"]),E=o("sqlite3_data_count","number",["number"]),N=o("sqlite3_column_double","number",["number","number"]),M=o("sqlite3_column_text","string",["number","number"]),x=o("sqlite3_column_blob","number",["number","number"]),A=o("sqlite3_column_bytes","number",["number","number"]),I=o("sqlite3_column_type","number",["number","number"]),B=o("sqlite3_column_name","string",["number","number"]),P=o("sqlite3_reset","number",["number"]),D=o("sqlite3_clear_bindings","number",["number"]),$=o("sqlite3_finalize","number",["number"]),L=o("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),U=o("sqlite3_value_type","number",["number"]),z=o("sqlite3_value_bytes","number",["number"]),W=o("sqlite3_value_text","string",["number"]),G=o("sqlite3_value_blob","number",["number"]),H=o("sqlite3_value_double","number",["number"]),Y=o("sqlite3_result_double","",["number","number"]),V=o("sqlite3_result_null","",["number"]),Q=o("sqlite3_result_text","",["number","string","number","number"]),K=o("sqlite3_result_blob","",["number","number","number","number"]),X=o("sqlite3_result_int","",["number","number"]),Z=o("sqlite3_result_error","",["number","string","number"]),ee=o("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=y(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),N(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),M(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=A(this.Qa,e);e=x(this.Qa,e);for(var r=new Uint8Array(t),n=0;n{let t=k((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=k((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=k((function(e,t){e=q(e),te.set(t,e)}),"vii");i._register_for_idb(t,r,n)},i.cleanup_file=e=>{let t=[...te.entries()].find((t=>t[1]===e));te.delete(t[0])},i.reset_filesystem=()=>{Re.root=null,Re.lc()}};var s,a={};for(s in i)i.hasOwnProperty(s)&&(a[s]=i[s]);var u,c,l,f,h,d="./this.program",p="object"==typeof window,_="function"==typeof importScripts,g="object"==typeof re&&"object"==typeof re.versions&&"string"==typeof re.versions.node,m="";g?(m=_?_t.dirname(m)+"/":"/Volumes/data/Workspace/npmPackage/open-im-sdk-web-wasm/node_modules/@jlongster/sql.js/dist/",u=function(e,t){return f||(f=gt),h||(h=_t),e=h.normalize(e),f.readFileSync(e,t?null:"utf8")},l=function(e){return(e=u(e,!0)).buffer||(e=new Uint8Array(e)),x(e.buffer),e},c=function(e,t,r){f||(f=gt),h||(h=_t),e=h.normalize(e),f.readFile(e,(function(e,n){e?r(e):t(n.buffer)}))},1>0]=0;break;case"i16":B[e>>1]=0;break;case"i32":P[e>>2]=0;break;case"i64":Z=[0,(X=0,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[e>>2]=Z[0],P[e+4>>2]=Z[1];break;case"float":D[e>>2]=0;break;case"double":$[e>>3]=0;break;default:se("invalid type for setValue: "+t)}}function R(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return C[e>>0];case"i16":return B[e>>1];case"i32":case"i64":return P[e>>2];case"float":return D[e>>2];case"double":return $[e>>3];default:se("invalid type for getValue: "+t)}return null}i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&se("no native wasm support detected");var N,M=!1;function x(e,t){e||se("Assertion failed: "+t)}function A(e){var t=i["_"+e];return x(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function T(e){var t=Ue(e.length);return e.subarray||e.slice?F.set(e,t):F.set(new Uint8Array(e),t),t}var I,C,F,B,P,D,$,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,r){var n=t+r;for(r=t;e[r]&&!(r>=n);)++r;if(16(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function q(e,t){return e?U(F,e,t):""}function j(e,t,r,n){if(!(0=s)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(127>=s){if(r>=n)break;t[r++]=s}else{if(2047>=s){if(r+1>=n)break;t[r++]=192|s>>6}else{if(65535>=s){if(r+2>=n)break;t[r++]=224|s>>12}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63}t[r++]=128|s>>6&63}t[r++]=128|63&s}}return t[r]=0,r-i}function J(e){for(var t=0,r=0;r=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function z(e){var t=J(e)+1,r=Ue(t);return r&&j(e,C,r,t),r}function W(){var e=N.buffer;I=e,i.HEAP8=C=new Int8Array(e),i.HEAP16=B=new Int16Array(e),i.HEAP32=P=new Int32Array(e),i.HEAPU8=F=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=D=new Float32Array(e),i.HEAPF64=$=new Float64Array(e)}var G,H=[],Y=[],V=[];function Q(){var e=i.preRun.shift();H.unshift(e)}var K,X,Z,ee,te=0,ne=null;function ie(){te++,i.monitorRunDependencies&&i.monitorRunDependencies(te)}function oe(){if(te--,i.monitorRunDependencies&&i.monitorRunDependencies(te),0==te&&ne){var e=ne;ne=null,e()}}function se(e){throw i.onAbort&&i.onAbort(e),y(e),M=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function ae(){return K.startsWith("data:application/octet-stream;base64,")}if(i.preloadedImages={},i.preloadedAudios={},K="sql-wasm.wasm",!ae()){var ue=K;K=i.locateFile?i.locateFile(ue,m):m+ue}function ce(){var e=K;try{if(e==K&&w)return new Uint8Array(w);if(l)return l(e);throw"both async and sync fetching of the wasm failed"}catch(e){se(e)}}function le(e){for(;0r?[]:e.slice(t,r-t+1)}e=me(e).substr(1),t=me(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;nt)throw new Re.ErrnoError(28);return t},allocate:function(e,t,r){Se.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new Re.ErrnoError(28);if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==I){if((0>>0)%Re.Ua.length},ec:function(e){var t=Re.Gb(e.parent.id,e.name);e.cb=Re.Ua[t],Re.Ua[t]=e},fc:function(e){var t=Re.Gb(e.parent.id,e.name);if(Re.Ua[t]===e)Re.Ua[t]=e.cb;else for(t=Re.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=Re.Vc(e);if(r)throw new Re.ErrnoError(r,e);for(r=Re.Ua[Re.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return Re.lookup(e,t)},createNode:function(e,t,r,n){return e=new Re.FSNode(e,t,r,n),Re.ec(e),e},Ab:function(e){Re.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=Re.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return Re.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=Re.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return Re.lookupNode(e,t),20}catch(e){}return Re.Za(e,"wx")},qb:function(e,t,r){try{var n=Re.lookupNode(e,t)}catch(e){return e.Oa}if(e=Re.Za(e,"wx"))return e;if(r){if(!Re.isDir(n.mode))return 54;if(Re.isRoot(n)||Re.Ya(n)===Re.cwd())return 10}else if(Re.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?Re.fb(e.mode)?32:Re.isDir(e.mode)&&("r"!==Re.$b(t)||512&t)?31:Re.Za(e,Re.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||Re.oc,e=e||0;e<=t;e++)if(!Re.streams[e])return e;throw new Re.ErrnoError(33)},$a:function(e){return Re.streams[e]},Jc:function(e,t,r){Re.ub||(Re.ub=function(){},Re.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new Re.ub;for(n in e)i[n]=e[n];return e=i,t=Re.$c(t,r),e.fd=t,Re.streams[t]=e},Dc:function(e){Re.streams[e]=null},Cc:{open:function(e){e.stream_ops=Re.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Re.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){Re.Xb[e]={stream_ops:t}},Oc:function(e){return Re.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return Re.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),Re.tb++,1t)throw new Re.ErrnoError(28);if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);if(Re.isDir(e.mode))throw new Re.ErrnoError(31);if(!Re.isFile(e.mode))throw new Re.ErrnoError(28);var r=Re.Za(e,"w");if(r)throw new Re.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(28);Re.truncate(e.node,t)},kd:function(e,t,r){(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,o){if(""===e)throw new Re.ErrnoError(44);if(r=64&(t="string"==typeof t?Re.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var s=e;else{e=he(e);try{s=Re.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(s){if(128&t)throw new Re.ErrnoError(20)}else s=Re.mknod(e,r,0),a=!0;if(!s)throw new Re.ErrnoError(44);if(Re.pb(s.mode)&&(t&=-513),65536&t&&!Re.isDir(s.mode))throw new Re.ErrnoError(54);if(!a&&(r=Re.Wc(s,t)))throw new Re.ErrnoError(r);512&t&&Re.truncate(s,0),t&=-131713,(n=Re.Jc({node:s,path:Re.Ya(s),flags:t,seekable:!0,position:0,stream_ops:s.stream_ops,jd:[],error:!1},n,o)).stream_ops.open&&n.stream_ops.open(n),!i.logReadFiles||1&t||(Re.Ob||(Re.Ob={}),e in Re.Ob||(Re.Ob[e]=1,y("FS.trackingDelegate error on read file: "+e)));try{Re.Sa.onOpenFile&&(o=0,1!=(2097155&t)&&(o|=Re.nc.kc.qc),0!=(2097155&t)&&(o|=Re.nc.kc.rc),Re.Sa.onOpenFile(e,o))}catch(t){y("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(Re.kb(e))throw new Re.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Re.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Re.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Re.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(1==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.read)throw new Re.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.write)throw new Re.ErrnoError(28);e.seekable&&1024&e.flags&&Re.llseek(e,0,2);var s=void 0!==i;if(s){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),s||(e.position+=t);try{e.path&&Re.Sa.onWriteToFile&&Re.Sa.onWriteToFile(e.path)}catch(t){y("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(0>t||0>=r)throw new Re.ErrnoError(28);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(!Re.isFile(e.node.mode)&&!Re.isDir(e.node.mode))throw new Re.ErrnoError(43);if(!e.stream_ops.allocate)throw new Re.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new Re.ErrnoError(2);if(1==(2097155&e.flags))throw new Re.ErrnoError(2);if(!e.stream_ops.mmap)throw new Re.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new Re.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=Re.open(e,t.flags);e=Re.stat(e).size;var i=new Uint8Array(e);return Re.read(n,i,0,e,0),"utf8"===t.encoding?r=U(i,0):"binary"===t.encoding&&(r=i),Re.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=Re.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array(J(t)+1);t=j(t,n,0,n.length),Re.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Re.write(e,t,0,t.byteLength,void 0,r.Bc)}Re.close(e)},cwd:function(){return Re.Wb},chdir:function(e){if(null===(e=Re.lookupPath(e,{Ta:!0})).node)throw new Re.ErrnoError(44);if(!Re.isDir(e.node.mode))throw new Re.ErrnoError(54);var t=Re.Za(e.node,"x");if(t)throw new Re.ErrnoError(t);Re.Wb=e.path},Fc:function(){Re.mkdir("/tmp"),Re.mkdir("/home"),Re.mkdir("/home/web_user")},Ec:function(){Re.mkdir("/dev"),Re.Qb(Re.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),Re.rb("/dev/null",Re.bb(1,3)),be(Re.bb(5,0),Ee),be(Re.bb(6,0),Oe),Re.rb("/dev/tty",Re.bb(5,0)),Re.rb("/dev/tty1",Re.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(g)try{var t=mt;return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){se("randomDevice")}}();Re.Wa("/dev","random",e),Re.Wa("/dev","urandom",e),Re.mkdir("/dev/shm"),Re.mkdir("/dev/shm/tmp")},Hc:function(){Re.mkdir("/proc");var e=Re.mkdir("/proc/self");Re.mkdir("/proc/self/fd"),Re.mount({mount:function(){var t=Re.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=Re.$a(+t);if(!r)throw new Re.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){i.stdin?Re.Wa("/dev","stdin",i.stdin):Re.symlink("/dev/tty","/dev/stdin"),i.stdout?Re.Wa("/dev","stdout",null,i.stdout):Re.symlink("/dev/tty","/dev/stdout"),i.stderr?Re.Wa("/dev","stderr",null,i.stderr):Re.symlink("/dev/tty1","/dev/stderr"),Re.open("/dev/stdin",0),Re.open("/dev/stdout",1),Re.open("/dev/stderr",1)},Yb:function(){Re.ErrnoError||(Re.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},Re.ErrnoError.prototype=Error(),Re.ErrnoError.prototype.constructor=Re.ErrnoError,[44].forEach((function(e){Re.Db[e]=new Re.ErrnoError(e),Re.Db[e].stack=""})))},lc:function(){Re.Yb(),Re.Ua=Array(4096),Re.mount(Se,{},"/"),Re.Fc(),Re.Ec(),Re.Hc(),Re.Lc={MEMFS:Se}},jb:function(e,t,r){Re.jb.Hb=!0,Re.Yb(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,Re.Ic()},wd:function(){Re.jb.Hb=!1;var e=i._fflush;for(e&&e(0),e=0;ethis.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var s=this;s.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===s.ob[e]){var a=s.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):De(u.responseText||"",!0),a[e]=t}if(void 0===s.ob[e])throw Error("doXHR failed!");return s.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!_)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o;Object.defineProperties(s,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),s={Ib:!1,Na:s}}else s={Ib:!1,url:r};var a=Re.Gc(e,t,s,n,i);s.Na?a.Na=s.Na:s.url&&(a.Na=null,a.url=s.url),Object.defineProperties(a,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];u[e]=function(){return Re.ac(a),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(Re.ac(a),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o>2]=n.dev,P[r+4>>2]=0,P[r+8>>2]=n.ino,P[r+12>>2]=n.mode,P[r+16>>2]=n.nlink,P[r+20>>2]=n.uid,P[r+24>>2]=n.gid,P[r+28>>2]=n.rdev,P[r+32>>2]=0,Z=[n.size>>>0,(X=n.size,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+40>>2]=Z[0],P[r+44>>2]=Z[1],P[r+48>>2]=4096,P[r+52>>2]=n.blocks,P[r+56>>2]=n.atime.getTime()/1e3|0,P[r+60>>2]=0,P[r+64>>2]=n.mtime.getTime()/1e3|0,P[r+68>>2]=0,P[r+72>>2]=n.ctime.getTime()/1e3|0,P[r+76>>2]=0,Z=[n.ino>>>0,(X=n.ino,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+80>>2]=Z[0],P[r+84>>2]=Z[1],0}var xe,Ae=void 0;function Te(){return P[(Ae+=4)-4>>2]}function Ie(e){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);return e}xe=g?function(){var e=re.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Ce,Fe={};function Be(){if(!Ce){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"};for(e in Fe)void 0===Fe[e]?delete t[e]:t[e]=Fe[e];var r=[];for(e in t)r.push(e+"="+t[e]);Ce=r}return Ce}function Pe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=Re.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function De(e,t){var r=Array(J(e)+1);return e=j(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Pe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return Re.isDir(this.mode)}},Ib:{get:function(){return Re.pb(this.mode)}}}),Re.FSNode=Pe,Re.lc();var $e={a:function(e,t,r,n){se("Assertion failed: "+q(e)+", at: "+[t?q(t):"unknown filename",r,n?q(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!ee){ee=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);P[We()>>2]=60*o,P[ze()>>2]=Number(t!=i),r=e(r),n=e(n),r=z(r),n=z(n),i>2]=r,P[Je()+4>>2]=n):(P[Je()>>2]=n,P[Je()+4>>2]=r)}}(),e=new Date(1e3*P[e>>2]),P[t>>2]=e.getSeconds(),P[t+4>>2]=e.getMinutes(),P[t+8>>2]=e.getHours(),P[t+12>>2]=e.getDate(),P[t+16>>2]=e.getMonth(),P[t+20>>2]=e.getFullYear()-1900,P[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);P[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,P[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),P[t+32>>2]=e,e=P[Je()+(e?4:0)>>2],P[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=q(e),-8&t)var n=-28;else(r=Re.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&Re.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},A:function(e,t){try{return e=q(e),Re.chmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},H:function(e,t,r){try{return e=q(e),Re.chown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},B:function(e,t){try{return Re.fchmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},I:function(e,t,r){try{return Re.fchown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},b:function(e,t,r){Ae=r;try{var n=Ie(e);switch(t){case 0:var i=Te();return 0>i?-28:Re.open(n.path,n.flags,0,i).fd;case 1:case 2:case 13:case 14:return 0;case 3:return n.flags;case 4:return i=Te(),n.flags|=i,0;case 12:return i=Te(),B[i+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return P[Le()>>2]=28,-1}}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},E:function(e,t){try{var r=Ie(e);return Me(Re.stat,r.path,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},n:function(e,t,r){try{return Re.Nc(e,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=Re.cwd();return t=r)var n=-28;else{var i=Re.readlink(e),o=Math.min(r,J(i)),s=C[t+o];j(i,F,t,r+1),C[t+o]=s,n=o}return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},F:function(e){try{return e=q(e),Re.rmdir(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},e:function(e,t){try{return e=q(e),Me(Re.stat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},i:function(e){try{return e=q(e),Re.unlink(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){F.copyWithin(e,t,t+r)},c:function(e){var t=F.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{N.grow(Math.min(2147483648,n)-I.byteLength+65535>>>16),W();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=xe();xe()-t>2]=o,o=0;o>0]=n.charCodeAt(o);C[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},s:function(e,t){try{var r=Be();P[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),P[t>>2]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},f:function(e){try{var t=Ie(e);return Re.close(t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},q:function(e,t){try{var r=Ie(e),n=r.tty?2:Re.isDir(r.mode)?3:Re.fb(r.mode)?7:4;return C[t>>0]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=Ie(e),o=e=0;o>2],a=Re.read(i,C,P[t+8*o>>2],s,void 0);if(0>a){var u=-1;break e}if(e+=a,a>2]=u,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},o:function(e,t,r,n,i){try{var o=Ie(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(Re.llseek(o,e,n),Z=[o.position>>>0,(X=o.position,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[i>>2]=Z[0],P[i+4>>2]=Z[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},k:function(e){try{var t=Ie(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=Ie(e),o=e=0;o>2],P[t+(8*o+4)>>2],void 0);if(0>s){var a=-1;break e}e+=s}a=e}return P[n>>2]=a,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||se(e),e.Oa}},h:function(e){var t=Date.now();return P[e>>2]=t/1e3|0,P[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(P[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*P[r>>2],t+=P[r+4>>2]/1e3}else t=Date.now();e=q(e);try{Re.kd(e,t,t);var n=0}catch(e){if(!(e instanceof Re.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw i.extraStackTrace&&(n+="\n"+i.extraStackTrace()),n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n),e+" : "+n}n=e.Oa,P[Le()>>2]=n,n=-1}return n}};!function(){function e(e){i.asm=e.exports,N=i.asm.L,W(),G=i.asm.Da,Y.unshift(i.asm.M),oe()}function t(t){e(t.instance)}function r(e){return function(){if(!w&&(p||_)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()})).catch((function(){return ce()}));if(c)return new Promise((function(e,t){c(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ce()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){y("failed to asynchronously prepare wasm: "+e),se(e)}))}var n={a:$e};if(ie(),i.instantiateWasm)try{return i.instantiateWasm(n,e)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}w||"function"!=typeof WebAssembly.instantiateStreaming||ae()||K.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.M).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.N).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.O).apply(null,arguments)};var Le=i.___errno_location=function(){return(Le=i.___errno_location=i.asm.P).apply(null,arguments)};i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.Q).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.R).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.S).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.T).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.U).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.V).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.W).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.X).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.Y).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.Z).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm._).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.$).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.aa).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.ba).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.ca).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.da).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.ea).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.fa).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.ga).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.ha).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.ia).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.ja).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.ka).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.la).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.ma).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.na).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.oa).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.pa).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.qa).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.ra).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sa).apply(null,arguments)},i._sqlite3_normalized_sql=function(){return(i._sqlite3_normalized_sql=i.asm.ta).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.ua).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.va).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.wa).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.xa).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.ya).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.za).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.Aa).apply(null,arguments)};var Ue=i._malloc=function(){return(Ue=i._malloc=i.asm.Ba).apply(null,arguments)},qe=i._free=function(){return(qe=i._free=i.asm.Ca).apply(null,arguments)};i._RegisterExtensionFunctions=function(){return(i._RegisterExtensionFunctions=i.asm.Ea).apply(null,arguments)},i._register_for_idb=function(){return(i._register_for_idb=i.asm.Fa).apply(null,arguments)};var je,Je=i.__get_tzname=function(){return(Je=i.__get_tzname=i.asm.Ga).apply(null,arguments)},ze=i.__get_daylight=function(){return(ze=i.__get_daylight=i.asm.Ha).apply(null,arguments)},We=i.__get_timezone=function(){return(We=i.__get_timezone=i.asm.Ia).apply(null,arguments)},Ge=i.stackSave=function(){return(Ge=i.stackSave=i.asm.Ja).apply(null,arguments)},He=i.stackRestore=function(){return(He=i.stackRestore=i.asm.Ka).apply(null,arguments)},Ye=i.stackAlloc=function(){return(Ye=i.stackAlloc=i.asm.La).apply(null,arguments)},Ve=i._memalign=function(){return(Ve=i._memalign=i.asm.Ma).apply(null,arguments)};function Qe(){function e(){if(!je&&(je=!0,i.calledRun=!0,!M)){if(i.noFSInit||Re.jb.Hb||Re.jb(),Re.hc=!1,le(Y),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;){var e=i.postRun.shift();V.unshift(e)}le(V)}}if(!(0{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(bt)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.lock(t)}unlock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.unlock(t)}createNode(e,t,r,n){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(yt);var i=this.FS.createNode(e,t,r,n);return this.FS.isDir(i.mode)?(i.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},i.stream_ops={},i.contents={}):this.FS.isFile(i.mode)&&(i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i.contents=this.backend.createFile(t)),e&&(e.contents[t]=i,e.timestamp=i.timestamp),i}};let Et=1,Ot=2;function kt(e){return(e[16]<<8)+e[17]}function St(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function Rt(e,t,r,n){let i=St(t,r,n),o=0;return i.map((i=>{let s=0,a=t;r>i&&ri&&ni+t||n<=i)return null;let l=e.byteOffset+o,f=e.buffer.byteLength-l;if(f<=0)return null;let h=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,h),s),o+=h,{pos:i,data:c,offset:s,length:h}})).filter(Boolean)}class Nt{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e}),{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;to.pos&&(s=t-o.pos),ro.data.byteLength||a<0)continue;let u=a-s;i.set(new Uint8Array(o.data,s,u),o.pos-t+s)}return n}(this.load(u),s,a);if(i.byteLength-t(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e)),{fullWrites:[],partialWrites:[]}),u=[];s.length>0&&(u=this.load(s.map((e=>e.pos))));let c=a.concat(u.map((e=>{let t=s.find((t=>t.pos===e.pos));return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e})));return this.bufferChunks(c),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=Ot&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=kt(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(Rt(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}let Mt,xt,At,Tt=3735928559;class It{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log(`waiting for ${e}`);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log(`resumed for ${e}`)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=new DataView(this.buffer,this.offset).getUint32(0)===Tt;return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new Ct(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new It(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",(e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}}))}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function Pt(e,t){return Math.round(e/t)}async function Dt(e){return await function(){if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const r=()=>indexedDB.databases().finally(t);e=setInterval(r,100),r()})).finally((()=>clearInterval(e)))}(),new Promise(((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)}))}class $t{constructor(e,t){this.dbName=e,this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=t}async getDb(){return this._openDb||(this._openDb=await Dt(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise(((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}}))}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise(((o,s)=>{let a=i.get(0);a.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(a.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void s(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>s()},a.onerror=s}))}}class Lt{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new $t(this.dbName,t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>Et&&e===Et&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:kt(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(Pt(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=Pt(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=Et&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>Et),this.writeQueue=[]),this.cachedFirstBlock=null}}class Ut{constructor(e){this.onFallbackFailure=e}createFile(e){let t;t="undefined"!=typeof SharedArrayBuffer?new Bt(e):new Lt(e,this.onFallbackFailure);let r=new Nt(e,t);return("production"!==re.env.NODE_ENV||re.env.PERF_BUILD)&&(null==this._files&&(this._files=new Set),this._files.add(r)),r}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}function qt(e,t){if(Mt)return Mt;if(!e)throw new Error("must speciefic database file");return Mt=new Promise(((r,n)=>{const i=async function(e,t="/sql-wasm.wasm"){if(!xt){xt=await vt({locateFile:()=>t});const e=new wt(xt.FS,new Ut);xt.register_for_idb(e),xt.FS.mkdir("/sql"),xt.FS.mount(e,{},"/sql")}const r=`/sql/${e}`,n=new xt.Database(r,{filename:!0});if("undefined"==typeof SharedArrayBuffer){const e=xt.FS.open(r,"a+");await e.node.contents.readIfFallback(),xt.FS.close(e)}return n.exec("\n PRAGMA page_size=8192;\n PRAGMA journal_mode=MEMORY;\n "),n}(e,t);i.then((e=>r(e))).catch((e=>n(e)))})),Mt}async function jt(e){try{const t=await qt(),r=(JSON.parse(e)||[]).map((e=>A(e)));if(0===r.length)return O("");const n=function(e,t){const r=v.insert().into("local_conversations").setFieldsRows(t).toString();return e.exec(r)}(t,r);return O(n)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}}async function Jt(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("temp_cache_local_chat_logs").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>A(e))));return O(r[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}}self.$RefreshReg$=()=>{},self.$RefreshSig$=()=>()=>{};const zt=new Map,Wt=self,Gt=new h({event:new class{constructor(e){c(this,"_currentEndpoint"),c(this,"_targetEndpoint"),c(this,"_events"),c(this,"_originOnmessage"),c(this,"_receiveMessage"),c(this,"onerror",null),c(this,"config"),c(this,"sendAdapter"),c(this,"receiveAdapter"),this._events={},this._currentEndpoint=e.currentEndpoint,this._targetEndpoint=e.targetEndpoint,this._originOnmessage=null,this.config=e.config,this.receiveAdapter=e.receiveAdapter,this.sendAdapter=e.sendAdapter;const t=e=>{const t=this.receiveAdapter?this.receiveAdapter(e):e.data;if(t&&"string"==typeof t.event){const e=this._events[t.event]||[];if(e.length)return void e.forEach((e=>{e(...t.args||[])}));this.onerror&&this.onerror(u(a({},l.METHOD_NOT_FOUND),{data:t}))}};if(this._currentEndpoint.addEventListener)return"start"in this._currentEndpoint&&this._currentEndpoint.start&&this._currentEndpoint.start(),this._currentEndpoint.addEventListener("message",t,!1),void(this._receiveMessage=t);this._originOnmessage=this._currentEndpoint.onmessage,this._currentEndpoint.onmessage=e=>{this._originOnmessage&&this._originOnmessage(e),t(e)},this._receiveMessage=this._currentEndpoint.onmessage}emit(e,...t){const r={event:e,args:t},n=this.sendAdapter?this.sendAdapter(r,this._targetEndpoint):{data:r},i=n.data||r,o=this.config?"function"==typeof this.config?this.config(i,this._targetEndpoint)||{}:this.config||{}:{};Array.isArray(n.transfer)&&n.transfer.length&&(o.transfer=n.transfer),this._targetEndpoint.postMessage(i,o)}on(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}off(e,t){if(!this._events[e])return;if(!t)return void(this._events[e]=[]);const r=this._events[e]||[];this._events[e]=r.filter((e=>e!==t))}destroy(){if(this._currentEndpoint.removeEventListener)this._currentEndpoint.removeEventListener("message",this._receiveMessage,!1);else try{this._currentEndpoint.onmessage=this._originOnmessage}catch(e){console.warn(e)}}}({currentEndpoint:Wt,targetEndpoint:Wt})});Gt.registerMethod("fileMapSet",((e,t)=>(zt.set(e,t),O(e)))),Gt.registerMethod("fileMapClear",(()=>(zt.clear(),O("")))),Gt.registerMethod("wasmOpen",(e=>new Promise(((t,r)=>{const n=zt.get(e);n?t(O(n.size)):r("file not found")})))),Gt.registerMethod("wasmClose",(async e=>new Promise((t=>{zt.delete(e),t(O(e))})))),Gt.registerMethod("wasmRead",((e,t,r)=>{const n=zt.get(e);if(!n)throw"file not found";const i=n.slice(t,t+r);return new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{t(r.error)},r.readAsArrayBuffer(i)}))})),Gt.registerMethod("getUpload",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_uploads where part_hash = '${t}' limit 1;\n `)}(await qt(),e),r=x(t[0],"CamelCase");if(0===r.length)throw`no upload with partHash = ${e}`;return O(r[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertUpload",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("local_uploads").setFields(t).toString();return e.exec(r)}(t,A(T(JSON.parse(e))));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateUpload",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.update().table("local_uploads").setFields(t).where(`part_hash = '${t.part_hash}'`).toString();return e.exec(r)}(t,A(T(JSON.parse(e))));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteUpload",(async function(e){try{const t=function(e,t){const r=v.delete().from("local_uploads").where(`part_hash = '${t}'`).toString();return e.exec(r)}(await qt(),e);return O(t)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("setSqlWasmPath",(function(e){At=e})),Gt.registerMethod("initDB",(async function(e,t){try{const r=await qt(`${t}${e}.sqlite`,At),n=[],i=function(e){return e.exec("\n create table if not exists 'local_uploads' (\n 'part_hash' text,\n 'upload_id' varchar(1000),\n 'upload_info' varchar(2000),\n 'expire_time' integer,\n 'create_time' integer,\n PRIMARY KEY ('part_hash')\n )\n ")}(r),o=function(e){return e.exec("\n create table if not exists 'local_stranger'\n (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n PRIMARY KEY ('user_id')\n )\n ")}(r),s=function(e){return e.exec("\n create table if not exists 'local_conversations' (\n 'conversation_id' char(128),\n 'conversation_type' integer,\n 'user_id' char(64),\n 'group_id' char(128),\n 'show_name' varchar(255),\n 'face_url' varchar(255),\n 'recv_msg_opt' integer,\n 'unread_count' integer,\n 'group_at_type' integer,\n 'latest_msg' varchar(1000),\n 'latest_msg_send_time' integer,\n 'draft_text' text,\n 'draft_text_time' integer,\n 'is_pinned' numeric,\n 'burn_duration' integer,\n 'is_private_chat' numeric,\n 'is_not_in_group' numeric,\n 'update_unread_count_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'max_seq' integer,\n 'min_seq' integer,\n 'has_read_seq' integer,\n 'msg_destruct_time' integer default 604800,\n 'is_msg_destruct' numeric default false,\n primary key ('conversation_id')\n )\n ")}(r),a=function(e){return e.exec("\n create table if not exists 'local_users' (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n primary key ('user_id')\n )\n ")}(r),u=function(e){return e.exec("\n create table if not exists 'local_blacks' (\n 'owner_user_id' varchar(64),\n 'block_user_id' varchar(64),\n 'nickname' varchar(255),\n 'face_url' varchar(255),\n 'gender' INTEGER,\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('owner_user_id', 'block_user_id')\n ) \n ")}(r),c=function(e){return e.exec("\n create table if not exists 'local_friends'\n (\n 'owner_user_id' varchar(64),\n 'friend_user_id' varchar(64),\n 'remark' varchar(255),\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'is_pinned' numeric,\n primary key ('owner_user_id', 'friend_user_id')\n ) \n ")}(r),l=function(e){return e.exec("\n create table if not exists 'local_groups'\n (\n 'group_id' varchar(64) PRIMARY KEY,\n 'name' TEXT,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' INTEGER,\n 'status' INTEGER,\n 'creator_user_id' varchar(64),\n 'group_type' INTEGER,\n 'owner_user_id' varchar(64),\n 'member_count' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' INTEGER,\n 'look_member_info' INTEGER,\n 'apply_member_friend' INTEGER,\n 'notification_update_time' INTEGER,\n 'notification_user_id' TEXT\n ) \n ")}(r),f=function(e){return e.exec('\n create table if not exists "local_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),h=function(e){return e.exec("\n create table if not exists 'local_group_members' (\n 'group_id' varchar(64),\n 'user_id' varchar(64),\n 'nickname' varchar(255),\n 'user_group_face_url' varchar(255),\n 'role_level' integer,\n 'join_time' integer,\n 'join_source' integer,\n 'inviter_user_id' text,\n 'mute_end_time' integer DEFAULT 0,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n PRIMARY KEY ('group_id', 'user_id')\n ) \n ")}(r),d=function(e){return e.exec('\n create table if not exists "local_admin_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),p=function(e){return e.exec("\n create table if not exists 'local_friend_requests'\n (\n 'from_user_id' varchar(64),\n 'from_nickname' varchar(255),\n 'from_face_url' varchar(255),\n 'to_user_id' varchar(64),\n 'to_nickname' varchar(255),\n 'to_face_url' varchar(255),\n 'handle_result' INTEGER,\n 'req_msg' varchar(255),\n 'create_time' INTEGER,\n 'handler_user_id' varchar(64),\n 'handle_msg' varchar(255),\n 'handle_time' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('from_user_id', 'to_user_id')\n ); \n ")}(r),_=function(e){return e.exec("\n create table if not exists 'local_super_groups' (\n 'group_id' varchar(64),\n 'name' text,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'status' integer,\n 'creator_user_id' varchar(64),\n 'group_type' integer,\n 'owner_user_id' varchar(64),\n 'member_count' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' integer,\n 'look_member_info' integer,\n 'apply_member_friend' integer,\n 'notification_update_time' integer,\n 'notification_user_id' text,\n primary key ('group_id')\n )\n ")}(r),g=function(e){return e.exec("\n create table if not exists 'temp_cache_local_chat_logs' (\n 'client_msg_id' char(64),\n 'server_msg_id' char(64),\n 'send_id' char(64),\n 'recv_id' char(64),\n 'sender_platform_id' integer,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' integer,\n 'msg_from' integer,\n 'content_type' integer,\n 'content' varchar(1000),\n 'is_read' numeric,\n 'status' integer,\n 'seq' integer DEFAULT 0,\n 'send_time' integer,\n 'create_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n PRIMARY KEY ('client_msg_id')\n );\n ")}(r),m=function(e){return e.exec("\n create table if not exists 'local_notification_seqs'\n (\n 'conversation_id' char(128),\n 'seq' integer,\n PRIMARY KEY ('conversation_id')\n )\n ")}(r),v=function(e){return e.exec("\n create table if not exists 'local_sending_messages'\n (\n conversation_id varchar(128),\n client_msg_id varchar(64),\n ex varchar(1024),\n PRIMARY KEY ('conversation_id', 'client_msg_id')\n );\n ")}(r),y=function(e){return e.exec("\n create table if not exists 'local_conversation_unread_messages' (\n 'conversation_id' char(128),\n 'client_msg_id' char(64),\n 'send_time' integer,\n 'ex' varchar(1024),\n primary key (\n 'conversation_id',\n 'client_msg_id'\n )\n );\n ")}(r);return function(e){try{e.exec("\n ALTER TABLE local_friends ADD COLUMN is_pinned numeric;\n ")}catch(e){}}(r),n.push(i,o,s,a,_,y,u,c,l,h,p,f,d,g,m,v),O(n)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("close",(async function(){try{return await async function(){if(!Mt)return;(await Mt).close(),Mt=void 0}(),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessage",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}' limit 1\n `)}(await qt(),e,t);return 0===r.length?O("",d.ErrorNoRecord,`no message with id ${t}`):O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMultipleMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await qt(),e,JSON.parse(t));return O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getSendingMessageList",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status = 1;\n `)}(await qt(),e);return O(x(t[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateMessageTimeAndStatus",(async function(e,t,r,n,i){try{const o=await qt(),s=function(e,t,r,n,i,o){return e.exec(`\n UPDATE 'chat_logs_${t}' SET server_msg_id = '${n}', send_time = ${i}, status = ${o} WHERE client_msg_id = '${r}' and seq=0;\n `)}(o,e,t,r,n,i);if(0===o.getRowsModified())throw"updateMessageTimeAndStatus no record updated";return O(s)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateMessage",(async function(e,t,r){try{const n=await qt(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,A(T(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return O(i)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateMessageBySeq",(async function(e,t,r){try{const n=await qt(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`seq = '${r}'`).toString();return e.exec(i)}(n,e,t,A(T(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessageBySeq no record updated";return O(i)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateColumnsMessage",(async function(e,t,r){try{const n=await qt(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,A(T(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return O(i)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertMessage",(async function(e,t){try{const r=await qt(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFields(r).toString();return e.exec(n)}(r,e,A(JSON.parse(t)));return O(n)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchInsertMessageList",(async function(e,t){try{const r=await qt(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFieldsRows(r).toString();return e.exec(n)}(r,e,JSON.parse(t).map((e=>A(e))));return O(n)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessageList",(async function(e,t,r,n=!1){try{const i=function(e,t,r,n,i){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${i?">":"<"} ${n} ORDER BY send_time ${i?"ASC":"DESC"} LIMIT ${r}\n `)}(await qt(),e,t,r,n);return O(x(i[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessageListNoTime",(async function(e,t,r=!1){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' ORDER BY send_time ${n?"ASC":"DESC"} LIMIT ${r}\n `)}(await qt(),e,t,r);return O(x(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("messageIfExists",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}';\n `)}(await qt(),e,t);return O(0!==r.length)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchMessageByKeyword",(async function(e,t,r,n,i,o,s,a){try{const u=function(e,t,r,n,i,o,s,a,u){const c=s||(new Date).getTime();let l="";const f=r.map((e=>`${e}`)).join(","),h=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(l+="And ("),t+1>=n.length?l+="content like '%"+n[t]+"%') ":l+="content like '%"+n[t]+"%' "+h})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${c} \n AND status <=3 \n And content_type IN (${f}) \n ${l}\n ORDER BY send_time DESC LIMIT ${u} OFFSET ${a};\n `)}(await qt(),e,JSON.parse(t),JSON.parse(r),n,i,o,s,a);return O(x(u[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchMessageByContentType",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=i||(new Date).getTime();return e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${n} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ORDER BY send_time DESC LIMIT ${s} OFFSET ${o};\n `)}(await qt(),e,JSON.parse(t),r,n,i,o);return O(x(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchMessageByContentTypeAndKeyword",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=s||(new Date).getTime();let c="";const l=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(c+="And ("),t+1>=n.length?c+="content like '%"+n[t]+"%') ":c+="content like '%"+n[t]+"%' "+l})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ${c}\n ORDER BY send_time DESC;\n `)}(await qt(),e,JSON.parse(t),JSON.parse(r),n,i,o);return O(x(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateMsgSenderFaceURLAndSenderNickname",(async function(e,t,r,n){try{return function(e,t,r,n,i){y(e,t),e.exec(`\n UPDATE 'chat_logs_${t}' SET sender_face_url = '${n}', sender_nick_name = '${i}' WHERE send_id = '${r}';\n `)}(await qt(),e,t,r,n),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAlreadyExistSeqList",(async function(e,t){var r;try{const n=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")})\n `)}(await qt(),e,JSON.parse(t));return O(null!==(r=x(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]).map((e=>e.seq)))&&void 0!==r?r:[])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessageBySeq",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq = ${r} limit 1;\n `)}(await qt(),e,t);return 0===r.length?O("",d.ErrorNoRecord,`no message with seq ${t}`):O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessagesByClientMsgIDs",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await qt(),e,JSON.parse(t));return 0===r.length?O("",d.ErrorNoRecord,`no message with clientMsgIDListStr ${t}`):O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMessagesBySeqs",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")}) order by send_time desc;\n `)}(await qt(),e,JSON.parse(t));return O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getConversationNormalMsgSeq",(async function(e){var t,r;try{const n=function(e,t){return y(e,t),e.exec(`\n SELECT seq FROM 'chat_logs_${t}' order by seq desc limit 1;\n `)}(await qt(),e);return O(null!==(r=null===(t=x(n[0],"CamelCase")[0])||void 0===t?void 0:t.seq)&&void 0!==r?r:0)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getConversationPeerNormalMsgSeq",(async function(e,t){var r,n;try{const i=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' where send_id != '${r}' order by seq desc limit 1;\n `)}(await qt(),e,t);return O(null!==(n=null===(r=x(i[0],"CamelCase")[0])||void 0===r?void 0:r.seq)&&void 0!==n?n:0)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE 1=1;\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("markDeleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n UPDATE 'chat_logs_${t}' SET status = 2 WHERE (1=1) and (conversation_id = '${t}')';\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getUnreadMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_id != '${r}' and is_read = 0;\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("markConversationMessageAsReadBySeqs",(async function(e,t,r){try{const n=await qt();return function(e,t,r,n){y(e,t);const i=r.map((e=>`${e}`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE seq IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),O(n.getRowsModified())}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("markConversationMessageAsRead",(async function(e,t,r){try{const n=await qt();return function(e,t,r,n){const i=r.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE client_msg_id IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),O(n.getRowsModified())}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteConversationMsgs",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`)).join(",");return e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE client_msg_id IN (${n});\n `)}(await qt(),e,JSON.parse(t));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("markConversationAllMessageAsRead",(async function(e,t){try{const r=await qt();return function(e,t,r){e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE is_read = 0 and send_id != '${r}';\n `)}(r,e,JSON.parse(t)),O(r.getRowsModified())}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchAllMessageByContentType",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE content_type = ${r};\n `)}(await qt(),e,JSON.parse(t));return O(x(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertSendingMessage",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("local_sending_messages").setFields(t).toString();return e.exec(r)}(t,A(JSON.parse(e)));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteSendingMessage",(async function(e,t){try{const r=function(e,t,r){const n=v.delete().from("local_sending_messages").where(`conversation_id = '${t}'`).where(`client_msg_id = '${r}'`).toString();return e.exec(n)}(await qt(),e,t);return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllSendingMessages",(async function(){try{const e=function(e){const t=v.select().from("local_sending_messages").toString();return e.exec(t)}(await qt());return O(x(e[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time > 0 order by case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) desc;\n ")}(await qt());return O(x(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllConversationListToSync",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations;\n ")}(await qt());return O(x(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getHiddenConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time = 0;\n ")}(await qt());return O(x(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getConversation",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where conversation_id = '${t}' limit 1;\n `)}(await qt(),e);return 0===t.length?O("",d.ErrorNoRecord,`no conversation with id ${e}`):O(x(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getMultipleConversation",(async function(e){try{const t=await qt(),r=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select * from local_conversations where conversation_id in (${r.join(",")});\n `)}(t,JSON.parse(e));return O(x(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateColumnsConversation",(async function(e,t){try{const r=await qt();let n=t;"string"==typeof t&&(n=A(T(JSON.parse(t))));const i=function(e,t,r){const n=v.update().table("local_conversations").setFields(r).where(`conversation_id = '${t}'`).toString();return e.exec(n)}(r,e,n);if(0===r.getRowsModified())throw"updateColumnsConversation no record updated";return O(i)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("decrConversationUnreadCount",(async function(e,t){try{const r=function(e,t,r){e.exec("begin"),e.exec(`\n update local_conversations set \n unread_count=unread_count-${r} \n where conversation_id = '${t}';\n `);const n=e.exec(`select unread_count from local_conversations where conversation_id = '${t}'`);return Number(n[0].values[0])<0&&e.exec(`\n update local_conversations set \n unread_count=0 \n where conversation_id = '${t}';\n `),e.exec("commit")}(await qt(),e,t);return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchInsertConversationList",jt),Gt.registerMethod("getTotalUnreadMsgCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n select sum(unread_count) from local_conversations where recv_msg_opt < 2 and latest_msg_send_time > 0;\n ")}(await qt());return O(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertConversation",(async function(e){return jt(`[${e}]`)})),Gt.registerMethod("getConversationByUserID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where user_id = "${t}" limit 1;\n `)}(await qt(),e);return 0===t.length?O("",d.ErrorNoRecord,`no conversation with userID ${e}`):O(x(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getConversationListSplit",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_conversations\n WHERE latest_msg_send_time > 0\n ORDER BY case\n when is_pinned = 1 then 0\n else 1 end, max(latest_msg_send_time, draft_text_time) DESC\n LIMIT ${r} OFFSET ${t}\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteConversation",(async function(e){try{return function(e,t){e.exec(`\n DELETE\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchUpdateConversationList",(async function(e){try{const t=await qt(),r=(JSON.parse(e)||[]).map((e=>A(e)));return 0===r.length||r.forEach((e=>{!function(e,t){const r=v.update().table("local_conversations").setFields(t).where(`conversation_id = '${t.conversation_id}'`).toString();e.exec(r)}(t,e)})),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("conversationIfExists",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT count(*)\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await qt(),e);return O(0!==t.length)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("resetConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("resetAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\n ')}(await qt()),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("clearConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("clearAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\n ')}(await qt()),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("setConversationDraft",(async function(e,t){try{return function(e,t,r){const n=(new Date).getTime();e.exec(`\n update local_conversations\n set draft_text='${r}',\n draft_text_time=${n},\n latest_msg_send_time=case when latest_msg_send_time = 0 then ${n} else latest_msg_send_time end\n where conversation_id = "${t}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("removeConversationDraft",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set draft_text="${r}",\n draft_text_time=0\n where conversation_id = "${t}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("unPinConversation",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set is_pinned=${r},\n draft_text_time=case when draft_text = "" then 0 else draft_text_time end\n where conversation_id = "${t}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("incrConversationUnreadCount",(async function(e){try{const t=function(e,t){return e.exec(`\n update local_conversations set \n unread_count=unread_count+1 \n where conversation_id = '${t}';\n `)}(await qt(),e);return O(t)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("setMultipleConversationRecvMsgOpt",(async function(e,t){try{return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE local_conversations\n SET recv_msg_opt=${r}\n WHERE conversation_id IN (${n})\n `)}(await qt(),JSON.parse(e),t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllSingleConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where conversation_type = 1;\n ")}(await qt());return O(x(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations;\n ")}(await qt());return O(x(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllConversations",(async function(){try{const e=function(e){return e.exec("\n SELECT * FROM local_conversations\n ")}(await qt());return O(x(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchConversations",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_conversations\n WHERE show_name LIKE '%${t}%'\n ORDER BY latest_msg_send_time DESC\n `)}(await qt(),e);return O(x(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getLoginUser",(async function(e){try{const t=function(e,t){return e.exec(`\n select *, name as nickname from local_users where user_id = '${t}' limit 1;\n `)}(await qt(),e);return 0===t.length?O("",d.ErrorNoRecord,`no login user with id ${e}`):O(x(t[0],"CamelCase",[],{name:"nickname"})[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertLoginUser",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("local_users").setFields(t).toString();return e.exec(r)}(t,A(T(JSON.parse(e),{nickname:"name"})));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateLoginUser",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.update().table("local_users").setFields(t).where(`user_id = '${t.user_id}'`).toString();return e.exec(r)}(t,A(T(JSON.parse(e),{nickname:"name"})));if(0===t.getRowsModified())throw"updateLoginUser no record updated";return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getStrangerInfo",(async function(e){try{const t=await qt();return O(x(E(t,JSON.parse(e))[0],"CamelCase",[],{name:"nickname"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("setStrangerInfo",(function(e){try{return JSON.parse(e).map((e=>A(T(e,{nickname:"name"})))).map((e=>async function(e){try{const t=await qt(),r=E(t,[e.user_id]);return x(r[0]).length?function(e,t){const r=v.update().table("local_stranger").setFields(t).where(`user_id = '${t.user_id}'`).toString();e.exec(r)}(t,e):function(e,t){const r=v.insert().into("local_stranger").setFields(t).toString();e.exec(r)}(t,e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}}(e))),Promise.resolve(O(""))}catch(e){return console.error(e),Promise.resolve(O(void 0,d.ErrorInit,JSON.stringify(e)))}})),Gt.registerMethod("getJoinedSuperGroupList",(async function(){try{const e=await qt();return O(x(b(e)[0]))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getJoinedSuperGroupIDList",(async function(){try{const e=await qt(),t=x(b(e)[0]);return O(t.map((e=>e.groupID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getSuperGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_super_groups where group_id = '${t}' LIMIT 1;\n `)}(await qt(),e);return 0===t.length?O("",d.ErrorNoRecord,`no super group with id ${e}`):O(x(t[0])[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteSuperGroup",(async function(e){try{const t=function(e,t){return e.exec(`\n delete from local_super_groups where group_id = '${t}';\n `)}(await qt(),e);return O(t)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertSuperGroup",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("local_super_groups").setFields(t).toString();return e.exec(r)}(t,A(T(JSON.parse(e),{groupName:"name"})));return O(r)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateSuperGroup",(async function(e,t){try{const r=await qt(),n=function(e,t,r){const n=v.update().table("local_super_groups").setFields(r).where(`group_id = '${t}'`).toString();return e.exec(n)}(r,e,A(T(JSON.parse(t),{groupName:"name"})));if(0===r.getRowsModified())throw"updateSuperGroup no record updated";return O(n)}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteConversationUnreadMessageList",(async function(e,t){try{const r=await qt();!function(e,t,r){e.exec(`\n delete from local_conversation_unread_messages where conversation_id = '${t}' and send_time <= ${r};\n `)}(r,e,t);return O(r.getRowsModified())}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchInsertConversationUnreadMessageList",(async function(e){try{const t=await qt(),r=function(e,t){const r=v.insert().into("local_conversation_unread_messages").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>A(e))));return O(r[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getBlackList",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_blacks\n ")}(await qt());return O(x(e[0],"CamelCase",[],{block_user_id:"userID"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getBlackListUserID",(async function(){try{const e=function(e){return e.exec("\n SELECT block_user_id\n FROM local_blacks\n ")}(await qt());return O(x(e[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getBlackInfoByBlockUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_blacks\n WHERE owner_user_id = "${r}"\n AND block_user_id = "${t}"\n LIMIT 1\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getBlackInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_blacks\n where block_user_id in (${r.join(",")})\n `)}(await qt(),JSON.parse(e));return O(x(t[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertBlack",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_blacks").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{userID:"block_user_id",name:"nickname"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteBlack",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_blacks\n where owner_user_id = "${r}"\n and block_user_id = "${t}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateBlack",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_blacks").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and block_user_id = '${t.block_user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e)))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertFriendRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_friend_requests").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e)))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteFriendRequestBothUserID",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateFriendRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_friend_requests").setFields(t).where(`from_user_id = '${t.from_user_id}' and to_user_id = '${t.to_user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e)))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getRecvFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friend_requests\n where to_user_id = "${t}"\n order by create_time desc\n `)}(await qt(),e);return O(x(t[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getSendFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_friend_requests\n where from_user_id = "${t}"\n order by create_time desc\n `)}(await qt(),e);return O(x(t[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getFriendApplicationByBothID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n limit 1\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getBothFriendReq",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where (from_user_id = "${t}"\n and to_user_id = "${r}")\n or (from_user_id = "${r}"\n and to_user_id = "${t}")\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertGroup",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_groups").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{groupName:"name"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteGroup",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_groups \n WHERE group_id="${t}" \n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateGroup",(async function(e,t){try{const r=await qt();return function(e,t,r){const n=v.update().table("local_groups").setFields(r).where(`group_id = '${t}'`).toString();e.exec(n)}(r,e,A(T(JSON.parse(t),{groupName:"name"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getJoinedGroupList",(async function(){try{const e=await qt();return O(x(w(e)[0],"CamelCase",[],{name:"groupName"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT *\n FROM local_groups\n WHERE group_id = "${t}"\n `)}(await qt(),e);return 0===t.length?O("",d.ErrorNoRecord,`no group with id ${e}`):O(x(t[0],"CamelCase",[],{name:"groupName"})[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllGroupInfoByGroupIDOrGroupName",(async function(e,t,r){try{const n=function(e,t,r,n){let i="";const o=`group_id like "%${t}%"`,s=`name like "%${t}%"`;return r&&(i=o),n&&(i=s),n&&r&&(i=o+" or "+s),e.exec(`\n select *\n from local_groups\n where ${i}\n order by create_time desc\n `)}(await qt(),e,t,r);return O(x(n[0],"CamelCase",[],{name:"groupName"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("subtractMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count-1 where group_id = '${t}'\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("addMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count+1 where group_id = '${t}' \n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getJoinedWorkingGroupIDList",(async function(){try{const e=await qt(),t=x(w(e)[0],"CamelCase"),r=[];return t.forEach((e=>{2===e.groupType&&r.push(e.groupID)})),O(JSON.stringify(r))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getJoinedWorkingGroupList",(async function(){try{const e=w(await qt()),t=x(e[0],"CamelCase",[],{name:"groupName"}).filter((e=>2===e.groupType));return O(JSON.stringify(t))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberAllGroupIDs",(async function(){try{const e=function(e){return e.exec("\n select distinct group_id from local_group_members\n ")}(await qt());return O(x(e[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroups",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select * from local_groups where group_id in (${r});\n `)}(await qt(),JSON.parse(e)),r=x(t[0],"CamelCase",[],{name:"groupName"});return O(JSON.stringify(r))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberInfoByGroupIDUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_group_members\n WHERE group_id = "${t}" \n AND user_id = "${r}" \n LIMIT 1\n `)}(await qt(),e,t);return O(x(r[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllGroupMemberList",(async function(){try{const e=function(e){return e.exec("\n SELECT *\n FROM local_group_members\n ")}(await qt());return O(x(e[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllGroupMemberUserIDList",(async function(){try{const e=function(e){return e.exec("\n SELECT user_id\n FROM local_group_members\n ")}(await qt());return O(x(e[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberCount",(async function(e){var t,r;try{const n=function(e,t){return e.exec(`\n SELECT count(*) FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await qt(),e);return O(null===(r=null===(t=n[0])||void 0===t?void 0:t.values[0])||void 0===r?void 0:r[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupSomeMemberInfo",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_group_members\n where group_id = "${t}"\n and user_id in (${n.join(",")})\n `)}(await qt(),e,JSON.parse(t));return O(x(r[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupAdminID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 3\n `)}(await qt(),e);return O(x(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await qt(),e);return O(x(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberListSplit",(async function(e,t,r,n,i){try{const o=function(e,t,r,n,i,o){let s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `;return 1===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n LIMIT ${i} OFFSET ${n}\n `),2===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),3===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),4===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),5===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),6===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id != "${o}" \n LIMIT ${i} OFFSET ${n}\n `),e.exec(s)}(await qt(),e,t,r,n,i);return O(x(o[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberOwnerAndAdmin",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1 \n ORDER BY role_level DESC\n `)}(await qt(),e);return O(x(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberOwner",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 2\n `)}(await qt(),e);return O(x(t[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberListSplitByJoinTimeFilter",(async function(e,t,r,n=0,i=1e11,o){try{const s=function(e,t,r,n,i=0,o=1e11,s){let a="";a=0===s.length?`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n And user_id NOT IN (${s.map((e=>`'${e}'`)).join(",")})\n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `;return e.exec(a)}(await qt(),e,t,r,n,i,JSON.parse(o));return O(x(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupOwnerAndAdminByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1\n `)}(await qt(),e);return O(x(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getGroupMemberUIDListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await qt(),e);return O(x(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertGroupMember",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_group_members").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{faceURL:"user_group_face_url"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchInsertGroupMember",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_group_members").setFieldsRows(t).toString();e.exec(r)}(t,(JSON.parse(e)||[]).map((e=>A(T(e,{faceURL:"user_group_face_url"}))))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteGroupMember",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}" \n and user_id="${r}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteGroupAllMembers",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}"\n `)}(await qt(),e),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateGroupMember",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_group_members").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e),{faceURL:"user_group_face_url"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateGroupMemberField",(async function(e,t,r){try{const n=await qt();return function(e,t,r,n){const i=v.update().table("local_group_members").setFields(n).where(`group_id = '${t}' and user_id = '${r}'`).toString();e.exec(i)}(n,e,t,A(T(JSON.parse(r),{faceURL:"user_group_face_url"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchGroupMembers",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){let a="";a=r?n&&i?`\n SELECT * FROM local_group_members \n WHERE ( user_id like "%${t}%" or nickname like "%${t}%" ) \n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||i?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`}\n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n&&n?`\n SELECT * FROM local_group_members \n WHERE user_id like "%${t}%" or nickname like "%${t}%" \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||n?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`} \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `;return e.exec(a)}(await qt(),e,t,r,n,i,o);return O(x(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getUserJoinedGroupIDs",(async function(e){try{const t=function(e,t){return e.exec(`\n select group_id from local_group_members where user_id = "${t}";\n `)}(await qt(),e);return O(x(t[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertGroupRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_group_requests").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateGroupRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getSendGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_group_requests\n order by create_time desc\n ")}(await qt());return O(x(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertAdminGroupRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_admin_group_requests").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteAdminGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_admin_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateAdminGroupRequest",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_admin_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAdminGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_admin_group_requests\n order by create_time desc\n ")}(await qt());return O(x(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("insertFriend",(async function(e){try{const t=await qt();return function(e,t){const r=v.insert().into("local_friends").setFields(t).toString();e.exec(r)}(t,A(T(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("deleteFriend",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_friends \n WHERE owner_user_id="${r}" \n and friend_user_id="${t}"\n `)}(await qt(),e,t),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateFriend",(async function(e){try{const t=await qt();return function(e,t){const r=v.update().table("local_friends").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and friend_user_id = '${t.friend_user_id}'`).toString();e.exec(r)}(t,A(T(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getAllFriendList",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${t}"\n `)}(await qt(),e);return O(x(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("searchFriendList",(async function(e,t,r,n){try{const i=function(e,t,r,n,i){let o="";const s=`name like "%${t}%"`,a=`remark like "%${t}%"`;return r&&(o=`friend_user_id like "%${t}%"`),n&&(o=o?o+" or "+s:s),i&&(o=o?o+" or "+a:a),e.exec(`\n select *\n from local_friends\n where ${o}\n order by create_time desc\n `)}(await qt(),e,t,r,n);return O(x(i[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getFriendInfoByFriendUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${r}"\n and friend_user_id = "${t}"\n limit 1\n `)}(await qt(),e,t);return 0===r.length?O("",d.ErrorNoRecord,`no friend with id ${e}`):O(x(r[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"})[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getFriendInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select *\n from local_friends\n where friend_user_id in (${r})\n `)}(await qt(),JSON.parse(e));return O(x(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("getPageFriendList",(async function(e,t,r){try{const n=function(e,t,r,n){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${n}"\n order by name\n limit ${r} offset ${t}\n `)}(await qt(),e,t,r);return O(x(n[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("updateColumnsFriend",(async function(e,t){try{const r=await qt(),n=A(T(JSON.parse(t),{userID:"friend_user_id",nickname:"name"}));return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(","),i=v.update().table("local_friends").setFields(r).where(`friend_user_id IN (${n})`).toString();e.exec(i)}(r,JSON.parse(e),n),O("")}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("batchInsertTempCacheMessageList",Jt),Gt.registerMethod("InsertTempCacheMessage",(async function(e){return Jt(`[${e}]`)})),Gt.registerMethod("getNotificationAllSeqs",(async function(){try{const e=function(e){return e.exec("SELECT * from local_notification_seqs where 1 = 1;")}(await qt());return O(x(e[0],"CamelCase"))}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("setNotificationSeq",(async function(e,t){try{const r=await qt();let n=function(e,t,r){return e.exec(`UPDATE local_notification_seqs set seq = ${r} where conversation_id = "${t}"`)}(r,e,t);return 0===r.getRowsModified()&&(n=function(e,t,r){return e.exec(`INSERT INTO local_notification_seqs (conversation_id, seq) VALUES ("${t}", ${r});`)}(r,e,t)),O(n[0])}catch(e){return console.error(e),O(void 0,d.ErrorInit,JSON.stringify(e))}})),Gt.registerMethod("exec",(async e=>{const t=await qt();try{const r=t.exec(e);console.info(`sql debug with exec sql = ${e.trim()} , return `,r)}catch(t){console.info(`sql debug with exec sql = ${e} , return `,t)}})),Gt.registerMethod("getRowsModified",(async()=>{const e=await qt();try{const t=e.getRowsModified();console.info("sql debug with getRowsModified return ",t)}catch(e){console.info("sql debug with getRowsModified return ",e)}})),Gt.registerMethod("exportDB",(async()=>{const e=await qt();try{const t=e.export(),r=new Blob([t]);return URL.createObjectURL(r)}catch(e){console.info("sql export error, return ",e)}}))}();