-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsendbird.min.js
1 lines (1 loc) · 868 KB
/
sendbird.min.js
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_(r.key),r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof g?t:g,i=Object.create(s.prototype),o=new M(r||[]);return a(i,"_invoke",{value:T(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,i,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(U([])));C&&C!==n&&r.call(C,i)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function T(t,n,r){var a=f;return function(s,i){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===s)throw i;return{value:e,done:!0}}for(r.method=s,r.arg=i;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var s=h(a,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,m;var i=s.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function U(t){if(t||""===t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,s=function n(){for(;++a<t.length;)if(r.call(t,a))return n.value=t[a],n.done=!1,n;return n.value=e,n.done=!0,n};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=E,a(w,"constructor",{value:E,configurable:!0}),a(E,"constructor",{value:y,configurable:!0}),y.displayName=c(E,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,c(e,u,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},x(S.prototype),c(S.prototype,o,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,a,s){void 0===s&&(s=Promise);var i=new S(l(e,n,r,a),s);return t.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},x(w),c(w,u,"Generator"),c(w,i,(function(){return this})),c(w,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=U,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function a(r,a){return o.type="throw",o.arg=t,n.next=r,a&&(n.method="next",n.arg=e),!!a}for(var s=this.tryEntries.length-1;s>=0;--s){var i=this.tryEntries[s],o=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var s=a;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var i=s?s.completion:{};return i.type=e,i.arg=t,s?(this.method="next",this.next=s.finallyLoc,m):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:U(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,s,i,o=[],u=!0,c=!1;try{if(s=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=s.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof a?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.17.2",C=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}])}();e.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N,A=function(e){return!(e instanceof M&&!e.shouldThrowOutside)},M=function(t){function a(e){var t,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=i,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),s(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),U=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN],D=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&j(t))||("string"!=typeof e?"object"===m(e)?L(e,t):P(e,t):m(t)===e)},L=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&j(t))||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&j(t))||Array.isArray(t)&&t.every((function(t){return R(e,t)}))},q=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&j(e))||"number"==typeof e&&13===e.toString().length},H=function(e){return e>0&&O.indexOf(e)>=0},G=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&j(e))return!0;var t="object"===m(e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},j=function(e){return null==e},V=function(){return s((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){R("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){R("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){R("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){R("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){R("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),z={encrypt:function(e){return e},decrypt:function(e){return e}},B=function(){return s((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l,h,f;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return s=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,s&&!(s.version<this._version)){r.next=33;break}r.t3=this._version,r.next=9===r.t3?22:27;break;case 22:if(u=o.find((function(e){return e.includes("groupchannel/sync.meta")})),!u){r.next=26;break}return r.next=26,this._store.remove(u);case 26:return r.abrupt("break",29);case 27:return r.next=29,this._resetPreferenceData(o);case 29:return r.next=31,this._updatePreferenceVersionInfo(a);case 31:r.next=52;break;case 33:c=i(o),r.prev=34,c.s();case 36:if((l=c.n()).done){r.next=44;break}return h=l.value,r.next=40,this._store.get(h);case 40:(f=r.sent)&&this._preference.set(h,f);case 42:r.next=36;break;case 44:r.next=49;break;case 46:r.prev=46,r.t4=r.catch(34),c.e(r.t4);case 49:return r.prev=49,c.f(),r.finish(49);case 52:case"end":return r.stop()}}),r,this,[[34,46,49,52]])})))}},{key:"_updatePreferenceVersionInfo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.set({key:e,value:{version:this._version}});case 2:case"end":return t.stop()}}),t,this)})))}},{key:"_resetPreferenceData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._preference=new Map,t.next=3,this._store.removeMany(e);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._preference.get(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=!this._preference.has(e),n.next=3,this._store.set({key:e,value:t});case 3:if(this._preference.set(e,t),!r){n.next=7;break}return n.next=7,this._savePreferenceKeys();case 7:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.remove(e);case 2:return this._preference.delete(e),t.next=5,this._savePreferenceKeys();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.removeMany(v(this._preference.keys()));case 2:return this._preference.clear(),e.next=5,this._savePreferenceKeys();case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Q=function(){return s((function e(t){var n=t.encryption,a=t.store,s=t.localCacheEnabled,i=t.localCacheConfig;r(this,e),this.store=a,this.preference=new B({store:a}),this.encryption=null!=n?n:z,this.localCacheEnabled=s,this.localCacheConfig=i}),[{key:"replaceStore",value:function(e){this.store=e,this.preference=new B({store:e})}}])}();e.PushTokenRegistrationState=void 0,(w=e.PushTokenRegistrationState||(e.PushTokenRegistrationState={})).SUCCESS="success",w.PENDING="pending",w.ERROR="error",e.PushTriggerOption=void 0,(x=e.PushTriggerOption||(e.PushTriggerOption={})).DEFAULT="default",x.ALL="all",x.MENTION_ONLY="mention_only",x.OFF="off",e.PushTokenType=void 0,(S=e.PushTokenType||(e.PushTokenType={})).FCM="gcm",S.APNS="apns",S.UNKNOWN="unknown",function(e){e.SESSION_TOKEN="session_token",e.ACCESS_TOKEN="access_token"}(T||(T={})),e.PushTemplate=void 0,(I=e.PushTemplate||(e.PushTemplate={})).ALTERNATIVE="alternative",I.DEFAULT="default",e.CachedDataClearOrder=void 0,(N=e.CachedDataClearOrder||(e.CachedDataClearOrder={})).CUSTOM="custom",N.MESSAGE_COLLECTION_ACCESSED_AT="messagecollection_accessed_at";var K,W=function(){return s((function e(t){var n=t.channel,a=t.cachedMessageCount;r(this,e),this._cachedMessageCount=0,this._channel=n,this._cachedMessageCount=a}),[{key:"channel",get:function(){return this._channel}},{key:"cachedMessageCount",get:function(){return this._cachedMessageCount}}])}(),Y=function(){return s((function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,s=void 0===a?256:a,i=n.clearOrder,o=void 0===i?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:i,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(s,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(K||(K={}));var Z,X,J,$,ee,te,ne,re,ae,se,ie,oe,ue,ce=function(){return s((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(K.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),le=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},de=function(){return s((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=le()}),[{key:"_register",value:function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){var e=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),he=function(){return s((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new de({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new de({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=i(n.keys());try{for(s.s();!(r=s.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),fe=function(){return s((function e(){r(this,e),this._dispatcher=new he}),[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}])}(),pe=s((function e(){r(this,e)})),ve=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},_e=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n<t.length;n++)t[n]=_e(t[n]);return t}return Object.keys(e).forEach((function(t){null===e[t]&&delete e[t]})),e}return e}};e.ChannelType=void 0,(Z=e.ChannelType||(e.ChannelType={})).BASE="base",Z.GROUP="group",Z.OPEN="open",Z.FEED="feed",e.Role=void 0,(X=e.Role||(e.Role={})).OPERATOR="operator",X.NONE="none",e.MutedState=void 0,(J=e.MutedState||(e.MutedState={})).MUTED="muted",J.UNMUTED="unmuted",e.MessageType=void 0,($=e.MessageType||(e.MessageType={})).BASE="base",$.USER="user",$.FILE="file",$.ADMIN="admin",e.MessageTypeFilter=void 0,(ee=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",ee.USER="MESG",ee.FILE="FILE",ee.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(te||(te={})),e.MentionType=void 0,(ne=e.MentionType||(e.MentionType={})).USERS="users",ne.CHANNEL="channel",e.ReplyType=void 0,(re=e.ReplyType||(e.ReplyType={})).ALL="all",re.NONE="none",re.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(ae=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",ae.SUPPRESS="suppress",e.SendingStatus=void 0,(se=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",se.SCHEDULED="scheduled",se.SUCCEEDED="succeeded",se.FAILED="failed",se.CANCELED="canceled",e.MessageReviewStatus=void 0,(ie=e.MessageReviewStatus||(e.MessageReviewStatus={})).INREVIEW="InReview",ie.APPROVED="Approved",function(e){e.HIGH="high",e.NORMAL="normal",e.LOW="low"}(oe||(oe={})),function(e){e.CREATED_AT="created_at",e.UPDATED_AT="updated_at"}(ue||(ue={}));var me,ge="v3",ye="/".concat(ge,"/users"),Ee="/".concat(ge,"/sdk/users"),ke="/".concat(ge,"/storage/file"),be="/".concat(ge,"/group_channels"),Ce="/".concat(ge,"/sdk/group_channels"),we="/".concat(ge,"/open_channels"),xe="/".concat(ge,"/sdk/open_channels"),Se="/".concat(ge,"/search"),Te="/".concat(ge,"/report"),Ie="/".concat(ge,"/emojis"),Ne="/".concat(ge,"/emoji_categories"),Ae="/".concat(ge,"/polls"),Me="/".concat(ge,"/scheduled_messages"),Ue="/".concat(ge,"/sdk/ui_kit/configuration"),Oe="/".concat(ge,"/sdk/statistics"),De="/".concat(ge,"/sdk/statistics/notification_statistics"),Re="/".concat(ge,"/message_templates"),Le="/".concat(ge,"/sdk/push_delivery"),Pe="/".concat(ge,"/forms"),Fe="/".concat(ge,"/report_category"),qe="/".concat(ge,"/sdk/applications/settings"),He=function(t){switch(t){case e.ChannelType.FEED:case e.ChannelType.GROUP:return be;case e.ChannelType.OPEN:return we;default:return null}},Ge=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Te,"/group_channels");case e.ChannelType.OPEN:return"".concat(Te,"/open_channels");default:return null}},je=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=i(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ve=function(e,t,n){var r,a,s,i,o=je(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=je(null!==(s=t.mentionType)&&void 0!==s?s:null,null!==(i=t.mentionedUserIds)&&void 0!==i?i:[],n);return!o&&u?1:o&&!u?-1:0},ze=function(e,t,n){var r,a=t||new FormData;for(var s in e)if(e.hasOwnProperty(s)){var i=e[s],o=n?"".concat(n,"[").concat(s,"]"):s;G(i)?a.append(o,i,null!==(r=i.name)&&void 0!==r?r:"filename"):"object"!==m(i)||null===i||Array.isArray(i)||i instanceof Blob?a.append(o,String(i)):a=ze(i,a,o)}return a};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(me||(me={}));var Be,Qe=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=le(),e}return c(t,e),s(t,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===m(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ve(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ve(this.params);return Object.keys(e).some((function(t){return G(e[t])}))?ze(e):JSON.stringify(e)}},{key:"hasSessionKey",get:function(){return void 0!==this.headers["Session-Key"]}}])}(pe),Ke=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t))._iid=e,s._payload=a,s}return c(t,e),s(t,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}])}(pe),We=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e,a}return c(t,e),s(t)}(pe),Ye=function(t){function a(t){var s,i=t.expires_in,o=t.reason,u=void 0===o?e.SendbirdErrorCode.SESSION_KEY_EXPIRED:o,c=t.message,l=void 0===c?"":c;switch(r(this,a),(s=n(this,a)).expiresIn=null!=i?i:0,u){case e.SendbirdErrorCode.SESSION_KEY_EXPIRED:case e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED:case e.SendbirdErrorCode.SESSION_REVOKED:case e.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:s.error=new M({code:u,message:l})}return s}return c(a,t),s(a,[{key:"invalidateSessionToken",get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}])}(pe),Ze=function(e){function t(e,a,s){var i,o,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(i=n(this,t))._iid=e,i.code=a,i.payload=s,i.requestId=null!==(o=s.req_id)&&void 0!==o?o:u,i}return c(t,e),s(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(pe),Xe=function(e){function t(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:le(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),s(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(pe),Je=function(e){function t(e){var a,s=e.userId,i=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/session_key"),a.method=me.POST,a.params=ve({token:i,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),s(t)}(Qe),$e=function(e){function t(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:ve({token:a,expiring_session:i?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),s(t)}(Xe),et=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.key,o=a.expires_at,u=a.services;return s.key=i,s.expiresAt=o,s.services=u,s}return c(t,e),s(t)}(Ke),tt=function(e){function t(e,a,s){var i,o;return r(this,t),(i=n(this,t,[e,"LOGI",s])).error=null,i.newKey=null,i.newKey=null!==(o=s.new_key)&&void 0!==o?o:null,i.error=s.error?new M(s):null,i}return c(t,e),s(t)}(Ze),nt=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),s(t)}(pe),rt=function(e){function t(e){var a,s=e.request,i=e.deferred,o=e.error,u=void 0===o?M.requestFailed:o;return r(this,t),(a=n(this,t)).request=s,a.deferred=i,a.error=u,a}return c(t,e),s(t)}(pe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Be||(Be={}));var at,st,it,ot=function(){return s((function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}),null,[{key:"payloadify",value:function(e){return ve({stat_type:e.type,ts:e.createdAt,data:ve(e.data)})}}])}(),ut=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ct=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(at=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",at.CALLS="calls",at.DESK="desk",at.LIVE="live",at.UIKIT_CHAT="uikit-chat",at.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(st=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",st.IOS="ios",st.JS="js",st.UNREAL="unreal",st.UNITY="unity",st.REACT_NATIVE="react-native",st.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(it=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",it.IOS="ios",it.WEB="web",it.MOBILE_WEB="mobile_web",it.WINDOWS="windows";var lt=s((function e(){r(this,e)}));lt.sendbirdSdkUserAgentWithExtension=function(t){var n=ut()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:ct()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,s=t.deviceOS,i=t.customData,o=void 0===i?{}:i;s.version&&(r.os_version=s.version),s.platform&&(r.device_os_platform=s.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},lt.userAgentWithExtension=function(e){var t=ut()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):ct()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var dt=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ht=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),s(t)}(pe),ft=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(He(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=ve({mesg_token:e.messageToken})),a}return c(t,e),s(t)}(Qe),pt=function(e){function t(e,a,s){var i,o;return r(this,t),(i=n(this,t,[e,"DELM",s])).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i.silent=s.silent,i.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,i.senderId=null!==(o=s.sender_id)&&void 0!==o?o:void 0,i}return c(t,e),s(t)}(Ze),vt=function(){return s((function e(t,n){var a=this,s=n.session,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._session=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof We&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,s=n.sendbirdRuntimeEnvironment,i=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":lt.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":lt.sendbirdSdkUserAgentWithExtension(s)});return t||(i["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(i["Session-Key"]=this._session.sessionKey),i["App-Id"]=r,this._session&&this._session.authToken&&(i["Access-Token"]=this._session.authToken),i}},{key:"_statLogApiResult",value:function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new nt(new ot({type:Be.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"_isBodyRequired",value:function(e){var t=e.method;return t!==me.GET&&(t!==me.DELETE||e instanceof ft)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,s=t.uploadProgressHandler,i=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(i?"":t.query),c=i?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!s){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return zm}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:s});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof M&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32:if(this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return Bm}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return mg}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new Ke(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new M(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Ye({reason:E.code,message:E.message})),t instanceof Je){n.next=59;break}return k=new dt,this._dispatcher.dispatch(new rt({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Ye({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw M.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof M)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw M.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),M.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ht({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=i(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear(),this._dispatcher.dispatch(new ht({}))}}])}(),_t=function(){};function mt(e){let t=e.length;for(;--t>=0;)e[t]=0}const gt=256,yt=286,Et=30,kt=15,bt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ct=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),wt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),xt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),St=new Array(576);mt(St);const Tt=new Array(60);mt(Tt);const It=new Array(512);mt(It);const Nt=new Array(256);mt(Nt);const At=new Array(29);mt(At);const Mt=new Array(Et);function Ut(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let Ot,Dt,Rt;function Lt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}mt(Mt);const Pt=e=>e<256?It[e]:It[256+(e>>>7)],Ft=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},qt=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,Ft(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},Ht=(e,t,n)=>{qt(e,n[2*t],n[2*t+1])},Gt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},jt=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=kt;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Gt(r[t]++,t))}},Vt=e=>{let t;for(t=0;t<yt;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Et;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},zt=e=>{e.bi_valid>8?Ft(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Bt=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]<e[s]||e[a]===e[s]&&r[t]<=r[n]},Qt=(e,t,n)=>{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a<e.heap_len&&Bt(t,e.heap[a+1],e.heap[a],e.depth)&&a++,!Bt(t,r,e.heap[a],e.depth));)e.heap[n]=e.heap[a],n=a,a<<=1;e.heap[n]=r},Kt=(e,t,n)=>{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Ht(e,a,t):(s=Nt[a],Ht(e,s+gt+1,t),i=bt[s],0!==i&&(a-=At[s],qt(e,a,i)),r--,s=Pt(r),Ht(e,s,n),i=Ct[s],0!==i&&(r-=Mt[s],qt(e,r,i)))}while(o<e.sym_next);Ht(e,256,t)},Wt=(e,t)=>{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i<s;i++)0!==n[2*i]?(e.heap[++e.heap_len]=c=i,e.depth[i]=0):n[2*i+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=c<2?++c:0,n[2*u]=1,e.depth[u]=0,e.opt_len--,a&&(e.static_len-=r[2*u+1]);for(t.max_code=c,i=e.heap_len>>1;i>=1;i--)Qt(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Qt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,Qt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=kt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(h+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),jt(n,c,e.bl_count)},Yt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o<u&&a===i||(o<c?e.bl_tree[2*a]+=o:0!==a?(a!==s&&e.bl_tree[2*a]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,s=a,0===i?(u=138,c=3):a===i?(u=6,c=3):(u=7,c=4))},Zt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o<u&&a===i)){if(o<c)do{Ht(e,a,e.bl_tree)}while(0!=--o);else 0!==a?(a!==s&&(Ht(e,a,e.bl_tree),o--),Ht(e,16,e.bl_tree),qt(e,o-3,2)):o<=10?(Ht(e,17,e.bl_tree),qt(e,o-3,3)):(Ht(e,18,e.bl_tree),qt(e,o-11,7));o=0,s=a,0===i?(u=138,c=3):a===i?(u=6,c=3):(u=7,c=4)}};let Xt=!1;const Jt=(e,t,n,r)=>{qt(e,0+(r?1:0),3),zt(e),Ft(e,n),Ft(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var $t=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<gt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),Wt(e,e.l_desc),Wt(e,e.d_desc),i=(e=>{let t;for(Yt(e,e.dyn_ltree,e.l_desc.max_code),Yt(e,e.dyn_dtree,e.d_desc.max_code),Wt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*xt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Jt(e,t,n,r):4===e.strategy||s===a?(qt(e,2+(r?1:0),3),Kt(e,St,Tt)):(qt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(qt(e,t-257,5),qt(e,n-1,5),qt(e,r-4,4),a=0;a<r;a++)qt(e,e.bl_tree[2*xt[a]+1],3);Zt(e,e.dyn_ltree,t-1),Zt(e,e.dyn_dtree,n-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,i+1),Kt(e,e.dyn_ltree,e.dyn_dtree)),Vt(e),r&&zt(e)},en={_tr_init:e=>{Xt||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(At[r]=n,e=0;e<1<<bt[r];e++)Nt[n++]=r;for(Nt[n-1]=r,a=0,r=0;r<16;r++)for(Mt[r]=a,e=0;e<1<<Ct[r];e++)It[a++]=r;for(a>>=7;r<Et;r++)for(Mt[r]=a<<7,e=0;e<1<<Ct[r]-7;e++)It[256+a++]=r;for(t=0;t<=kt;t++)s[t]=0;for(e=0;e<=143;)St[2*e+1]=8,e++,s[8]++;for(;e<=255;)St[2*e+1]=9,e++,s[9]++;for(;e<=279;)St[2*e+1]=7,e++,s[7]++;for(;e<=287;)St[2*e+1]=8,e++,s[8]++;for(jt(St,287,s),e=0;e<Et;e++)Tt[2*e+1]=5,Tt[2*e]=Gt(e,5);Ot=new Ut(St,bt,257,yt,kt),Dt=new Ut(Tt,Ct,0,Et,kt),Rt=new Ut(new Array(0),wt,0,19,7)})(),Xt=!0),e.l_desc=new Lt(e.dyn_ltree,Ot),e.d_desc=new Lt(e.dyn_dtree,Dt),e.bl_desc=new Lt(e.bl_tree,Rt),e.bi_buf=0,e.bi_valid=0,Vt(e)},_tr_stored_block:Jt,_tr_flush_block:$t,_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Nt[n]+gt+1)]++,e.dyn_dtree[2*Pt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{qt(e,2,3),Ht(e,256,St),(e=>{16===e.bi_valid?(Ft(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var tn=(e,t,n,r)=>{let a=65535&e,s=e>>>16&65535,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16};const nn=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var rn=(e,t,n,r)=>{const a=nn,s=r+n;e^=-1;for(let n=r;n<s;n++)e=e>>>8^a[255&(e^t[n])];return~e},an={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},sn={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:on,_tr_stored_block:un,_tr_flush_block:cn,_tr_tally:ln,_tr_align:dn}=en,{Z_NO_FLUSH:hn,Z_PARTIAL_FLUSH:fn,Z_FULL_FLUSH:pn,Z_FINISH:vn,Z_BLOCK:_n,Z_OK:mn,Z_STREAM_END:gn,Z_STREAM_ERROR:yn,Z_DATA_ERROR:En,Z_BUF_ERROR:kn,Z_DEFAULT_COMPRESSION:bn,Z_FILTERED:Cn,Z_HUFFMAN_ONLY:wn,Z_RLE:xn,Z_FIXED:Sn,Z_DEFAULT_STRATEGY:Tn,Z_UNKNOWN:In,Z_DEFLATED:Nn}=sn,An=258,Mn=262,Un=42,On=113,Dn=666,Rn=(e,t)=>(e.msg=an[t],t),Ln=e=>2*e-(e>4?9:0),Pn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Fn=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let qn=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask;const Hn=e=>{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},Gn=(e,t)=>{cn(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Hn(e.strm)},jn=(e,t)=>{e.pending_buf[e.pending++]=t},Vn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},zn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=tn(e.adler,t,a,n):2===e.state.wrap&&(e.adler=rn(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Bn=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-Mn?e.strstart-(e.w_size-Mn):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+An;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<h);if(r=An-(h-s),s=h-An,r>i){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=d[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},Qn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Mn)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Fn(e),r+=t),0===e.strm.avail_in)break;if(n=zn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=qn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=qn(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Mn&&0!==e.strm.avail_in)},Kn=(e,t)=>{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a)break;if(a=e.strm.avail_out-a,r=e.strstart-e.block_start,n>r+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n<s&&(0===n&&t!==vn||t===hn||n!==r+e.strm.avail_in))break;i=t===vn&&n===r+e.strm.avail_in?1:0,un(e,0,0,i),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Hn(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(zn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),i?4:t!==hn&&t!==vn&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(zn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===vn)&&t!==hn&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===vn&&0===e.strm.avail_in&&n===r?1:0,un(e,e.block_start,n,i),e.block_start+=n,Hn(e.strm)),i?3:1)},Wn=(e,t)=>{let n,r;for(;;){if(e.lookahead<Mn){if(Qn(e),e.lookahead<Mn&&t===hn)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=qn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Mn&&(e.match_length=Bn(e,n)),e.match_length>=3)if(r=ln(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=qn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=qn(e,e.ins_h,e.window[e.strstart+1]);else r=ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===vn?(Gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Gn(e,!1),0===e.strm.avail_out)?1:2},Yn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead<Mn){if(Qn(e),e.lookahead<Mn&&t===hn)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=qn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-Mn&&(e.match_length=Bn(e,n),e.match_length<=5&&(e.strategy===Cn||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=ln(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=qn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(Gn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=ln(e,0,e.window[e.strstart-1]),r&&Gn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ln(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===vn?(Gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Gn(e,!1),0===e.strm.avail_out)?1:2};function Zn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Xn=[new Zn(0,0,0,0,Kn),new Zn(4,4,8,4,Wn),new Zn(4,5,16,8,Wn),new Zn(4,6,32,32,Wn),new Zn(4,4,16,16,Yn),new Zn(8,16,32,32,Yn),new Zn(8,16,128,128,Yn),new Zn(8,32,128,256,Yn),new Zn(32,128,258,1024,Yn),new Zn(32,258,258,4096,Yn)];function Jn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Nn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Pn(this.dyn_ltree),Pn(this.dyn_dtree),Pn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Pn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Pn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const $n=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Un&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==On&&t.status!==Dn?1:0},er=e=>{if($n(e))return Rn(e,yn);e.total_in=e.total_out=0,e.data_type=In;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Un:On,e.adler=2===t.wrap?0:1,t.last_flush=-2,on(t),mn},tr=e=>{const t=er(e);var n;return t===mn&&((n=e.state).window_size=2*n.w_size,Pn(n.head),n.max_lazy_match=Xn[n.level].max_lazy,n.good_match=Xn[n.level].good_length,n.nice_match=Xn[n.level].nice_length,n.max_chain_length=Xn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},nr=(e,t,n,r,a,s)=>{if(!e)return yn;let i=1;if(t===bn&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==Nn||r<8||r>15||t<0||t>9||s<0||s>Sn||8===r&&1!==i)return Rn(e,yn);8===r&&(r=9);const o=new Jn;return e.state=o,o.strm=e,o.status=Un,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=s,o.method=n,tr(e)};var rr={deflateInit:(e,t)=>nr(e,t,Nn,15,8,Tn),deflateInit2:nr,deflateReset:tr,deflateResetKeep:er,deflateSetHeader:(e,t)=>$n(e)||2!==e.state.wrap?yn:(e.state.gzhead=t,mn),deflate:(e,t)=>{if($n(e)||t>_n||t<0)return e?Rn(e,yn):yn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Dn&&t!==vn)return Rn(e,0===e.avail_out?kn:yn);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Hn(e),0===e.avail_out)return n.last_flush=-1,mn}else if(0===e.avail_in&&Ln(t)<=Ln(r)&&t!==vn)return Rn(e,kn);if(n.status===Dn&&0!==e.avail_in)return Rn(e,kn);if(n.status===Un&&0===n.wrap&&(n.status=On),n.status===Un){let t=Nn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=wn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Vn(n,t),0!==n.strstart&&(Vn(n,e.adler>>>16),Vn(n,65535&e.adler)),e.adler=1,n.status=On,Hn(e),0!==n.pending)return n.last_flush=-1,mn}if(57===n.status)if(e.adler=0,jn(n,31),jn(n,139),jn(n,8),n.gzhead)jn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),jn(n,255&n.gzhead.time),jn(n,n.gzhead.time>>8&255),jn(n,n.gzhead.time>>16&255),jn(n,n.gzhead.time>>24&255),jn(n,9===n.level?2:n.strategy>=wn||n.level<2?4:0),jn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(jn(n,255&n.gzhead.extra.length),jn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=rn(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(jn(n,0),jn(n,0),jn(n,0),jn(n,0),jn(n,0),jn(n,9===n.level?2:n.strategy>=wn||n.level<2?4:0),jn(n,3),n.status=On,Hn(e),0!==n.pending)return n.last_flush=-1,mn;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=rn(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Hn(e),0!==n.pending)return n.last_flush=-1,mn;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=rn(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=rn(e.adler,n.pending_buf,n.pending-r,r)),Hn(e),0!==n.pending)return n.last_flush=-1,mn;r=0}t=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,jn(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>r&&(e.adler=rn(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=rn(e.adler,n.pending_buf,n.pending-r,r)),Hn(e),0!==n.pending)return n.last_flush=-1,mn;r=0}t=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,jn(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>r&&(e.adler=rn(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Hn(e),0!==n.pending))return n.last_flush=-1,mn;jn(n,255&e.adler),jn(n,e.adler>>8&255),e.adler=0}if(n.status=On,Hn(e),0!==n.pending)return n.last_flush=-1,mn}if(0!==e.avail_in||0!==n.lookahead||t!==hn&&n.status!==Dn){let r=0===n.level?Kn(n,t):n.strategy===wn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Qn(e),0===e.lookahead)){if(t===hn)return 1;break}if(e.match_length=0,n=ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vn?(Gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Gn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===xn?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=An){if(Qn(e),e.lookahead<=An&&t===hn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+An;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&a<s);e.match_length=An-(s-a),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=ln(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vn?(Gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Gn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Xn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Dn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),mn;if(2===r&&(t===fn?dn(n):t!==_n&&(un(n,0,0,!1),t===pn&&(Pn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Hn(e),0===e.avail_out))return n.last_flush=-1,mn}return t!==vn?mn:n.wrap<=0?gn:(2===n.wrap?(jn(n,255&e.adler),jn(n,e.adler>>8&255),jn(n,e.adler>>16&255),jn(n,e.adler>>24&255),jn(n,255&e.total_in),jn(n,e.total_in>>8&255),jn(n,e.total_in>>16&255),jn(n,e.total_in>>24&255)):(Vn(n,e.adler>>>16),Vn(n,65535&e.adler)),Hn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?mn:gn)},deflateEnd:e=>{if($n(e))return yn;const t=e.state.status;return e.state=null,t===On?Rn(e,En):mn},deflateSetDictionary:(e,t)=>{let n=t.length;if($n(e))return yn;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Un||r.lookahead)return yn;if(1===a&&(e.adler=tn(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Pn(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Qn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=qn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Qn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,mn},deflateInfo:"pako deflate (from Nodeca project)"};const ar=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var sr=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)ar(n,t)&&(e[t]=n[t])}}return e},ir=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;const n=new Uint8Array(t);for(let t=0,r=0,a=e.length;t<a;t++){let a=e[t];n.set(a,r),r+=a.length}return n};let or=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){or=!1}const ur=new Uint8Array(256);for(let e=0;e<256;e++)ur[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ur[254]=ur[254]=1;var cr=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a<i;a++)n=e.charCodeAt(a),55296==(64512&n)&&a+1<i&&(r=e.charCodeAt(a+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),a++)),o+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(o),s=0,a=0;s<o;a++)n=e.charCodeAt(a),55296==(64512&n)&&a+1<i&&(r=e.charCodeAt(a+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),a++)),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},lr=(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r<n;){let t=e[r++];if(t<128){s[a++]=t;continue}let i=ur[t];if(i>4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r<n;)t=t<<6|63&e[r++],i--;i>1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&or)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n})(s,a)},dr=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+ur[e[n]]>t?n:t};var hr=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const fr=Object.prototype.toString,{Z_NO_FLUSH:pr,Z_SYNC_FLUSH:vr,Z_FULL_FLUSH:_r,Z_FINISH:mr,Z_OK:gr,Z_STREAM_END:yr,Z_DEFAULT_COMPRESSION:Er,Z_DEFAULT_STRATEGY:kr,Z_DEFLATED:br}=sn;function Cr(e){this.options=sr({level:Er,method:br,chunkSize:16384,windowBits:15,memLevel:8,strategy:kr},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new hr,this.strm.avail_out=0;let n=rr.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==gr)throw new Error(an[n]);if(t.header&&rr.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?cr(t.dictionary):"[object ArrayBuffer]"===fr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=rr.deflateSetDictionary(this.strm,e),n!==gr)throw new Error(an[n]);this._dict_set=!0}}function wr(e,t){const n=new Cr(t);if(n.push(e,!0),n.err)throw n.msg||an[n.err];return n.result}Cr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?mr:pr,"string"==typeof e?n.input=cr(e):"[object ArrayBuffer]"===fr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===vr||s===_r)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=rr.deflate(n,s),a===yr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=rr.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===gr;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Cr.prototype.onData=function(e){this.chunks.push(e)},Cr.prototype.onEnd=function(e){e===gr&&(this.result=ir(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var xr={Deflate:Cr,deflate:wr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,wr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,wr(e,t)},constants:sn};const Sr=16209;var Tr=function(e,t){let n,r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<<S.lenbits)-1,m=(1<<S.distbits)-1;e:do{f<15&&(h+=w[n++]<<f,f+=8,h+=w[n++]<<f,f+=8),g=p[h&_];t:for(;;){if(y=g>>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Sr;break e}g=p[(65535&g)+(h&(1<<y)-1)];continue t}for(E=65535&g,y&=15,y&&(f<y&&(h+=w[n++]<<f,f+=8),E+=h&(1<<y)-1,h>>>=y,f-=y),f<15&&(h+=w[n++]<<f,f+=8,h+=w[n++]<<f,f+=8),g=v[h&m];;){if(y=g>>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,f<y&&(h+=w[n++]<<f,f+=8,f<y&&(h+=w[n++]<<f,f+=8)),k+=h&(1<<y)-1,k>o){e.msg="invalid distance too far back",S.mode=Sr;break e}if(h>>>=y,f-=y,y=a-s,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=Sr;break e}if(b=0,C=d,0===l){if(b+=u-y,y<E){E-=y;do{x[a++]=d[b++]}while(--y);b=a-k,C=x}}else if(l<y){if(b+=u+l-y,y-=l,y<E){E-=y;do{x[a++]=d[b++]}while(--y);if(b=0,l<E){y=l,E-=y;do{x[a++]=d[b++]}while(--y);b=a-k,C=x}}}else if(b+=l-y,y<E){E-=y;do{x[a++]=d[b++]}while(--y);b=a-k,C=x}for(;E>2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=Sr;break e}g=v[(65535&g)+(h&(1<<y)-1)]}}break}}while(n<r&&a<i);E=f>>3,n-=E,f-=E<<3,h&=(1<<f)-1,e.next_in=n,e.next_out=a,e.avail_in=n<r?r-n+5:5-(n-r),e.avail_out=a<i?i-a+257:257-(a-i),S.hold=h,S.bits=f};const Ir=15,Nr=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Ar=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Mr=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Ur=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Or=(e,t,n,r,a,s,i,o)=>{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=Ir;v++)S[v]=0;for(_=0;_<r;_++)S[t[n+_]]++;for(y=u,g=Ir;g>=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m<g&&0===S[m];m++);for(y<m&&(y=m),b=1,v=1;v<=Ir;v++)if(b<<=1,b-=S[v],b<0)return-1;if(b>0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v<Ir;v++)T[v+1]=T[v]+S[v];for(_=0;_<r;_++)0!==t[n+_]&&(i[T[t[n+_]]++]=_);if(0===e?(x=M=i,p=20):1===e?(x=Nr,M=Ar,p=257):(x=Mr,M=Ur,p=0),w=0,_=0,v=m,f=s,E=y,k=0,d=-1,C=1<<y,h=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){I=v-k,i[_]+1<p?(N=0,A=i[_]):i[_]>=p?(N=M[i[_]-p],A=x[i[_]-p]):(N=96,A=0),c=1<<v-k,l=1<<E,m=l;do{l-=c,a[f+(w>>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<<v-1;w&c;)c>>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<<E;E+k<g&&(b-=S[E+k],!(b<=0));)E++,b<<=1;if(C+=1<<E,1===e&&C>852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-s}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Dr,Z_BLOCK:Rr,Z_TREES:Lr,Z_OK:Pr,Z_STREAM_END:Fr,Z_NEED_DICT:qr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:Gr,Z_MEM_ERROR:jr,Z_BUF_ERROR:Vr,Z_DEFLATED:zr}=sn,Br=16180,Qr=16190,Kr=16191,Wr=16192,Yr=16194,Zr=16199,Xr=16200,Jr=16206,$r=16209,ea=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ta(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const na=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Br||t.mode>16211?1:0},ra=e=>{if(na(e))return Hr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Br,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Pr},aa=e=>{if(na(e))return Hr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ra(e)},sa=(e,t)=>{let n;if(na(e))return Hr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Hr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,aa(e))},ia=(e,t)=>{if(!e)return Hr;const n=new ta;e.state=n,n.strm=e,n.window=null,n.mode=Br;const r=sa(e,t);return r!==Pr&&(e.state=null),r};let oa,ua,ca=!0;const la=e=>{if(ca){oa=new Int32Array(512),ua=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Or(1,e.lens,0,288,oa,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Or(2,e.lens,0,32,ua,0,e.work,{bits:5}),ca=!1}e.lencode=oa,e.lenbits=9,e.distcode=ua,e.distbits=5},da=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=a))),0};var ha={inflateReset:aa,inflateReset2:sa,inflateResetKeep:ra,inflateInit:e=>ia(e,15),inflateInit2:ia,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=0;const x=new Uint8Array(4);let S,T;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(na(e)||!e.output||!e.input&&0!==e.avail_in)return Hr;n=e.state,n.mode===Kr&&(n.mode=Wr),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Pr;e:for(;;)switch(n.mode){case Br:if(0===n.wrap){n.mode=Wr;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,x[0]=255&c,x[1]=c>>>8&255,n.check=rn(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=$r;break}if((15&c)!==zr){e.msg="unknown compression method",n.mode=$r;break}if(c>>>=4,l-=4,b=8+(15&c),0===n.wbits&&(n.wbits=b),b>15||b>n.wbits){e.msg="invalid window size",n.mode=$r;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&c?16189:Kr,c=0,l=0;break;case 16181:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(n.flags=c,(255&n.flags)!==zr){e.msg="unknown compression method",n.mode=$r;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=$r;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=rn(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.head&&(n.head.time=c),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=rn(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=rn(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=rn(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(b=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),b)),512&n.flags&&4&n.wrap&&(n.check=rn(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{b=r[s+f++],n.head&&b&&n.length<65536&&(n.head.name+=String.fromCharCode(b))}while(b&&f<o);if(512&n.flags&&4&n.wrap&&(n.check=rn(n.check,r,f,s)),o-=f,s+=f,b)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===o)break e;f=0;do{b=r[s+f++],n.head&&b&&n.length<65536&&(n.head.comment+=String.fromCharCode(b))}while(b&&f<o);if(512&n.flags&&4&n.wrap&&(n.check=rn(n.check,r,f,s)),o-=f,s+=f,b)break e}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(4&n.wrap&&c!==(65535&n.check)){e.msg="header crc mismatch",n.mode=$r;break}c=0,l=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Kr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}e.adler=n.check=ea(c),c=0,l=0,n.mode=Qr;case Qr:if(0===n.havedict)return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,qr;e.adler=n.check=1,n.mode=Kr;case Kr:if(t===Rr||t===Lr)break e;case Wr:if(n.last){c>>>=7&l,l-=7&l,n.mode=Jr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}switch(n.last=1&c,c>>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(la(n),n.mode=Zr,t===Lr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=$r}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=$r;break}if(n.length=65535&c,c=0,l=0,n.mode=Yr,t===Lr)break e;case Yr:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=Kr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(n.nlen=257+(31&c),c>>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=$r;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;l<3;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.lens[I[n.have++]]=7&c,c>>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},C=Or(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=$r;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;w=n.lencode[c&(1<<n.lenbits)-1],_=w>>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(g<16)c>>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(T=_+2;l<T;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(c>>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=$r;break}b=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(T=_+3;l<T;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}c>>>=_,l-=_,b=0,f=3+(7&c),c>>>=3,l-=3}else{for(T=_+7;l<T;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}c>>>=_,l-=_,b=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=$r;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===$r)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=$r;break}if(n.lenbits=9,S={bits:n.lenbits},C=Or(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=$r;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Or(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=$r;break}if(n.mode=Zr,t===Lr)break e;case Zr:n.mode=Xr;case Xr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Tr(e,h),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Kr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<<n.lenbits)-1],_=w>>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(m&&!(240&m)){for(y=_,E=m,k=g;w=n.lencode[k+((c&(1<<y+E)-1)>>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}c>>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=Kr;break}if(64&m){e.msg="invalid literal/length code",n.mode=$r;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l<T;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;w=n.distcode[c&(1<<n.distbits)-1],_=w>>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(!(240&m)){for(y=_,E=m,k=g;w=n.distcode[k+((c&(1<<y+E)-1)>>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}c>>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=$r;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(T=n.extra;l<T;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=$r;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=$r;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=Xr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=Xr;break;case Jr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<<l,l+=8}if(h-=u,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?rn(n.check,a,h,i-h):tn(n.check,a,h,i-h)),h=u,4&n.wrap&&(n.flags?c:ea(c))!==n.check){e.msg="incorrect data check",n.mode=$r;break}c=0,l=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;l<32;){if(0===o)break e;o--,c+=r[s++]<<l,l+=8}if(4&n.wrap&&c!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=$r;break}c=0,l=0}n.mode=16208;case 16208:C=Fr;break e;case $r:C=Gr;break e;case 16210:return jr;default:return Hr}return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,(n.wsize||h!==e.avail_out&&n.mode<$r&&(n.mode<Jr||t!==Dr))&&da(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?rn(n.check,a,h,e.next_out-h):tn(n.check,a,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Kr?128:0)+(n.mode===Zr||n.mode===Yr?256:0),(0===d&&0===h||t===Dr)&&C===Pr&&(C=Vr),C},inflateEnd:e=>{if(na(e))return Hr;let t=e.state;return t.window&&(t.window=null),e.state=null,Pr},inflateGetHeader:(e,t)=>{if(na(e))return Hr;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Pr):Hr},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return na(e)?Hr:(r=e.state,0!==r.wrap&&r.mode!==Qr?Hr:r.mode===Qr&&(a=1,a=tn(a,t,n,0),a!==r.check)?Gr:(s=da(e,t,n,n),s?(r.mode=16210,jr):(r.havedict=1,Pr)))},inflateInfo:"pako inflate (from Nodeca project)"};var fa=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const pa=Object.prototype.toString,{Z_NO_FLUSH:va,Z_FINISH:_a,Z_OK:ma,Z_STREAM_END:ga,Z_NEED_DICT:ya,Z_STREAM_ERROR:Ea,Z_DATA_ERROR:ka,Z_MEM_ERROR:ba}=sn;function Ca(e){this.options=sr({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new hr,this.strm.avail_out=0;let n=ha.inflateInit2(this.strm,t.windowBits);if(n!==ma)throw new Error(an[n]);if(this.header=new fa,ha.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=cr(t.dictionary):"[object ArrayBuffer]"===pa.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ha.inflateSetDictionary(this.strm,t.dictionary),n!==ma)))throw new Error(an[n])}function wa(e,t){const n=new Ca(t);if(n.push(e),n.err)throw n.msg||an[n.err];return n.result}Ca.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?_a:va,"[object ArrayBuffer]"===pa.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=ha.inflate(n,i),s===ya&&a&&(s=ha.inflateSetDictionary(n,a),s===ma?s=ha.inflate(n,i):s===ka&&(s=ya));n.avail_in>0&&s===ga&&n.state.wrap>0&&0!==e[n.next_in];)ha.inflateReset(n),s=ha.inflate(n,i);switch(s){case Ea:case ka:case ya:case ba:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===ga))if("string"===this.options.to){let e=dr(n.output,n.next_out),t=n.next_out-e,a=lr(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ma||0!==o){if(s===ga)return s=ha.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ca.prototype.onData=function(e){this.chunks.push(e)},Ca.prototype.onEnd=function(e){e===ma&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=ir(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var xa={Inflate:Ca,inflate:wa,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wa(e,t)},ungzip:wa,constants:sn};const{Deflate:Sa,deflate:Ta,deflateRaw:Ia,gzip:Na}=xr,{Inflate:Aa,inflate:Ma,inflateRaw:Ua,ungzip:Oa}=xa;var Da,Ra={Deflate:Sa,deflate:Ta,deflateRaw:Ia,gzip:Na,Inflate:Aa,inflate:Ma,inflateRaw:Ua,ungzip:Oa,constants:sn},La=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ra.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))},Pa=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof M)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},Fa=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))};e.ConnectionState=void 0,(Da=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Da.OPEN="OPEN",Da.CLOSED="CLOSED";var qa,Ha=function(t){function a(e,t){var s,i=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(s=n(this,a)).lastActive=0,s._iid=e,s._sdkState=i,s._dispatcher=o,s._logger=u,s}return c(a,t),s(a,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ze.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Ye(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("function"==typeof fetch){n.next=3;break}return n.next=3,Promise.resolve().then((function(){return mg}));case 3:Fa((function(){return E(r,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:fetch(this._sdkState.api.host);case 1:case"end":return e.stop()}}),e,this)})))})),this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,La(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,La(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,s=e.data,i=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),t.next=26,La(i);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",M.networkError)},this._ws.onclose=function(e){r._logger.debug("websocket close",e.code,e.reason),r.cleanUpWebSocket(),r.dispatch("close")},this.lastActive=Date.now();case 10:case"end":return n.stop()}}),n,this)})))}},{key:"cleanUpWebSocket",value:function(){this._ws&&(this._ws.onopen=_t,this._ws.onmessage=_t,this._ws.onerror=_t,this._ws.onclose=_t,this.connectionState===e.ConnectionState.OPEN&&this._ws.close(1e3,"Normal Closure"),this._ws=void 0)}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){if(t._ws){if(t.connectionState===e.ConnectionState.CLOSED)return t.cleanUpWebSocket(),void n();t._ws.onclose=function(){t.cleanUpWebSocket(),t.dispatch("close"),n()},t._ws.close()}else n()}))}},{key:"send",value:function(e){if(!this._ws)throw M.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}])}(he),Ga=function(e){function t(e){var a,s=e.all,i=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=s,a.feed=i,a.customTypes=o,a.ts=u,a}return c(t,e),s(t)}(pe),ja=function(){return s((function e(t,n){var a=this,s=n.session,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new vt(t,{session:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ha(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Ga(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new M({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(M.connectionClosed)})),a._ackStateMap.clear()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._sdkState.websocket){t.next=2;break}throw M.connectionRequired;case 2:if(n=new dt,e.ackRequired){a=function(t,a){s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(s._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(s._logger.debug("receive websocket ack",e.requestId,e),s._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(M.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qe)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof Xe)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw M.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(qa||(qa={}));var Va,za,Ba=function(e){function t(e){var a,s=e.stateType;return r(this,t),(a=n(this,t)).stateType=s,a}return c(t,e),s(t)}(pe),Qa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),s(t)}(pe),Ka=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),s(t)}(pe),Wa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),s(t)}(pe),Ya=function(){return s((function e(t){var n,a,s,i;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(s=t.template_list_token)&&void 0!==s?s:null,this.settingsUpdatedAt=null!==(i=t.settings_updated_at)&&void 0!==i?i:0}),null,[{key:"payloadify",value:function(e){return ve(_e({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Za=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Xa=function(){return s((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return ve(_e({last_updated_at:e.lastUpdatedAt}))}}])}(),Ja=function(){return s((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return ve(_e({template_list_token:e.token}))}}])}(),$a=function(){return s((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return ve(_e({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),es=function(){return s((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new $a(t.default),this.realTime=new $a(t.realtime)}),null,[{key:"payloadify",value:function(e){return ve(_e({default:$a.payloadify(e.default),realtime:$a.payloadify(e.realTime)}))}}])}(),ts=1048576;e.UnreadCountThreadingPolicy=void 0,(Va=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Va.NONE=0]="NONE",Va[Va.INCLUDE_REPLY=1]="INCLUDE_REPLY",Va[Va.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Va[Va.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(za=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[za.NONE=0]="NONE",za[za.INCLUDE_REPLY=1]="INCLUDE_REPLY",za[za.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",za[za.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var ns,rs=function(){return s((function t(){var n,a,s,i,o,u,c,l,d,h=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=h.emoji_hash||"",this.uploadSizeLimit=h.file_upload_size_limit?h.file_upload_size_limit*ts:Number.MAX_SAFE_INTEGER,this.useReaction=!!h.use_reaction,this.applicationAttributes=null!==(n=h.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=h.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(s=h.multiple_file_send_max_size)&&void 0!==s?s:5,this.allowSdkStatsUpload=null===(i=h.allow_sdk_log_ingestion)||void 0===i||i,this.unreadCountThreadingPolicy=null!==(o=h.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=h.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new Xa(null!==(c=h.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=h.notifications?new Ya(h.notifications):null,this.messageTemplateInfo=h.message_template?new Ja(h.message_template):null,this.statConfigInfo=h.log_publish_config?new es(h.log_publish_config):new es,this.disableSuperGroupMack=null!==(l=h.disable_supergroup_mack)&&void 0!==l&&l,this.configSyncNeeded=null!==(d=h.config_sync_needed)&&void 0!==d&&d}),null,[{key:"payloadify",value:function(e){return ve(_e({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/ts,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Xa.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ya.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Ja.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?es.payloadify(e.statConfigInfo):null,disable_supergroup_mack:e.disableSuperGroupMack,config_sync_needed:e.configSyncNeeded}))}}])}(),as=function(e){return"sendbird@".concat(e,"/app_configs_info")},ss=function(){return s((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),is=function(e){function t(e){var a,s=e.userId,i=e.metadata;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ye,"/").concat(s,"/metadata"),a.params={metadata:i},a}return c(t,e),s(t)}(Qe),os=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).metaData=a,s}return c(t,e),s(t)}(Ke),us=function(e){function t(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return c(t,e),s(t)}(Qe),cs=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).metadata=a,s}return c(t,e),s(t)}(Ke),ls=function(e){function t(e){var a,s=e.userId,i=e.metadataKey;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(s,"/metadata/").concat(i),a}return c(t,e),s(t)}(Qe),ds=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(s,"/metadata"),a}return c(t,e),s(t)}(Qe),hs=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},fs=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ps=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ns=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ns.OFFLINE="offline",ns.NON_AVAILABLE="nonavailable";var vs,_s=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,_,m,g,y,E;return r(this,a),(i=n(this,a,[t])).userId=null!==(u=null!==(o=s.guest_id)&&void 0!==o?o:s.user_id)&&void 0!==u?u:"",i.nickname=null!==(l=null!==(c=s.nickname)&&void 0!==c?c:s.name)&&void 0!==l?l:"",i.plainProfileUrl=null!==(h=null!==(d=s.profile_url)&&void 0!==d?d:s.image)&&void 0!==h?h:"",i.requireAuth=null!==(f=s.require_auth_for_profile_image)&&void 0!==f&&f,i.metaData=null!==(p=s.metadata)&&void 0!==p?p:{},i.connectionStatus=e.UserOnlineState.NON_AVAILABLE,L(e.UserOnlineState,s.is_online)?i.connectionStatus=s.is_online:R("boolean",s.is_online)&&(i.connectionStatus=s.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),i.isActive=null===(_=s.is_active)||void 0===_||_,i.lastSeenAt=null!==(m=s.last_seen_at)&&void 0!==m?m:null,i.preferredLanguages=s.preferred_languages?v(s.preferred_languages):null,i.friendDiscoveryKey=null!==(g=s.friend_discovery_key)&&void 0!==g?g:null,i.friendName=null!==(y=s.friend_name)&&void 0!==y?y:null,i._hashValue=i._generateHashValue(),i._updatedAt=null!==(E=s.updatedat)&&void 0!==E?E:0,i}return c(a,t),s(a,[{key:"_generateHashValue",value:function(){for(var e,t=JSON.stringify({userId:this.userId,nickname:this.nickname,plainProfileUrl:this.plainProfileUrl,friendDiscoveryKey:this.friendDiscoveryKey,friendName:this.friendName,metaData:JSON.stringify(this.metaData),performanceLanguages:null===(e=this.preferredLanguages)||void 0===e?void 0:e.toString(),requireAuth:this.requireAuth}),n=0,r=0;r<t.length;r++){n=(n<<5)-n+t.charCodeAt(r),n|=0}return n}},{key:"profileUrl",get:function(){var e=vi.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return hs(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return R("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(this._isValidMetaData(e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new is({userId:r.userId,metadata:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(os),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(this._isValidMetaData(e)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new us({userId:a.userId,metadata:e,upsert:t}),n.next=5,s.send(i);case 5:return o=n.sent,u=o.as(cs),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new ls({userId:r.userId,metadataKey:e}),t.next=5,a.send(s);case 5:return this._applyMetaData((i={},u=!0,(o=_(o=e))in i?Object.defineProperty(i,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[o]=u,i),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var i,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ds({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}},{key:"_buildUserFromSerializedData",value:function(e){var t=fs(e);return new a(t._iid,a.payloadify(t))}}])}(ss),ms=function(e){function t(e){var a,s=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=s,a}return c(t,e),s(t)}(pe),gs=function(){return s((function e(t,n){var a,s,i,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new rs(n),this.user=new _s(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=vi.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ms({userProfile:this}))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign(Object.assign({},_s.payloadify(e.user)),rs.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}}])}(),ys=function(e){function t(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=i,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),s(t)}(pe),Es=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).configSyncNeeded=!1,a.configSyncNeeded=e,a}return c(t,e),s(t)}(pe),ks=function(e){function t(e,a,s){var i,o,u,c,l;return r(this,t),(i=n(this,t,[e,a,s])).error=null,i.services=[],i.userProfile=new gs(e,s),i.deviceTokenLastDeletedAt=null!==(o=s.device_token_last_deleted_at)&&void 0!==o?o:0,i.key=null!==(u=s.key)&&void 0!==u?u:"",i.ekey=null!==(c=s.ekey)&&void 0!==c?c:"",i.error=s.error?new M(s):null,i.services=null!==(l=s.services)&&void 0!==l?l:[],i}return c(t,e),s(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=14;break}if(!(n=vi.of(e))){t.next=11;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new Es(this.userProfile.appInfo.configSyncNeeded)),a.dispatch(new ys({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=12;break;case 11:throw M.lostInstance;case 12:t.next=15;break;case 14:throw this.error;case 15:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ze),bs=function(){return s((function e(){r(this,e),this.type=qa.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),Cs=function(e){function t(){var e,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=qa.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=s.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),s(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Rs,n);case 6:this._wasPreviouslyConnected&&Pa((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(bs),ws=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=qa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),s(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Us({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ns,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Cs,n);case 3:case"end":return t.stop()}}),t)})))}}])}(bs),xs=function(e){function t(e){var a,s=e.autoReconnect;return r(this,t),(a=n(this,t)).type=qa.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=s,a}return c(t,e),s(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Ns,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Us({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ns,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new ws,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Cs,n);case 3:case"end":return t.stop()}}),t)})))}}])}(bs),Ss=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},Ts=function(){return s((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),Is=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Ts;return E(void 0,void 0,void 0,d().mark((function r(){var a,s,i,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,s=null,i=function(e){return s=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a<t)){r.next=29;break}return r.prev=5,r.next=8,e(i,o);case 8:if(u=r.sent,s){r.next=13;break}return r.abrupt("return",u);case 13:throw s;case 14:r.next=27;break;case 16:if(r.prev=16,r.t0=r.catch(5),s){r.next=26;break}if(++a!==t){r.next=22;break}throw r.t0;case 22:return r.next=24,Ss(n.calcTimeout(a));case 24:r.next=27;break;case 26:throw s;case 27:r.next=4;break;case 29:throw"It should not happen.";case 30:case"end":return r.stop()}}),r,null,[[5,16]])})))},Ns=function(t){function a(){var e;return r(this,a),(e=n(this,a,arguments)).type=qa.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return c(a,t),s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new dt,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Pa((function(){return E(u,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()}));case 1:case"end":return e.stop()}}),e)})))})),n.prev=4,s=t.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,Is((function(n,r){return E(u,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._haltConnect=n,this._resetConnect=r,a.prev=2,a.next=5,t.connect();case 5:a.next=20;break;case 7:if(a.prev=7,a.t0=a.catch(2),t.clearLoginTimer(),!(a.t0 instanceof M)){a.next=19;break}a.t1=a.t0.code,a.next=a.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?14:16;break;case 14:return n(a.t0),a.abrupt("return");case 16:if(!a.t0.isSessionExpiredError&&!a.t0.isSessionInvalidatedError){a.next=19;break}return n(a.t0),a.abrupt("return");case 19:throw a.t0;case 20:case"end":return a.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,t.changeState(new As,r);case 10:this._flushCallbacks(),Pa((function(){return E(u,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()}));case 1:case"end":return e.stop()}}),e)})))})),n.next=26;break;case 14:if(n.prev=14,n.t0=n.catch(4),A(n.t0)){n.next=25;break}if(!(n.t0 instanceof M)){n.next=21;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=21;break}return n.next=21,t.changeState(new xs({autoReconnect:!1}),r);case 21:this._flushCallbacks(n.t0),Pa((function(){return E(u,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()}));case 1:case"end":return e.stop()}}),e)})))})),n.next=26;break;case 25:throw n.t0;case 26:return n.abrupt("return",a.promise);case 27:case"end":return n.stop()}}),n,this,[[4,14]])})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new dt,this._halt(M.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var n=Date.now();e.changeState(new Us({authToken:t}),n).then((function(){r.resolve()})).catch((function(e){r.reject(e)}))})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"onReconnect",value:function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new dt,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){t._error;var n=t.autoReconnect,r=void 0===n||n;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new xs({autoReconnect:r}),n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new ws,n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new Cs,n);case 4:case"end":return t.stop()}}),t,this)})))}}])}(bs),As=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=qa.CONNECTED,e.name="connected",e}return c(t,e),s(t,[{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ns,n);case 5:case"end":return t.stop()}}),t)})))}},{key:"onDisconnect",value:function(e,t){var n=t.autoReconnect;return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new xs({autoReconnect:n}),r);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new ws,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Cs,n);case 3:case"end":return t.stop()}}),t)})))}}])}(bs);!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(vs||(vs={}));var Ms=function(){return s((function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,d=n.disableWebSocketCloseEventHandling,h=void 0!==d&&d;r(this,e),this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=l,this._disableWebSocketCloseEventHandling=h,this._context=new qs(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}),[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),Fa((function(){return E(e,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reconnect();case 2:case"end":return e.stop()}}),e,this)})))})))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._webSocketClosedCause||Fa((function(){return E(e,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._sessionManager.isSessionKeyRefreshing){e.next=6;break}return this._logger.debug("try reconnect by websocket connection closed"),e.next=4,this.reconnect();case 4:e.next=8;break;case 6:return e.next=8,this.disconnectWebSocket();case 8:case"end":return e.stop()}}),e,this)})))}))})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===qa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===qa.CONNECTING||e.type===qa.RECONNECTING}},{key:"websocketClient",get:function(){return this._websocketClient}},{key:"connect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._webSocketClosedCause=null,t.next=4,n.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"reconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,this._webSocketClosedCause=null,e.next=4,t.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,this._webSocketClosedCause=null,e.next=4,t.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,this._webSocketClosedCause=vs.ExternalSetBackground,e.next=4,t.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,t.next=3,n.onDisconnect(this._context,{error:e,autoReconnect:!0,cause:this._webSocketClosedCause});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"disconnectWebSocket",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=vs.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Us=function(t){function a(e){var t,s=e.authToken;return r(this,a),(t=n(this,a)).type=qa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=s,t}return c(a,t),s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new dt,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Is((function(n){return E(s,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof M)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new As,r);case 8:Pa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),A(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Rs,r);case 20:Pa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new dt,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,s=void 0!==a&&a,i=t.cause,o=void 0===i?null:i;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:Os(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new xs({autoReconnect:s}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Cs,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(Os((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new ws,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new Cs,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:M.connectionCanceled),n.next=4,e.changeState(new Cs,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(bs);function Os(e){var t=M.connectionCanceled;if(e){var n=null;switch(e){case vs.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case vs.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var Ds,Rs=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=qa.INITIALIZED,e.name="initialized",e}return c(t,e),s(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Us({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Cs({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(bs),Ls=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),s(t)}(Xe),Ps=function(){return s((function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=s}),[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;var n=new Ls;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}])}(),Fs=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],qs=function(e){function t(e,a){var s,i,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Rs:p;return r(this,t),(s=n(this,t))._stateUpdatedAt=0,s._connectingAt=0,s._connectedAt=0,s._logiReceivedAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=o,s.cacheContext=u,s.connectionHandlers=c,s._sessionManager=l,s._websocketClient=d,s._dispatcher=h,s._logger=f,s._currentState=v,(null===(i=s.sdkState.websocket)||void 0===i?void 0:i.pingerDisabled)||(s._pinger=new Ps({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:f})),s._websocketClient.on("open",(function(){s._connectedAt=Date.now(),s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(ks))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=void 0,s._unresolvedLogi||s._rejectConnectionRequest(M.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof ks&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return c(t,e),s(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Ba({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=17;break}if(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),n.error){t.next=14;break}return t.next=7,n.applyTo(this._iid);case 7:this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=17;break;case 14:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Ye({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 17:case"end":return t.stop()}}),t,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(e){var t,n=e.configTs,r=this.sdkState,a=r.appId,s=r.appVersion,i=r.userId,o=r.extensions,u=r.sendbirdRuntimeEnvironment,c=this.cacheContext.localCacheEnabled,l=this._sessionManager.session,d=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,h=!!(null!=o?o:{}).sb_uikit,f=lt.userAgentWithExtension(o);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(a).concat(s?"&av=".concat(s):"").concat(l.hasSession?"":"&user_id=".concat(encodeURIComponent(i)),"&pmce=").concat(d?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&SB-SDK-User-Agent=").concat(encodeURIComponent(lt.sendbirdSdkUserAgentWithExtension(u)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Fs))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(c?1:0,"&include_poll_details=1").concat(h?"&uikit_config=1":"","&config_ts=").concat(n)}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new nt(new ot({type:Be.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:Date.now()-this._connectingAt,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectingAt:void 0,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(M.connectionCanceled)),r=new dt,this._connectionRequestQueue.push(r),1!==this._connectionRequestQueue.length){n.next=17;break}return this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){u._loginTimer=void 0,u._rejectConnectionRequest(M.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),s=0,n.next=13,this.cacheContext.preference.get(as(this.sdkState.appId));case 13:(i=n.sent)&&(s=i.configTs),o=this._url({configTs:s}),a.sessionKey||a.authToken?this._websocketClient.connect(o,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(o,JSON.stringify({}));case 17:return n.abrupt("return",r.promise);case 18:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(ks.asError(M.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,e.next=4,this.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(he),Hs=function(e){function t(e){var a,s=e.appId,i=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d,f=e.configTs,p=void 0===f?0:f;return r(this,t),(a=n(this,t)).path="".concat(Ee,"/").concat(i,"/authentication"),a.method=me.POST,a.params=ve({expiring_session:!!h,include_logi:!0,include_extra_data:String(Fs),uikit_config:u,use_local_cache:l,app_id:s,config_ts:p}),a.requireAuth=!1,a}return c(t,e),s(t)}(Qe),Gs=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).logi=new ks(e,"LOGI",a),s}return c(t,e),s(t)}(Ke);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ds||(Ds={}));var js,Vs,zs=[Je,Hs],Bs=function(){return s((function e(t,n){var a=this,s=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=qa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ja(t,{session:s,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=s,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof Ba){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case qa.CONNECTED:a._resolveLazyCallQueue();break;case qa.INITIALIZED:case qa.INTERNAL_DISCONNECTED:case qa.EXTERNAL_DISCONNECTED:case qa.LOGOUT:a._session.isRefreshing||a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?M.connectionClosed:M.connectionRequired)}}else if(e instanceof Qa)a._session.hasChatServicePermission||a._resolveLazyCallQueue(Ds.API);else if(e instanceof Ka||e instanceof Wa)a._rejectLazyCallQueue(M.connectionClosed);else if(e instanceof rt){var r,s=e.request,o=e.deferred,u=e.error,c=i(zs);try{for(c.s();!(r=c.n()).done;){if(s instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:s,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===qa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===qa.CONNECTING||this._currentConnectionStateType===qa.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case Ds.ALL:t=null;break;case Ds.WEBSOCKET:t=Xe;break;case Ds.API:t=Qe}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ds.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:s=e.sent,r.resolve(s),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ds.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],s=r[1];this._lazyCallQueue=s,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Xe)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new dt,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return s.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),M.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof Qe)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new dt,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return s.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=M.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw M.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof Xe||e instanceof Qe)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw M.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(M.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}])}(),Qs="sendbird@devicetokens",Ks=function(){return s((function e(t){var n=t.type,a=t.token,s=t.device_os,i=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return ve(_e({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),Ws=new WeakMap,Ys=function(t){function a(e){var t,s=e._iid,i=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=qa.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=i,t._iid=s,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof Ba){var s=e.stateType;t._currentConnectionStateType=s}else if(e instanceof Ye&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===qa.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(A(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(A(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),s(a,[{key:"ekey",get:function(){return Ws.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new $e({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(tt),s=a.newKey,!(i=a.error)){t.next=7;break}throw i;case 7:this.session.sessionKey=null!=s?s:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Je({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,Is((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(et),s=a.key,i=a.services,this.session.sessionKey=s,this.session.services=i,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==qa.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new dt;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return i()}),1e3*this._sdkState.sessionTokenRefreshTimeout),Pa((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(s,i);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof M)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof M&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=0,r.next=4,this._cacheContext.preference.get(as(this._sdkState.appId));case 4:return(s=r.sent)&&(a=s.configTs),i=new Hs({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring,configTs:a}),r.next=9,this._requestQueue.commandRouter.send(i);case 9:if(o=r.sent,u=o.as(Gs),(c=u.logi).error){r.next=17;break}if(this.session.hasChatServicePermission){r.next=15;break}return r.next=15,c.applyTo(this._iid);case 15:r.next=18;break;case 17:throw c.error;case 18:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,s=e.services,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=s,Ws.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Qs);case 9:if((l=n.sent)&&!(l.lastDeletedAt<u)){n.next=17;break}return this._deviceTokens=[],this._deviceTokenLastDeletedAt=u,n.next=15,this.saveDeviceToken();case 15:n.next=19;break;case 17:this._deviceTokens=l.tokens.map((function(e){return new Ks(Ks.payloadify(e))})),this._deviceTokenLastDeletedAt=l.lastDeletedAt;case 19:n.next=23;break;case 21:return n.next=23,c.remove(Qs);case 23:case"end":return n.stop()}}),n,this)})))}},{key:"complete",value:function(){var e=this;this.dispatch("refresh"),this._dispatcher.dispatch(new Qa),Pa((function(){return E(e,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._logger.debug("session refreshed"),(null===(t=this.handler)||void 0===t?void 0:t.onSessionRefreshed)&&this.handler.onSessionRefreshed();case 2:case"end":return e.stop()}}),e,this)})))}))}},{key:"error",value:function(e){var t=this;Pa((function(){return E(t,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(null===(n=this.handler)||void 0===n?void 0:n.onSessionError)&&this.handler.onSessionError(e);case 1:case"end":return t.stop()}}),t,this)})))}))}},{key:"close",value:function(){var e=this;this.dispatch("close"),this._dispatcher.dispatch(new Wa),Pa((function(){return E(e,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._logger.debug("session closed"),(null===(t=this.handler)||void 0===t?void 0:t.onSessionClosed)&&this.handler.onSessionClosed();case 2:case"end":return e.stop()}}),e,this)})))}))}},{key:"refreshAuthToken",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.isSessionExpiring||this.session.isRefreshing){e.next=28;break}return this.session.isRefreshing=!0,e.prev=3,e.next=6,this._receiveNewAuthToken();case 6:if(!(t=e.sent)){e.next=14;break}return this._logger.debug("session refreshing.."),this.session.authToken=t,e.next=12,this._refreshSessionKey(this.session.authToken);case 12:e.next=16;break;case 14:return e.next=16,this.clear();case 16:e.next=25;break;case 18:throw e.prev=18,e.t0=e.catch(3),n=t?M.sessionTokenRefreshFailed:M.sessionTokenRequestFailed,this._dispatcher.dispatch(new Ka),this.error(n),this._logger.debug("refresh auth token error = ",n),n;case 25:return e.prev=25,this.session.isRefreshing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[3,18,25,28]])})))}},{key:"refreshSessionKey",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isSessionExpiring||this.session.isRefreshing){e.next=16;break}return this.session.isRefreshing=!0,e.prev=2,e.next=5,this._refreshSessionKey(this.session.authToken);case 5:e.next=13;break;case 7:throw e.prev=7,e.t0=e.catch(2),t=M.sessionTokenRefreshFailed,this._dispatcher.dispatch(new Ka),this.error(t),t;case 13:return e.prev=13,this.session.isRefreshing=!1,e.finish(13);case 16:case"end":return e.stop()}}),e,this,[[2,7,13,16]])})))}},{key:"setDeviceToken",value:function(e,t,n){if(this._deviceTokenCacheEnabled&&this.indexOfDeviceToken(e,t)<0){var r=new Ks({type:e,token:t,device_os:null==n?void 0:n.deviceOS,device_manufacturer:null==n?void 0:n.deviceManufacturer,system_push_enabled:null==n?void 0:n.systemPushEnabled});return this._deviceTokens.push(r),!0}return!1}},{key:"unsetDeviceToken",value:function(e,t){if(this._deviceTokenCacheEnabled){var n=this.indexOfDeviceToken(e,t);n>=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Qs,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),Ws.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(he),Zs=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),s={},o=i(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?s[u]=t[u]:"undefined"===l?s[u]=e[u]:c!==l?s[u]=t[u]:"object"===c&&e[u]&&t[u]?s[u]=Zs(e[u],t[u]):s[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return s}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(js||(js={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Vs||(Vs={}));var Xs,Js=100,$s=function(){return s((function e(t){var n=t.deviceId,a=t.cacheContext,s=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=js.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=s,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Js}),[{key:"isEnabled",get:function(){return this.enabledState===js.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return ot.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),ei=function(e){function t(e){var a,s,i,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return c(t,e),s(t)}(ot),ti=function(e){function t(e){var a,s=e.deviceId,i=e.statLogs;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(Oe),a.params={device_id:s,log_entries:i.map((function(e){return ot.payloadify(e)}))},a}return c(t,e),s(t)}(Qe),ni=function(t){function a(e){var t=e.deviceId,s=e.cacheContext,i=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:s,requestQueue:i}])}return c(a,t),s(a,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new ot({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?js.ENABLED:js.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=js.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),s=0;case 16:if(!(s<r.length)){n.next=25;break}return i=r.slice(s,1+this.statConfig.maxStatCountPerRequest),n.next=20,Ss(a);case 20:return n.next=22,this._flush(i);case 22:s+=this.statConfig.maxStatCountPerRequest,n.next=16;break;case 25:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==js.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===js.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,r=n.filter((function(t){return t instanceof ei&&t.key===e.key})),a=f(r,1),(s=a[0])?s.data=Zs(s.data,e.data):n.push(e),this.enabledState===js.PENDING){t.next=8;break}return t.next=8,this._save();case 8:if(!this.isEnabled){t.next=17;break}if(this._mergeQueue(),!this._isSendable){t.next=17;break}return t.next=13,this._getUploadStats();case 13:return i=t.sent,t.next=16,this._flush(i);case 16:return t.abrupt("return",t.sent);case 17:return t.abrupt("return",!0);case 18:case"end":return t.stop()}}),t,this)})))}},{key:"_getUploadStats",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.queue.filter((function(e){if(e instanceof ei){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r<a)return!0;if(r===a){var s=[e.date.getMonth(),t.getMonth()],i=s[0],o=s[1];if(i<o)return!0;if(i===o){var u=[e.date.getDate(),t.getDate()];return u[0]<u[1]}}}return!1})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new ti({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(s);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Js,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof M)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=js.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=js.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}($s),ri=function(t){function a(e){var t=e.deviceId,s=e.cacheContext,i=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:s,requestQueue:i}])}return c(a,t),s(a,[{key:"_isSendable",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length<this.statConfig.lowerThreshold)return!1;if(e){if(Date.now()-this.logInfo.lastFlushedAt<this.statConfig.minInterval)return!1}else if(this.queue.length<this.statConfig.minStatCount)return!1;return!0}},{key:"_filterQueueByType",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t?e.filter((function(e){return e.type!==Be.FEATURE_LOCALCACHE_EVENT})):e.filter((function(e){return e.type===Be.FEATURE_LOCALCACHE_EVENT})));case 1:case"end":return n.stop()}}),n)})))}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".default");case 2:this.queue=this.logInfo.statLogs.map((function(e){return e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new ot({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.requestStat&&!t.localCacheStat){n.next=17;break}if(this.enabledState=t.enabledStat?js.ENABLED:js.COLLECT_ONLY,r=void 0,t.requestStat||(r=!1),t.localCacheStat||(r=!0),void 0===r){n.next=15;break}return n.next=10,this._filterQueueByType(this.queue,r);case 10:return this.queue=n.sent,n.next=13,this._filterQueueByType(this.flushWaitQueue,r);case 13:this.flushWaitQueue=n.sent,this._save();case 15:n.next=20;break;case 17:return this.enabledState=js.DISABLED,n.next=20,this.clear();case 20:if(!this.isEnabled||!this._isSendable(!0)){n.next=26;break}return a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=24,Ss(a);case 24:return n.next=26,this._flush(this.queue);case 26:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==js.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if((n=this.enabledState===js.PENDING||this.isFlushing?this.flushWaitQueue:this.queue).push(e),this.enabledState===js.PENDING){t.next=7;break}return t.next=7,this._save();case 7:if(!this.isEnabled){t.next=13;break}if(this._mergeQueue(),!this._isSendable()){t.next=13;break}return t.next=12,this._flush(n);case 12:return t.abrupt("return",t.sent);case 13:return t.abrupt("return",!0);case 14:case"end":return t.stop()}}),t,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new ti({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(s);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Js,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof M)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=js.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=js.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}($s),ai=function(e){function t(e){var a,s=e.deviceId,i=e.statLogs;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(De),a.params={device_id:s,log_entries:i.map((function(e){return ot.payloadify(e)}))},a}return c(t,e),s(t)}(Qe),si=function(t){function a(e){var t=e.deviceId,s=e.cacheContext,i=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:s,requestQueue:i}])}return c(a,t),s(a,[{key:"_isSendable",get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=ve(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new ot({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?js.ENABLED:js.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=js.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,Ss(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==js.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===js.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===js.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new ai({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(s);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Js,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof M)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=js.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=js.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}($s),ii=function(){return s((function e(t){var n=t.cacheContext,a=t.requestQueue,s=t.dispatcher,i=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=le(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new ni({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new ri({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new si({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===Be.FEATURE_LOCALCACHE&&n.push(new ot({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return ot.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==Be.FEATURE_LOCALCACHE&&e.stat_type!==Be.NOTIFICATION&&(e.stat_type===Be.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new ot({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return ot.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===Be.NOTIFICATION&&(e.data=ve(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new ot({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return ot.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._notificationStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof nt?(r=e.statLog,this.put(r)):e instanceof ys&&(a=e.request,s=e.features,i=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==s?void 0:s.localCache,this._collectionNotificationStat=null==s?void 0:s.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:i.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:i.ingestion}),this._notificationStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:i.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof ei)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===Be.API_RESULT||t.t0===Be.WEBSOCKET_CONNECT?11:t.t0===Be.FEATURE_LOCALCACHE||t.t0===Be.FEATURE_LOCALCACHE_EVENT?16:t.t0===Be.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._notificationStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=js.COLLECT_ONLY,this._defaultStatCollector.enabledState=js.COLLECT_ONLY,this._notificationStatCollector.enabledState=js.COLLECT_ONLY,this.logger.debug(M.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),oi=function(){return s((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length<this.limit)){n.next=8;break}return this.workersByKey[e].push(t),n.next=5,t();case 5:return r=n.sent,this.workersByKey[e].pop(),n.abrupt("return",r);case 8:throw M.tooManyRequests;case 9:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(e){this.workersByKey[e]=[]}}])}();!function(e){e.DELIVERY_RECEIPT="delivery_receipt",e.PUSH_ACKNOWLEDGEMENT="push_acknowledgement"}(Xs||(Xs={}));var ui,ci=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._pushAckedCache={},e}return c(t,e),s(t,[{key:"isAcked",value:function(e,t){var n,r="".concat(e,"_").concat(t);return null!==(n=this._pushAckedCache[r])&&void 0!==n&&n}},{key:"markAsAcked",value:function(e,t){var n="".concat(e,"_").concat(t);this._pushAckedCache[n]=!0}},{key:"clear",value:function(){vi.of(this._iid).logger.debug("clear push acked cache"),this._pushAckedCache={}}},{key:"parseData",value:function(e){var t,n,r,a,s=vi.of(this._iid).logger,i=e.sendbird;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){throw s.info("push notification payload does not contain sendbird payload in JSON format."),M.malformedDataError}if(!i||"object"!==m(i))throw s.info("push notification payload does not contain sendbird payload in JSON format."),M.malformedDataError;var o=null!==(t=i.push_tracking_id)&&void 0!==t?t:"",u=i.notification_message_id,c=i.notification_channel_key,l=i.notification_template_key,d=i.notification_event_deadline,h=null!==(n=i.session_key)&&void 0!==n?n:{},f=null!==(r=null==h?void 0:h.key)&&void 0!==r?r:"",p=null!==(a=null==h?void 0:h.topics)&&void 0!==a?a:[];if("string"!=typeof o||0===o.length)throw s.info("push tracking id is not available"),M.malformedDataError;if("string"!=typeof u||0===u.length)throw s.info("message id is not available"),M.malformedDataError;return{pushTrackingId:o,sessionKey:f,sessionTopics:p,messageId:u,channelKey:c,templateKey:l,notificationEventDeadline:d}}}])}(ss),li=s((function e(t){r(this,e),this.name=t.name,this._custom=t.custom,this._usedByModerationEngine=t.used_by_moderation_engine})),di=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=me.GET,e.path=Fe,e}return c(t,e),s(t)}(Qe),hi=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).reportCategories=a.categories,s}return c(t,e),s(t)}(Ke),fi=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._categories=[],a}return c(t,e),s(t,[{key:"categories",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._categories.length){e.next=3;break}return e.next=3,this._fetchCategories();case 3:return e.abrupt("return",this._categories);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_fetchCategories",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new di,e.next=4,n.send(r);case 4:a=e.sent,s=a.as(hi),(i=s.reportCategories)&&(o=this._categories).push.apply(o,v(i.map((function(e){return new li(e)}))));case 7:case"end":return e.stop()}}),e,this)})))}}])}(ss),pi={},vi=function(){return s((function e(t,n){var a,s,i,o,u,c,l,d,h;if(r(this,e),this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!pi[t]){pi[t]=this;var f=null!==(a=n.options)&&void 0!==a?a:new V,p=this.sdkState={appId:n.appId,appVersion:null!==(s=n.appVersion)&&void 0!==s?s:"",appState:"foreground",userId:void 0,extensions:{},api:{host:null!==(i=n.apiHost)&&void 0!==i?i:"https://api-".concat(n.appId,".sendbird.com")},websocket:{host:null!==(o=n.websocketHost)&&void 0!==o?o:"wss://ws-".concat(n.appId,".sendbird.com"),pingerDisabled:!!n.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new Ts,responseTimeout:f.websocketResponseTimeout},sessionTokenRefreshTimeout:f.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,feed:0,customTypes:{},ts:0};var v=this.logger=n.logger;this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map;var _=this.cacheContext=new Q({encryption:n.encryption,store:n.store,localCacheEnabled:null!==(u=n.localCacheEnabled)&&void 0!==u&&u,localCacheConfig:null!==(c=n.localCacheConfig)&&void 0!==c?c:new Y});this.debugMode=null!==(l=n.debugMode)&&void 0!==l&&l,this.maxSuperGroupChannelUnreadCount=C.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=f.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=f.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=f.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;var m=this.dispatcher=new fe,g=new ce;this.requestQueue=new Bs(t,{session:g,sdkState:p,dispatcher:m,logger:v,useFetchCompat:n.useFetchCompat}),this.pushNotificationAckManager=new ci(t),this.sessionManager=new Ys({_iid:t,session:g,cacheContext:_,sdkState:p,dispatcher:m,requestQueue:this.requestQueue,logger:v,pushNotificationAckManager:this.pushNotificationAckManager}),this.connectionManager=new Ms(t,{sdkState:p,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:m,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:null!==(d=n.disableWebSocketCloseEventHandling)&&void 0!==d&&d,logger:v}),this.statManager=new ii({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:this.dispatcher,logger:v}),this.appStateToggleEnabled=null===(h=n.appStateToggleEnabled)||void 0===h||h,this.messageBackgroundSyncThrottleController=new oi({limit:5}),this.reportCategoryManager=new fi(t)}return pi[t]}),[{key:"hasExtension",value:function(e){return this.sdkState.extensions&&this.sdkState.extensions[e]}}],[{key:"of",value:function(e){if(pi[e])return pi[e];throw M.lostInstance}},{key:"clear",value:function(e){pi[e]&&delete pi[e]}}])}(),_i=function(){return s((function e(){r(this,e)}),[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,a=t.sessionManager,s=t.requestQueue,i=t.logger;t.onlineDetector;var o=t.cacheContext;this._iid=e,this._cacheContext=o,this._sdkState=n,this._dispatcher=r,this._sessionManager=a,this._requestQueue=s,this._logger=i}}])}(),mi=function(){function e(t,n,a){var s,i;r(this,e),this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=t,this.plainUrl=n.url,this.width=n.width,this.height=n.height,this.realWidth=null!==(s=n.real_width)&&void 0!==s?s:n.width,this.realHeight=null!==(i=n.real_height)&&void 0!==i?i:n.height,this._requireAuth=a}return s(e,[{key:"url",get:function(){var e=vi.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(t){return ve(_e(t instanceof e?{url:t.plainUrl,width:t.width,height:t.height,real_width:t.realWidth,real_height:t.realHeight}:{url:"",width:t.maxWidth,height:t.maxHeight,real_width:0,real_height:0}))}}])}(),gi=function(e){function t(e){var a;if(r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ke),a.params=ve({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var s=0;s<e.thumbnailSizes.length;s++){var i=e.thumbnailSizes[s],o=i.maxWidth,u=i.maxHeight;a.params["thumbnail".concat(s+1)]="".concat(o,",").concat(u)}return a.requestId=e.requestId,a}return c(t,e),s(t)}(Qe),yi=function(e){function t(e,a){var s,i,o,u,c;return r(this,t),(s=n(this,t,[e,a])).url=a.url,s.fileSize=null!==(i=a.file_size)&&void 0!==i?i:0,s.thumbnails=null!==(u=null===(o=a.thumbnails)||void 0===o?void 0:o.map((function(t){return new mi(e,t,!1)})))&&void 0!==u?u:[],s.requireAuth=null!==(c=a.require_auth)&&void 0!==c&&c,s}return c(t,e),s(t)}(Ke),Ei=function(e){function t(e,a){var s,i,o,u,c,l;return r(this,t),(s=n(this,t,[e])).replyCount=0,s.memberCount=0,s.lastRepliedAt=0,s.updatedAt=0,s.replyCount=null!==(i=a.reply_count)&&void 0!==i?i:0,s.memberCount=null!==(o=a.member_count)&&void 0!==o?o:0,s.mostRepliedUsers=a.most_replies&&F("object",a.most_replies)?a.most_replies.map((function(e){return new _s(s._iid,e)})):[],s.unreadReplyCount=null!==(u=a.unread_message_count)&&void 0!==u?u:0,s.isPushNotificationEnabled="number"==typeof a.push_enabled?a.push_enabled>0:void 0,s.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,s.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,s}return c(t,e),s(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return _s.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}(ss);e.ReactionEventOperation=void 0,(ui=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",ui.DELETE="delete";var ki,bi=s((function t(n){var a;r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var s=R("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,o=n.operation?n.operation.toLowerCase():null,u=n.reaction,c=n.updated_at,l=n.count,d=n.sampled_user_ids,h=null!==(a=n.sampled_user_info)&&void 0!==a?a:{};s&&R("string",i)&&R("string",o)&&L(e.ReactionEventOperation,o)&&R("string",u)&&u&&R("number",c)&&(this.messageId=s,this.userId=i,this.key=u,this.operation=o,this.updatedAt=c,this._count=l,this._sampledUserIds=d,this._sampledUserInfoList=h)})),Ci=function(e){function t(e,a,s){var i,o;return r(this,t),(i=n(this,t,[e])).userId=a,i.nickname=s.nickname,i.plainProfileUrl=s.profile_url,i.requireAuth=null!==(o=s.require_auth_for_profile_image)&&void 0!==o&&o,i}return c(t,e),s(t,[{key:"profileUrl",get:function(){var e=vi.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}}],[{key:"payloadify",value:function(e){return{nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth}}}])}(ss),wi=function(t){function a(e,t){var s,o,u,c,l,d,h,f;r(this,a),(s=n(this,a,[e]))._sampledUserInfoList=[],s._count=0,s._hasCurrentUserReacted=!1;var p=t.key,_=v(null!==(u=null!==(o=t.sampled_user_ids)&&void 0!==o?o:t.user_ids)&&void 0!==u?u:[]),m=null!==(l=null!==(c=t.last_ts)&&void 0!==c?c:t.updated_at)&&void 0!==l?l:0,g=null!==(d=t.is_self_included)&&void 0!==d?d:_.includes(vi.of(e).sdkState.userId),y=null!==(h=t.sampled_user_info)&&void 0!==h?h:{};R("string",p)&&p&&F("string",_)&&_.length>0&&R("number",m)&&(s.key=p,s._sampledUserIds=_,s._updatedAt=m,s._count=null!==(f=t.count)&&void 0!==f?f:_.length,s._hasCurrentUserReacted=g,Object.keys(y).forEach((function(t){s._sampledUserInfoList.push(new Ci(e,t,y[t]))})));var E,k={},b=i(s.sampledUserIds);try{for(b.s();!(E=b.n()).done;){k[E.value]=s.updatedAt}}catch(e){b.e(e)}finally{b.f()}return s._version=k,s}return c(a,t),s(a,[{key:"isEmpty",get:function(){return 0===this._count}},{key:"userIds",get:function(){return this._sampledUserIds}},{key:"sampledUserIds",get:function(){return this._sampledUserIds}},{key:"sampledUserInfoList",get:function(){return this._sampledUserInfoList}},{key:"count",get:function(){return this._count}},{key:"updatedAt",get:function(){return this._updatedAt}},{key:"hasCurrentUserReacted",get:function(){return this._hasCurrentUserReacted}},{key:"applyEvent",value:function(t){var n=this;if(t.key===this.key&&this.updatedAt<=t.updatedAt)if(t._sampledUserIds)this._sampledUserIds=t._sampledUserIds,this._sampledUserInfoList=[],Object.keys(t._sampledUserInfoList).forEach((function(e){n._sampledUserInfoList.push(new Ci(n._iid,e,t._sampledUserInfoList[e]))})),this._count=t._count,void 0!==t._hasCurrentUserReacted&&(this._hasCurrentUserReacted=t._hasCurrentUserReacted),this._updatedAt=t.updatedAt;else{if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var r=this._sampledUserIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:r<0&&this._sampledUserIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:r>=0&&this._sampledUserIds.splice(r,1)}this._count=this._sampledUserIds.length,this._version[t.userId]=t.updatedAt}this._updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){var t={};return e._sampledUserInfoList.forEach((function(e){t[e.userId]=Ci.payloadify(e)})),ve(_e({key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:t,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e._updatedAt}))}}])}(ss),xi=function(){return s((function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}),null,[{key:"payloadify",value:function(e){var t,n;return ve(_e({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))}}])}(),Si=function(){return s((function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new xi(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return ve(_e({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?xi.payloadify(e.defaultImage):null}))}}])}(),Ti=function(){return s((function e(t){var n,a;r(this,e),this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return ve(_e({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(ki=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",ki.BAD="bad";var Ii,Ni=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return s(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return ve(_e({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),Ai=function(t){function a(t,s){var i,o;return r(this,a),(i=n(this,a,[t,s])).isBlockedByMe=!1,i.role=L(e.Role,s.role)?s.role:e.Role.NONE,i.isBlockedByMe=null!==(o=s.is_blocked_by_me)&&void 0!==o&&o,i}return c(a,t),s(a,null,[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(_s),Mi=function(){return s((function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return ve(_e({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),Ui=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Oi=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,v;r(this,a),(i=n(this,a,[t])).channelType=e.ChannelType.BASE,i.messageType=e.MessageType.BASE,i.mentionType=null,i.mentionedUsers=null,i.mentionedUserIds=null,i.metaArrays=[],i.extendedMessage={},i.createdAt=0,i.updatedAt=0,i.channelUrl=s.channel_url,i.channelType=L(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.data=null!==(o=s.data)&&void 0!==o?o:"",i.customType=null!==(u=s.custom_type)&&void 0!==u?u:"",i.mentionType=L(e.MentionType,s.mention_type)?s.mention_type:null,i.mentionedUsers=s.mentioned_users?s.mentioned_users.map((function(e){return new _s(i._iid,e)})):null,i.mentionedUserIds=null!==(c=s.mentioned_user_ids)&&void 0!==c?c:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId})));var _=null!==(l=s.metaarray)&&void 0!==l?l:{},m=null!==(d=s.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));i.metaArrays=[];for(var g=0;g<m.length;g++){var y=m[g];i.metaArrays.push(new Mi({key:y,value:_[y]||[]}))}return s.sorted_metaarray&&(i.metaArrays=s.sorted_metaarray.map((function(e){return new Mi(e)}))),i.extendedMessage=null!==(h=s.extended_message)&&void 0!==h?h:{},i.extendedMessagePayload=s.extended_message_payload,i.createdAt=null!==(p=null!==(f=s.created_at)&&void 0!==f?f:s.ts)&&void 0!==p?p:0,i.updatedAt=null!==(v=s.updated_at)&&void 0!==v?v:0,i}return c(a,t),s(a,[{key:"isIdentical",value:function(e){return!0}},{key:"isEqual",value:function(e){return D(this,e)}},{key:"isUserMessage",value:function(){return this.messageType===e.MessageType.USER}},{key:"isFileMessage",value:function(){return this.messageType===e.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}},{key:"isMultipleFilesMessage",value:function(){return this.messageType===e.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}},{key:"isAdminMessage",value:function(){return this.messageType===e.MessageType.ADMIN}},{key:"serialize",value:function(){return hs(this)}},{key:"getMetaArraysByKeys",value:function(e){return this.metaArrays.filter((function(t){return e.includes(t.key)}))}}],[{key:"payloadify",value:function(e){var t,n;return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{channel_url:e.channelUrl,channel_type:e.channelType,type:Ui(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return _s.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Mi.payloadify(e)})),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}}])}(ss),Di=function(t){function a(t,s){var i,o,u;return r(this,a),(i=n(this,a,[t])).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new _s(i._iid,s.user),i.readAt=s.ts,i}return c(a,t),s(a)}(ss),Ri=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"READ",ackRequired:!0,payload:{channel_url:a}}])}return c(t,e),s(t)}(Xe),Li=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"READ",s])).readStatus=new Di(e,s),i}return c(t,e),s(t)}(Ze),Pi=function(e){function t(e){var a=e.channelUrl,s=e.messageId;return r(this,t),n(this,t,[{code:"READ",ackRequired:!0,payload:{channel_url:a,parent_message_id:s}}])}return c(t,e),s(t)}(Xe),Fi=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.pushEnabled;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/thread_push"),a.params={push_enabled:u},a}return c(t,e),s(t)}(Qe),qi=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.rating,c=e.comment;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/feedbacks"),a.params={rating:u,comment:c},a}return c(t,e),s(t)}(Qe),Hi=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).feedback=new Ni(a),s}return c(t,e),s(t)}(Ke),Gi=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.feedbackId,c=e.rating,l=e.comment;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/feedbacks/").concat(u),a.params={rating:c,comment:l},a}return c(t,e),s(t)}(Qe),ji=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).feedback=new Ni(a),s}return c(t,e),s(t)}(Ke),Vi=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.feedbackId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/feedbacks/").concat(u),a}return c(t,e),s(t)}(Qe);e.CollectionEventSource=void 0,(Ii=e.CollectionEventSource||(e.CollectionEventSource={})).UNKNOWN="UNKNOWN",Ii.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Ii.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Ii.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Ii.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Ii.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Ii.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Ii.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Ii.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Ii.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Ii.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Ii.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Ii.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",Ii.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",Ii.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Ii.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Ii.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Ii.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Ii.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Ii.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Ii.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Ii.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Ii.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Ii.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",Ii.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",Ii.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",Ii.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",Ii.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",Ii.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",Ii.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Ii.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Ii.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Ii.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Ii.REQUEST_CHANNEL="REQUEST_CHANNEL",Ii.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Ii.REFRESH_CHANNEL="REFRESH_CHANNEL",Ii.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",Ii.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Ii.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",Ii.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Ii.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Ii.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Ii.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Ii.EVENT_MESSAGE_FEEDBACK_ADDED="EVENT_MESSAGE_FEEDBACK_ADDED",Ii.EVENT_MESSAGE_FEEDBACK_UPDATED="EVENT_MESSAGE_FEEDBACK_UPDATED",Ii.EVENT_MESSAGE_FEEDBACK_DELETED="EVENT_MESSAGE_FEEDBACK_DELETED",Ii.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Ii.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Ii.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Ii.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Ii.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Ii.REQUEST_MESSAGE="REQUEST_MESSAGE",Ii.EVENT_THREAD_INFO_UPDATED="EVENT_THREADINFO_UPDATED",Ii.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Ii.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Ii.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Ii.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Ii.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Ii.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Ii.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Ii.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Ii.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Ii.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Ii.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Ii.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Ii.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var zi,Bi,Qi=Object.assign({},e.CollectionEventSource),Ki=function(t){return t.startsWith("EVENT_")||t.startsWith("LOCAL_MESSAGE_")||t===e.CollectionEventSource.SYNC_MESSAGE_FILL||t===e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.CollectionEventSource.SYNC_POLL_CHANGELOGS},Wi=function(e){function t(e){var a,s=e.messages,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).messages=s,a.source=i,a.isWebSocketEventComing=u,a}return c(t,e),s(t)}(pe),Yi=function(e){function t(e){var a,s=e.messageIds,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).messageIds=s,a.source=i,a.isWebSocketEventComing=u,a}return c(t,e),s(t)}(pe),Zi=function(e){function t(e){var a,s=e.messageDeletionTimestamp,i=e.channelUrl,o=e.source;return r(this,t),(a=n(this,t)).messageDeletionTimestamp=s,a.channelUrl=i,a.source=o,a}return c(t,e),s(t)}(pe),Xi=function(e){function t(e){var a,s=e.event,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).event=s,a.source=i,a.isWebSocketEventComing=u,a}return c(t,e),s(t)}(pe),Ji=function(e){function t(e){var a,s=e.event,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).event=s,a.source=i,a.isWebSocketEventComing=u,a}return c(t,e),s(t)}(pe),$i=function(e){function t(e){var a,s=e.reqId,i=e.source;return r(this,t),(a=n(this,t)).reqId=s,a.source=i,a}return c(t,e),s(t)}(pe),eo=function(e){function t(e){var a,s=e.polls,i=e.source;return r(this,t),(a=n(this,t)).polls=s,a.source=i,a}return c(t,e),s(t)}(pe),to=function(e){function t(e){var a,s=e.event,i=e.source;return r(this,t),(a=n(this,t)).event=s,a.source=i,a}return c(t,e),s(t)}(pe),no=function(e){function t(e){var a,s=e.event,i=e.source;return r(this,t),(a=n(this,t)).event=s,a.source=i,a}return c(t,e),s(t)}(pe),ro=function(e){function t(e,a){var s,i,o,u,c,l;return r(this,t),(s=n(this,t,[e])).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=null!==(i=a.url)&&void 0!==i?i:"",s.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,s.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,s.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,s._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l,s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){var t;return new mi(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s._requireAuth)})):[],s}return c(t,e),s(t,[{key:"url",get:function(){var e=vi.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return ve(_e({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}}])}(ss),ao=s((function e(t){var n=t.channelUrl,a=t.channelType,s=t.parentMessage;r(this,e),this.channelUrl=n,this.channelType=a,this.parentMessage=s}));!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(zi||(zi={})),e.MessageFormItemLayout=void 0,(Bi=e.MessageFormItemLayout||(e.MessageFormItemLayout={})).TEXT="text",Bi.TEXTAREA="textarea",Bi.NUMBER="number",Bi.PHONE="phone",Bi.EMAIL="email",Bi.CHIP="chip";var so,io=function(){return s((function e(t,n){r(this,e);var a=n.id,s=n.name,i=n.items,o=n.version,u=n.is_submitted;this.messageId=t,this.id=a,this.name=s,this.items=i.map((function(e){return new oo(e)})).sort((function(e,t){return e.sortOrder-t.sortOrder})),this.version=null!=o?o:1,this._isSubmitted=u}),[{key:"isSubmitted",get:function(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((function(e){return Array.isArray(e.submittedValues)}))}},{key:"isSubmittable",get:function(){return this.items.every((function(e){return e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return ve(_e({id:e.id,name:e.name,items:e.items.map((function(e){return oo.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),oo=function(){return s((function e(t){r(this,e);var n=t.id,a=t.name,s=t.required,i=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=s,this.sortOrder=i,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=ve({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case zi.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&n<t.min||"number"==typeof t.max&&n>t.max);case zi.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case zi.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.length<t.min_length||"number"==typeof t.max_length&&e.length>t.max_length);case zi.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case zi.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return ve(_e({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:ve({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),uo=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(Pe,"/").concat(e.formId,"/submit"),a.params=ve({message_id:e.messageId,items:e.items}),a}return c(t,e),s(t)}(Qe);!function(e){e.OPEN="open",e.CLOSED="closed"}(so||(so={}));var co,lo,ho="removed",fo=function(e){switch(e){case"open":return so.OPEN;case"closed":return so.CLOSED;default:return null}},po=function(e){return!e||!!e.text&&R("string",e.text)},vo=function(e){function t(e,a){var s,i,o,u,c,l,d,h;return r(this,t),(s=n(this,t,[e])).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,s.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,s}return c(t,e),s(t,null,[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}])}(ss),_o=function(e){function t(e,a){var s,i,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(s=n(this,t,[e])).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=so.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(d=fo(a.status))&&void 0!==d?d:so.CLOSED,s.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new vo(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return c(t,e),s(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=fo(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new vo(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at<this.updatedAt)&&(this._applyPollUpdatePayload(t),!0)}},{key:"applyPollVoteEvent",value:function(e){if(this.id!==e.pollId)return!1;var t=this.options,n=t.map((function(e){return e.id})),r=e._payload,a=Math.floor(r.ts/1e3);return r.updated_vote_counts.forEach((function(e){var r=n.indexOf(e.option_id);if(r>-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return hs(this)}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return vo.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}(ss);e.ScheduledStatus=void 0,(co=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",co.SENT="sent",co.FAILED="failed",co.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(lo||(lo={}));var mo,go=function(t){function a(e,t){var s,i,o,u,c,l,d,h,f,p;return r(this,a),(s=n(this,a,[e,t])).parentMessage=null,s.silent=!1,s.isOperatorMessage=!1,s.threadInfo=null,s.reactions=[],s.appleCriticalAlertOptions=null,s.scheduledInfo=null,s.suggestedReplies=null,s.myFeedback=null,s.myFeedbackStatus="NOT_APPLICABLE",s.messageForm=null,s._isContinuousMessages=!1,s._scheduledStatus=null,s._poll=null,s.messageId=null!==(o=null!==(i=t.msg_id)&&void 0!==i?i:t.message_id)&&void 0!==o?o:0,s.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,s.threadInfo=t.thread_info?new Ei(s._iid,t.thread_info):null,t.reactions_summary?s.reactions=t.reactions_summary.map((function(t){return new wi(e,t)})):t.reactions?s.reactions=t.reactions.map((function(t){return new wi(e,t)})):s.reactions=[],s.ogMetaData=t.og_tag?new Si(t.og_tag):null,s.silent=null!==(c=t.silent)&&void 0!==c&&c,s.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,s.appleCriticalAlertOptions=t.apple_critical_alert_options?new Ti(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(s.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},s._scheduledStatus=t.scheduled_status),s._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,s.myFeedback=Ni._isSubmitted(t.feedback)?new Ni(t.feedback):null,s.myFeedbackStatus=Ni._getStatus(t.feedback),s.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,s.messageForm=io.isMessageFormPayload(t.extended_message_payload)?new io(s.messageId,t.extended_message_payload.message_form):null,s.message=null!==(p=t.message)&&void 0!==p?p:"",s._poll=t.poll?new _o(s._iid,t.poll):null,s}return c(a,t),s(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"_findReactionIndex",value:function(e){for(var t=0;t<this.reactions.length;t++)if(this.reactions[t].key===e)return t;return-1}},{key:"applyReactionEvent",value:function(t){var n=vi.of(this._iid).sdkState;if(this.messageId===t.messageId)switch(t.operation){case e.ReactionEventOperation.ADD:t.userId===n.userId&&(t._hasCurrentUserReacted=!0);var r=this._findReactionIndex(t.key);-1!==r?this.reactions[r].applyEvent(t):t._sampledUserIds?this.reactions.push(new wi(this._iid,{key:t.key,sampled_user_ids:t._sampledUserIds,sampled_user_info:t._sampledUserInfoList,count:t._count,is_self_included:t._hasCurrentUserReacted,last_ts:t.updatedAt})):this.reactions.push(new wi(this._iid,{key:t.key,user_ids:[t.userId],updated_at:t.updatedAt}));break;case e.ReactionEventOperation.DELETE:var a=this._findReactionIndex(t.key);-1!==a&&(t._sampledUserIds?0===t._count?this.reactions.splice(a,1):(t.userId===n.userId&&(t._hasCurrentUserReacted=!1),this.reactions[a].applyEvent(t)):(this.reactions[a].applyEvent(t),this.reactions[a].isEmpty&&this.reactions.splice(a,1)))}}},{key:"applyParentMessage",value:function(e){if(!this.parentMessage)return this.parentMessage=e,!0;if(this.parentMessageId===e.messageId){var t=this.parentMessage.updatedAt;if(e.updatedAt>=t)return this.parentMessage=e,!0}return!1}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=vi.of(this._iid),(r=n.dispatcher).dispatch(new ao({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Wi({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new Pi({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new Fi({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=vi.of(this._iid),a=r.requestQueue,s=null,i=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new M({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new M({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:s=o.id,i=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(s=t.formId,i=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],s=r[1],i=Number(a);if(Number.isNaN(i))throw new M({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:i,value:s}),t}),[]));case 14:if(s&&i){n.next=16;break}throw new M({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new uo({messageId:this.messageId,formId:s,items:i}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new qi({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(i);case 4:o=n.sent,u=o.as(Hi),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",s.dispatch(new Wi({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Gi({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(i);case 4:o=n.sent,u=o.as(ji),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",s.dispatch(new Wi({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Vi({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(i);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",s.dispatch(new Wi({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?Ei.payloadify(e.threadInfo):null,reactions_summary:e.reactions.map((function(e){return wi.payloadify(e)})),og_tag:e.ogMetaData?Si.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?Ti.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?Ni.payloadify(e.myFeedback):Ni._getPayloadByStatus(e.myFeedbackStatus),message:e.message,poll:e._poll?_o.payloadify(e._poll):null})))}},{key:"_getParentMessageInfoPayload",value:function(e){return ve(_e({type:Ui(e.messageType),ts:e.createdAt,user:e.sender?Ai.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return ro.payloadify(e)})):null}))}}])}(Oi),yo=function(t){function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n(this,a,[t,s])).reqId="",i.replyToChannel=!1,i.errorCode=0,i.sender=s.user?new Ai(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&L(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(s.scheduled_status&&(i._scheduledStatus=s.scheduled_status),s.scheduled_status){case lo.SENT:case lo.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case lo.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case lo.FAILED:case lo.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case lo.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i._messageToken=s.mesg_token,i}return c(a,t),s(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&U.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:Ai.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(go),Eo={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ko=function(t){return R("number",t.prevResultSize)&&R("number",t.nextResultSize)&&R("boolean",t.isInclusive)&&R("boolean",t.reverse)&&R("string",t.messageTypeFilter)&&L(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeReactions)&&R("boolean",t.includeParentMessageInfo)},bo=function(t){function a(t,s){var i,o,u,c;if(r(this,a),(i=n(this,a,[t,s])).translations={},i.messageType=e.MessageType.ADMIN,i.translations=null!==(o=s.translations)&&void 0!==o?o:{},s.parent_message_info){var l=s.parent_message_info;i.parentMessage=No(t,ve(_e(Object.assign(Object.assign({},l),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:l.file,url:null===(u=l.file)||void 0===u?void 0:u.url,require_auth:null===(c=l.file)||void 0===c?void 0:c.require_auth}))))}return i}return c(a,t),s(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Eo),t),ps(this.messageId>0&&R("number",e)&&ko(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(go),Co=function(){return s((function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&R("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return ve(_e({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}(),wo=function(){return s((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return ve({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),xo=function(t){function a(t,s){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,s])).messageParams=null,o.mentionedMessageTemplate=void 0,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o.messageType=e.MessageType.USER,o.translations=null!==(u=s.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=s.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=i(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.mentionedMessageTemplate=s.mentioned_message_template,o.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=s.plugins?s.plugins.map((function(e){return new Co(e)})):[],s.parent_message_info){var _=s.parent_message_info;o.parentMessage=No(t,ve(_e(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return s.review_info&&(o.messageReviewInfo=new wo(s.review_info)),o}return c(a,t),s(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Eo),t),ps(this.messageId>0&&R("number",e)&&ko(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,mentioned_message_template:e.mentionedMessageTemplate,plugins:e.plugins.map((function(e){return Co.payloadify(e)})),parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?wo.payloadify(e.messageReviewInfo):void 0})))}}])}(yo),So=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p;if(r(this,a),(i=n(this,a,[t,s])).messageParams=null,i.fileInfoList=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE,i.data=null!==(c=null!==(u=null===(o=s.file)||void 0===o?void 0:o.data)&&void 0!==u?u:s.custom)&&void 0!==c?c:"",i.fileInfoList=null!==(d=null===(l=s.files)||void 0===l?void 0:l.map((function(e){return new ro(t,e)})))&&void 0!==d?d:[],i.messageSurvivalSeconds=null!==(h=s.message_survival_seconds)&&void 0!==h?h:-1,s.parent_message_info){var v=s.parent_message_info;i.parentMessage=No(t,ve(_e(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:v.file,url:null===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return i}return c(a,t),s(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Eo),t),ps(this.messageId>0&&R("number",e)&&ko(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,s,i,o;return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(s=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==s?s:0,type:null!==(o=null===(i=e.fileInfoList[0])||void 0===i?void 0:i.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return ro.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}])}(yo);!function(e){e.SENT="SENT",e.READ="READ"}(mo||(mo={}));var To=function(t){function a(t,s){var i,o,u;if(r(this,a),(i=n(this,a,[t,s])).notificationData=null,i.notificationId=s.notification_message_id,i.messageType=e.MessageType.ADMIN,i.messageStatus=null!==(o=s.message_status)&&void 0!==o?o:mo.SENT,i.priority=null!==(u=s.priority)&&void 0!==u?u:oe.NORMAL,i.notificationEventDeadline=s.notification_event_deadline,0===i.extendedMessage.sub_type)try{var c=JSON.parse(i.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;i.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return i}return c(a,t),s(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(Oi),Io=function(t){if(t.notificationId)return To.payloadify(t);switch(t.messageType){case e.MessageType.USER:return xo.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?So.payloadify(t):Ao.payloadify(t);case e.MessageType.ADMIN:return bo.payloadify(t);default:throw M.unknown}},No=function(e,t){if(t.notification_message_id)return new To(e,t);switch(t.type){case"MESG":return new xo(e,t);case"FILE":return So._isMultipleFilesMessagePayload(t)?new So(e,t):new Ao(e,t);case"ADMM":case"BRDM":return new bo(e,t);default:return null}},Ao=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(i=n(this,a,[t,s])).messageParams=null,i.plainUrl="",i.requireAuth=!1,i.thumbnails=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE;var k=s.file;if(i.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:s.url)&&void 0!==u?u:"").split("?auth=")[0],i.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:s.name)&&void 0!==l?l:"File",i.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:s.size)&&void 0!==h?h:0,i.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:s.custom)&&void 0!==p?p:"",i.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=s.type)&&void 0!==_?_:"",i.requireAuth=null!==(m=s.require_auth)&&void 0!==m&&m,i.thumbnails=s.thumbnails?s.thumbnails.map((function(e){var t;return new mi(i._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),i.requireAuth)})):[],i.messageSurvivalSeconds=null!==(g=s.message_survival_seconds)&&void 0!==g?g:-1,s.parent_message_info){var b=s.parent_message_info;i.parentMessage=No(t,ve(_e(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return i}return c(a,t),s(a,[{key:"url",get:function(){var e=vi.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Eo),t),ps(this.messageId>0&&R("number",e)&&ko(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(yo),Mo=function(e){function t(e,a){var s,i=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(s=n(this,t,[e]))._plainUrl=o,s.file=i,s.fileName=u,s.fileSize=c,s.mimeType=l,s.thumbnailSizes=d,s._uploadedMetaData=h,s._thumbnails=f,s}return c(t,e),s(t,[{key:"fileUrl",get:function(){var e,t=vi.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}(ss),Uo=function(t){function a(t){var s,i,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:ve(_e({channel_url:t.channelUrl,files:t.files?Lo(t.files):null,url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return mi.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,message:t.message}))}])}return c(a,t),s(a)}(Xe),Oo=function(t){function a(t){var s,i,o;r(this,a),s=n(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=me.POST,s.path="".concat(He(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ve(_e({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?Lo(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t._thumbnails)||void 0===i?void 0:i.map((function(e){return mi.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Mi.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})),s}return c(a,t),s(a)}(Qe),Do=function(e){function t(e,a,s){var i,o,u,c,l;r(this,t),(i=n(this,t,[e,"FILE",s])).message=s.files&&s.files.length>=2?new So(e,s):new Ao(e,s);var d=vi.of(e).sdkState;return i.isMentioned=je(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return c(t,e),s(t)}(Ze),Ro=function(e){function t(e,a){var s,i,o,u,c;r(this,t),(s=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new So(e,a):new Ao(e,a);var l=vi.of(e).sdkState;return s.isMentioned=je(s.message.mentionType,null!==(u=null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:null===(o=s.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),s.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,s}return c(t,e),s(t)}(Ke);function Lo(e){return e.map((function(e){var t,n;return ve(_e({url:Mo.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e._thumbnails)||void 0===t?void 0:t.map((function(e){return mi.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Po;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Po||(Po={}));var Fo=function(){return s((function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Ba&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===qa.CONNECTED||this._connectionState===qa.CONNECTING||this._connectionState===qa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new Uo(r),n.next=5,this._requestQueue.send(a);case 5:return s=n.sent,i=s.as(Do),o=i.message,n.abrupt("return",o);case 10:return u=new Oo(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(Ro),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,s=[],o=!0,u=i(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===Po.PENDING||r.t0===Po.UPLOADING?14:r.t0===Po.UPLOADED?17:r.t0===Po.FAILED?35:38;break;case 14:return o=!1,s.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=Po.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,Ss(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:s.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:M.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?M.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=s,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===Po.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(s=a.multipleFileUploadInfo,i=s.uploadIndex,o=s.uploadCount,u=s.requestHandler,c=a.params,l=c.fileInfoList[i],!G(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=i<o-1?Po.PENDING:Po.UPLOADED;case 14:h=c.fileInfoList[i],f=a.multipleFileUploadInfo.uploadIndex++,a.multipleFileUploadInfo.isCopy||null==u||u._triggerOnFileUploaded(a.requestId,f,h,a.error),n.next=27;break;case 19:if(p=a.params,!G(p.file)){n.next=25;break}return n.next=23,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 23:n.next=27;break;case 25:p.thumbnailSizes=[],a.state=Po.UPLOADED;case 27:return this._uploadNextPendingItem(e),n.next=30,this._resolveMessageQueue(e);case 30:case"end":return n.stop()}}),n,this)})))}},{key:"_tryUploadNextItemAndUpdateItemState",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u,c,l,h;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._onlineDetector.isOnline();case 2:if(s=a.sent,i=vi.of(this._iid),i.sessionManager.currentUser&&s){a.next=8;break}return r.error=M.connectionRequired,r.state=Po.FAILED,a.abrupt("return");case 8:if(!(n.uploadQueue.length<6)){a.next=38;break}if(r.state=Po.UPLOADING,n.uploadQueue.push(r),a.prev=11,!r.multipleFileUploadInfo){a.next=20;break}return o=r.multipleFileUploadInfo,u=o.uploadIndex,c=o.uploadCount,l=r.params,a.next=17,this._uploadNextFileForMultipleFilesItemAndUpdateParams(t,r,l);case 17:r.state=u<c-1?Po.PENDING:Po.UPLOADED,a.next=24;break;case 20:return h=r.params,a.next=23,this._uploadNextFileForSingleFileItemAndUpdateParams(t,r,h);case 23:r.state=Po.UPLOADED;case 24:a.next=37;break;case 26:a.prev=26,a.t0=a.catch(11),a.t1=a.t0.code,a.next=a.t1===e.SendbirdErrorCode.REQUEST_FAILED?31:a.t1===e.SendbirdErrorCode.REQUEST_CANCELED?33:35;break;case 31:return r.error=new M({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"Failed to upload a file."}),a.abrupt("break",36);case 33:return r.error=M.fileUploadCanceled,a.abrupt("break",36);case 35:r.error=a.t0;case 36:r.state=Po.FAILED;case 37:this._dequeueUploadItem(n,r);case 38:case"end":return a.stop()}}),a,this,[[11,26]])})))}},{key:"_dequeueUploadItem",value:function(e,t){var n=e.uploadQueue.findIndex((function(e){return e.requestId===t.requestId}));n>=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,s;return E(this,void 0,void 0,d().mark((function i(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o=new gi({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),i.next=3,this._requestQueue.send(o);case 3:u=i.sent,c=u.as(yi),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return i.stop()}}),i,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,s;return E(this,void 0,void 0,d().mark((function i(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new gi({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),i.next=5,this._requestQueue.send(c);case 5:l=i.sent,h=l.as(yi),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r:u.file.name,u.mimeType=null!==(a=u.mimeType)&&void 0!==a?a:u.file.type,u.fileSize=null!==(s=u.fileSize)&&void 0!==s?s:u.file.size,u.file=void 0,u.fileUrl=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof Mo||(n.fileInfoList[o]=new Mo(this._iid,u));case 16:case"end":return i.stop()}}),i,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(s={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,s)),i=this._queueMap.get(e.url),o=new dt,u={requestId:t,params:n,state:Po.PENDING,deferred:o},qo(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),i.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,this)})))}},{key:"cancel",value:function(e,t){var n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:v(n.messageQueue),s=i(a);try{for(s.s();!(r=s.n()).done;){var o=r.value;if(o)switch(o.state){case Po.PENDING:if(o.state=Po.FAILED,o.error=M.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,M.fileUploadCanceled)}this._resolveMessageQueue(e);break;case Po.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ht({requestId:o.requestId}))}}}catch(e){s.e(e)}finally{s.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ht({requestId:t})))}}])}();function qo(e){return"fileInfoList"in e}var Ho,Go,jo={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Vo=function(t){return R("number",t.prevResultSize)&&R("number",t.nextResultSize)&&R("boolean",t.isInclusive)&&R("boolean",t.reverse)&&R("string",t.messageTypeFilter)&&L(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L(e.ReplyType,t.replyType)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeReactions)&&R("boolean",t.includeParentMessageInfo)&&R("boolean",t.includeThreadInfo)&&R("boolean",t.showSubchannelMessagesOnly)},zo={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Bo=function(t){return L(e.ReplyType,t.replyType)&&R("boolean",t.includeReactions)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeParentMessageInfo)&&R("boolean",t.includeThreadInfo)};!function(e){e.MESSAGE="message"}(Ho||(Ho={})),function(e){e.INTERNAL_BACKSYNC="internal_backsync",e.INTERNAL_FILL_GAP="internal_fill_gap",e.EXTERNAL_LEGACY="external_legacy",e.EXTERNAL_COLLECTION="external_collection"}(Go||(Go={}));var Qo,Ko=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions_summary:null!=c&&c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),s(t)}(Qe),Wo=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=a?No(e,Object.assign({},a)):null,s}return c(t,e),s(t)}(Ke),Yo=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages,x=e.sdkSource;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ve(_e({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions_summary:g,parent_message_id:y,include_thread_info:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w,sdk_source:x})),a}return c(t,e),s(t)}(Qe),Zo=function(e){function t(e,a){var s;return r(this,t),s=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(s.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(s.hasNext=a.has_next),s.messages=a.messages.map((function(t){return No(e,t)})),s}return c(t,e),s(t)}(Ke),Xo=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions_summary:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),s(t)}(Qe),Jo=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return No(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s.forceUseNextToken=a.force_use_next_token||!1,s}return c(t,e),s(t)}(Ke),$o=function(e){function t(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return c(t,e),s(t)}(Qe),eu=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=a?No(e,Object.assign({},a)):null,s}return c(t,e),s(t)}(Ke);e.RestrictionType=void 0,(Qo=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",Qo.BANNED="banned";var tu=function(){return s((function t(n){var a,s,i,o;r(this,t),this.restrictionType=null,L(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(i=null!==(s=n.end_at)&&void 0!==s?s:n.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return ve(_e({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),nu=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).restrictionInfo=new tu(a),s}return c(t,e),s(t,null,[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),tu.payloadify(e.restrictionInfo))))}}])}(_s),ru=function(e){function t(e,a){var s,i;return r(this,t),(s=n(this,t,[e,a])).isMuted=!1,s.isMuted=null!==(i=a.is_muted)&&void 0!==i&&i,s}return c(t,e),s(t)}(_s),au=function(){return s((function e(){r(this,e),this._onPending=_t,this._onFailed=_t,this._onSucceeded=_t}),[{key:"_trigger",value:function(t){switch(null==t?void 0:t.sendingStatus){case e.SendingStatus.PENDING:0===t.errorCode&&this._onPending(t);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(t)}}},{key:"_triggerFailed",value:function(t,n){switch(null==n?void 0:n.sendingStatus){case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}])}(),su={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1,pollId:void 0},iu=function(t){return R("string",t.data,!0)&&R("string",t.customType,!0)&&L(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(_s,t.mentionedUsers,!0)&&F(Mi,t.metaArrays,!0)&&R("number",t.parentMessageId,!0)&&R("boolean",t.isReplyToChannel)&&L(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&R(Ti,t.appleCriticalAlertOptions,!0)&&R("boolean",t.isPinnedMessage,!0)&&R("number",t.pollId,!0)},ou=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},uu=Object.assign(Object.assign({},su),{message:"",mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,extendedMessagePayload:void 0});function cu(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:_e(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),mentionedMessageTemplate:t.mentionedMessageTemplate,translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var lu,du=function(e){var t;return ve(_e({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},hu=function(e){return iu(e)&&R("string",e.message)&&R("string",e.mentionedMessageTemplate,!0)&&F("string",e.translationTargetLanguages,!0)&&R("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(lu||(lu={}));var fu=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},pu=function(e){return e===lu.BLOB||e===lu.FILE},vu=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},_u=Object.assign(Object.assign({},su),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1,message:void 0});function mu(t){var n,r,a,s;return null!==(n=t.messageParams)&&void 0!==n?n:_e(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=t.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1,_thumbnails:t.thumbnails,message:t.message}))}var gu,yu=function(e,t){var n,r;return e.messageParams?(!e.url&&G(t)&&(e.messageParams.file=t),e.messageParams):ve(_e({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),message:e.message,pollId:null===(r=e.poll)||void 0===r?void 0:r.id}))},Eu=function(e){return iu(e)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&R("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ku={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},bu=function(t){return R("string",t.data,!0)&&R("string",t.customType,!0)&&L(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(_s,t.mentionedUsers,!0)&&F(Mi,t.metaArrays,!0)&&L(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&R(Ti,t.appleCriticalAlertOptions,!0)},Cu=Object.assign(Object.assign({},ku),{message:void 0,mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,pollId:void 0}),wu=function(e){return bu(e)&&R("string",e.mentionedMessageTemplate,!0)&&R("string",e.message,!0)&&F("string",e.translationTargetLanguages,!0)&&R("number",e.pollId,!0)},xu=Object.assign({},ku),Su=function(e){return bu(e)},Tu=function(){return s((function e(t,n){var a;r(this,e),this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return R("number",this.limit)&&this.limit>0}}])}(),Iu=function(t){function a(e,t,s,i){var o;return r(this,a),(o=n(this,a,[e,i])).channelUrl=t,o.channelType=s,o}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("string",this.channelUrl)&&L(e.ChannelType,this.channelType)}}])}(Tu),Nu=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={token:o,limit:u},a}return c(t,e),s(t)}(Qe),Au=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).operators=a.operators.map((function(t){return new _s(e,t)})),s.token=a.next,s}return c(t,e),s(t)}(Ke),Mu=function(e){function t(e,a,s,i){return r(this,t),n(this,t,[e,a,s,i])}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=vi.of(this._iid),r=n.requestQueue,a=new Nu(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return s=e.sent,i=s.as(Au),o=i.operators,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Uu=function(t){function a(t,s,i,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,s,i,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("boolean",this.reverse)&&L(e.MessageTypeFilter,this.messageTypeFilter)&&L(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&R("boolean",this.includeMetaArray)&&R("boolean",this.includeReactions)&&R("boolean",this.includeParentMessageInfo)&&R("boolean",this.includeThreadInfo)&&R("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=xh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,_e({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw M.queryInProgress;case 16:e.next=19;break;case 18:throw M.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Ou=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={limit:o,token:u},a}return c(t,e),s(t)}(Qe),Du=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).mutedUsers=[];var i=a.next,o=a.muted_list;return s.token=i,o&&o.length>0&&(s.mutedUsers=o.map((function(t){return new nu(e,t)}))),s}return c(t,e),s(t)}(Ke),Ru=function(e){function t(e,a,s,i){return r(this,t),n(this,t,[e,a,s,i])}return c(t,e),s(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Ou(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Du),i=s.mutedUsers,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Lu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ve({limit:o,token:u}),a}return c(t,e),s(t)}(Qe),Pu=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new nu(e,t.user)}))),s}return c(t,e),s(t)}(Ke),Fu=function(e){function t(e,a,s,i){return r(this,t),n(this,t,[e,a,s,i])}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Lu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Pu),i=s.bannedUsers,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu);e.ReportCategory=void 0,(gu=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",gu.HARASSING="harassing",gu.SUSPICIOUS="suspicious",gu.INAPPROPRIATE="inappropriate";var qu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=me.POST,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return c(t,e),s(t)}(Qe),Hu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return c(t,e),s(t)}(Qe),Gu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return c(t,e),s(t)}(Qe),ju=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).isMuted=!1,s.startAt=0,s.endAt=0;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return c(t,e),s(t)}(Ke),Vu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),s(t)}(Qe),zu=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return c(t,e),s(t)}(Ke),Bu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=n(this,t)).method=me.POST,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),s(t)}(Qe),Qu=function(e){function t(e,a){var s,i,o;return r(this,t),(s=n(this,t,[e,a])).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return c(t,e),s(t)}(Ke),Ku=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=me.PUT,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),s(t)}(Qe),Wu=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return c(t,e),s(t)}(Ke),Yu=function(e){function t(e,a,s){var i;return r(this,t),i=n(this,t,[e,"SYEV",s]),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return c(t,e),s(t)}(Ze),Zu=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),s(t)}(Qe),Xu=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.ts;return s.ts=i,s}return c(t,e),s(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return c(t,e),s(t)}(Qe),$u=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.ts;return s.ts=i,s}return c(t,e),s(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return c(t,e),s(t)}(Qe),tc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).metaCounter=a,s}return c(t,e),s(t)}(Ke),nc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=me.POST,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return c(t,e),s(t)}(Qe),rc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).metaCounter=a,s}return c(t,e),s(t)}(Ke),ac=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=me.PUT,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),s(t)}(Qe),sc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).metaCounter=a,s}return c(t,e),s(t)}(Ke),ic=function(e){function t(e,a,s){var i;return r(this,t),i=n(this,t,[e,"SYEV",s]),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return c(t,e),s(t)}(Ze),oc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params={},a}return c(t,e),s(t)}(Qe),uc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={},a}return c(t,e),s(t)}(Qe),cc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=me.POST,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),s(t)}(Qe),lc=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new nu(e,s.data),i}return c(t,e),s(t)}(Ze),dc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),s(t)}(Qe),hc=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new nu(e,s.data),i}return c(t,e),s(t)}(Ze),fc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=me.POST,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ve({user_id:o,seconds:u,description:c}),a}return c(t,e),s(t)}(Qe),pc=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new nu(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return c(t,e),s(t)}(Ze),vc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=n(this,t)).method=me.DELETE,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),s(t)}(Qe),_c=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new nu(e,s.data),i}return c(t,e),s(t)}(Ze),mc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=n(this,t)).method=me.PUT,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return c(t,e),s(t)}(Qe),gc=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).freeze=s.data.freeze,i}return c(t,e),s(t)}(Ze),yc=function(e){return e instanceof li?e._custom?"custom":e.name:e},Ec=function(e){if(e instanceof li&&e._custom)return e.name},kc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=me.POST,a.path="".concat(Ge(i),"/").concat(encodeURIComponent(s)),a.params=ve({report_category:yc(o),reporting_user_id:u,report_description:c,custom_report_category_name:Ec(o)}),a}return c(t,e),s(t)}(Qe),bc=function(t){function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(s=n(this,a)).method=me.POST,s.path="".concat(Te,"/users/").concat(l),s.params=ve({channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:yc(u),reporting_user_id:c,report_description:d,custom_report_category_name:Ec(u)}),s}return c(a,t),s(a)}(Qe),Cc=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description;return(a=n(this,t)).method=me.POST,a.path="".concat(Ge(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params=ve({report_category:yc(o),reporting_user_id:u,report_description:d,offending_user_id:c,custom_report_category_name:Ec(o)}),a}return c(t,e),s(t)}(Qe),wc=function(t){function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:ve(_e({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),s(a)}(Xe),xc=function(e){function t(e,a,s){var i,o,u,c,l;r(this,t),(i=n(this,t,[e,"MESG",s])).message=new xo(e,s);var d=vi.of(e).sdkState;return i.isMentioned=je(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return c(t,e),s(t)}(Ze),Sc=function(t){function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:ve(_e({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),s(a)}(Xe),Tc=function(e){function t(e,a,s){var i,o,u,c,l,d;r(this,t),(i=n(this,t,[e,"MEDI",s])).message=new xo(e,s);var h=vi.of(e).sdkState;return i.mentionCountChange=Ve({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},_e({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return c(t,e),s(t)}(Ze),Ic=function(t){function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:ve(_e({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),s(a)}(Xe),Nc=function(e){function t(e,a,s){var i,o,u,c,l,d;r(this,t),(i=n(this,t,[e,"FEDI",s])).message=new Ao(e,s);var h=vi.of(e).sdkState;return i.mentionCountChange=Ve({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},_e({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return c(t,e),s(t)}(Ze),Ac=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),s(t)}(Qe),Mc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).reactionEvent=new bi(a),s}return c(t,e),s(t)}(Ke),Uc=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),s(t)}(Qe),Oc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).reactionEvent=new bi(Object.assign({},a)),s}return c(t,e),s(t)}(Ke),Dc=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),s(t)}(Qe),Rc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=new xo(e,a),s}return c(t,e),s(t)}(Ke),Lc=function(t){function a(t){var s,i;r(this,a),s=n(this,a);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=me.POST,s.path="".concat(He(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ve(_e({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:te.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return c(a,t),s(a)}(Qe),Pc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=new xo(e,a),s}return c(t,e),s(t)}(Ke),Fc=function(t){function a(t){var s,i,o;r(this,a),s=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return s.method=me.POST,s.path="".concat(He(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),s.params=_e({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:te.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(i=t._thumbnails)||void 0===i?void 0:i.map((function(e){return mi.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),s}return c(a,t),s(a)}(Qe),qc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=new Ao(e,a),s}return c(t,e),s(t)}(Ke),Hc=function(e){return R("string",e.title,!0)&&po(e.data)&&R("boolean",e.allowUserSuggestion,!0)&&R("boolean",e.allowMultipleVotes,!0)&&R("number",e.closeAt,!0)},Gc=function(e){function t(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(Ae,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),s(t)}(Qe),jc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),Vc=function(e){function t(e){var a,s=e.pollId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(Ae,"/").concat(encodeURIComponent(s)),a}return c(t,e),s(t)}(Qe),zc=function(e){function t(e){var a,s=e.pollId;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(Ae,"/").concat(encodeURIComponent(s),"/close"),a}return c(t,e),s(t)}(Qe),Bc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),Qc=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(Ae,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return c(t,e),s(t)}(Qe),Kc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),Wc=function(e){function t(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(Ae,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return c(t,e),s(t)}(Qe),Yc=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),Zc=function(e){function t(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(Ae,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return c(t,e),s(t)}(Qe),Xc=function(t){function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:ve({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),s(a)}(Xe),Jc=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),$c=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"VOTE",s])).event=new Jc(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return c(t,e),s(t)}(Ze),el=function(e){function t(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=me.POST,a.path=Ae,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),s(t)}(Qe),tl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),nl=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Ae,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return c(t,e),s(t)}(Qe),rl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).poll=new _o(e,a),s}return c(t,e),s(t)}(Ke),al=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Ae,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return c(t,e),s(t)}(Qe),sl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).pollOption=new vo(e,a),s}return c(t,e),s(t)}(Ke),il=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ve({change_ts:o,token:u}),a}return c(t,e),s(t)}(Qe),ol=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new _o(e,t)}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return c(t,e),s(t)}(Ke),ul={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},cl=function(e){return R("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&po(e.data)&&R("boolean",e.allowUserSuggestion,!0)&&R("boolean",e.allowMultipleVotes,!0)&&R("number",e.closeAt,!0);var t},ll={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},dl=function(t){return R("string",t.channelUrl)&&""!==t.channelUrl&&L(e.ChannelType,t.channelType)&&R("number",t.pollId)&&t.pollId>0&&R("number",t.pollOptionId)&&t.pollOptionId>0},hl={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},fl=function(t){return R("string",t.channelUrl)&&""!==t.channelUrl&&L(e.ChannelType,t.channelType)&&R("number",t.pollId)},pl={},vl=function(){return s((function e(t,n){var a=n.sdkState,s=n.dispatcher,i=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,pl[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=fs(e);return new _o(this._iid,_o.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(fl(e)).throw(M.invalidParameters),n=new nl(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(rl),s=a.poll,t.abrupt("return",s);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(cl(e)).throw(M.invalidParameters),n=new el(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(tl),s=a.poll,t.abrupt("return",s);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(dl(e)).throw(M.invalidParameters),n=new al(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(sl),s=a.pollOption,t.abrupt("return",s);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,i,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new il(_e({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(s);case 3:return i=e.sent,o=i.as(ol),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new eo({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return pl[e]}}])}(),_l="GroupChannel",ml="Message",gl="NotificationMessage",yl="UserInfo",El=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=me.GET,a.path=Ae,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return c(t,e),s(t)}(Qe),kl=function(e){function t(e,a){var s,i;return r(this,t),(s=n(this,t,[e,a])).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new _o(e,t)})),s.token=a.next,s}return c(t,e),s(t)}(Ke),bl=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),s(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new El(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(kl),i=s.polls,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Cl=function(e){function t(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Ae,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return c(t,e),s(t)}(Qe),wl=function(e){function t(e,a){var s,i;return r(this,t),(s=n(this,t,[e,a])).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new _s(e,t)})),s.token=a.next,s}return c(t,e),s(t)}(Ke),xl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,s.pollOptionId=a.pollOptionId,s}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&R("number",this.pollId)&&R("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Cl(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(wl),i=s.voters,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu);var Sl,Tl=Object.assign(Object.assign({},su),{fileInfoList:[],message:""}),Il=function(e){return(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Nl=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=_t,e}return c(t,e),s(t,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(au),Al=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e])).message=null,s.message=No(e,a.message),s}return c(t,e),s(t)}(ss),Ml=function(e){function t(e){var a;r(this,t);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ve({limit:o,token:u,include_reactions_summary:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),s(t)}(Qe),Ul=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new Al(e,t)})),s.hasMore=o,s.token=u,s}return c(t,e),s(t)}(Ke),Ol=function(e){function t(e,a,s,i){var o;return r(this,t),(o=n(this,t,[e,a,s,i])).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&R("boolean",this.includeMetaArray,!0)&&R("boolean",this.includeReactions,!0)&&R("boolean",this.includeParentMessageInfo,!0)&&R("boolean",this.includeThreadInfo,!0)&&R("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Ml(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Ul),i=s.pinnedMessages,o=s.hasMore,u=s.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Dl=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return c(t,e),s(t)}(Qe),Rl=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return c(t,e),s(t)}(Qe);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(Sl||(Sl={}));var Ll,Pl=function(t){function a(t,s){var i,o,u,c,l,d,h,f;return r(this,a),(i=n(this,a,[t]))._name="",i._createdAt=0,i.pinnedMessageIds=[],i.channelType=e.ChannelType.BASE,i.coverUrl="",i.customType="",i.data="",i.isFrozen=!1,i.isEphemeral=!1,i.creator=null,i._messageCollectionLastAccessedAt=0,i._url=s.channel_url,i._name=null!==(o=s.name)&&void 0!==o?o:"",i._createdAt=1e3*s.created_at,i.coverUrl=null!==(u=s.cover_url)&&void 0!==u?u:"",i.customType=null!==(c=s.custom_type)&&void 0!==c?c:"",i.data=null!==(l=s.data)&&void 0!==l?l:"",i.isFrozen=null!==(d=s.freeze)&&void 0!==d&&d,i.isEphemeral=null!==(h=s.is_ephemeral)&&void 0!==h&&h,i.creator=s.created_by?new _s(i._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(i._cachedMetaData=new Map,Object.keys(s.metadata).forEach((function(e){i._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(i._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),i.pinnedMessageIds=null!==(f=s.pinned_message_ids)&&void 0!==f?f:[],i}return c(a,t),s(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){Object.assign(this,e)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,s){var i;a.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(i=e[s])&&void 0!==i?i:a.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt<t&&(r.isRemoved=!0,r.updatedAt=t)}))}},{key:"_clearCachedMetaData",value:function(){this._cachedMetaData&&this._cachedMetaData.clear()}},{key:"_runIfHandleableWithGroupChannel",value:function(e){this.isGroupChannel()?e(this):this.isFeedChannel()&&e(this.groupChannel)}},{key:"_generateRequestId",value:function(){return"rq-".concat(le())}},{key:"isIdentical",value:function(e){return e&&this.url===e.url}},{key:"isEqual",value:function(e){return D(this,e)}},{key:"createOperatorListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Mu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ru(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Fu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Uu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ol(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new Hu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Gu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ju),o=i.isMuted,u=i.startAt,c=i.endAt,l=i.remainingDuration,h=i.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new Vu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return s=t.sent,i=s.as(zu),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new Vu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,s=a.as(zu),i=s.metadata,o=s.ts,this._updateCachedMetaData(i,o),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(Qu),o=i.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=new Ku({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(s);case 4:return i=n.sent,o=i.as(Wu),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new Zu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:s=t.sent,i=s.as(Xu),o=i.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,s=a.as($u),i=s.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),i);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new ec({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return s=t.sent,i=s.as(tc),o=i.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new ec({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,s=a.as(tc),i=s.metaCounter,e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new nc({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(rc),o=i.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=new ac({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(s);case 4:return i=n.sent,o=i.as(sc),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new ac({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(sc),o=i.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new ac({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(sc),o=i.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new oc({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new uc({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps(R("string",e)&&R("number",t,!0)&&R("string",n,!0)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new cc({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,s.send(i);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new dc({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps(R("string",e)&&R("number",t,!0)&&R("string",n,!0)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new fc({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,s.send(i);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new vc({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new mc({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new mc({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},jo),t),ps(R("number",e)&&Vo(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},jo),t),ps(R("number",e)&&Vo(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},zo),t),ps(R("number",e)&&Bo(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},zo),t),ps(R("string",e)&&Bo(r)).throw(M.invalidParameters),a=xh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=vi.of(this._iid).sessionManager;return ve(_e({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return Mi.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:s.currentUser?Ai.payloadify(s.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return _s.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,o=i(t.translationTargetLanguages);try{for(o.s();!(s=o.n()).done;){a[s.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=ve(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new xo(this._iid,u);return c.messageParams=t,c}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,s,i,o,u,c,l,d=ve(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(s=t.file)||void 0===s?void 0:s.name,size:null!==(i=t.fileSize)&&void 0!==i?i:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return mi.payloadify(e)})),message:t.message})),h=new Ao(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ve(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),s=new So(this._iid,a);return s.messageParams=t,s}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===e.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},uu),e);return ps(hu(t)).throw(M.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Sl.SEND,a=arguments.length>2?arguments[2]:void 0,s=vi.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new au;return Ss(2).then((function(){var a=n._createPendingUserMessage(t,u,c);i.dispatch(new Wi({messages:[a],source:r===Sl.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var s=new wc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(s).then((function(t){var r=t.as(xc).message;i.dispatch(new Wi({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Ss(2).then((function(){var a=n._createPendingUserMessage(t,u,c),s=vi.of(n._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&H(r.code);n._markMessageAsFailed(a,r,o),i.dispatch(new Wi({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ps(e instanceof xo&&!!e.messageParams).throw(M.invalidParameters),this._sendUserMessage(e.messageParams,Sl.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(e instanceof xo&&!e.scheduledInfo).throw(M.invalidParameters),r=new dt,a=null!==(t=e.messageParams)&&void 0!==t?t:du(e),this._sendUserMessage(a,Sl.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Cu),t),ps(R("number",e)&&wu(r)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new Sc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,s.send(i);case 6:return o=n.sent,u=o.as(Tc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,s,i;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ps(t instanceof a&&n instanceof xo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters),ps(!n.poll).throw(M.notSupportedError),u=new dt,c=null!==(r=n.messageParams)&&void 0!==r?r:_e(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(s=n.mentionedUserIds)&&void 0!==s?s:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(e instanceof xo&&e.messageId>0&&F("string",t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Dc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(s);case 5:return i=n.sent,o=i.as(Rc),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=vi.of(this._iid).requestQueue,a=Date.now(),s=this._generateRequestId();Ss(2).then((function(){var r=n._createPendingScheduledUserMessage(e,s,a);Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var i=new Lc(Object.assign({reqId:s,channelType:this.channelType,channelUrl:this.url},e));r.send(i).then((function(e){var r=e.as(Pc).message;Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Ss(2).then((function(){var i=n._createPendingScheduledUserMessage(e,s,a);n._markMessageAsFailed(i,r),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},_u),e);return ps(Eu(t)).throw(M.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},Tl),e),r=vi.of(this._iid);ps(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return iu(e)&&R("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Il(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(M.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return ps(!a).throw(M.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Sl.SEND,a=arguments.length>2?arguments[2]:void 0,s=vi.of(this._iid).dispatcher,i=xh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new au;return Ss(2).then((function(){var a=n._createPendingFileMessage(t,o,u);s.dispatch(new Wi({messages:[a],source:r===Sl.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),i.request(n,o,t).then((function(t){s.dispatch(new Wi({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Ss(2).then((function(){var a=n._createPendingFileMessage(t,o,u),i=vi.of(n._iid).cacheContext,l=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&H(r.code);n._markMessageAsFailed(a,r,l),s.dispatch(new Wi({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ps(e instanceof Ao&&!!e.messageParams).throw(M.invalidParameters);var t=vi.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,Sl.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,s=vi.of(this._iid).dispatcher,i=xh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Nl;return Ss(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);s.dispatch(new Wi({messages:[r],source:n===Sl.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Pa((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),i.request(a,o,t,{requestHandler:c,isCopy:n===Sl.COPY}).then((function(t){s.dispatch(new Wi({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Pa((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(A(n))throw n;Ss(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),s.dispatch(new Wi({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Pa((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,s=vi.of(this._iid).requestQueue,i=new Fc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));s.send(i).then((function(e){var n=e.as(qc).message;Pa((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(s){if(A(s))throw s;Ss(2).then((function(){var i=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(i,s),Pa((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(s,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ps(e.every((function(e){return Eu(Object.assign(Object.assign({},_u),e))}))).throw(M.invalidParameters);var t,n=new au,r=i(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(e)})).onFailed((function(e,t){return n._triggerFailed(e,t)})).onSucceeded((function(e){return n._trigger(e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ps(e instanceof Ao&&r&&!e.scheduledInfo).throw(M.invalidParameters),a=new dt,s=yu(e,t),this._sendFileMessage(s,Sl.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ps(e instanceof yo&&!e.scheduledInfo&&e.isResendable).throw(M.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:du(e);return this._sendUserMessage(a,Sl.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);ps(s).throw(M.invalidParameters);var i=null!==(r=e.messageParams)&&void 0!==r?r:yu(e,t);return this._sendFileMessage(i,Sl.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw M.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},xu),t),ps(R("number",e)&&Su(r)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new Ic(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,s.send(i);case 6:return o=n.sent,u=o.as(Nc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=le(),(s=new gi({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(s);case 7:return i=t.sent,o=i.as(yi),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=xh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,s,i;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ps(t instanceof a&&n instanceof Ao&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters),u=new dt,c=_e(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ps(t instanceof a&&n instanceof yo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters);var r=n,s=t;if(r.isUserMessage()){ps(!r.poll).throw(M.notSupportedError);var i=cu(r);return s._sendUserMessage(i)}if(r.isFileMessage()){var o=mu(r);return s._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw M.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ps(e instanceof go).throw(M.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=vi.of(this._iid),r=n.requestQueue,a=new ft({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof yo?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(e instanceof go&&e.messageId>0&&R("string",t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Ac({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(s);case 5:return i=n.sent,o=i.as(Mc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(e instanceof go&&e.messageId>0&&R("string",t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Uc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(s);case 5:return i=n.sent,o=i.as(Oc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l,h,f;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=vi.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new Sc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),s.next=4,u.send(c);case 4:return l=s.sent,h=l.as(Tc),f=h.message,o.dispatch(new Wi({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),s.abrupt("return",f);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l,h,f;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=vi.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new Ic({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),s.next=4,u.send(c);case 4:return l=s.sent,h=l.as(Nc),f=h.message,o.dispatch(new Wi({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),s.abrupt("return",f);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(e instanceof go&&e.messageId>0&&F("string",t)).throw(M.invalidParameters),r=t.map((function(e){return new Mi({key:e})})),!(e instanceof Ao)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(e instanceof go&&e.messageId>0&&F("string",t)).throw(M.invalidParameters),r=t.map((function(e){return new Mi({key:e})})),!(e instanceof Ao)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(e instanceof go&&e.messageId>0&&t.every((function(e){return e instanceof Mi}))).throw(M.invalidParameters),!(e instanceof Ao)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(e instanceof go&&e.messageId>0&&t.every((function(e){return e instanceof Mi}))).throw(M.invalidParameters),!(e instanceof Ao)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps((L(e.ReportCategory,t)||t instanceof li)&&R("string",n)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new kc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,category:t,description:n}),r.next=5,i.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ps(t instanceof _s&&(L(e.ReportCategory,n)||n instanceof li)&&R("string",r)).throw(M.invalidParameters),s=vi.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new bc({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ps(t instanceof yo&&(L(e.ReportCategory,n)||n instanceof li)&&R("string",r)).throw(M.invalidParameters),s=vi.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Cc({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("number",e)&&Hc(t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Gc(Object.assign({pollId:e},t)),n.next=5,a.send(s);case 5:return i=n.sent,o=i.as(jc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=R("number",e),ps(n).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Vc({pollId:e}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=R("number",e),ps(n).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new zc({pollId:e}),t.next=6,a.send(s);case 6:return i=t.sent,o=i.as(Bc),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=R("number",e)&&R("string",t)&&""!==t.trim(),ps(r).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new Qc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,s.send(i);case 6:return o=n.sent,u=o.as(Kc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=R("number",e)&&R("number",t)&&R("string",n)&&""!==n.trim(),ps(a).throw(M.invalidParameters),s=vi.of(this._iid),i=s.requestQueue,o=new Wc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,i.send(o);case 6:return u=r.sent,c=u.as(Yc),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=R("number",e)&&R("number",t),ps(r).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new Zc({pollId:e,pollOptionId:t}),n.next=6,s.send(i);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=R("number",t)&&F("number",n),ps(a).throw(M.invalidParameters),s=vi.of(this._iid),i=s.requestQueue,o=s.dispatcher,u=new Xc({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,i.send(u);case 6:return c=r.sent,l=c.as($c),h=l.event,o.dispatch(new no({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("number",e)).throw(M.invalidParameters),n=vl.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e,!0)),n=vl.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new bl(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new xl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("number",e)&&e>0).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new Dl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("number",e)&&e>0).throw(M.invalidParameters),n=vi.of(this._iid),r=n.requestQueue,a=new Rl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?_s.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}(ss),Fl=s((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ql=s((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new Fl(e)})):[]})),Hl=s((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ql(e)})):[]})),Gl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),s(t)}(s((function e(){r(this,e),this.onConnected=_t,this.onReconnectStarted=_t,this.onReconnectSucceeded=_t,this.onReconnectFailed=_t,this.onDisconnected=_t}))),jl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),s(t)}(s((function e(){r(this,e),this.onSessionExpired=_t,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=_t,this.onSessionRefreshed=_t,this.onSessionClosed=_t}))),Vl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),s(t)}(s((function e(){r(this,e),this.onFriendsDiscovered=_t,this.onTotalUnreadMessageCountChanged=_t,this.onTotalUnreadMessageCountUpdated=_t}))),zl=function(e){function t(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=me.GET,a.path=ye,a.params=ve({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),s(t)}(Qe),Bl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).users=a.users.map((function(t){return new _s(e,t)})),s.next=a.next,s}return c(t,e),s(t)}(Ke),Ql=function(e){function t(e,a){var s,i,o,u;return r(this,t),(s=n(this,t,[e,a])).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=a.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,s}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&F("string",this.userIdsFilter,!0)&&R("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&R("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new zl(_e(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Bl),i=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Tu),Kl=function(e){function t(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(s,"/block"),a.params=ve({limit:i,token:o,user_ids:u}),a}return c(t,e),s(t)}(Qe),Wl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).users=a.users.map((function(t){return new _s(e,t)})),s.next=a.next,s}return c(t,e),s(t)}(Ke),Yl=function(e){function t(e,a){var s,i;return r(this,t),(s=n(this,t,[e,a])).userIdsFilter=null,s.userIdsFilter=null!==(i=a.userIdsFilter)&&void 0!==i?i:null,s}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Kl(_e(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Wl),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Tu),Zl=function(e){function t(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return c(t,e),s(t)}(Qe),Xl=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).hasMore=a.has_more,s.users=a.users.map((function(t){return new _s(e,t)})),s.next=a.next,s}return c(t,e),s(t)}(Ke),Jl=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Zl(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Xl),o=i.users,u=i.hasMore,c=i.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Tu),$l={},ed=function(){return s((function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),$l[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,$l[n]=this),$l[n]}),null,[{key:"get",value:function(e){return $l[e]}}])}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ll||(Ll={}));var td,nd=function(e){function t(e){var a,s=e.code,i=void 0===s?Ll.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=i,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),s(t,null,[{key:"storeNotDefined",get:function(){return new t({code:Ll.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:Ll.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:Ll.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:Ll.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:Ll.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:Ll.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:Ll.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:Ll.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:Ll.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:Ll.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:Ll.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:Ll.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:Ll.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:Ll.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:Ll.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:Ll.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:Ll.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:Ll.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:Ll.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:Ll.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:Ll.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:Ll.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:Ll.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:Ll.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:Ll.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(td||(td={}));var rd,ad=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw nd.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return ad(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=ad(e[r],t)}))),t.delete(e),n}return e},sd=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw nd.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},id=function(e,t){for(var n=0,r=0;r<e.length;r++)n=e.charCodeAt(r)+(n<<6)+(n<<16)-n;return(n>>>0)%t},od=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},ud=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!ud(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!ud(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var s in a)switch(s){case"/eq":case"=":if(t[r]!==a[s])return!1;break;case"/neq":case"!=":if(t[r]===a[s])return!1;break;case"/gt":case">":var i=t[r],o=a[s];if(!(sd(i,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[s];if(!(sd(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[s];if(!(sd(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[s];if(!(sd(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[s].includes(p))return!1;break;case"/nin":var v=t[r];if(a[s].includes(v))return!1;break;case"/contain":var _=t[r],g=a[s];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[s].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[s])(E))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},cd=function(){},ld=function(){return Promise.resolve()},dd=function(e){return e},hd=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(rd||(rd={}));var fd,pd,vd,_d=function(){return s((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?dd:u,l=t.backward,d=void 0===l?ld:l,h=t.forward,f=void 0===h?ld:h,p=t.complete,v=void 0===p?cd:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),md=function(){return s((function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var a=0;a<this._indexer.fields.length;a++){var s=this._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),this.condition[s])if("object"===m(this.condition[s])){var o=i>0?n:t;for(var u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(i*sd(this._indexer.origin[c].columnValues[a],this.condition[s][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(i*sd(this._indexer.origin[l].columnValues[a],this.condition[s])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],s=1;if("-"===a[0]&&(a=a.slice(1),s=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(i){if((s>0?t:n).includes(i))for(var o=d;o<e._indexer.origin.length;o++)if(s*sd(e._indexer.origin[o].columnValues[r],e.condition[a][i])>=0){d=o;break}}));else for(var i=d;i<e._indexer.origin.length;i++)if(s*sd(e._indexer.origin[i].columnValues[r],e.condition[a])>=0){d=i;break}},f=0;f<this._indexer.fields.length;f++)h(f);return Math.max(d-1,0)}},{key:"each",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.findOptimizedStartPosition(),r=0,this.backward&&this._indexer.origin[n]&&(r=this._indexer.origin[n].keys.length-1),a=function(){if(c._indexer.origin[n]){if(!c._indexer.origin[n].keys[++r]){if(!c._indexer.origin[++n])return!1;r=0}return!0}return!1},s=function(){if(c._indexer.origin[n]){if(!c._indexer.origin[n].keys[--r]){if(!c._indexer.origin[--n])return!1;r=c._indexer.origin[n].keys.length-1}return!0}return!1},i=null,!this._indexer.origin[n]){t.next=15;break}o=this.backward?s:a;case 8:return t.next=10,this._blockManager.getFromBlock(this._indexer.origin[n].keys[r]);case 10:if(!(u=t.sent)||!ud(this.condition,u)){t.next=14;break}return i=u,t.abrupt("break",15);case 14:if(o()){t.next=8;break}case 15:return t.next=17,new Promise((function(t){var o=new _d({initialNextValue:ad(i),iterator:e,forward:function(){return E(c,void 0,void 0,d().mark((function e(){var t,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.backward?s:a;case 1:if(!t()){e.next=9;break}return e.next=4,this._blockManager.getFromBlock(this._indexer.origin[n].keys[r]);case 4:if(!(i=e.sent)||!ud(this.condition,i)){e.next=7;break}return e.abrupt("return",ad(i));case 7:e.next=1;break;case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)})))},backward:function(){return E(c,void 0,void 0,d().mark((function e(){var t,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.backward?a:s;case 1:if(!t()){e.next=9;break}return e.next=4,this._blockManager.getFromBlock(this._indexer.origin[n].keys[r]);case 4:if(!(i=e.sent)||!ud(this.condition,i)){e.next=7;break}return e.abrupt("return",ad(i));case 7:e.next=1;break;case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)})))},complete:t});e(o)}));case 17:return t.abrupt("return",t.sent);case 18:case"end":return t.stop()}}),t,this)})))}}])}(),gd=function(){return s((function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.mutex,u=t.blockManager,c=t.indexer;r(this,e),this._mutex=o,this._iterator=new md({condition:a,backward:i,blockManager:u,indexer:c})}),[{key:"fetch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw nd.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(s,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),0<r&&r<=a.length?e.stop():e.next()):(n--,e.next()):e.stop();case 1:case"end":return t.stop()}}),t)})))}));case 14:return this._mutex.unlock(),t.abrupt("return",a);case 18:throw t.prev=18,t.t0=t.catch(8),this._mutex.unlock(),t.t0;case 22:case"end":return t.stop()}}),t,this,[[8,18]])})))}},{key:"count",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=0,e.next=4,this._mutex.lock();case 4:return e.next=6,this._iterator.each((function(e){return E(n,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.error?e.stop():e.hasNext?(t++,e.next()):e.stop();case 1:case"end":return n.stop()}}),n)})))}));case 6:return this._mutex.unlock(),e.abrupt("return",t);case 10:throw e.prev=10,e.t0=e.catch(0),this._mutex.unlock(),e.t0;case 14:case"end":return e.stop()}}),e,this,[[0,10]])})))}}])}(),yd=function(e){return"".concat("nest","@").concat(e)},Ed=function(e,t){return"".concat(yd(e),"/").concat(t)},kd=function(e,t){return"".concat(Ed(e,t),".metadata")},bd=function(e,t){return"".concat(Ed(e,t),"/block.")},Cd=function(e,t){return"".concat(Ed(e,t),"/blob.")},wd=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Cd(e,t)).concat(n,".").concat(r)},xd=function(){return s((function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return s=t.sent,t.next=11,s.blob();case 11:return t.abrupt("return",t.sent);case 14:for(i=[],o=atob(r.split(",")[1]),u=0;u<o.length;u+=512){for(c=o.slice(u,u+512),l=new Array(c.length),h=0;h<c.length;h++)l[h]=c.charCodeAt(h);i.push(new Uint8Array(l))}return t.abrupt("return",new Blob(i,{type:a}));case 19:return t.abrupt("return",null);case 20:case"end":return t.stop()}}),t,this)})))}},{key:"save",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=wd(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,s=r.data,i=r.type,n.next=8,this.store.set({key:a,value:{data:s,type:i}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cd(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(fd||(fd={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(pd||(pd={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(vd||(vd={}));var Sd,Td,Id=[pd.PENDING,pd.VOLATILE],Nd={},Ad=function(){return s((function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),Nd[n]||(this.dbname=n,this._items=[],this._limit=s,Nd[n]=this),Nd[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vd.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(s=r.sent)&&(a={key:t,value:s,state:n===vd.PERSISTENT?pd.PERSISTENT:pd.VOLATILE},this.put(a)),r.next=9;break;case 8:n===vd.PERSISTENT&&(a.state=pd.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vd.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===vd.PERSISTENT&&(r.state=pd.PERSISTENT),t!==vd.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Id.includes(this._items[t].state)&&Id.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===pd.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],o=i(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===pd.VOLATILE&&r>0?r--:s.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(yd(e))}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==pd.VOLATILE}))}}],[{key:"get",value:function(e){return Nd[e]}}])}(),Md=function(){return s((function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Ed(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Ed(e,t),"/trans.recordset")}(n,a),this._store=s}),[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Ad.get(this.dbname),a=t.generation,s=t.requests,i=null,n.prev=3,n.next=6,this._store.setMany(s.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u<s.length;u++)o[u]instanceof Error&&(i||(i=o[u]),c=s[u].data,r.put(Object.assign(Object.assign({},c),{state:pd.PERSISTENT})));n.next=13;break;case 10:n.prev=10,n.t0=n.catch(3),i=n.t0;case 13:if(i){n.next=20;break}return l=e.filter((function(e){return e.generation!==a})),n.next=17,this._store.set({key:this.recordsetKey,value:l});case 17:this._onWrite.forEach((function(e){e(s.map((function(e){return e.data})))})),n.next=21;break;case 20:this._onError.forEach((function(e){i&&e(i)}));case 21:case"end":return n.stop()}}),n,this,[[3,10]])})))}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.get(this.metadataKey);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0={generation:1};case 5:return this._metadata=e.t0,e.next=8,this._getReducedRecordset();case 8:t=e.sent,n=i(t),e.prev=10,n.s();case 12:if((r=n.n()).done){e.next=18;break}return a=r.value,e.next=16,this._applyRecord(t,a);case 16:e.next=12;break;case 18:e.next=23;break;case 20:e.prev=20,e.t1=e.catch(10),n.e(e.t1);case 23:return e.prev=23,n.f(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,20,23,26]])})))}},{key:"on",value:function(e,t,n){switch(e){case fd.COMMIT:this._onCommit.set(t,n);break;case fd.WRITE:this._onWrite.set(t,n);break;case fd.ERROR:this._onError.set(t,n)}}},{key:"requestWrite",value:function(e,t){this._requests.push({data:e,options:t}),Ad.get(this.dbname).put(Object.assign({state:pd.PENDING},e))}},{key:"requestMultipleWrite",value:function(e,t){var n,r=Ad.get(this.dbname),a=i(e);try{for(a.s();!(n=a.n()).done;){var s=n.value;this._requests.push({data:s,options:t}),r.put(Object.assign({state:pd.PENDING},s))}}catch(e){a.e(e)}finally{a.f()}}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Ad.get(this.dbname).clearByCondition((function(e){return e.state===pd.PENDING})),this._requests=[];case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c,l,h,f,p,v,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((t=this._requests).length>0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)s=t[a],i=s.data,r[i.key]||(r[i.key]=!0,n.unshift(s));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=Ad.get(this.dbname),l=0;l<n.length;l++)h=n[l],f=h.data,p=h.options,c.put(Object.assign(Object.assign({},f),{state:p&&p.persistent?pd.PERSISTENT:pd.VOLATILE}));this._requests=[],this._onCommit.forEach((function(e){e(t.map((function(e){return e.data})))})),v=ed.get(this.dbname),setTimeout((function(){try{_._applyRecord(u,o)}catch(e){_._onError.forEach((function(t){return t(e)}))}}),v.transactionApplyDelay);case 20:case"end":return e.stop()}}),e,this)})))}}])}(),Ud=function(){function e(t){var n=t.blockId,a=t.keyName,s=t.items,i=void 0===s?[]:s,o=t.limit;r(this,e),this.blockId=n,this.keyName=a,this.limit=o,this._items=v(i)}return s(e,[{key:"isEmpty",get:function(){return 0===this._items.length}},{key:"items",get:function(){return this._items}},{key:"serialize",value:function(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}}},{key:"getItemByKey",value:function(e){var t=this,n=this._items.find((function(n){var r=n[t.keyName];return e===r}));return null!=n?n:null}},{key:"has",value:function(e){var t=this;return this._items.map((function(e){return e[t.keyName]})).includes(e)}},{key:"add",value:function(e){var t=this,n=this._items.map((function(e){return e[t.keyName]})).indexOf(e[this.keyName]);return n<0?this._items.length<this.limit&&(this._items.push(e),!0):(this._items[n]=e,!0)}},{key:"remove",value:function(e){for(var t=0;t<this._items.length;t++)if(this._items[t][this.keyName]===e)return this._items.splice(t,1),!0;return!1}},{key:"clear",value:function(){this._items=[]}}],[{key:"createFromCacheItem",value:function(t){return t?new e(t.value):null}}])}(),Od=function(){return s((function e(t){var n=t.dbname,a=t.collectionName,s=t.metadata,i=t.hashFunction,o=void 0===i?id:i,u=t.transaction,c=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.hashFunction=o,this.metadata=s,this._transaction=u,this._store=c}),[{key:"keyName",get:function(){return this.metadata.keyName}},{key:"createBlockId",value:function(e){var t,n,r,a,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||id)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(bd(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Ad.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(s=t.sent)){t.next=12;break}if(i=Ud.createFromCacheItem(s),!(null==i?void 0:i.getItemByKey(e))){t.next=12;break}return t.abrupt("return",i);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ed.get(this.dbname),a=this.createBlockId(e),s=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),i=Ad.get(this.dbname),n.next=6,i.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?Ud.createFromCacheItem(o):new Ud({blockId:a,keyName:this.keyName,items:[],limit:s}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=bd(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:Ad.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),Dd=function(){return s((function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Ed(e,t),"/index.").concat(n)}(a,s,o.join(">"));this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._store=c,this._transaction=u,this._transaction.on(fd.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(fd.ERROR,this.indexerKey,(function(){return n.abort()}))}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],s=i(this.fields);try{for(s.s();!(t=s.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw nd.indexTypesNotMatch;a.push(e[o])}}catch(e){s.e(e)}finally{s.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=sd(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Ad.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,vd.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=bd(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,s=i(a),e.prev=10,s.s();case 12:if((o=s.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,vd.NO_CACHE);case 17:if(c=e.sent,l=Ud.createFromCacheItem(c)){h=i(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}catch(e){h.e(e)}finally{h.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),s.e(e.t0);case 27:return e.prev=27,s.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=n.value,this._table=ad(this._origin);case 35:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ad.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=ad(this._origin)}},{key:"abort",value:function(){this._table=ad(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}}])}(),Rd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ld=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Sd||(Sd={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Td||(Td={}));var Pd,Fd={},qd=function(){return s((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Sd.PROCESSING,this._queue=[],this._activationQueue=[],Fd[t]&&!a.forceCreate||(this.nodeId=Ld(),this.key=t,Rd()&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,s=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&s===n.key)switch(o){case Td.NEWNODE:n._sendSync();break;case Td.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Td.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=i(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Td.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case Td.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Td.REQUEST_LOCK:n._requestLock(t);break;case Td.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case Td.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(Td.REMOVENODE)}))),Fd[t]=this),Fd[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Sd.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:Ld(),key:this.key,op:e,data:n.data,ts:Date.now()};return Rd()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Td.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Td.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1,s=0;s<t._queue.length;s++)if(t._queue[s].ts>r.ts){t._queue.splice(s,0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Td.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Sd.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Td.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Td.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(Td.REQUEST_LOCK),e.next=5,this._requestLock(t);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}])}(),Hd=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=td.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(v(u.filter((function(e){return Dd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new qd(function(e,t){return"".concat(Ed(e,t),".lock")}(a,s)),this._blobContainer=new xd({dbname:a,collectionName:s,store:c}),this._transaction=new Md({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===td.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=ed.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new Od({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),s=[],o=a.map((function(e){return Dd.createKey(e)})),u=r?r.indexes.map((function(e){return Dd.createKey(e)})):[],c=i(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||s.push(Dd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new Dd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(s.map((function(e){return new Dd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=kd(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=td.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=td.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=Dd.createKey(e),r=i(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===Dd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw nd.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=kd(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=i(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return s=a.value,t.next=20,s.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw nd.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=i(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return o=s.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=i(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=i(this._indexers),t.prev=8,a.s();case 10:if((s=a.n()).done){t.next=19;break}if(0===(o=s.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=i(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,s.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=i(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",ad(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw nd.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new gd({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw nd.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw nd.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(ad(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw nd.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!s._hasPropertyOfKeyName(e)}))){t.next=6;break}throw nd.collectionKeyNotGiven;case 6:n=i(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(ad(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw nd.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw nd.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(ad(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw nd.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!s._hasPropertyOfKeyName(e)}))){t.next=6;break}throw nd.collectionKeyNotGiven;case 6:n=i(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(ad(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw nd.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw nd.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(ad(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw nd.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,s=e.index,i=void 0===s?null:s,o=e.backward,u=void 0!==o&&o,c=[],l=new md({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(i)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}e.hasNext?(r=e.nextValue,ud(a,r)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var n;r[e]=null===(n=t.set)||void 0===n?void 0:n[e]})):t.set(r),c.push(r)),e.next()):e.stop(),n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h<f.length)){n.next=17;break}return p=f[h],n.next=14,this._requestUpdate(ad(p));case 14:h++,n.next=10;break;case 17:return n.next=19,this._transaction.commit();case 19:return this._mutex.unlock(),n.abrupt("return",c);case 23:return n.prev=23,n.t0=n.catch(3),n.next=27,this._transaction.clear();case 27:throw this._mutex.unlock(),n.t0;case 29:n.next=33;break;case 31:throw this._transaction.clear(),nd.collectionNotReady;case 33:case"end":return n.stop()}}),n,this,[[3,23]])})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=19;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._requestRemove(e);case 6:return t.next=8,this._transaction.commit();case 8:this._mutex.unlock(),t.next=17;break;case 11:return t.prev=11,t.t0=t.catch(3),t.next=15,this._transaction.clear();case 15:throw this._mutex.unlock(),t.t0;case 17:t.next=20;break;case 19:throw nd.collectionNotReady;case 20:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"removeIf",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l,h,f,p=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=29;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,n=e.where,r=void 0===n?{}:n,a=e.index,s=void 0===a?null:a,i=e.backward,o=void 0!==i&&i,u=[],c=new md({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}),t.next=9,c.each((function(e){return E(p,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}e.hasNext?(n=e.nextValue,ud(r,n)&&(a=n[this.keyName],u.push(a)),e.next()):e.stop(),t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),t,this)})))}));case 9:l=0,h=u;case 10:if(!(l<h.length)){t.next=17;break}return f=h[l],t.next=14,this._requestRemove(f);case 14:l++,t.next=10;break;case 17:return t.next=19,this._transaction.commit();case 19:return this._mutex.unlock(),t.abrupt("return",u);case 23:throw t.prev=23,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 27:t.next=31;break;case 29:throw this._transaction.clear(),nd.collectionNotReady;case 31:case"end":return t.stop()}}),t,this,[[3,23]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isReady){e.next=19;break}return e.next=3,this._mutex.lock();case 3:return e.prev=3,e.next=6,this._requestClear();case 6:return e.next=8,this._transaction.commit();case 8:this._mutex.unlock(),e.next=17;break;case 11:return e.prev=11,e.t0=e.catch(3),e.next=15,this._transaction.clear();case 15:throw this._mutex.unlock(),e.t0;case 17:e.next=20;break;case 19:throw nd.collectionNotReady;case 20:case"end":return e.stop()}}),e,this,[[3,11]])})))}},{key:"getBlob",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"saveBlob",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._blobContainer.save(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeBlob",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"removeAllBlobs",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blobContainer.clear();case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"metadataOf",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=kd(e,t),r.next=3,n.get(a);case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}}),r)})))}}])}(),Gd="[NESTDB]",jd=!0,Vd=function(){return s((function e(){r(this,e)}),null,[{key:"off",value:function(){jd=!1}},{key:"log",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];jd&&(e=console).log.apply(e,["".concat(Gd,"[LOG]")].concat(n))}},{key:"warning",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];jd&&(e=console).warn.apply(e,["".concat(Gd,"[WARNING]")].concat(n))}},{key:"error",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];jd&&(e=console).error.apply(e,["".concat(Gd,"[ERROR]")].concat(n))}}])}(),zd=[{},{a:700400,n:"error"}],Bd=function(){return s((function e(t){var n,a,s;r(this,e),this.encryption=null!==(n=t.encryption)&&void 0!==n?n:z,this.itemSizeLimit=null!==(a=t.itemSizeLimit)&&void 0!==a?a:4194304,this.metadataBuffer=null!==(s=t.metadataBuffer)&&void 0!==s?s:256}),[{key:"_encryptionCheckKey",get:function(){return"".concat(this.dbname,".encrypt")}},{key:"_reservedKeys",get:function(){return[this._encryptionCheckKey]}},{key:"_getRawKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:zd.map((function(e){var t;return null===(t=i.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),s=JSON.stringify(n.encrypted[r]),a===s){e.next=16;break}return Vd.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=i(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return s=a.value,e.next=11,this._getRaw(s);case 11:(o=e.sent)&&(t+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(s=r.metadata)?void 0:s.shards)&&s.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(s=n.sent){n.next=7;break}throw nd.storeBrokenIntegrity;case 7:return n.abrupt("return",s.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return i=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(i.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,s=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(s);case 9:return null==(i=Ad.get(this.dbname))||i.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Ad.get(this.dbname),r=[],a=i(e),t.prev=3,o=d().mark((function e(){var t,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(i=e.sent)&&(o=i.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((s=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=Ad.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),Qd={},Kd=function(e){function t(){var e,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},s),{itemSizeLimit:null!==(a=s.itemSizeLimit)&&void 0!==a?a:4194304})]);var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return c(t,e),s(t,[{key:"rawData",get:function(){return Qd[this.dbname]},set:function(e){Qd[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Qd[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Qd[this.dbname]));case 4:throw nd.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Qd[this.dbname]){t.next=6;break}return t.next=3,od(this.delay);case 3:return t.abrupt("return",Qd[this.dbname][e]?Object.assign({key:e},Qd[this.dbname][e]):null);case 6:throw nd.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Qd[this.dbname]){t.next=7;break}return t.next=3,od(this.delay);case 3:n=i(e);try{for(n.s();!(r=n.n()).done;)a=r.value,s=a.key,o=a.data,u=a.metadata,Qd[this.dbname][s]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw nd.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Qd[this.dbname]){t.next=7;break}return t.next=3,od(this.delay);case 3:n=i(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Qd[this.dbname][a]&&delete Qd[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw nd.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,Qd[this.dbname]||(Qd[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(s=a.value,!(o=this.observer[s.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,od(this.delay);case 4:Qd[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(Bd),Wd="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Pd||(Pd={}));var Yd,Zd=function(e){function t(){var e,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},s),{itemSizeLimit:null!==(a=s.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Wd,e._state=Pd.UNINITIALIZED,e._openJobQueue=[],e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return c(t,e),s(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Pd.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Wd,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=Pd.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Pd.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=Pd.UNINITIALIZED,r(e.target.error)}))}else r(nd.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===Pd.UNINITIALIZED||t.t0===Pd.OPEN?7:t.t0===Pd.OPENING||t.t0===Pd.CLOSED?8:9;break;case 7:throw nd.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=i(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return s=a.value,t.next=18,this._putToObjectStore(n,s);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=i(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return s=a.value,t.next=18,this._deleteFromObjectStore(n,s);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!Rd()){e.next=13;break}if(!(Rd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw nd.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(nd.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(nd.storeNotAvailable)}}catch(e){t(nd.storeNotAvailableInPrivateBrowsing)}else t(nd.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw nd.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,this._openDatabase(e);case 5:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(Bd),Xd=function(e){function t(e){var a;r(this,t);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?2097152:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}(e,["AsyncStorage","itemSizeLimit"]);return(a=n(this,t,[Object.assign(Object.assign({},u),{itemSizeLimit:o})]))._asyncStorage=s,a}return c(t,e),s(t,[{key:"_isBelonging",value:function(e){return e.startsWith("".concat(this.dbname,"/"))}},{key:"_getActualKey",value:function(e){return"".concat(this.dbname,"/").concat(e)}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._asyncStorage.getAllKeys();case 2:return t=e.sent,n=t.filter((function(e){return r._isBelonging(e)})),e.abrupt("return",n.map((function(e){return e.substring("".concat(r.dbname,"/").length)})));case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._asyncStorage.getItem(this._getActualKey(e));case 2:return n=t.sent,t.abrupt("return",n?JSON.parse(n):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],r=i(e);try{for(r.s();!(a=r.n()).done;)s=a.value,o=s.key,s.data.length<=this.adjustedItemSizeLimit&&n.push([this._getActualKey(o),JSON.stringify(s)])}catch(e){r.e(e)}finally{r.f()}return t.next=5,this._asyncStorage.multiSet(n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._asyncStorage.multiRemove(e.map((function(e){return n._getActualKey(e)})));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._asyncStorage){e.next=2;break}throw nd.storeNotAvailable;case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this._resetIfEncryptionChanged();case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this.getAllKeys();case 4:return t=e.sent,e.next=7,this.removeMany(t);case 7:case"end":return e.stop()}}),e,this)})))}}])}(Bd),Jd=function(e){function t(e){var a,s;return r(this,t),(a=n(this,t,[Object.assign(Object.assign({},e),{itemSizeLimit:null!==(s=e.itemSizeLimit)&&void 0!==s?s:6291456})]))._mmkv=e.MMKV,a}return c(t,e),s(t,[{key:"_isBelonging",value:function(e){return e.startsWith("".concat(this.dbname,"/"))}},{key:"_getActualKey",value:function(e){return"".concat(this.dbname,"/").concat(e)}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mmkv.getAllKeys();case 2:return t=e.sent,n=t.filter((function(e){return r._isBelonging(e)})),e.abrupt("return",n.map((function(e){return e.substring("".concat(r.dbname,"/").length)})));case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mmkv.getString(this._getActualKey(e));case 2:return n=t.sent,t.abrupt("return",n?JSON.parse(n):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i(e);try{for(n.s();!(r=n.n()).done;)a=r.value,s=a.key,a.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(s),JSON.stringify(a))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i(e);try{for(n.s();!(r=n.n()).done;)a=r.value,this._mmkv.delete(this._getActualKey(a))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return t.stop()}}),t,this)})))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._mmkv){e.next=2;break}throw nd.storeNotAvailable;case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this._resetIfEncryptionChanged();case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this.getAllKeys();case 4:return t=e.sent,e.next=7,this.removeMany(t);case 7:case"end":return e.stop()}}),e,this)})))}}])}(Bd),$d=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.usage();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))};!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Yd||(Yd={}));var eh,th=function(){return s((function e(t){var n=t.name,a=t.version,s=t.store,i=t.config;r(this,e),this.name=n,this._version=a,this._state=Yd.INIT,this._config=i||new ed({dbname:n}),this._store=s,this._event={success:cd,error:cd,storeReplaced:cd,upgrade:hd},this._collections=new Map,this._globalMutex=new qd("".concat(this.name,".lock")),this._config.disableLogger&&Vd.off(),new Ad({dbname:n,limit:this._config.cacheLimit})}),[{key:"version",get:function(){return this._version}},{key:"state",get:function(){return this._state}},{key:"store",get:function(){return this._store}},{key:"_initializeCollection",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,s,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(s=this._collections.get(e),!t){r.next=5;break}a=new Hd({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:null!==(n=t.index)&&void 0!==n?n:[[t.keyName]],store:this._store}),r.next=10;break;case 5:if(s&&s.state===td.READY){r.next=10;break}return r.next=8,Hd.metadataOf(this.name,e,this._store);case 8:(i=r.sent)&&(a=new Hd({dbname:this.name,collectionName:e,keyName:i.keyName,indexes:i.indexes,store:this._store}));case 10:if(!a){r.next=14;break}return this._collections.set(e,a),r.next=14,a.init();case 14:case"end":return r.stop()}}),r,this)})))}},{key:"estimateUsage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,$d(this._store);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commitSchema",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._state!==Yd.OPENING){t.next=5;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._initializeCollection(e.collectionName,e);case 2:case"end":return t.stop()}}),t,this)})))})));case 3:t.next=6;break;case 5:throw nd.databaseSchemaNotOnUpgrade;case 6:case"end":return t.stop()}}),t,this)})))}},{key:"open",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._globalMutex.lock();case 2:if(this._state===Yd.OPENED){t.next=66;break}return this._state=Yd.OPENING,t.prev=4,t.next=7,this._store.init(this.name);case 7:return l=this.name,n="".concat(yd(l),".metadata"),r={version:0,collectionNames:[]},t.next=11,this._store.get(n);case 11:if(t.t1=e=t.sent,t.t0=null!==t.t1,!t.t0){t.next=15;break}t.t0=void 0!==e;case 15:if(!t.t0){t.next=19;break}t.t2=e,t.next=20;break;case 19:t.t2=r;case 20:a=t.t2,s=i(a.collectionNames),t.prev=22,s.s();case 24:if((o=s.n()).done){t.next=30;break}return u=o.value,t.next=28,this._initializeCollection(u);case 28:t.next=24;break;case 30:t.next=35;break;case 32:t.prev=32,t.t3=t.catch(22),s.e(t.t3);case 35:return t.prev=35,s.f(),t.finish(35);case 38:return t.abrupt("return",new Promise((function(e,t){var r=function(e){a.version<c._version?c._event.upgrade(a.version,(function(t){return E(c,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(t){r.next=14;break}return a.version++,a.collectionNames=Array.from(this._collections.keys()),r.prev=3,r.next=6,this._store.set({key:n,value:a});case 6:e({continued:!0}),r.next=12;break;case 9:r.prev=9,r.t0=r.catch(3),e({continued:!1,err:r.t0});case 12:r.next=15;break;case 14:e({continued:!1,err:t});case 15:case"end":return r.stop()}}),r,this,[[3,9]])})))})):e({continued:!1})},s=function(n){var i=n.continued,o=void 0!==i&&i,u=n.err,l=void 0===u?null:u;o?setTimeout((function(){return r(s)}),10):l?(Vd.error(l.message),c._globalMutex.unlock(),c._event.error(l),t(l)):Promise.all(a.collectionNames.map((function(e){return c._initializeCollection(e)}))).then((function(){c._state=Yd.OPENED,c._globalMutex.unlock(),c._event.success(),e()})).catch((function(e){Vd.error(e.message),c._globalMutex.unlock(),c._event.error(e),t(e)}))};r(s)})));case 41:t.prev=41,t.t4=t.catch(4),t.t5=t.t4.code,t.next=t.t5===Ll.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING?46:t.t5===Ll.STORE_NOT_AVAILABLE?54:62;break;case 46:return Vd.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new Kd({}),this._globalMutex.unlock(),this._event.error(t.t4),this._event.storeReplaced(this._store),t.next=53,this.open();case 53:return t.abrupt("break",66);case 54:return Vd.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new Kd({}),this._globalMutex.unlock(),this._event.error(t.t4),this._event.storeReplaced(this._store),t.next=61,this.open();case 61:return t.abrupt("break",66);case 62:throw Vd.error(t.t4.message),this._globalMutex.unlock(),this._event.error(t.t4),t.t4;case 66:case"end":return t.stop()}var l}),t,this,[[4,41],[22,32,35,38]])})))}},{key:"close",value:function(){this._collections.forEach((function(e){return e.close()})),this._state=Yd.CLOSED}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Array.from(this._collections.values()).map((function(e){return e.clear()})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"reset",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=Ad.get(this.name))&&t.clearForDatabase(this.name),e.next=4,this._store.clear();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){this._event[e]=t}},{key:"off",value:function(e){if("function"==typeof this._event[e])if("upgrade"===e)this._event[e]=hd;else this._event[e]=cd}},{key:"collection",value:function(e){var t=this._collections.get(e);if(t)return t;throw nd.collectionNotReady}}])}();e.LogLevel=void 0,(eh=e.LogLevel||(e.LogLevel={}))[eh.VERBOSE=0]="VERBOSE",eh[eh.DEBUG=1]="DEBUG",eh[eh.INFO=2]="INFO",eh[eh.WARN=3]="WARN",eh[eh.ERROR=4]="ERROR",eh[eh.NONE=5]="NONE";var nh,rh=function(){return s((function t(){r(this,t),this.level=e.LogLevel.WARN}),[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];(t=console).log.apply(t,["[verbose]"].concat(r))}}},{key:"debug",value:function(){if(this.level<=e.LogLevel.DEBUG){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];(t=console).log.apply(t,["[debug]"].concat(r))}}},{key:"info",value:function(){if(this.level<=e.LogLevel.INFO){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];(t=console).log.apply(t,["[info]"].concat(r))}}},{key:"warn",value:function(){if(this.level<=e.LogLevel.WARN){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];(t=console).warn.apply(t,["[warn]"].concat(r))}}},{key:"error",value:function(){if(this.level<=e.LogLevel.ERROR){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];(t=console).error.apply(t,["[error]"].concat(r))}}}])}(),ah=function(){function t(n){var a,s,i,o;r(this,t),this.messageTypeFilter=null!==(a=null==n?void 0:n.messageTypeFilter)&&void 0!==a?a:e.MessageTypeFilter.ALL,this.customTypesFilter=null!==(s=null==n?void 0:n.customTypesFilter)&&void 0!==s?s:null,this.senderUserIdsFilter=null!==(i=null==n?void 0:n.senderUserIdsFilter)&&void 0!==i?i:null,this.replyType=null!==(o=null==n?void 0:n.replyType)&&void 0!==o?o:e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof yo))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof go)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof yo&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(nh||(nh={}));var sh,ih=function(e){switch(e){case nh.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case nh.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},oh=Object.assign(Object.assign({},uu),{scheduledAt:void 0}),uh=Object.assign(Object.assign({},su),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),ch="UnsentMessage",lh={},dh=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new qd("unsendmessagecache.lock"),lh[e]=a,a}return c(t,e),s(t,[{key:"_cacheContext",get:function(){return vi.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(ch);if(!t)throw M.databaseError;return t}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw M.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof xo?(e.messageParams&&(n.messageParams=ou(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},ou(t)),{scheduledAt:t.scheduledAt})))):e instanceof Ao?(e.messageParams&&(n.messageParams=vu(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},vu(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof So&&e.messageParams&&(n.messageParams=function(e){return ve({fileInfoList:e.fileInfoList.map((function(e){return{file:e.file,fileUrl:Mo.getPlainUrl(e),fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:e.thumbnailSizes,_thumbnails:e._thumbnails,_uploadedMetaData:e._uploadedMetaData}})),isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),xh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(s=xh.of(this._iid),i=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(i instanceof xo)){a.next=8;break}o=e.messageParams,i.messageParams=s.buildUserMessageCreateParamsFromSerializedData(o,i),a.next=32;break;case 8:if(!(i instanceof Ao)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!pu(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:i.messageParams=s.buildFileMessageCreateParamsFromSerializedData(u,i),a.next=32;break;case 26:if(!(i instanceof So)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return i.messageParams=s.buildMultipleFilesMessageCreateParamsFromSerializedData(c,i),a.next=32,Promise.all(i.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!pu(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=s=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==s;case 7:if(!t.t0){t.next=11;break}t.t2=s,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),t,this)})))})));case 32:if(!(i.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(i instanceof xo)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,i.scheduledInfo.scheduledMessageParams=s.buildScheduledUserMessageCreateParamsFromSerializedData(l,i),a.next=54;break;case 38:if(!(i instanceof Ao)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!pu(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:i.scheduledInfo.scheduledMessageParams=s.buildScheduledFileMessageCreateParamsFromSerializedData(h,i);case 54:return a.abrupt("return",i);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new ah:n,a=e.order,s=void 0===a?nh.CHANNEL_LATEST:a,i=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=ih(s),a={"/where":function(e){return!!(s!==nh.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),i&&(a.sendingStatus=i),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ah;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:nh.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ao||e instanceof So)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=i(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ao)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!fu(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=lu.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!fu(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:s=t.sent,a.fileKey=s,a.fileType=lu.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof So)){t.next=24;break}if(!((i=e.messageParams)&&i.fileInfoList&&Array.isArray(i.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(i.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!fu(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=lu.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return lh[e]&&!n||(lh[e]=new t(e)),lh[e]}}])}(ss),hh={},fh=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),hh[e]=a,a}return c(t,e),s(t,[{key:"_sdkState",get:function(){return vi.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return vi.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return dh.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ps(!!e).throw(M.databaseError),e.collection(ml)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),xh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,s=e.filter,i=void 0===s?new ah:s,o=e.order,u=void 0===o?nh.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,v=e.exactMatch,_=void 0!==v&&v,m=e.inclusive,g=void 0===m||m;return E(this,void 0,void 0,d().mark((function e(){var r,s,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=ih(u),s={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case nh.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAt<n||!g&&e.createdAt<=n)return!1}else if(g&&e.createdAt>n||!g&&e.createdAt>=n)return!1;break;case nh.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&i.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(s);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._deserialize(e));case 1:case"end":return t.stop()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ah;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:nh.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=i(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(s=a.value,!(null===(t=s.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(s.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&s.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=i(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:ih(nh.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=3;break}return r.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:n?{"<=":t}:{"<":t}},index:ih(nh.CHANNEL_LATEST)});case 3:case"end":return r.stop()}}),r,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=ih(nh.CHANNEL_LATEST),s=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,s.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ao&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!fu(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return s=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return i=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),s&&(n+=JSON.stringify(s).length),i&&(n+=JSON.stringify(i).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return hh[e]&&!n||(hh[e]=new t(e)),hh[e]}}])}(ss),ph={},vh=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),ph[e]=a,a}return c(t,e),s(t,[{key:"_sdkState",get:function(){return vi.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return vi.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ps(!!e).throw(M.databaseError),e.collection(gl)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return xh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,s=e.filter,i=void 0===s?new ah:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,s,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAt<n||!f&&e.createdAt<=n)return!1}else if(f&&e.createdAt>n||!f&&e.createdAt>=n)return!1}return i.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return s=e.sent,e.next=8,s.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=i(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:mo.SENT,createdAt:{"<":t}}},{set:{messageStatus:mo.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:mo.SENT}},{set:{messageStatus:mo.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ih(nh.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,i=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],s=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,s.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return ph[e]&&!n||(ph[e]=new t(e)),ph[e]}}])}(ss),_h={},mh=function(t){function a(t){var s;return r(this,a),(s=n(this,a,[t]))._observers=new Map,s._dispatcherContext=s._dispatcher.on((function(t){return E(s,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,U,O,D,R=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Wi)){n.next=19;break}if(r=t.messages,a=t.source,s=t.isWebSocketEventComing,i=r.filter((function(t){return t instanceof go&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof go&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof To})),!(i.length>0)){n.next=9;break}return n.next=8,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(i);case 2:return e.next=4,this._unsentMessageCache.remove(i.map((function(e){return e instanceof yo?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:s||this._broadcastUpdateEvent(i,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:s||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:s||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof Yi)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof $i)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof eo)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return R._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof to)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof no)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,Fa((function(){return E(R,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Xi?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Ji?(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M)):t instanceof Zi&&(U=t.messageDeletionTimestamp,O=t.channelUrl,D=t.source,this._broadcastMessageRetentionEvent(U,O,D));case 71:case"end":return n.stop()}}),n,this)})))})),s}return c(a,t),s(a,[{key:"_cacheContext",get:function(){return vi.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return vi.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return fh.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return dh.of(this._iid)}},{key:"_notificationCache",get:function(){return vh.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastMessageRetentionEvent",value:function(e,t,n){var r,a=i(this._observers.values());try{for(a.s();!(r=a.n()).done;){var s=r.value;s.onDeletedByRetentionPolicy&&s.onDeletedByRetentionPolicy(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return _h[e]&&!n||(_h[e]&&(null===(t=_h[e]._dispatcherContext)||void 0===t||t.close()),_h[e]=new a(e)),_h[e]}}])}(ss),gh={},yh=function(e){function t(e,a){var s,i=a.sdkState,o=a.cacheContext;return r(this,t),(s=n(this,t,[e]))._users=new Map,s._sdkState=i,s._cacheContext=o,gh[e]=s,s}return c(t,e),s(t,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ps(!!e).throw(M.databaseError),e.collection(yl)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"users",get:function(){return v(this._users.values())}},{key:"_serialize",value:function(e,t){return Object.assign(Object.assign({},e.serialize()),{updatedAt:t})}},{key:"_deserialize",value:function(e){return _s._buildUserFromSerializedData(e)}},{key:"isCachedInMemory",value:function(e){return this._users.has(e)}},{key:"getUserInfoFromCache",value:function(e){if(this._users.has(e))return this._users.get(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._users.has(e)){t.next=12;break}if(!this.localCacheEnabled){t.next=9;break}return t.next=4,this.collection.getByKey(e);case 4:if(!(n=t.sent)){t.next=9;break}return r=this._deserialize(n),this._users.set(r.userId,r),t.abrupt("return",r);case 9:return t.abrupt("return",void 0);case 12:return t.abrupt("return",this._users.get(e));case 13:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.limit,n=void 0===t?100:t,r=e.backward,a=void 0!==r&&r;return E(this,void 0,void 0,d().mark((function e(){var t,r,s,i,o=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.localCacheEnabled){e.next=2;break}return e.abrupt("return",[]);case 2:return e.prev=2,t={index:["-userId","-updatedAt"],backward:a},e.next=6,this.collection.query(t);case 6:return r=e.sent,e.next=9,r.fetch({limit:n});case 9:return s=e.sent,(i=s.map((function(e){return o._deserialize(e)}))).forEach((function(e){o._users.has(e.userId)||o._users.set(e.userId,e)})),e.abrupt("return",i);case 15:return e.prev=15,e.t0=e.catch(2),e.abrupt("return",[]);case 18:case"end":return e.stop()}}),e,this,[[2,15]])})))}},{key:"upsert",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=11;break}if(r=this._serialize(e,t),!(a=this._users.get(e.userId))){n.next=8;break}if(a._hashValue!==e._hashValue){n.next=6;break}return n.abrupt("return");case 6:if(!(a._updatedAt>t)){n.next=8;break}return n.abrupt("return");case 8:return this._users.set(e.userId,_s._buildUserFromSerializedData(r)),n.next=11,this.collection.upsertOne(r);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._users.has(e)&&this._users.delete(e),!this.localCacheEnabled){t.next=4;break}return t.next=4,this.collection.remove(e);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"clearMemoryCache",value:function(){this._users.clear()}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.clearMemoryCache(),!this.localCacheEnabled){e.next=4;break}return e.next=4,this.collection.clear();case 4:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return gh[e]}}])}(ss),Eh=function(e){function t(e){var a;r(this,t);var s=e.reverse,i=void 0!==s&&s,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=me.GET,a.path="".concat(Re),a.params=ve({token:l,limit:u,reverse:i,order:ue.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),s(t)}(Qe),kh=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return s.nextToken=i,s.hasMore=u,s.templates=c.map((function(e){return{template:JSON.stringify(e)}})),s}return c(t,e),s(t)}(Ke),bh=function(e){function t(e){var a;r(this,t);var s=e.key;return(a=n(this,t)).method=me.GET,a.path="".concat(Re,"/").concat(s),a}return c(t,e),s(t)}(Qe),Ch=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).template=JSON.stringify(a),s}return c(t,e),s(t)}(Ke),wh={},xh=function(){return s((function e(t,n){var a=n.sdkState,s=n.dispatcher,i=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,fh.of(t),dh.of(t),mh.of(t),this.fileMessageQueue=new Fo(t,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),wh[t]=this}),[{key:"_setSenderInfo",value:function(t){if(this._cacheContext.localCacheEnabled&&(t.messageType===e.MessageType.USER||t.messageType===e.MessageType.FILE)){var n=t.sender;if(n){var r=yh.of(this._iid).getUserInfoFromCache(n.user_id);r&&(t.sender=_s.payloadify(r))}}}},{key:"buildMessageFromSerializedData",value:function(t){var n=fs(t);if(n.notificationId)return new To(this._iid,To.payloadify(n));switch(this._setSenderInfo(n),n.messageType){case e.MessageType.USER:return new xo(this._iid,xo.payloadify(n));case e.MessageType.FILE:return So._isMultipleFilesMessageSerializedData(n)?new So(this._iid,So.payloadify(n)):new Ao(this._iid,Ao.payloadify(n));case e.MessageType.ADMIN:return new bo(this._iid,bo.payloadify(n))}throw M.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ve(_e({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ve(_e({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){var n=this;return ve({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList.map((function(e){return new Mo(n._iid,e)}))})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=fs(e);return new Ai(this._iid,Ai.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ko(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Wo),s=a.message,t.abrupt("return",s);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new $o(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(eu),s=a.message,t.abrupt("return",s);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var i,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Yo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},jo),a),{sdkSource:Go.EXTERNAL_LEGACY})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Zo),c=u.messages,this._dispatcher.dispatch(new Wi({messages:c,source:s})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var i,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Yo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},jo),a),{sdkSource:Go.EXTERNAL_LEGACY})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Zo),c=u.messages,this._dispatcher.dispatch(new Wi({messages:c,source:s})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,i=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,u=arguments.length>7?arguments[7]:void 0;return E(this,void 0,void 0,d().mark((function e(){var c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=new Yo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},jo),a),{checkingHasNext:i,checkingContinuousMessages:o,sdkSource:u})),e.next=3,this._requestQueue.send(c);case 3:return l=e.sent,h=l.as(Zo),f=h.messages,p=h.isContinuousMessages,v=h.hasNext,this._dispatcher.dispatch(new Wi({messages:f,source:s})),e.abrupt("return",{messages:f,isContinuousMessages:p,hasNext:v});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=new Yo(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},Eo),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),s.next=3,this._requestQueue.send(i);case 3:return o=s.sent,u=o.as(Zo),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Wi({messages:l,source:a})),s.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return s.stop()}}),s,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new Eh(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,s=a.as(kh),i=s.hasMore,o=s.nextToken,u=s.templates,n.abrupt("return",{hasMore:i,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new bh({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ch),s=a.template,t.abrupt("return",{template:s});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Xo(ve(_e(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},zo),a)))),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Jo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=u.forceUseNextToken,v=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Wi({messages:c,source:s})),v.length>0&&this._dispatcher.dispatch(new Yi({messageIds:v,source:s})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:v,hasMore:h,token:f,forceUseNextToken:p});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return wh[e]}}])}(),Sh=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e])).targetMessageId=0;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&R("object",i)&&R("number",o)&&R("string",u)&&R("string",c)&&(s.threadInfo=new Ei(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return c(t,e),s(t)}(ss),Th={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ih=function(t){return R("string",t.channelUrl)&&L(e.ChannelType,t.channelType)&&R("number",t.messageId)&&R("boolean",t.includeReactions,!0)&&R("boolean",t.includeMetaArray,!0)&&R("boolean",t.includeParentMessageInfo,!0)&&R("boolean",t.includeThreadInfo,!0)},Nh=function(e){function t(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Se,"/messages"),a.params=ve({custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_}),a}return c(t,e),s(t)}(Qe),Ah=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).messages=a.results.map((function(t){return No(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return c(t,e),s(t)}(Ke);e.MessageSearchOrder=void 0,(sh=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",sh.TIMESTAMP="ts";var Mh,Uh,Oh,Dh=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a,[t,s])).keyword="",i.reverse=!1,i.exactMatch=!1,i.channelUrl=null,i.channelCustomType=null,i.messageTimestampFrom=null,i.messageTimestampTo=null,i.order=e.MessageSearchOrder.SCORE,i.advancedQuery=!1,i.targetFields=null,i._nextToken="",i.totalCount=-1,i.keyword=s.keyword,i.reverse=null!==(o=s.reverse)&&void 0!==o&&o,i.exactMatch=null!==(u=s.exactMatch)&&void 0!==u&&u,i.channelUrl=null!==(c=s.channelUrl)&&void 0!==c?c:null,i.channelCustomType=null!==(l=s.channelCustomType)&&void 0!==l?l:null,i.messageTimestampFrom=null!==(d=s.messageTimestampFrom)&&void 0!==d?d:null,i.messageTimestampTo=null!==(h=s.messageTimestampTo)&&void 0!==h?h:null,i.order=null!==(f=s.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,i.advancedQuery=null!==(p=s.advancedQuery)&&void 0!==p&&p,i.targetFields=null!==(v=s.targetFields)&&void 0!==v?v:null,i}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("string",this.keyword)&&this.keyword.length>0&&R("boolean",this.reverse)&&R("boolean",this.exactMatch)&&R("string",this.channelUrl,!0)&&R("string",this.channelCustomType,!0)&&R("number",this.messageTimestampFrom,!0)&&R("number",this.messageTimestampTo,!0)&&L(e.MessageSearchOrder,this.order)&&R("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Nh(_e(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Ah),i=s.messages,o=s.hasNext,u=s.nextToken,c=s.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",i);case 15:return e.abrupt("return",[]);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(Tu),Rh=function(e){function t(e){var a,s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/messages/parent_thread_message"),a.params=ve(_e({limit:o,token:u})),a}return c(t,e),s(t)}(Qe),Lh=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).token=a.next,s.messages=a.messages.map((function(t){return No(e,t)})),s}return c(t,e),s(t)}(Ke),Ph=function(e){function t(e,a,s,i){var o;return r(this,t),(o=n(this,t,[e,a,s,i]))._edge="",o}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Rh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Lh),i=s.messages,o=s.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Fh={channelUrl:"",scheduledMessageId:0},qh=function(e){return R("string",e.channelUrl)&&""!==e.channelUrl&&R("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Hh={reverse:!1,limit:20},Gh=function(e){return R("boolean",e.reverse,!0)&&R("number",e.limit,!0)&&F("string",e.keys,!0)},jh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),s(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new xh(e,{sdkState:r,dispatcher:a,requestQueue:i,onlineDetector:u,cacheContext:c})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Th),e),ps(Ih(n)).throw(M.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof go||r instanceof To||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Fh),e),ps(qh(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Hh),t),ps(R("string",e,!0)&&Gh(r)).throw(M.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(_i),Vh=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),zh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),s(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new vl(e,{sdkState:r,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ul),e),ps(cl(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hl),e),ps(fl(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ll),e),ps(dl(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(_i),Bh={profileImage:void 0,profileUrl:void 0,nickname:void 0},Qh=function(e){return G(e.profileImage,!0)&&R("string",e.profileUrl,!0)&&R("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(Mh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Mh.CHRONOLOGICAL="chronological",Mh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Mh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Uh=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Uh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Uh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Oh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Oh.SCHEDULED_AT="scheduled_at";var Kh,Wh=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},Yh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:_l,keyName:"url",index:[Wh(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Wh(e.GroupChannelListOrder.CHRONOLOGICAL),Wh(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ml,keyName:"messageId",index:[ih(nh.CHANNEL_LATEST),ih(nh.NEWEST_CHILD_MESSAGE)]},{collectionName:ch,keyName:"reqId",index:[ih(nh.CHANNEL_LATEST),ih(nh.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:gl,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v5:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:yl,keyName:"userId",index:[["-userId","-updatedAt"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Zh=function(t){var n=new rh;return function(r,a){return E(void 0,void 0,void 0,d().mark((function s(){var i,o,u,c,l,h,f;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:s.t0=r,s.next=1===s.t0||2===s.t0||3===s.t0||4===s.t0?3:5===s.t0?5:6===s.t0?9:7===s.t0?27:38;break;case 3:return a(),s.abrupt("break",39);case 5:return s.next=7,t.reset();case 7:return a(),s.abrupt("break",39);case 9:return s.prev=9,i=Yh(t),o=i.v2,u=i.v3,c=i.v4,s.next=13,o();case 13:return s.next=15,u();case 15:return s.next=17,c();case 17:return l=t.collection(ml),s.next=20,l.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:s.next=25;break;case 22:s.prev=22,s.t1=s.catch(9),n.warn("Failed to migrate to v2, v3, v4");case 25:return a(),s.abrupt("break",39);case 27:return s.prev=27,h=Yh(t),f=h.v5,s.next=31,f();case 31:s.next=36;break;case 33:s.prev=33,s.t2=s.catch(27),n.warn("Failed to migrate to v5");case 36:return a(),s.abrupt("break",39);case 38:a();case 39:case"end":return s.stop()}}),s,null,[[9,22],[27,33]])})))}},Xh=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Jh=function(e){function t(e){var a,s=e.getVisibilityState,i=void 0===s?Xh:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),s(t,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}])}(he),$h=function(){return s((function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}),[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:me.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),ef=function(e){function t(e){var a,s=e.message;return r(this,t),(a=n(this,t)).message=s,a}return c(t,e),s(t)}(pe),tf={},nf=function(){return s((function e(t,n){var a=this,s=n.localCacheEnabled,i=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,tf[t]=this,this._localCacheEnabled=s,this._enableAutoResend=i,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof Ba)switch(e.stateType){case qa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case qa.INTERNAL_DISCONNECTED:case qa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=i(n);try{for(r.s();!(a=r.n()).done;)0===(s=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=e.SendingStatus.FAILED,s.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Wi({messages:[s],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=i(n);try{for(r.s();!(a=r.n()).done;)s=a.value,this._enableAutoResend&&s.errorCode&&H(s.errorCode)&&(o=(new Date).getTime(),u=s.createdAt+2592e5,this._enableAutoResend&&o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),s.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new Wi({messages:[s],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!H(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=dh.of(this._iid),(r=new ah).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new ef({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return tf[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Kh||(Kh={}));var rf,af=function(){return s((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new _s(e,r),blockee:new _s(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new _s(e,t)})):[]}}}])}(),sf=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),s(t)}(pe),of=function(e){function t(e,a){var s,i=a.userId;return r(this,t),(s=n(this,t))._iid=e,s.userId=i,s}return c(t,e),s(t)}(pe),uf=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),s(t)}(pe),cf=function(e){function t(e){var a,s=e.configTs;return r(this,t),(a=n(this,t)).configTs=s,a}return c(t,e),s(t)}(pe),lf=function(e){function t(e){var a,s;return r(this,t),(a=n(this,t)).method=me.GET,a.path=qe,a.params=ve(_e({ts:"number"==typeof e.token?e.token:void 0,token:"string"==typeof e.token?e.token:void 0,limit:null!==(s=e.limit)&&void 0!==s?s:100})),a}return c(t,e),s(t)}(Qe),df=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).configs=a.configs,s.hasMore=a.has_more,s.nextToken=a.next,s.ts=a.ts,s}return c(t,e),s(t)}(Ke),hf=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"USEV",s])).event=new af(s),i}return c(t,e),s(t)}(Ze),ff=function(e){function t(e){var a,s=e.userId,i=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s)),a.params=ve(_e({nickname:i,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),s(t)}(Qe),pf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).user=new _s(e,Object.assign({},a)),s}return c(t,e),s(t)}(Ke),vf=function(e){function t(e){var a,s=e.userId,i=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/apns"),a.params=ve({apns_device_token:i,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),s(t)}(Qe),_f=function(e){function t(e){var a,s=e.userId,i=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params=ve({gcm_reg_token:i,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),s(t)}(Qe),mf=function(e){function t(e){var a,s=e.userId,i=e.token;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return c(t,e),s(t)}(Qe),gf=function(e){function t(e){var a,s=e.userId,i=e.token;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return c(t,e),s(t)}(Qe),yf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/apns"),a}return c(t,e),s(t)}(Qe),Ef=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return c(t,e),s(t)}(Qe),kf=function(e){function t(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),s(t)}(Qe),bf=function(t){function a(t,s){var i;return r(this,a),(i=n(this,a,[t,s])).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return c(a,t),s(a)}(Ke),Cf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return c(t,e),s(t)}(Qe),wf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).autoAccept=a.auto_accept,s}return c(t,e),s(t)}(Ke),xf=function(e){function t(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return c(t,e),s(t)}(Qe),Sf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).autoAccept=a.auto_accept,s}return c(t,e),s(t)}(Ke),Tf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a}return c(t,e),s(t)}(Qe),If=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return c(t,e),s(t)}(Ke),Nf=function(e){function t(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),s(t)}(Qe),Af=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return c(t,e),s(t)}(Ke),Mf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a}return c(t,e),s(t)}(Qe),Uf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return c(t,e),s(t)}(Ke),Of=function(e){function t(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),s(t)}(Qe),Df=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return c(t,e),s(t)}(Ke),Rf=function(e){function t(e){var a,s=e.userId,i=e.blockedUserId;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return c(t,e),s(t)}(Qe),Lf=function(e){function t(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return c(t,e),s(t)}(Qe),Pf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a}return c(t,e),s(t)}(Qe),Ff=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,s}return c(t,e),s(t)}(Ke),qf=function(e){function t(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return c(t,e),s(t)}(Qe),Hf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,s}return c(t,e),s(t)}(Ke),Gf=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/template"),a}return c(t,e),s(t)}(Qe),jf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).name=a.name,s}return c(t,e),s(t)}(Ke),Vf=function(e){function t(e){var a,s=e.userId,i=e.templateName;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return c(t,e),s(t)}(Qe),zf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).name=a.name,s}return c(t,e),s(t)}(Ke),Bf=function(e){function t(e){var a,s=e.userId,i=e.token;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return c(t,e),s(t)}(Qe),Qf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new _s(e,t)})),updatedUsers:a.updated.map((function(t){return new _s(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return c(t,e),s(t)}(Ke),Kf=function(e){function t(e){var a,s=e.userId,i=e.discoveries;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),s(t)}(Qe),Wf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return c(t,e),s(t)}(Ke),Yf=function(e){function t(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return c(t,e),s(t)}(Qe),Zf=function(e){function t(e){var a,s=e.userId,i=e.userIds;return r(this,t),(a=n(this,t)).method=me.POST,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return c(t,e),s(t)}(Qe),Xf=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).users=a.users.map((function(t){return new _s(e,t)})),s}return c(t,e),s(t)}(Ke),Jf=function(e){function t(e){var a,s=e.userId,i=e.userIds;return r(this,t),(a=n(this,t)).method=me.DELETE,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return c(t,e),s(t)}(Qe),$f=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return c(t,e),s(t)}(Qe),ep=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,s}return c(t,e),s(t)}(Ke),tp=function(e){function t(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return c(t,e),s(t)}(Qe),np=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=me.GET,e.path=Ne,e}return c(t,e),s(t)}(Qe),rp=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).emojiContainer=new Hl(a),s}return c(t,e),s(t)}(Ke),ap=function(e){function t(e){var a,s=e.categoryId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Ne,"/").concat(s),a}return c(t,e),s(t)}(Qe),sp=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).emojiCategory=new ql(a),s}return c(t,e),s(t)}(Ke),ip=function(e){function t(e){var a,s=e.key;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Ie,"/").concat(s),a}return c(t,e),s(t)}(Qe),op=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).emoji=new Fl(a),s}return c(t,e),s(t)}(Ke),up=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=me.GET,e.path="".concat(Ue),e}return c(t,e),s(t)}(Qe),cp=function(e){function t(e,a){var s,i;r(this,t);var o=null!=a?a:{};return(s=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return c(t,e),s(t)}(Ke),lp=function(e){function t(e){var a,s=e.appConfigsInfo,i=e.configTs;return r(this,t),(a=n(this,t)).appConfigsInfo={},a.configTs=0,a.appConfigsInfo=s,a.configTs=i,a}return c(t,e),s(t)}(pe);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(rf||(rf={}));var dp,hp=function(e){function t(e){var a,s=e.deviceToken,i=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=me.POST,a.path=Le,a.params=ve({device_token:s,push_tracking_id:i,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),s(t)}(Qe);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(dp||(dp={}));var fp,pp,vp=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t))._state=dp.IDLE,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=a,s}return c(t,e),s(t,[{key:"isIdle",get:function(){return this._state===dp.IDLE}},{key:"isRunning",get:function(){return this._state===dp.RUNNING}},{key:"isDone",get:function(){return this._state===dp.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount<this._retryLimit?(this._retryCount++,this._run(e)):this.stop();case 14:case"end":return t.stop()}}),t,this,[[1,10]])})))}},{key:"start",value:function(e){this.isIdle&&(this._state=dp.RUNNING,this._run(e))}},{key:"stop",value:function(){this._state=dp.IDLE,this.dispatch("stop")}},{key:"end",value:function(){this._state=dp.END,this.dispatch("end")}}])}(he),_p=function(){function t(e,n,a){var s=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var i=vi.of(e),o=i.sdkState,u=i.cacheContext,c=i.dispatcher,l=i.sessionManager,h=i.requestQueue,f=i.logger,p=i.userEventHandlers,v=i.appStateToggleEnabled;this._onlineDetector=new $h({logger:f,connectionDelegate:{reconnect:function(){return E(s,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=vi.of(e),r=n.sdkState,a=n.connectionManager,(s=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(s.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!A(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!A(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new sf);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){Fa((function(){return E(s,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new nf(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:s._onlineDetector}),s[t.name]=t})),this._appStateChangeDetector=new Jh({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),s.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),s.setBackgroundState()})),c.on((function(t){var n;if(t instanceof Ba){if(t.stateType===qa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ze){if("USEV"===t.code){var r=t.as(hf).event;if(r.category===Kh.FRIEND_DISCOVERED){var a=af.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;Pa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(t instanceof Ga){var i=vi.of(s._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>i.ts&&(i.all!==t.all&&(c=!0),i.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){i.customTypes[e]!==t.customTypes[e]&&(c=!0),i.customTypes[e]=t.customTypes[e]})),c=c&&i.ts>0,i.ts=l),c&&Pa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:i.all,feedChannelCount:i.feed,customTypeUnreadCount:i.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(i.all,i.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof ms?(u.preference.set(s._getUserProfileCacheKey(o.userId),gs.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Za(s.appId),{value:!0})):t instanceof Es?t.configSyncNeeded&&Fa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAppConfigsInfo();case 2:case"end":return e.stop()}}),e,this)})))})):t instanceof cf?u.preference.set(as(s.appId),{configTs:t.configTs}):t instanceof Ye&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),s._internalDisconnect(t.error))}))}return s(t,[{key:"appId",get:function(){return vi.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=vi.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=vi.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!vi.of(this._iid).debugMode}},{key:"logLevel",get:function(){return vi.of(this._iid).logger.level},set:function(e){vi.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return vi.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=vi.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return vi.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=vi.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=vi.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=vi.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{key:"_getNestDBVersion",value:function(){return 8}},{key:"_getPreferenceVersion",value:function(){return 9}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.connectionManager,a=n.sdkState,s=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"_getAppConfigsInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=t.dispatcher,a=t.cacheContext,s=t.sdkState,i={},e.next=4,a.preference.get(as(s.appId));case 4:(u=e.sent)&&(o=u.configTs),new vp("appConfigsInfo",(function(e){return E(c,void 0,void 0,d().mark((function t(){var a,s,o,u,c,l,h,f;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:e},s=new lf({token:e}),t.next=4,n.send(s);case 4:return o=t.sent,u=o.as(df),c=u.configs,l=u.hasMore,h=u.nextToken,f=u.ts,Object.keys(c).forEach((function(e){i[e]=c[e]})),a.hasNext=l,a.nextToken=h,l||r.dispatch(new lp({appConfigsInfo:i,configTs:f})),t.abrupt("return",a);case 11:case"end":return t.stop()}}),t)})))})).start(o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=vi.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Kd?n.store:null;throw M.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=vi.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=vi.of(this._iid),a=r.logger,s=r.sdkState,i=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!i.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o<u.length;o++){var c=f(u[o],2),l=c[0],d=c[1];if(/&|=/.test(l)||/&|=/.test(d))return a.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}return s.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.cacheContext,t.prev=1,t.next=4,r.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),r.replaceStore(new Kd),t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),t,this,[[1,7]])})))}},{key:"setLocaleForChatbot",value:function(e){var t=vi.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)}},{key:"initializeCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=vi.of(this._iid),r=n.sdkState,a=n.cacheContext,s=n.dispatcher,i=n.logger,r.userId&&r.userId===e){t.next=38;break}if(o="sendbird@".concat(r.appId,"/").concat(e,".db"),t.prev=3,!a.localCacheEnabled){t.next=21;break}if(a.nestdb&&a.nestdb.state!==Yd.CLOSED&&a.nestdb.name===o){t.next=16;break}return u="sendbird@".concat(r.appId,"/").concat(e,".db"),(c=a.nestdb=new th({name:u,version:this._getNestDBVersion(),store:a.store,config:new ed({dbname:u,itemSizeLimit:61440})})).on("upgrade",Zh(c)),c.on("storeReplaced",(function(e){a.replaceStore(e),a.localCacheEnabled=!1,c.on("upgrade",Zh(c))})),t.next=12,c.open();case 12:this._storeInitialized=!0,s.dispatch(new of(this._iid,{userId:e})),t.next=18;break;case 16:return t.next=18,this._safeInitializeStore(o);case 18:r.userId=e,t.next=24;break;case 21:return t.next=23,this._safeInitializeStore(o);case 23:r.userId=e;case 24:t.next=34;break;case 26:return t.prev=26,t.t0=t.catch(3),i.warn("Nest DB Open Failed. ",t.t0),a.store instanceof Kd||(a.replaceStore(new Kd),a.localCacheEnabled=!1),t.next=32,this._safeInitializeStore(o);case 32:throw r.userId=e,M.databaseError;case 34:return t.prev=34,t.next=37,this._setupPreference(e);case 37:return t.finish(34);case 38:case"end":return t.stop()}}),t,this,[[3,26,34,38]])})))}},{key:"getCacheDataSize",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=vi.of(this._iid),!(n=t.cacheContext).localCacheEnabled||!n.nestdb){e.next=5;break}return e.next=4,n.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=vi.of(this._iid),!(n=t.cacheContext).localCacheEnabled){e.next=5;break}if(!n.nestdb){e.next=5;break}return e.next=5,n.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,n.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ps(F("string",e)).throw(M.invalidParameters),n=fh.of(this._iid),r=dh.of(this._iid),!n||!r){t.next=6;break}return t.next=6,Promise.all(e.map((function(e){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.removeMessagesOfChannel(e);case 2:return t.next=4,r.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),t)})))})));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setupPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.sdkState,a=n.cacheContext,s=n.statManager,t.next=3,a.preference.init(this._getPreferenceCacheKey(e),this._getPreferenceVersion());case 3:return t.next=5,a.preference.get(this._getUserProfileCacheKey(e));case 5:return(i=t.sent)&&new gs(this._iid,i).apply(),t.next=9,s.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"_ready",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ps(R("string",e)&&R("string",t,!0)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!s.userId||s.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=vi.of(this._iid),c.dispatcher.dispatch(new uf),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=vi.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T.SESSION_TOKEN;return E(this,void 0,void 0,d().mark((function a(){var s,i,o;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return s=vi.of(this._iid),i=s.sessionManager,o=s.connectionManager,a.next=3,this._ready(e,t,{errorForOtherUser:o.isConnected?M.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(K.CHAT)){a.next=7;break}return i.handler||t&&r!==T.ACCESS_TOKEN||this.setSessionHandler(new jl),a.next=7,i.authenticate(e,t);case 7:return a.abrupt("return",this.currentUser);case 8:case"end":return a.stop()}}),a,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=vi.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=vi.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=vi.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=vi.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new sf))}},{key:"setSessionHandler",value:function(e){ps(e instanceof jl).throw(M.invalidParameters),vi.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ps(R("string",e)&&t instanceof Vl).throw(M.invalidParameters),vi.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){vi.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){vi.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ps(R("string",e)&&t instanceof Gl).throw(M.invalidParameters),vi.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){vi.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){vi.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ql(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yl(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Jl(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Dh(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new bl(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new xl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=fs(e);return new _s(this._iid,_s.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Bh),e),ps(Qh(n)).throw(M.invalidParameters),!this.currentUser){t.next=13;break}return r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ff(Object.assign({userId:a.userId},n)),t.next=7,s.send(i);case 7:return o=t.sent,u=o.as(pf),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw M.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ps(F("string",e)).throw(M.invalidParameters),!this.currentUser){t.next=12;break}return n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new ff({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(s);case 6:return i=t.sent,o=i.as(pf),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw M.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l,h,f=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(ps(R("string",t)&&R("string",null==n?void 0:n.deviceManufacturer,!0)).throw(M.invalidParameters),(null==n?void 0:n.deviceOS)&&ps(L(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&R("string",n.deviceOS.version,!0)).throw(M.invalidParameters),!this.currentUser){s.next=22;break}if(i={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},s.prev=4,o=vi.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){s.next=8;break}return s.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new _f({userId:c.userId,token:t,deviceOS:i.deviceOS,deviceManufacturer:i.deviceManufacturer,systemPushEnabled:i.systemPushEnabled}),s.next=11,l.send(h);case 11:return s.next=13,Fa((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,i),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",s.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return s.prev=17,s.t0=s.catch(4),s.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:s.next=24;break;case 22:return this._fcmPushToken=t,s.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return s.stop()}}),s,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(R("string",t)).throw(M.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=vi.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new gf({userId:s.userId,token:t}),n.next=7,i.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,Fa((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=vi.of(this._iid),r=n.sessionManager,a=n.sdkState,s=n.requestQueue,i=new Ef({userId:a.userId}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,Fa((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l,h,f=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(ps(R("string",t)&&R("string",null==n?void 0:n.deviceManufacturer,!0)).throw(M.invalidParameters),(null==n?void 0:n.deviceOS)&&ps(L(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&R("string",n.deviceOS.version,!0)).throw(M.invalidParameters),!this.currentUser){s.next=22;break}if(i={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},s.prev=4,o=vi.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){s.next=8;break}return s.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new vf({userId:c.userId,token:t,deviceOS:i.deviceOS,deviceManufacturer:i.deviceManufacturer,systemPushEnabled:i.systemPushEnabled}),s.next=11,l.send(h);case 11:return s.next=13,Fa((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,i),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",s.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return s.prev=17,s.t0=s.catch(4),s.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:s.next=24;break;case 22:return this._apnsPushToken=t,s.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return s.stop()}}),s,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ps(R("string",t)).throw(M.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=vi.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new mf({userId:s.userId,token:t}),n.next=7,i.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,Fa((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=vi.of(this._iid),r=n.sessionManager,a=n.sdkState,s=n.requestQueue,i=new yf({userId:a.userId}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,Fa((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=vi.of(this._iid),s=a.logger,i=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,s.debug("markPushNotificationAsDelivered:",e),c=rf.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw s.info("Can't use markPushNotificationAsDelivered() feature."),M.malformedDataError;case 7:if(f.includes(Xs.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw s.info("Can't use markPushNotificationAsDelivered() feature."),M.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return s.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new hp({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),s.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=vi.of(this._iid),a=r.logger,s=r.sessionManager,i=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=rf.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsClicked() feature."),M.malformedDataError;case 7:if(h.includes(Xs.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsClicked() feature."),M.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,y=new hp({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,i.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Cf({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(wf),o=i.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("boolean",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new xf({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Sf),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Tf({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(If),o=i.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function i(){var o,u,c,l,h,f,p;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return ps(R("boolean",e)&&R("number",t)&&R("number",n)&&R("number",r)&&R("number",a)&&R("string",s)).throw(M.invalidParameters),o=vi.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new Nf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:s}),i.next=5,c.send(l);case 5:return h=i.sent,f=h.as(Af),p=f.preference,i.abrupt("return",p);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Mf({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Uf),o=i.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps(R("boolean",e)&&R("number",t)&&R("number",n)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Of({userId:s.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,i.send(o);case 5:return u=r.sent,c=u.as(Df),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps(R("string",t)&&L(e.PushTokenType,n)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new kf({userId:s.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(bf),f=h.pushTokens,p=i(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Pf({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,e.abrupt("return",s.as(Ff).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(L(e.PushTriggerOption,t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new qf({userId:a.userId,pushTriggerOption:t}),n.next=5,s.send(i);case 5:return o=n.sent,n.abrupt("return",o.as(Hf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Gf({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,e.abrupt("return",s.as(jf).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(L(e.PushTemplate,t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Vf({userId:a.userId,templateName:t}),n.next=5,s.send(i);case 5:return o=n.sent,n.abrupt("return",o.as(zf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(e instanceof _s||R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Rf({userId:r.userId,blockedUserId:e instanceof _s?e.userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(e instanceof _s||R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Lf({userId:r.userId,unblockedUserId:e instanceof _s?e.userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Bf({userId:r.userId,token:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Qf),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new $f({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ep),o=i.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("boolean",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tp({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(s);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Kf({userId:r.userId,discoveries:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Wf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Yf({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Zf({userId:r.userId,userIds:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Xf),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(F("string",e)).throw(M.invalidParameters),n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Jf({userId:r.userId,userIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new np,e.next=4,n.send(r);case 4:return a=e.sent,s=a.as(rp),i=s.emojiContainer,e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new ap({categoryId:e}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(sp),o=i.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.requestQueue,a=new ip({key:e}),t.next=4,r.send(a);case 4:return s=t.sent,i=s.as(op),o=i.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),ps(t.hasExtension("sb_uikit")).throw(M.notSupportedError),n=t.requestQueue,r=new up,e.next=6,n.send(r);case 6:return a=e.sent,s=a.as(cp),i=s.uikitConfiguration,e.abrupt("return",i);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getReportCategoryInfoList",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.reportCategoryManager,e.next=3,n.categories();case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,s=n.modules,i=void 0===s?[]:s,o=n.options,u=void 0===o?new V:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new Y:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!fp||p){var I="su-".concat(le()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new rh;A.level=null!=_?_:e.LogLevel.WARN;var M=new Kd({encryption:N});l||(ut()?x?M=new Jd({MMKV:x,encryption:N}):C&&(M=new Xd({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Zd({encryption:N})),new vi(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var U=[new jh,new zh],O=new t(I,u,[].concat(v(i),U));return fp||(fp=O),O}return fp}},{key:"instance",get:function(){return fp}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(pp=e.MemberState||(e.MemberState={})).NONE="none",pp.JOINED="joined",pp.INVITED="invited",pp.LEFT="left";var mp,gp,yp,Ep,kp,bp,Cp,wp,xp=function(t){function a(t,s){var i;return r(this,a),(i=n(this,a,[t,s])).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=L(e.MemberState,s.state)?s.state:null,i.role=L(e.Role,s.role)?s.role:null,"boolean"==typeof s.is_muted&&(i.isMuted=s.is_muted),"boolean"==typeof s.is_blocked_by_me&&(i.isBlockedByMe=s.is_blocked_by_me),"boolean"==typeof s.is_blocking_me&&(i.isBlockingMe=s.is_blocking_me),i}return c(a,t),s(a,null,[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(nu),Sp=function(t){function a(t,s){var i,o,u;return r(this,a),(i=n(this,a,[t])).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.member=new _s(i._iid,s.user),i.deliveryAt=s.ts,i}return c(a,t),s(a)}(ss);e.PublicChannelFilter=void 0,(mp=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",mp.PUBLIC="public",mp.PRIVATE="private",e.MyMemberStateFilter=void 0,(gp=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",gp.JOINED="joined_only",gp.INVITED="invited_only",gp.INVITED_BY_FRIEND="invited_by_friend",gp.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(yp=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",yp.SUPER="super",yp.NON_SUPER="nonsuper",yp.BROADCAST_ONLY="broadcast_only",yp.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Ep=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Ep.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(kp=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",kp.UNHIDDEN="unhidden_only",kp.HIDDEN="hidden_only",kp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",kp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(bp=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",bp.OPERATOR="operator",bp.NONOPERATOR="nonoperator",e.QueryType=void 0,(Cp=e.QueryType||(e.QueryType={})).AND="AND",Cp.OR="OR",e.GroupChannelSearchField=void 0,(wp=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",wp.CHANNEL_NAME="channel_name";var Tp,Ip=function(){function t(n){var a,s,i,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(s=null==n?void 0:n.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(i=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==i?i:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return s(t,[{key:"_isFriend",value:function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a<n.length;++a)if(n[a]!==r[a])return!1;return!0}(o,l))return!1}}if(!this.includeEmpty&&!t.lastMessage)return!1;if(!this.includeFrozen&&t.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.ALL:if("none"===t.myMemberState)return!1;break;case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!(this.createdAfter&&t.createdAt<this.createdAfter)&&!(this.createdBefore&&t.createdAt>this.createdBefore)}}])}(),Np=function(t){function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n(this,a,[e]))._channels=new Map,s._sdkState=i,s._cacheContext=o,s}return c(a,t),s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ps(!!e).throw(M.databaseError),e.collection(_l)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Jv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp<e.messageOffsetTimestamp}))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._channels.has(e)){t.next=12;break}if(!this.localCacheEnabled){t.next=9;break}return t.next=4,this.collection.getByKey(e);case 4:if(!(n=t.sent)){t.next=9;break}return r=this._deserialize(n),this._channels.set(e,r),t.abrupt("return",r);case 9:return t.abrupt("return",void 0);case 12:return t.abrupt("return",this._channels.get(e));case 13:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(t){var n=t.token,r=t.limit,a=void 0===r?100:r,s=t.backward,i=void 0!==s&&s,o=t.filter,u=void 0===o?new Ip:o,c=t.order,l=void 0===c?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:c,h=t.borderlineChannelUrl;return E(this,void 0,void 0,d().mark((function t(){var r,s,o,c,f,p,v=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=13;break}return r=!!h,s=Wh(l),o={where:function(t){if(n)switch(l){case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!i&&t.name.localeCompare(n)<0||i&&t.name.localeCompare(n)>0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!i&&t.createdAt>n||i&&t.createdAt<n)return!1;break;case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(!i&&t.lastMessageUpdatedAt>n||i&&t.lastMessageUpdatedAt<n)return!1}return r&&h&&h===t.url?(r=!1,!1):!r&&u.match(v._deserialize(t),v._sdkState.userId)},index:s,backward:i},t.next=6,this.collection.query(o);case 6:return c=t.sent,t.next=9,c.fetch({limit:a});case 9:return f=t.sent,(p=f.map((function(e){return v._deserialize(e)}))).forEach((function(e){!u.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),v._channels.has(e.url)||v._channels.set(e.url,e)})),t.abrupt("return",p);case 13:return t.abrupt("return",[]);case 14:case"end":return t.stop()}}),t,this)})))}},{key:"upsert",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=[],e.forEach((function(e){if(i._channels.has(e.url)){var n=i._channels.get(e.url);if(n._pinnedMessagesUpdatedAt<e._pinnedMessagesUpdatedAt&&(n._pinnedMessagesUpdatedAt=e._pinnedMessagesUpdatedAt),n._messageCollectionLastAccessedAt>e._messageCollectionLastAccessedAt&&(e._messageCollectionLastAccessedAt=n._messageCollectionLastAccessedAt),e.cachedMetaData instanceof Map&&e.cachedMetaData.size>0&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:n.cachedMetaData});n._update(e),r.push(n)}else i._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],s=0;s<r.length;s++)a.push(this._serialize(r[s],s));return n.next=7,this.collection.upsertMany(a);case 7:return n.abrupt("return",r);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=11;break}if(a=r.value,this._channels.delete(a),!this.localCacheEnabled){t.next=9;break}return t.next=9,this.collection.remove(a);case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),n.e(t.t0);case 16:return t.prev=16,n.f(),t.finish(16);case 19:case"end":return t.stop()}}),t,this,[[1,13,16,19]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.clearMemoryCache(),!this.localCacheEnabled){e.next=4;break}return e.next=4,this.collection.clear();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMemoryCache",value:function(){this._channels.clear()}},{key:"_setBlockStateOfAllChannels",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=[],e!==this._sdkState.userId){r.next=38;break}s=i(this._channels.values()),r.prev=3,s.s();case 5:if((o=s.n()).done){r.next=28;break}u=o.value,c=i(u.members),r.prev=8,c.s();case 10:if((l=c.n()).done){r.next=18;break}if((h=l.value).userId!==t){r.next=16;break}return h.isBlockedByMe=n,a.push(u),r.abrupt("break",18);case 16:r.next=10;break;case 18:r.next=23;break;case 20:r.prev=20,r.t0=r.catch(8),c.e(r.t0);case 23:return r.prev=23,c.f(),r.finish(23);case 26:r.next=5;break;case 28:r.next=33;break;case 30:r.prev=30,r.t1=r.catch(3),s.e(r.t1);case 33:return r.prev=33,s.f(),r.finish(33);case 36:r.next=73;break;case 38:if(t!==this._sdkState.userId){r.next=73;break}f=i(this._channels.values()),r.prev=40,f.s();case 42:if((p=f.n()).done){r.next=65;break}v=p.value,_=i(v.members),r.prev=45,_.s();case 47:if((m=_.n()).done){r.next=55;break}if((g=m.value).userId!==e){r.next=53;break}return g.isBlockingMe=n,a.push(v),r.abrupt("break",55);case 53:r.next=47;break;case 55:r.next=60;break;case 57:r.prev=57,r.t2=r.catch(45),_.e(r.t2);case 60:return r.prev=60,_.f(),r.finish(60);case 63:r.next=42;break;case 65:r.next=70;break;case 67:r.prev=67,r.t3=r.catch(40),f.e(r.t3);case 70:return r.prev=70,f.f(),r.finish(70);case 73:if(!(a.length>0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=i(t),n.prev=2,a.s();case 4:if((s=a.n()).done){n.next=12;break}return o=s.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}(ss);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(Tp||(Tp={}));var Ap,Mp=function(){return s((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),Up={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Op=function(e){return F("string",e.invitedUserIds,!0)&&R("string",e.channelUrl,!0)&&R("string",e.coverUrl,!0)&&(G(e.coverImage)||R("string",e.coverImage,!0))&&R("boolean",e.isDistinct,!0)&&R("boolean",e.isSuper,!0)&&R("boolean",e.isBroadcast,!0)&&R("boolean",e.isExclusive,!0)&&R("boolean",e.isPublic,!0)&&R("boolean",e.isStrict,!0)&&R("boolean",e.isDiscoverable,!0)&&R("boolean",e.isEphemeral,!0)&&R("string",e.accessCode,!0)&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&R("number",e.messageSurvivalSeconds,!0)},Dp={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},Rp=function(e){return F("string",e.customTypes,!0)&&R("boolean",e.includeEmpty,!0)&&R("boolean",e.includeFrozen,!0)&&R("boolean",e.includeMetaData,!0)&&R("boolean",e.includeChatNotification,!0)},Lp={myMemberStateFilter:e.MyMemberStateFilter.ALL},Pp=function(t){return L(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(Ap=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",Ap.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",Ap.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",Ap.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",Ap.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",Ap.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",Ap.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",Ap.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",Ap.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var Fp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},qp=function(t){return F(e.UnreadItemKey,t.keys)&&F("string",t.customTypeFilters,!0)&&F("string",t.customTypesFilter,!0)},Hp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Gp=function(t){return F("string",t.channelCustomTypesFilter,!0)&&L(e.SuperChannelFilter,t.superChannelFilter)},jp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Vp=function(t){return R("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&L(e.MessageTypeFilter,t.messageTypeFilter)},zp=Object.assign({},e.CollectionEventSource),Bp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},Qp=function(e){function t(e){var a,s=e.channels,i=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=s,a.context=i,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),s(t)}(pe),Kp=function(e){function t(e){var a,s=e.channelUrls,i=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=s,a.context=i,a.isWebSocketEventComing=u,a}return c(t,e),s(t)}(pe),Wp=function(e){function t(e){var a,s=e.channel;return r(this,t),(a=n(this,t)).channel=s,a}return c(t,e),s(t)}(pe),Yp=function(){return s((function t(n){var a=this,s=n.groupChannelCache,o=n.userInfoCache,u=n.messageCache,c=n.unsentMessageCache,l=n.dispatcher;r(this,t),this._observers=new Map,l.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,l,h,f,p,v,_,m,g,y,k,b,C,w,x=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Qp)){n.next=47;break}if(r=t.channels,a=t.context,l=t.isWebSocketEventComing,h=r.filter((function(e){return e instanceof Z_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}f=i(h),n.prev=5,f.s();case 7:if((p=f.n()).done){n.next=13;break}return v=p.value,n.next=11,u.removeUnderOffset(v.url,v.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),f.e(n.t0);case 18:return n.prev=18,f.f(),n.finish(18);case 21:n.next=41;break;case 23:_=s.filterOffsetChanged(h),m=i(_),n.prev=25,m.s();case 27:if((g=m.n()).done){n.next=33;break}return y=g.value,n.next=31,u.removeUnderOffset(y.url,y.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),m.e(n.t1);case 38:return n.prev=38,m.f(),n.finish(38);case 41:return n.next=43,s.upsert(h,t.ts);case 43:k=n.sent,l||this._broadcastUpdateEvent(k,a),n.next=61;break;case 47:if(!(t instanceof Kp)){n.next=56;break}return b=t.channelUrls,C=t.context,w=t.isWebSocketEventComing,n.next=51,s.remove(b);case 51:return n.next=53,Fa((function(){return E(x,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(b),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,u.removeMessagesOfChannel(r);case 7:return e.next=9,c.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:w||this._broadcastRemoveEvent(b,C),n.next=61;break;case 56:if(!(t instanceof of)){n.next=61;break}return n.next=59,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:return n.next=61,o.fetch({limit:Number.MAX_SAFE_INTEGER});case 61:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=i(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}])}(),Zp=function(e){function t(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},Dp),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ve(_e({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),s(t)}(Qe),Xp=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new Z_(e,Object.assign(t,{ts:a.ts}))})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s.ts=a.ts,s}return c(t,e),s(t)}(Ke),Jp=function(e){function t(e){var a,s=e.channelUrl,i=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(i?Ce:be,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),s(t)}(Qe),$p=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Z_(e,a),s}return c(t,e),s(t)}(Ke),ev={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},tv=function(e){function t(e){var a;r(this,t);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,U=e.includeLeftChannel,O=void 0!==U&&U,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ve({token:i,limit:o,order:null!=u?u:ev.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:ev.includeEmpty,member_state_filter:null!=l?l:ev.myMemberStateFilter,super_mode:null!=d?d:ev.superChannelFilter,public_mode:null!=h?h:ev.publicChannelFilter,unread_filter:null!=f?f:ev.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:O,created_after:D,created_before:R}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return c(t,e),s(t)}(Qe),nv=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Z_(e,t)}))),s.ts=null!=u?u:0,s}return c(t,e),s(t)}(Ke),rv=function(t){function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n(this,a);var u=o.myMemberStateFilter;return s.method=me.GET,s.path="".concat(ye,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return c(a,t),s(a)}(Qe),av=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,s}return c(t,e),s(t)}(Ke),sv=function(e){function t(e){var a,s=e.userId,i=e.filter;r(this,t),a=n(this,t);var o=i.keys,u=i.customTypeFilters,c=i.customTypesFilter;return a.method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=ve({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),s(t)}(Qe),iv=function(t){function a(t,s){var i;return r(this,a),i=n(this,a,[t,s]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return c(a,t),s(a)}(Ke),ov=function(e){function t(e){var a,s=e.userId;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return c(t,e),s(t)}(Qe),uv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).unreadCount=a.unread_count,s}return c(t,e),s(t)}(Ke),cv=function(t){function a(t){var s,i=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),s=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return s.method=me.GET,s.path="".concat(ye,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},s}return c(a,t),s(a)}(Qe),lv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).unreadCount=a.unread_count,s.unreadFeedCount=a.unread_feed_count,s}return c(t,e),s(t)}(Ke),dv=function(e){function t(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(Me,"/count"),a.params={channel_url:s,status:fv(i)},o&&(a.params.message_type=o),a}return c(t,e),s(t)}(Qe),hv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).count=a.count,s}return c(t,e),s(t)}(Ke),fv=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(lo.PENDING);break;case e.ScheduledStatus.SENT:n.push(lo.IN_QUEUE),n.push(lo.SENT);break;case e.ScheduledStatus.CANCELED:n.push(lo.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(lo.FAILED)}})),n},pv=function(e){function t(e){var a;r(this,t);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=me.POST,a.path=be,a.params=ve({user_ids:[s].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),s(t)}(Qe),vv=function(e){function t(e,a){var s,i;return r(this,t),(s=n(this,t,[e,a])).channel=new Z_(e,a),s.isCreated=null===(i=a.is_created)||void 0===i||i,s}return c(t,e),s(t)}(Ke),_v=function(e){function t(e){var a,s=e.userId,i=e.channelUrls;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return c(t,e),s(t)}(Qe),mv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).event=new Mp(s),i}return c(t,e),s(t)}(Ze),gv=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return c(t,e),s(t)}(Qe),yv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Z_(e,a),s}return c(t,e),s(t)}(Ke),Ev=function(e){function t(e,a,s){var i;r(this,t),i=n(this,t,[e,a,s]);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return i.memberCount=c,i.joinedMemberCount=d,i.members=Array.isArray(f)?f.map((function(t){return new xp(e,t)})):[new xp(e,s.data)],i}return c(t,e),s(t)}(mv),kv=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return c(t,e),s(t)}(Qe),bv=function(e){function t(e,a,s){var i;r(this,t),i=n(this,t,[e,a,s]);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return i.memberCount=c,i.joinedMemberCount=d,i.member=new xp(i._iid,s.data),i}return c(t,e),s(t)}(mv),Cv=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userIds;return(a=n(this,t)).method=me.POST,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return c(t,e),s(t)}(Qe),wv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Z_(e,a),s}return c(t,e),s(t)}(Ke),xv=function(e){function t(e,a,s){var i;r(this,t),(i=n(this,t,[e,a,s])).inviter=null;var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return i.memberCount=c,i.joinedMemberCount=d,h&&Object.keys(h).length>0&&(i.inviter=new _s(e,h)),i.invitees=p.map((function(t){return new xp(e,t)})),i}return c(t,e),s(t)}(mv),Sv=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userId;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return c(t,e),s(t)}(Qe),Tv=function(e){function t(e,a,s){var i;r(this,t),i=n(this,t,[e,a,s]);var o=s.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return i.memberCount=null!=u?u:0,i.joinedMemberCount=null!=c?c:0,i.inviter=new _s(e,l),i.invitee=new xp(e,d),i}return c(t,e),s(t)}(mv),Iv={hidePreviousMessages:!1,allowAutoUnhide:!0},Nv=function(e){return R("boolean",e.hidePreviousMessages,!0)&&R("boolean",e.allowAutoUnhide,!0)},Av=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:null!=o?o:Iv.hidePreviousMessages,allow_auto_unhide:null!=u?u:Iv.allowAutoUnhide},a}return c(t,e),s(t)}(Qe),Mv=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return c(t,e),s(t)}(Ke),Uv=function(e){function t(e,a,s){var i,o,u,c;return r(this,t),(i=n(this,t,[e,"SYEV",s])).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=null!==(o=s.data.allow_auto_unhide)&&void 0!==o?o:null,i.hidePreviousMessages=null!==(u=s.data.hide_previous_messages)&&void 0!==u?u:null),i.messageOffsetTimestamp=null!==(c=s.ts_message_offset)&&void 0!==c?c:null,i}return c(t,e),s(t)}(Ze),Ov=function(e){function t(e){var a=e.channelUrl,s=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}}])}return c(t,e),s(t)}(Xe),Dv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new _s(e,s.data),i}return c(t,e),s(t)}(Ze),Rv=function(e){function t(e){var a=e.channelUrl,s=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}}])}return c(t,e),s(t)}(Xe),Lv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"SYEV",s])).user=new _s(e,s.data),i}return c(t,e),s(t)}(Ze),Pv=function(e){function t(e,a,s){var i;r(this,t),i=n(this,t,[e,a,s]);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new _s(i._iid,e)})),i}return c(t,e),s(t)}(mv),Fv=function(e){function t(e){var a=e.channelUrl,s=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}}])}return c(t,e),s(t)}(Xe),qv=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(i=n(this,a,[t,s])).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.includeChatNotification=!1,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.nicknameContainsFilter=null,i.nicknameStartsWithFilter=null,i.nicknameExactMatchFilter=null,i.channelNameContainsFilter="",i.myMemberStateFilter=e.MyMemberStateFilter.ALL,i.unreadChannelFilter=e.UnreadChannelFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.publicChannelFilter=e.PublicChannelFilter.ALL,i.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,i.searchFilter={fields:[],query:null},i.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.includeEmpty=null!==(o=s.includeEmpty)&&void 0!==o&&o,i.includeFrozen=null===(u=s.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=s.includeMetaData)||void 0===c||c,i.includeChatNotification=null!==(l=s.includeChatNotification)&&void 0!==l&&l,i.channelUrlsFilter=null!==(d=s.channelUrlsFilter)&&void 0!==d?d:null,i.customTypesFilter=null!==(h=s.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(f=s.customTypeStartsWithFilter)&&void 0!==f?f:"",i.nicknameContainsFilter=null!==(p=s.nicknameContainsFilter)&&void 0!==p?p:null,i.nicknameStartsWithFilter=null!==(v=s.nicknameStartsWithFilter)&&void 0!==v?v:null,i.nicknameExactMatchFilter=null!==(_=s.nicknameExactMatchFilter)&&void 0!==_?_:null,i.channelNameContainsFilter=null!==(m=s.channelNameContainsFilter)&&void 0!==m?m:"",i.myMemberStateFilter=null!==(g=s.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,i.unreadChannelFilter=null!==(y=s.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,i.superChannelFilter=null!==(E=s.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,i.publicChannelFilter=null!==(k=s.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,i.hiddenChannelFilter=null!==(b=s.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,i.searchFilter=null!==(C=s.searchFilter)&&void 0!==C?C:{fields:[],query:null},i.userIdsFilter=null!==(w=s.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null!==(x=s.metadataKey)&&void 0!==x?x:null,i.metadataValues=null!==(S=s.metadataValues)&&void 0!==S?S:null,i.metadataOrderKeyFilter=null!==(T=s.metadataOrderKeyFilter)&&void 0!==T?T:null,i.metadataValueStartsWith=null!==(I=s.metadataValueStartsWith)&&void 0!==I?I:null,i.order=null!==(N=s.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.createdAfter&&(i.createdAfter=s.createdAfter),s.createdBefore&&(i.createdBefore=s.createdBefore),i}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("boolean",this.includeEmpty)&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&R("string",this.customTypeStartsWithFilter)&&R("string",this.nicknameContainsFilter,!0)&&R("string",this.nicknameStartsWithFilter,!0)&&R("string",this.nicknameExactMatchFilter,!0)&&L(e.MyMemberStateFilter,this.myMemberStateFilter)&&L(e.SuperChannelFilter,this.superChannelFilter)&&L(e.PublicChannelFilter,this.publicChannelFilter)&&L(e.UnreadChannelFilter,this.unreadChannelFilter)&&L(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&R("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&R("boolean",this.userIdsFilter.includeMode)&&L(e.QueryType,this.userIdsFilter.queryType)&&L(e.GroupChannelListOrder,this.order)&&R("string",this.metadataOrderKeyFilter,!0)&&R("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&R("string",this.metadataValueStartsWith,!0)&&q(this.createdAfter,!0)&&q(this.createdBefore,!0)}},{key:"serialize",value:function(){return hs(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Jv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,_e(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:t.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(Tu),Hv=function(e){function t(e,a,s){var i,o;return r(this,t),(i=n(this,t,[e,"SYEV",s])).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(o=s.data.pinned_message_ids)&&void 0!==o?o:[],i.latestPinnedMessage=s.data.latest_pinned_message?No(e,Object.assign({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return c(t,e),s(t)}(Ze),Gv=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e]))._logger=a.logger,s._sdkState=a.sdkState,s._sessionManager=a.sessionManager,s._requestQueue=a.requestQueue,s._dispatcher=a.dispatcher,s._cacheContext=a.cacheContext,s._channelType=a.channelType,s}return c(t,e),s(t,[{key:"_messageBroadcast",get:function(){return mh.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,s){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(ss),jv=function(e){function t(e,a,s){var i,o,u,c,l;r(this,t),(i=n(this,t,[e,"ADMM",s])).message=new bo(e,s);var d=vi.of(e).sdkState;return i.isMentioned=je(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return c(t,e),s(t)}(Ze),Vv=function(e){function t(e,a,s){var i,o,u,c,l,d;r(this,t),(i=n(this,t,[e,"AEDI",s])).message=new bo(e,s);var h=vi.of(e).sdkState;return i.mentionCountChange=Ve({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},_e({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return c(t,e),s(t)}(Ze),zv=function(e){function t(e){var a,s=e.channelUrl,i=e.userId;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ve({user_id:i}),a}return c(t,e),s(t)}(Qe),Bv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"DLVR",s])).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return c(t,e),s(t)}(Ze),Qv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"MRCT",s])).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new bi(s),i}return c(t,e),s(t)}(Ze),Kv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"MTHD",s])).event=new Sh(e,s),i}return c(t,e),s(t)}(Ze),Wv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"MCNT",s])).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return c(t,e),s(t)}(Ze),Yv=function(e){function t(e,a,s){var i;return r(this,t),(i=n(this,t,[e,"PEDI",s])).event=new Vh(e,s),i.status=fo(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return c(t,e),s(t)}(Ze),Zv=function(){return s((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.every((function(t){return e.top<=t&&t<=e.bottom}))}},{key:"overlap",value:function(e){return this.includes(e.top)||this.includes(e.bottom)}},{key:"intersect",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.some((function(t){return e.top<=t&&t<=e.bottom}))}},{key:"extends",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.top=Math.min.apply(Math,[this.top].concat(t)),this.bottom=Math.max.apply(Math,[this.bottom].concat(t))}}])}(),Xv={},Jv=function(t){function a(t,s){var o,u;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},s),{channelType:e.ChannelType.GROUP})]))._leftChannels=new Map,o._markAsReadAllLastSentAt=0,o._forceDisableMack=null!==(u=s.forceDisableMack)&&void 0!==u&&u,o._groupChannelHandlers=new Map,o._groupChannelCache=new Np(o._iid,{sdkState:s.sdkState,cacheContext:s.cacheContext}),o._userInfoCache=new yh(o._iid,{sdkState:s.sdkState,cacheContext:s.cacheContext}),o._groupChannelBroadcast=new Yp({dispatcher:s.dispatcher,groupChannelCache:o._groupChannelCache,userInfoCache:o._userInfoCache,messageCache:fh.of(o._iid),unsentMessageCache:dh.of(o._iid)}),setInterval((function(){var t,n=i(o._groupChannelCache.channels);try{var r=function(){var n=t.value;n.invalidateTypingStatus()&&(o._dispatcher.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),o._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(n)})))};for(n.s();!(t=n.n()).done;)r()}catch(e){n.e(e)}finally{n.f()}}),1e3),o._dispatcher.on((function(t){if(t instanceof Ze)o._handleEvent(t).catch((function(e){if(A(e)&&"foreground"===o._sdkState.appState)throw e}));else if(t instanceof ef)E(o,void 0,void 0,d().mark((function e(){var n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.message,e.next=3,this.getChannelFromCache(n.channelUrl);case 3:if((r=e.sent)&&!r.isFrozen){e.next=8;break}return e.next=7,this.getChannelWithoutCache(n.channelUrl,!0);case 7:r=e.sent;case 8:if(!r.isFrozen){e.next=10;break}return e.abrupt("return");case 10:n instanceof xo?r._autoResendUserMessage(n):n instanceof Ao&&r._autoResendFileMessage(n);case 11:case"end":return e.stop()}}),e,this)})));else if(t instanceof uf)o.reduceDBSize();else if(t instanceof lp){var n=t.appConfigsInfo,r=t.configTs,a=n.message_purge_offset;a&&o._messageDataRetention(a),o._dispatcher.dispatch(new cf({configTs:r}))}else t instanceof ao&&E(o,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.channelUrl,a=t.channelType,s=t.parentMessage,o=new Sh(this._iid,{channel_type:e.ChannelType.GROUP,channel_url:r,parent_message_id:s.messageId,thread_info:Ei.payloadify(s.threadInfo)}),a!==e.ChannelType.GROUP){n.next=7;break}return n.next=5,this.getChannel(r,!0);case 5:u=n.sent,Pa((function(){return E(c,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(u,o)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 7:case"end":return n.stop()}}),n,this)})))})),Xv[t]||(Xv[t]=o),o}return c(a,t),s(a,[{key:"_messageCache",get:function(){return fh.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return dh.of(this._iid)}},{key:"handlers",get:function(){return v(this._groupChannelHandlers.values())}},{key:"buildGroupChannelFromSerializedData",value:function(e){var t=fs(e);return new Z_(this._iid,Z_.payloadify(t))}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){var t=fs(e);return new qv(this._iid,t)}},{key:"buildMemberFromSerializedData",value:function(e){var t=fs(e);return new xp(this._iid,xp.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._groupChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelsFromCache",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._groupChannelCache.fetch({token:e,filter:t,order:n,limit:r,borderlineChannelUrl:a});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clearChannelsFromCache",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._groupChannelCache.clear();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"reduceDBSize",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=fh.of(this._iid),n=vi.of(this._iid),r=n.cacheContext,a=r.localCacheConfig,s=r.nestdb,r.localCacheEnabled&&s&&s.state==Yd.OPENED){e.next=5;break}return e.abrupt("return");case 5:return i=1024*a.maxSize*1024,e.next=8,s.estimateUsage();case 8:if(!((o=e.sent)<i)){e.next=11;break}return e.abrupt("return");case 11:u=[],c=this._groupChannelCache.channels,l={},h=0;case 15:if(!(h<c.length)){e.next=25;break}return e.next=18,this.getMessagesFromCache(c[h].url,0,"prev",new ah);case 18:f=e.sent,l[c[h].url]=JSON.stringify(f).length,p=new W({channel:c[h],cachedMessageCount:f.length}),u.push(p);case 22:h++,e.next=15;break;case 25:v=u.sort(a.clearOrderComparator),_=0;case 27:if(!(_<v.length)){e.next=40;break}return e.next=30,t.removeMessagesOfChannel(v[_].channel.url);case 30:return e.next=32,t._getGroupChannelPreferenceSize(v[_].channel.url);case 32:if(m=e.sent,g=l[v[_].channel.url]+m,!((o-=g)<i)){e.next=37;break}return e.abrupt("break",40);case 37:_++,e.next=27;break;case 40:return y=yh.of(this._iid),e.next=43,y.clear();case 43:case"end":return e.stop()}}),e,this)})))}},{key:"_messageDataRetention",value:function(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=[],s=fh.of(this._iid),o=i(this._groupChannelCache.channels),r.prev=3,c=d().mark((function r(){var o,c,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=u.value,c=o.customType,h=null!==(n=t[c])&&void 0!==n?n:t.global,r.next=5,s.removeUnderOffset(o.url,h,!0);case 5:o.lastMessage&&o.lastMessage.createdAt<=h&&(o.lastMessage=null,a.push(o),Pa((function(){return E(l,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(o)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),l._dispatcher.dispatch(new Zi({channelUrl:o.url,messageDeletionTimestamp:h,source:e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED}));case 7:case"end":return r.stop()}}),r)})),o.s();case 6:if((u=o.n()).done){r.next=10;break}return r.delegateYield(c(),"t0",8);case 8:r.next=6;break;case 10:r.next=15;break;case 12:r.prev=12,r.t1=r.catch(3),o.e(r.t1);case 15:return r.prev=15,o.f(),r.finish(15);case 18:a.length>0&&this._dispatcher.dispatch(new Qp({channels:a,context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}}));case 19:case"end":return r.stop()}}),r,this,[[3,12,15,18]])})))}},{key:"_isSuperGroupMackDisabled",value:function(e){var t=vi.of(this._iid).appInfo;return!(!e.isSuper||e.isBroadcast||!(null==t?void 0:t.disableSuperGroupMack))}},{key:"_getCachedUserInfo",value:function(e){return this._userInfoCache.getUserInfoFromCache(e)}},{key:"_upsertCachedUserInfo",value:function(e,t){vi.of(this._iid).useMemberInfoInMessage&&this._userInfoCache.upsert(e,t)}},{key:"_handleEvent",value:function(t){var n,r;return E(this,void 0,void 0,d().mark((function a(){var s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,M,U,O,D,R,L,P,F,q,H,G,j,V,z,B,Q,K,W,Y,Z,X,J,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Ue,Oe,De,Re,Le,Pe,Fe,qe,He,Ge,je,Ve,ze,Be,Qe,Ke,We,Ye,Ze,Xe,Je,$e,et,tt,nt,rt,at,st,it,ot,ut,ct,lt,dt,ht,ft,vt,_t,mt,gt,yt,Et,kt,bt,Ct,wt,xt,St,Tt,It,Nt,At,Mt,Ut,Ot,Dt,Rt,Lt,Pt,Ft,qt,Ht,Gt,jt,Vt,zt,Bt,Qt,Kt,Wt,Yt,Zt,Xt,Jt,$t,en,tn,nn,rn,an,sn,on,un,cn,ln,dn,hn,fn,pn,vn,_n,mn,gn,yn,En,kn,bn,Cn,wn,xn,Sn,Tn,In,Nn,An,Mn,Un,On,Dn,Rn,Ln=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.prev=0,a.t0=t.code,a.next="MESG"===a.t0||"FILE"===a.t0||"ADMM"===a.t0||"BRDM"===a.t0?4:"MEDI"===a.t0||"FEDI"===a.t0||"AEDI"===a.t0?46:"DELM"===a.t0?88:"READ"===a.t0?98:"DLVR"===a.t0?107:"MRCT"===a.t0?115:"MTHD"===a.t0?137:"MCNT"===a.t0?149:"PEDI"===a.t0?173:"VOTE"===a.t0?181:"SYEV"===a.t0?189:"USEV"===a.t0?374:385;break;case 4:if(s=null,"MESG"===t.code?s=t.as(xc):"FILE"===t.code?s=t.as(Do):"ADMM"!==t.code&&"BRDM"!=t.code||(s=t.as(jv)),!s){a.next=45;break}if(u=(o=s).message,c=o.isMentioned,l=o.forceUpdateLastMessage,u.channelType!==e.ChannelType.GROUP){a.next=45;break}return h=this._groupChannelCache.isCachedInMemory(u.channelUrl),f=u instanceof yo&&u.sender.userId===this._sdkState.userId,a.next=13,this.getChannel(u.channelUrl,!0);case 13:if(p=a.sent,v=vi.of(this._iid),_=v.useMemberInfoInMessage,this._forceDisableMack||this._isSuperGroupMackDisabled(p)||u instanceof bo||f||Fa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Fv(u),e.next=3,this._requestQueue.send(t);case 3:case"end":return e.stop()}}),e,this)})))})),!(u instanceof yo)){a.next=39;break}m=u.sender,p.isSuper&&this._upsertCachedUserInfo(m,u.createdAt),g=i(p.members),a.prev=20,g.s();case 22:if((y=g.n()).done){a.next=29;break}if((k=y.value).userId!==u.sender.userId){a.next=27;break}return _&&(k.nickname=u.sender.nickname,k.plainProfileUrl=u.sender.plainProfileUrl,k.metaData=u.sender.metaData,k.isBlockedByMe=u.sender.isBlockedByMe),a.abrupt("break",29);case 27:a.next=22;break;case 29:a.next=34;break;case 31:a.prev=31,a.t1=a.catch(20),g.e(a.t1);case 34:return a.prev=34,g.f(),a.finish(34);case 37:_&&c&&(null===(n=u.mentionedUsers)||void 0===n||n.forEach((function(e){var t,n=i(p.members);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(e.userId===r.userId){r.nickname=e.nickname,r.plainProfileUrl=e.plainProfileUrl,r.metaData=e.metaData;break}}}catch(e){n.e(e)}finally{n.f()}}))),f&&(b=this._sessionManager.currentUser)&&(b.nickname=u.sender.nickname,b.plainProfileUrl=u.sender.plainProfileUrl,b.metaData=u.sender.metaData);case 39:u.silent&&!f||(p.isEphemeral||h)&&(p._updateLastMessage(u),f||p._shouldUpdateUnreadCountWith(u)&&p._updateUnreadCount(p.unreadMessageCount+1,p.unreadMentionCount+(c?1:0))),l&&p._updateLastMessage(u),this._dispatcher.dispatch(new Qp({channels:[p],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),u.silent&&!f||Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(p)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),this._dispatcher.dispatch(new Wi({messages:[u],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageReceived&&r.onMessageReceived(p,u),c&&r.onMentionReceived&&r.onMentionReceived(p,u)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 45:return a.abrupt("break",385);case 46:if(C=null,"MEDI"===t.code?C=t.as(Tc):"FEDI"===t.code?C=t.as(Nc):"AEDI"===t.code&&(C=t.as(Vv)),!C){a.next=87;break}if(x=(w=C).message,S=w.mentionCountChange,T=vi.of(this._iid),I=T.useMemberInfoInMessage,x.threadInfo&&(x.threadInfo.unreadReplyCount=void 0),x.channelType!==e.ChannelType.GROUP){a.next=87;break}return N=this._groupChannelCache.isCachedInMemory(x.channelUrl),a.next=56,this.getChannel(x.channelUrl,!0);case 56:if(M=a.sent,U=!1,!(x instanceof yo)){a.next=79;break}U=x.sender.userId===this._sdkState.userId,M.isSuper&&this._upsertCachedUserInfo(x.sender,x.updatedAt),O=i(M.members),a.prev=62,O.s();case 64:if((D=O.n()).done){a.next=71;break}if((R=D.value).userId!==x.sender.userId){a.next=69;break}return I&&(R.nickname=x.sender.nickname,R.plainProfileUrl=x.sender.plainProfileUrl,R.metaData=x.sender.metaData,R.isBlockedByMe=x.sender.isBlockedByMe),a.abrupt("break",71);case 69:a.next=64;break;case 71:a.next=76;break;case 73:a.prev=73,a.t2=a.catch(62),O.e(a.t2);case 76:return a.prev=76,O.f(),a.finish(76);case 79:L=!1,U?(P=x.sender,(F=this._sessionManager.currentUser)&&(F.nickname=P.nickname,F.plainProfileUrl=P.plainProfileUrl,F.metaData=P.metaData)):M.isReadMessage(x)||0!==S&&!x.silent&&N&&(M._updateUnreadCount(M.unreadMessageCount,M.unreadMentionCount+S),L=!0),M._updateLastMessage(x)?L=!0:(null===(r=M.lastMessage)||void 0===r?void 0:r.isIdentical(x))&&(N?M._updateLastMessage(x)&&(L=!0):L=!0),q=!1,M.lastPinnedMessage&&M.lastPinnedMessage.messageId===x.messageId&&(M.lastPinnedMessage=x,L=!0,q=!0),L&&(this._dispatcher.dispatch(new Qp({channels:[M],context:{source:q?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),x.silent&&!U||Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(M)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),q&&Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPinnedMessageUpdated&&r.onPinnedMessageUpdated(M)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),this._dispatcher.dispatch(new Wi({messages:[x],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageUpdated&&r.onMessageUpdated(M,x),S>0&&r.onMentionReceived&&r.onMentionReceived(M,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 87:return a.abrupt("break",385);case 88:if(H=t.as(pt),G=H.channelUrl,j=H.channelType,V=H.messageId,z=H.silent,B=H.messageCreatedAt,Q=H.senderId,j!==e.ChannelType.GROUP){a.next=97;break}return a.next=92,this.getChannel(G,!0);case 92:K=a.sent,W=Q===this._sdkState.userId,z||W||B>0&&K.myLastRead<B&&K.unreadMessageCount>0&&K._updateUnreadCount(K.unreadMessageCount-1,0),this._dispatcher.dispatch(new Yi({messageIds:[V],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(K,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 97:return a.abrupt("break",385);case 98:if(Y=t.as(Li),(Z=Y.readStatus).channelType!==e.ChannelType.GROUP){a.next=106;break}return X=this._groupChannelCache.isCachedInMemory(Z.channelUrl),a.next=103,this.getChannel(Z.channelUrl,!0);case 103:J=a.sent,X&&J._updateUnreadMemberState(Z.reader.userId,Z.readAt),Z.reader.userId===this._sdkState.userId?X?(J.unreadMessageCount>0||J.unreadMentionCount>0)&&(J._updateUnreadCount(0,0),this._dispatcher.dispatch(new Qp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==J.unreadMessageCount&&0!==J.unreadMentionCount||(this._dispatcher.dispatch(new Qp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Qp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 106:return a.abrupt("break",385);case 107:return $=t.as(Bv),ee=$.channelUrl,te=$.deliveredStateUpdate,ne=void 0===te?{}:te,re=this._groupChannelCache.isCachedInMemory(ee),a.next=111,this.getChannel(ee,!0);case 111:return ae=a.sent,re&&Object.keys(ne).forEach((function(e){ae._updateUndeliveredMemberState(e,ne[e])})),Object.keys(ne).some((function(e){return e!==Ln._sdkState.userId}))&&(this._dispatcher.dispatch(new Qp({channels:[ae],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(ae)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",385);case 115:if(se=t.as(Qv),ie=se.channelUrl,oe=se.channelType,ue=se.event,oe!==e.ChannelType.GROUP){a.next=136;break}return a.next=119,this.getChannel(ie,!0);case 119:return ce=a.sent,a.next=122,this.getMessageFromCache(ue.messageId);case 122:if(le=a.sent,!ce.isSuper){a.next=134;break}de=0,he=Object.keys(ue._sampledUserInfoList);case 125:if(!(de<he.length)){a.next=134;break}return fe=he[de],a.next=129,this._userInfoCache.get(fe);case 129:(pe=a.sent)?(pe.plainProfileUrl=ue._sampledUserInfoList[fe].profile_url,pe.nickname=ue._sampledUserInfoList[fe].nickname,this._upsertCachedUserInfo(pe,ue.updatedAt)):(ve=new _s(this._iid,{user_id:fe,nickname:ue._sampledUserInfoList[fe].nickname,profile_url:ue._sampledUserInfoList[fe].profile_url,require_auth_for_profile_image:ue._sampledUserInfoList[fe].require_auth_for_profile_image}),this._upsertCachedUserInfo(ve,ue.updatedAt));case 131:de++,a.next=125;break;case 134:le?le instanceof go&&(le.applyReactionEvent(ue),this._dispatcher.dispatch(new Wi({messages:[le],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Xi({event:ue,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(ce,ue)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 136:return a.abrupt("break",385);case 137:if(_e=t.as(Kv),(me=_e.event).channelType!==e.ChannelType.GROUP){a.next=148;break}return a.next=141,this.getChannel(me.channelUrl,!0);case 141:return ge=a.sent,a.next=144,this.getMessageFromCache(me.targetMessageId);case 144:if((ye=a.sent)?ye instanceof go&&(ye.applyThreadInfoUpdateEvent(me),this._dispatcher.dispatch(new Wi({messages:[ye],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Ji({event:me,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),ge.isSuper){Ee=i(me.threadInfo.mostRepliedUsers);try{for(Ee.s();!(ke=Ee.n()).done;)be=ke.value,this._upsertCachedUserInfo(be,me.threadInfo.updatedAt)}catch(e){Ee.e(e)}finally{Ee.f()}}Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(ge,me)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 148:return a.abrupt("break",385);case 149:Ce=t.as(Wv),we=Ce.groupChannelMemberCounts,xe=[],Se=i(we),a.prev=152,Se.s();case 154:if((Te=Se.n()).done){a.next=163;break}return Ie=Te.value,Ne=Ie.channelUrl,Ae=Ie.memberCount,Me=Ie.joinedMemberCount,Ue=Ie.updatedAt,a.next=159,this.getChannelFromCache(Ne);case 159:(Oe=a.sent)&&Oe._setLatestMemberCount(Ae,Me,Ue)&&xe.push(Oe);case 161:a.next=154;break;case 163:a.next=168;break;case 165:a.prev=165,a.t3=a.catch(152),Se.e(a.t3);case 168:return a.prev=168,Se.f(),a.finish(168);case 171:return xe.length>0&&(this._dispatcher.dispatch(new Qp({channels:xe,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(xe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",385);case 173:if(De=t.as(Yv),Re=De.event,Le=De.status,Pe=De.channelUrl,Fe=De.channelType,!Pe||Fe!==e.ChannelType.GROUP){a.next=180;break}return a.next=177,this.getChannel(Pe,!0);case 177:qe=a.sent,this._dispatcher.dispatch(new to({event:Re,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Pa(Le===ho?function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(qe,Re.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(qe,Re)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 180:return a.abrupt("break",385);case 181:if(He=t.as($c),Ge=He.event,je=He.channelUrl,Ve=He.channelType,!je||Ve!==e.ChannelType.GROUP){a.next=188;break}return a.next=185,this.getChannel(je,!0);case 185:ze=a.sent,this._dispatcher.dispatch(new no({event:Ge,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(ze,Ge)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 188:return a.abrupt("break",385);case 189:if(Be=t.as(mv),!(Qe=Be.event).isGroupChannelEvent){a.next=373;break}a.t4=Qe.category,a.next=a.t4===Tp.CHANNEL_JOIN?194:a.t4===Tp.CHANNEL_LEAVE?204:a.t4===Tp.CHANNEL_OPERATOR_UPDATE?221:a.t4===Tp.CHANNEL_INVITE?232:a.t4===Tp.CHANNEL_DECLINE_INVITE?242:a.t4===Tp.TYPING_START||a.t4===Tp.TYPING_END?250:a.t4===Tp.USER_CHANNEL_MUTE||a.t4===Tp.USER_CHANNEL_UNMUTE?259:a.t4===Tp.USER_CHANNEL_BAN?287:a.t4===Tp.USER_CHANNEL_UNBAN?303:a.t4===Tp.CHANNEL_FREEZE||a.t4===Tp.CHANNEL_UNFREEZE?312:a.t4===Tp.CHANNEL_HIDE?320:a.t4===Tp.CHANNEL_UNHIDE?330:a.t4===Tp.CHANNEL_DELETED?337:a.t4===Tp.CHANNEL_PROP_CHANGED?343:a.t4===Tp.CHANNEL_META_DATA_CHANGED?349:a.t4===Tp.CHANNEL_META_COUNTERS_CHANGED?358:a.t4===Tp.PINNED_MESSAGE_CHANGED?367:373;break;case 194:return a.next=196,this.getChannel(Qe.channelUrl,!0);case 196:if(Ke=a.sent,We=t.as(Ev),Ye=We.memberCount,Ze=We.joinedMemberCount,Xe=We.members,Je=!1,Xe.forEach((function(t){Ke.isExclusive||Ke.isSuper||Ke.isBroadcast?Je=Je||Ke._setLatestMemberCount(Ye,Ze,Qe.ts):(t.state=e.MemberState.JOINED,Ke.addMember(t,Qe.ts),Ln._updateJoinedMemberCount(Ke)),t.userId===Ln._sdkState.userId&&(Ke.myMemberState=e.MemberState.JOINED)})),Ke.isSuper){$e=i(Xe);try{for($e.s();!(et=$e.n()).done;)tt=et.value,this._upsertCachedUserInfo(tt,Qe.ts)}catch(e){$e.e(e)}finally{$e.f()}}return this._dispatcher.dispatch(new Qp({channels:[Ke],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Xe}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=i(Xe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ke,r)}}catch(e){n.e(e)}finally{n.f()}Ke.isBroadcast&&Je&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ke])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 204:if(!(nt=this._leftChannels.get(Qe.channelUrl))){a.next=209;break}a.t5=nt.channel,a.next=212;break;case 209:return a.next=211,this.getChannel(Qe.channelUrl,!0);case 211:a.t5=a.sent;case 212:return rt=a.t5,at=t.as(bv),st=at.memberCount,it=at.joinedMemberCount,ot=at.member,ut=!1,ct=vi.of(this._iid),lt=ct.appInfo,rt.isExclusive||rt.isSuper||rt.isBroadcast?ut=rt._setLatestMemberCount(st,it,Qe.ts):((null==lt?void 0:lt.enabledChannelMemberShipHistory)?((dt=rt.members.find((function(e){return e.userId===ot.userId})))&&(dt.state=e.MemberState.LEFT),rt.memberCount=st):rt.removeMember(ot),this._updateJoinedMemberCount(rt)),ot.userId===this._sdkState.userId?(rt.myMemberState=e.MemberState.NONE,rt.invitedAt=0,rt.joinedAt=0,rt._updateUnreadCount(0,0),rt.isPublic?this._dispatcher.dispatch(new Qp({channels:[rt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ot}})):(this._markAsLeave(rt),this._dispatcher.dispatch(new Kp({channelUrls:[rt.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ot}})))):this._dispatcher.dispatch(new Qp({channels:[rt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ot}})),rt.isSuper&&this._upsertCachedUserInfo(ot,Qe.ts),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(rt,ot),rt.isBroadcast&&ut&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([rt])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 221:return a.next=223,this.getChannel(Qe.channelUrl,!0);case 223:ht=a.sent,ft=t.as(Pv),vt=ft.operators,_t=vt.map((function(e){return e.userId})),mt=i(ht.members);try{for(mt.s();!(gt=mt.n()).done;)(yt=gt.value).role=_t.includes(yt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){mt.e(e)}finally{mt.f()}return ht.myRole=_t.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Qp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:vt}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(ht,vt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 232:return a.next=234,this.getChannel(Qe.channelUrl,!0);case 234:Et=a.sent,kt=t.as(xv),bt=kt.memberCount,Ct=kt.joinedMemberCount,wt=kt.inviter,(xt=kt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),St=i(xt);try{for(St.s();!(Tt=St.n()).done;)It=Tt.value,Et.isExclusive||Et.isSuper||Et.isBroadcast?(Et.isSuper&&this._userInfoCache.upsert(It,Qe.ts),Et._setLatestMemberCount(bt,Ct,Qe.ts)):Et.addMember(It,Qe.ts),this._sdkState.userId===It.userId&&(Et.hiddenState=e.HiddenState.UNHIDDEN,Et.myMemberState!==e.MemberState.JOINED&&(Et.myMemberState=e.MemberState.INVITED),Et.invitedAt=Qe.ts)}catch(e){St.e(e)}finally{St.f()}return this._dispatcher.dispatch(new Qp({channels:[Et],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:wt,invitees:xt}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Et,wt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 242:return a.next=244,this.getChannel(Qe.channelUrl,!0);case 244:return Nt=a.sent,At=t.as(Tv),Mt=At.memberCount,Ut=At.joinedMemberCount,Ot=At.inviter,Dt=At.invitee,Nt.isExclusive||Nt.isSuper||Nt.isBroadcast?(Nt.isSuper&&this._userInfoCache.upsert(Dt,Qe.ts),Nt._setLatestMemberCount(Mt,Ut,Qe.ts)):Nt.removeMember(Dt),this._sdkState.userId===Dt.userId?(Nt.invitedAt=0,Nt.myMemberState=e.MemberState.NONE,Nt.isPublic?this._dispatcher.dispatch(new Qp({channels:[Nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:Ot,invitee:Dt}})):this._dispatcher.dispatch(new Kp({channelUrls:[Nt.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:Ot,invitee:Dt}}))):this._dispatcher.dispatch(new Qp({channels:[Nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:Ot,invitee:Dt}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(Nt,Ot,Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 250:return a.next=252,this.getChannel(Qe.channelUrl,!0);case 252:return Rt=a.sent,Lt=Qe.category===Tp.TYPING_START,Pt=t.as(Lt?Dv:Lv),Ft=Pt.user,Rt._updateTypingStatus(Ft,Lt?Qe.ts:0),this._dispatcher.dispatch(new Qp({channels:[Rt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 259:return a.next=261,this.getChannel(Qe.channelUrl,!0);case 261:qt=a.sent,Ht=Qe.category===Tp.USER_CHANNEL_MUTE,Gt=t.as(Ht?lc:hc),(jt=Gt.user).userId===this._sdkState.userId&&(qt.myMutedState=Ht?e.MutedState.MUTED:e.MutedState.UNMUTED,qt._myMutedRemainingTime=jt.restrictionInfo.remainingDuration),Vt=i(qt.members),a.prev=266,Vt.s();case 268:if((zt=Vt.n()).done){a.next=275;break}if((Bt=zt.value).userId!==jt.userId){a.next=273;break}return Bt.isMuted=Ht,a.abrupt("break",275);case 273:a.next=268;break;case 275:a.next=280;break;case 277:a.prev=277,a.t6=a.catch(266),Vt.e(a.t6);case 280:return a.prev=280,Vt.f(),a.finish(280);case 283:return qt.isSuper&&this._userInfoCache.upsert(jt,Qe.ts),this._dispatcher.dispatch(new Qp({channels:[qt],context:{source:Ht?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:jt}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ht?e.onUserMuted&&e.onUserMuted(qt,jt):e.onUserUnmuted&&e.onUserUnmuted(qt,jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 287:if(!(Qt=this._leftChannels.get(Qe.channelUrl))){a.next=292;break}a.t7=Qt.channel,a.next=295;break;case 292:return a.next=294,this.getChannel(Qe.channelUrl,!0);case 294:a.t7=a.sent;case 295:return Kt=a.t7,this._markAsLeave(Kt),Wt=t.as(pc),Yt=Wt.user,Zt=Yt.userId===this._sdkState.userId,Kt.isSuper&&this._userInfoCache.upsert(Yt,Qe.ts),Zt&&this._dispatcher.dispatch(new Kp({channelUrls:[Kt.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Yt}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(Kt,Yt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 303:return a.next=305,this.getChannel(Qe.channelUrl,!0);case 305:return Xt=a.sent,Jt=t.as(_c),$t=Jt.user,en=$t.userId===this._sdkState.userId,Xt.isSuper&&this._userInfoCache.upsert($t,Qe.ts),en&&this._dispatcher.dispatch(new Kp({channelUrls:[Xt.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:$t}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Xt,$t)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 312:return a.next=314,this.getChannel(Qe.channelUrl,!0);case 314:return tn=a.sent,nn=t.as(gc),rn=nn.freeze,tn.isFrozen=rn,this._dispatcher.dispatch(new Qp({channels:[tn],context:{source:rn?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){rn?e.onChannelFrozen&&e.onChannelFrozen(tn):e.onChannelUnfrozen&&e.onChannelUnfrozen(tn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 320:return a.next=322,this.getChannel(Qe.channelUrl,!0);case 322:return an=a.sent,sn=t.as(Uv),on=sn.allowAutoUnhide,un=sn.hidePreviousMessages,cn=sn.messageOffsetTimestamp,null!==on&&(an.hiddenState=on?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==un&&un&&an._updateUnreadCount(0,0),null!==cn&&(an.messageOffsetTimestamp=cn),this._dispatcher.dispatch(new Qp({channels:[an],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(an)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 330:return a.next=332,this.getChannel(Qe.channelUrl,!0);case 332:return(ln=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Qp({channels:[ln],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(ln)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 337:return a.next=339,this.getChannel(Qe.channelUrl,!0);case 339:return dn=a.sent,this._dispatcher.dispatch(new Kp({channelUrls:[Qe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(dn.url,dn.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 343:return a.next=345,this.getChannelWithoutCache(Qe.channelUrl,!0);case 345:return hn=a.sent,this._dispatcher.dispatch(new Qp({channels:[hn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(hn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 349:return a.next=351,this.getChannel(Qe.channelUrl,!0);case 351:return fn=a.sent,pn=t.as(Yu),vn=pn.created,_n=pn.updated,mn=pn.deleted,vn&&(fn._upsertCachedMetaData(vn,Qe.ts),this._dispatcher.dispatch(new Qp({channels:[fn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:vn},ts:Qe.ts}))),_n&&(fn._upsertCachedMetaData(_n,Qe.ts),this._dispatcher.dispatch(new Qp({channels:[fn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:_n},ts:Qe.ts}))),mn&&(fn._removeFromCachedMetaData(mn,Qe.ts),this._dispatcher.dispatch(new Qp({channels:[fn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:mn},ts:Qe.ts}))),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vn&&e.onMetaDataCreated&&e.onMetaDataCreated(fn,vn),_n&&e.onMetaDataUpdated&&e.onMetaDataUpdated(fn,_n),mn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(fn,mn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 358:return a.next=360,this.getChannel(Qe.channelUrl,!0);case 360:return gn=a.sent,yn=t.as(ic),En=yn.created,kn=yn.updated,bn=yn.deleted,En&&this._dispatcher.dispatch(new Qp({channels:[gn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:En}})),kn&&this._dispatcher.dispatch(new Qp({channels:[gn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:kn}})),bn&&this._dispatcher.dispatch(new Qp({channels:[gn],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:bn}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){En&&e.onMetaCounterCreated&&e.onMetaCounterCreated(gn,En),kn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(gn,kn),bn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(gn,bn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",373);case 367:return a.next=369,this.getChannel(Qe.channelUrl,!0);case 369:return Cn=a.sent,wn=t.as(Hv),xn=wn.pinnedMessageIds,Sn=wn.latestPinnedMessage,(Tn=wn.ts)>Cn._pinnedMessagesUpdatedAt&&(Cn.pinnedMessageIds=null!=xn?xn:[],Cn.lastPinnedMessage=Sn,Cn._pinnedMessagesUpdatedAt=Tn,this._dispatcher.dispatch(new Qp({channels:[Cn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Cn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Pa((function(){return E(Ln,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Cn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",373);case 373:return a.abrupt("break",385);case 374:In=t.as(hf),Nn=In.event,a.t8=Nn.category,a.next=a.t8===Kh.USER_BLOCK?378:a.t8===Kh.USER_UNBLOCK?381:384;break;case 378:return An=af.getDataAsUserBlockEvent(this._iid,Nn),Mn=An.blocker,Un=An.blockee,this._groupChannelCache.block(Mn.userId,Un.userId),a.abrupt("break",384);case 381:return On=af.getDataAsUserBlockEvent(this._iid,Nn),Dn=On.blocker,Rn=On.blockee,this._groupChannelCache.unblock(Dn.userId,Rn.userId),a.abrupt("break",384);case 384:return a.abrupt("break",385);case 385:a.next=391;break;case 387:if(a.prev=387,a.t9=a.catch(0),!A(a.t9)){a.next=391;break}throw a.t9;case 391:case"end":return a.stop()}}),a,this,[[0,387],[20,31,34,37],[62,73,76,79],[152,165,168,171],[266,277,280,283]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,s,i,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ps(R("string",t)).throw(M.invalidParameters),a=new Jp({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:s=r.sent,i=s.as($p),o=i.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function s(){var i,o,u,c,l;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,i=new Jp({channelUrl:t,isInternalCall:n,showLatestMessage:a}),s.next=4,this._requestQueue.send(i);case 4:if(o=s.sent,u=o.as($p),(c=u.channel).myMemberState!==e.MemberState.NONE){s.next=10;break}this._dispatcher.dispatch(new Kp({channelUrls:[c.url],context:{source:r}})),s.next=14;break;case 10:return s.next=12,this.upsertChannelsToCache([c]);case 12:l=s.sent,this._dispatcher.dispatch(new Qp({channels:l,context:{source:r}}));case 14:s.next=19;break;case 16:s.prev=16,s.t0=s.catch(0),s.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&s.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Kp({channelUrls:[t],context:{source:r}}));case 19:case"end":return s.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var i,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),i=!1,s&&(o=vi.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new tv(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:s&&i})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(nv),p=f.channels,v=f.token,this._dispatcher.dispatch(new Qp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,s,i,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},Dp),n),ps((R("string",t)||R("number",t))&&Rp(a)).throw(M.invalidParameters),s=new Zp(_e({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(s);case 5:return i=e.sent,o=i.as(Xp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new Qp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new Kp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Lp),e),ps(Pp(n)).throw(M.invalidParameters),r=new rv({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,s=a.as(av),i=s.groupChannelCount,t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Fp),e),ps(qp(n)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new sv({userId:a.userId,filter:n}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(iv),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",ve({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ov({userId:n.userId}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(uv),o=i.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Hp),e),ps(Gp(n)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new cv({userId:a.userId,filter:n}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(lv),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},jp),e),ps(Vp(n)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new dv(n),t.next=6,a.send(s);case 6:return i=t.sent,o=i.as(hv),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=vi.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=vi.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=vi.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Up),e),ps(Op(n)).throw(M.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new pv(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,s=a.as(vv),i=s.channel,t.next=10,this.upsertChannelsToCache([i]);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ps(t-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new _v({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=i(r);try{for(a.s();!(s=a.n()).done;)(o=s.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ps(F("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new _v({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=[],o=i(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),c._updateUnreadCount(0,0),s.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(s.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(s);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function i(){return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:s});case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Zv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Xv[e]||(Xv[e]=new a(e,vi.of(e))),Xv[e]}},{key:"clear",value:function(e){Xv[e]&&delete Xv[e]}}])}(Gv),$v=function(e,t){return t instanceof yo?e.findIndex((function(e){return e instanceof yo&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},e_=function(e,t){return e.findIndex((function(e){return e instanceof go?e.messageId===t:e instanceof To?e.notificationId===t:void 0}))},t_=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n<r;){var s=e[a].createdAt-t.createdAt;if(s>0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},n_={},r_=function(){function t(n){var a=this,s=n._iid,i=n.channel,o=n.limit,u=void 0===o?100:o;r(this,t),this.ref=0,this._iid=s,this._channel=i,this._limit=u,this._prevSyncLoopCount=0;var c,l,h=vi.of(this._iid),f=h.sdkState,p=h.cacheContext,_=h.dispatcher,m=h.logger,g=h.statManager,y=h.messageBackgroundSyncThrottleController;this._metadataKey=(c=f.userId,l=i.url,"sendbird:".concat(c,"@groupchannel/").concat(l,"/message/sync.meta"));var k=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/sync")}(f.userId,i.url);this._prevSync=new vp(k,(function(t){return E(a,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,y.run("message-background-sync-".concat(i.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c,l,h,f,_,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return h={hasNext:!0,nextToken:0},this._prevSyncLoopCount++,n.next=4,this.loadMetadata();case 4:if(m.debug("message background prev sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.top),null===(a=this._metadata)||void 0===a?void 0:a.previousComplete){n.next=32;break}return n.prev=6,f=xh.of(this._iid),n.next=10,f._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,(null===(o=null===(s=this._metadata)||void 0===s?void 0:s.range)||void 0===o?void 0:o.top)?this._metadata.range.top:t,{prevResultSize:this._limit,nextResultSize:0,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},e.CollectionEventSource.SYNC_MESSAGE_BACKGROUND,!1,!1,Go.INTERNAL_BACKSYNC);case 10:return _=n.sent,(y=_.messages).length>0&&(k=y.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(E=u.range).intersect.apply(E,v(k)))?this.extendRange(y):this._metadata={range:new Zv({top:Math.min.apply(Math,v(k)),bottom:Math.max.apply(Math,v(k))}),previousComplete:!1}),h.hasNext=y.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=y.length<this._limit),m.debug("message background prev sync progress",h),n.next=18,this.saveMetadata();case 18:n.next=27;break;case 20:if(n.prev=20,n.t0=n.catch(6),m.debug("message background prev sync error",n.t0),!(n.t0 instanceof M&&n.t0.isInvalidTokenError)){n.next=26;break}return n.next=26,this.clearMetadata();case 26:throw n.t0;case 27:return n.prev=27,g.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:i.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(l=null===(c=p.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==l?l:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(27);case 30:n.next=33;break;case 32:h.hasNext=!1;case 33:return n.abrupt("return",h);case 34:case"end":return n.stop()}}),n,this,[[6,20,27,30]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._nextSync=new vp(k,(function(t){return E(a,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,y.run("message-background-sync-".concat(i.url,"-next"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c,l,h,f,_,y,E;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l={hasNext:!0,nextToken:0},n.next=3,this.loadMetadata();case 3:return m.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),n.prev=4,h=xh.of(this._iid),n.next=8,h._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,(null===(s=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===s?void 0:s.bottom)?this._metadata.range.bottom:t,{prevResultSize:0,nextResultSize:this._limit,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},e.CollectionEventSource.SYNC_MESSAGE_BACKGROUND,!1,!1,Go.INTERNAL_BACKSYNC);case 8:return f=n.sent,(_=f.messages).length>0&&(E=_.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(y=o.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new Zv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),l.hasNext=_.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=16,this.saveMetadata();case 16:n.next=22;break;case 18:throw n.prev=18,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 22:return n.prev=22,g.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:i.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(22);case 25:return n.abrupt("return",l);case 26:case"end":return n.stop()}}),n,this,[[4,18,22,25]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof Ba)if(e.stateType===qa.CONNECTED)a.resume();else a.pause()}))}return s(t,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Zv({})}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new Zv(r.range),previousComplete:r.previousComplete}:{range:new Zv({}),previousComplete:!1};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=vi.of(this._iid),i=s.logger,o=s.sessionManager;s.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){vi.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete n_[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return n_[e]||(n_[e]={}),n_[e][n.url]||(n_[e][n.url]=new t({_iid:e,channel:n})),n_[e][n.url].ref++,n_[e][n.url]}},{key:"clear",value:function(e,t){n_[e]&&n_[e][t]&&(n_[e][t].close(),delete n_[e])}}])}(),a_={},s_=function(){function t(n){var a=this,s=n._iid,i=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=s,this._channel=i,this._includeParams=o;var u,c,l=vi.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new vp(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=xh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return s=t.sent,i=s.updatedMessages,o=s.deletedMessageIds,u=s.hasMore,c=s.token,l=s.forceUseNextToken,r.hasNext=u,r.nextToken=c,i.length>0||o.length>0?this._metadata&&(this._metadata.token=c):l&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetadata();case 28:throw t.t0;case 29:return t.abrupt("return",r);case 30:case"end":return t.stop()}}),t,this,[[4,22]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Ba)if(e.stateType===qa.CONNECTED)a.resume();else a.pause()}))}return s(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=vi.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=vi.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){vi.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete a_[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return a_[e]||(a_[e]={}),a_[e][n.url]||(a_[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),a_[e][n.url].ref++,a_[e][n.url]}},{key:"clear",value:function(e,t){a_[e]&&a_[e][t]&&(a_[e][t].close(),delete a_[e])}}])}(),i_={},o_=function(){function e(t){var n=this,a=t._iid,s=t.channel,i=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=s;var o,u,c=vi.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=s.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new vp(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,s,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,i();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=vi.of(this._iid),s=a.firstConnectedAt,this._metadata={token:s}),e.prev=13,o=vl.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof M&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Ba)if(e.stateType===qa.CONNECTED)n.resume();else n.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){vi.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){vi.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete i_[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return i_[t]||(i_[t]={}),i_[t][n.url]||(i_[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),i_[t][n.url].ref++,i_[t][n.url]}}])}(),u_=function(t){function a(t){var s,i,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a)).method=me.GET,s.path="".concat(He(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),s.params=ve({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(i=t.threshold)&&void 0!==i?i:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions_summary:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),s}return c(a,t),s(a)}(Qe),c_=function(e){function t(e,a){var s,i,o,u,c,l,d;return r(this,t),(s=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return No(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return No(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,s}return c(t,e),s(t)}(Ke),l_={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var d_,h_,f_,p_=function(){return s((function e(){r(this,e),this._onCacheResult=_t,this._onApiResult=_t}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;Pa((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),v_=function(){return s((function t(n,a){var s=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(le()),this._isDisposed=!1,this.filter=null!=o?o:new ah,this._channel=f,this._syncRange=new Zv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=vi.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(s.channel)}));a>=0&&(s._replaceChannelOfCollection(t[a]),s.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,i=0;i<s._messages.length;i++){if(s._messages[i].createdAt>=t.messageOffsetTimestamp){a=!0;var o=i;if(o>0){var u=s._messages.splice(0,o);s._removeMessagesFromView(u.map((function(e){return s.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&s._messages.length>0&&s._removeMessagesFromView(s._messages.map((function(e){return s.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=vi.of(s._iid).sdkState,l=n.user;c.userId===l.userId&&s._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=vi.of(s._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&s._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&s._clearCheckMyMutedTimer()}Pa((function(){return E(s,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Bp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),s._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(t,n){var r=t.indexOf(s.channel.url);r>=0&&s._channel._runIfHandleableWithGroupChannel((function(a){a.myMemberState=e.MemberState.NONE,s._clearCheckMyMutedTimer(),Pa((function(){return E(s,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onChannelDeleted)&&this._handler.onChannelDeleted(n,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),s._postprocessChannelRemoveEvent(t[r])}))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=i(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===s._channel.url&&(s.filter.match(c)?a.push(c):o.push(s.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ki(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:s._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:s._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:s.hasNext||s._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:s._addMessagesToView(a,n)}o.length>0&&s._removeMessagesFromView(o,n)}s._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){s._removeMessagesFromView(e,t),s._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){s._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){s._updatePollsToView(e,t)},onPollUpdate:function(e,t){s._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){s._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){s._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){s._applyThreadInfoEventToView(e,t)},onDeletedByRetentionPolicy:function(e,t,n){t===s.channel.url&&s._messageRetention(e,n)}});var y=vi.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new Qp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=r_.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=s_.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=o_.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new vp(this._key,(function(t){return E(s,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled,sdkSource:Go.INTERNAL_FILL_GAP});case 2:if(i=n.sent,o=i.messages,u=i.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop<c,nextToken:this._syncRange.top});case 10:return k.localCacheEnabled&&g.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(s=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==s?s:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._nextFill=new vp(this._key,(function(t){return E(s,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-next"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:k.localCacheEnabled,sdkSource:Go.INTERNAL_FILL_GAP});case 2:if(i=n.sent,o=i.messages,u=i.isContinuousMessages,c=i.hasNext,!(o.length>0)){n.next=11;break}return l=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(l),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(l)),n.abrupt("return",{hasNext:c,nextToken:this._syncRange.bottom});case 11:return k.localCacheEnabled&&g.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(s=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==s?s:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 13:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof Ba)switch(e.stateType){case qa.CONNECTED:Fa((function(){return E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case qa.LOGOUT:s.dispose();break;default:s._clearCheckMyMutedTimer(),s._prevFill.stop(),s._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=vi.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof go&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],s=i(e);try{for(s.s();!(n=s.n()).done;){var o=n.value,u=e_(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){s.e(e)}finally{s.f()}return a.length>0&&Ki(t)&&Pa((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,s,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=e_(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ki(t)&&Pa((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,s,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=e_(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ki(t)&&Pa((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,s,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=e_(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ki(t)&&(a.applyReactionEvent(e),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,s,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=e_(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ki(t)&&(a.applyThreadInfoUpdateEvent(e),Pa((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,s,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],s=[],o=i(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var i=r._messages[t];a.push(r.keyOf(i)),s.push(i),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ki(t)&&s.length>0&&Pa((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,i,this.channel,a,s);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_messageRetention",value:function(e,t){var n,r=[],a=i(this._messages);try{for(a.s();!(n=a.n()).done;){var s=n.value;s.createdAt<=e&&r.push(this.keyOf(s))}}catch(e){a.e(e)}finally{a.f()}r.length>0&&this._removeMessagesFromView(r,t)}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,s=void 0===a?0:a,i=t.inclusive,o=void 0===i||i;return E(this,void 0,void 0,d().mark((function t(){var n,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(s>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return i=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(i)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:i.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p,_=n.sdkSource;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=xh.of(this._iid),!(a>0||i>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,_e(Object.assign(Object.assign(Object.assign({},this.filter),l_),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:i})),u,f,v,_);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var t,n,r,a,s;return E(this,void 0,void 0,d().mark((function i(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,A,U,O,D=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(o=vi.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){i.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,i.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=i.sent,i.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=i.sent,i.prev=12,i.next=15,Is((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new u_(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),l_)),t.next=3,c.send(r);case 3:a=t.sent,s=a.as(c_),i=s.isHugeGap,o=s.prevMessages,h=void 0===o?[]:o,f=s.prevHasMore,b=s.isContinuousPrevMessages,C=s.nextMessages,w=void 0===C?[]:C,x=s.nextHasmore,S=s.isContinuousNextMessages,i?Pa((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Wi({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Wi({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:i.next=20;break;case 17:i.prev=17,i.t0=i.catch(12),f.debug("Failed HugeGap Check ",i.t0);case 20:return i.prev=20,l.localCacheEnabled&&h.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),i.finish(20);case 23:i.next=42;break;case 25:return b=Date.now(),i.prev=26,i.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled,sdkSource:Go.INTERNAL_FILL_GAP});case 29:if(C=i.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,A=0,U=0;U<I.length;U++)(O=I[U])<=b?N++:O>=b&&A++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:A>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;i.next=39;break;case 36:i.prev=36,i.t1=i.catch(26),i.t1 instanceof M&&i.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return i.prev=39,l.localCacheEnabled&&h.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(s=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==s?s:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),i.finish(39);case 42:case"end":return i.stop()}}),i,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,s,i=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=vi.of(this._iid),s=a.logger,r.prev=1,r.next=4,this._channelManager.refreshChannel(this.channel.url,!0,t,n);case 4:this.channel._runIfHandleableWithGroupChannel((function(t){t.myMutedState===e.MutedState.MUTED&&Fa((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}))})),r.next=10;break;case 7:r.prev=7,r.t0=r.catch(1),s.warn("Failed to refresh channel",r.t0);case 10:case"end":return r.stop()}}),r,this,[[1,7]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,s,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=vi.of(this._iid),s=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:s.currentUser};null===(r=null===(n=i._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,i.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,s=0;s<n.length;s++){var i=n[s];i<this._startingPoint?r++:i>this._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new p_;this._messages=[],this._unsentMessages=[],this._syncRange=new Zv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],s={messages:[],prevMessagesCount:0,nextMessagesCount:0};return Pa((function(){return E(n,void 0,void 0,d().mark((function n(){var i,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata();case 2:o=n.sent,u=vi.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t,a=this._filterUnderOffsetMessage(s.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(A(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var i,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=vi.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&s.prevMessagesCount<this._prevResultLimit?p=!0:this._startingPoint>o.range.bottom||s.nextMessagesCount<this._nextResultLimit?_=!0:p=!1),n.next=7,this._refreshChannel(e.CollectionEventSource.REFRESH_CHANNEL,_);case 7:_&&this._channel._runIfHandleableWithGroupChannel((function(e){var t=Math.max.apply(Math,v(a.map((function(e){return e.createdAt}))));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled,sdkSource:Go.EXTERNAL_COLLECTION}).then((function(t){var n,a,s,i=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(i);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(s=g._syncRange).extends.apply(s,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(A(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(i=h.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new ei({type:Be.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new M({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(s=vi.of(this._iid),i=s.cacheContext,o=s.statManager,u=s.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,Fa((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,i.localCacheEnabled&&o.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=i.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:i.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,Fa((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=vi.of(this._iid),i=s.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:i.localCacheEnabled,sdkSource:Go.EXTERNAL_COLLECTION});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return $v(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=i.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:i.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var s,i,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new M({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(s=vi.of(this._iid),i=s.cacheContext,o=s.statManager,u=s.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,Fa((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,i.localCacheEnabled&&o.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=i.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:i.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,Fa((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=vi.of(this._iid),u=i.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled,sdkSource:Go.EXTERNAL_COLLECTION});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return $v(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(s=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==s?s:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var s=vi.of(this._iid),i=s.cacheContext,o=s.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new Qp({channels:[a._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),i.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),__=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Jv.of(e)})])}return c(a,t),s(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){return p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,s=this._filterUnderOffsetMessage(t),o=[],u=[],c=i(s);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if($v(this._messages,l)<0){$v(this._unsentMessages,l)<0&&o.push(l);var h=t_(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof yo){$v(this._unsentMessages,l)<0&&$v(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=$v(this._messages,l);if(f<0){var p=$v(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=t_(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof yo){var g=$v(this._unsentMessages,l);g<0?$v(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ki(n)&&Pa((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,i,this.channel,o)),u.length>0&&(null===(s=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===s||s.call(a,i,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],s=[],o=[],u=i(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=$v(this._messages,c);if(l>=0)s.push(c),this._messages[l]=c;else{var h=$v(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{s.push(c);var _=t_(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAt<Math.min.apply(Math,v(m))&&!this._hasPrevious||c.createdAt>Math.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof yo){var g=$v(this._unsentMessages,c);g>=0&&(s.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ki(t)&&Pa((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},s.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,s):o.length>0?null===(u=null===(i=this._handler)||void 0===i?void 0:i.onMessagesDeleted)||void 0===u||u.call(i,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),s}}])}(v_),m_={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},g_=function(e){return R("string",e.coverUrl,!0)&&(G(e.coverImage)||R("string",e.coverImage,!0))&&R("boolean",e.isDistinct,!0)&&R("boolean",e.isPublic,!0)&&R("boolean",e.isDiscoverable,!0)&&R("string",e.accessCode,!0)&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&R("number",e.messageSurvivalSeconds,!0)},y_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=me.GET,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),s(t)}(Qe),E_=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new xp(e,t)}))),s}return c(t,e),s(t)}(Ke);e.MutedMemberFilter=void 0,(d_=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",d_.MUTED="muted",d_.UNMUTED="unmuted",e.MemberListOrder=void 0,(h_=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",h_.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(f_=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",f_.JOINED="joined_only",f_.INVITED="invited_only",f_.INVITED_BY_FRIEND="invited_by_friend",f_.INVITED_BY_NON_FRIEND="invited_by_non_friend";var k_,b_,C_=function(t){function a(t,s,i){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,s,e.ChannelType.GROUP,i])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=i.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=i.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=i.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=i.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&L(e.MutedMemberFilter,this.mutedMemberFilter)&&L(e.MemberStateFilter,this.memberStateFilter)&&(R("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&L(e.OperatorFilter,this.operatorFilter)&&L(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new y_(_e(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(E_),i=s.members,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),w_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return c(t,e),s(t)}(Qe),x_=function(t){function a(t,s){var i;return r(this,a),(i=n(this,a,[t,s])).channel=new Z_(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return c(a,t),s(a)}(Ke),S_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a.params=ve({is_distinct:i,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),s(t)}(Qe),T_=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Z_(e,a),s}return c(t,e),s(t)}(Ke),I_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl;return(a=n(this,t)).method=me.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a}return c(t,e),s(t)}(Qe),N_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl;return(a=n(this,t)).method=me.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/hide"),a}return c(t,e),s(t)}(Qe),A_=function(e){function t(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return c(t,e),s(t)}(Qe),M_=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).countPreference=a.count_preference,s}return c(t,e),s(t)}(Ke),U_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.locale;return(a=n(this,t)).method=me.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/reset_user_history"),a.params=ve({locale:i}),a}return c(t,e),s(t)}(Qe),O_=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return c(t,e),s(t)}(Ke),D_=Object.assign(Object.assign({},ku),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),R_=function(e){return bu(e)&&R("number",e.scheduledAt,!0)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},L_=Object.assign(Object.assign({},Cu),{scheduledAt:void 0}),P_=function(e){return wu(e)&&R("number",e.scheduledAt,!0)},F_=function(t){function a(t){var s,i,o;r(this,a),s=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return s.method=me.PUT,s.path="".concat(He(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),s.params=ve(_e({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:te.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(i=t._thumbnails)||void 0===i?void 0:i.map((function(e){return mi.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),s}return c(a,t),s(a)}(Qe),q_=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).message=new Ao(e,a),s}return c(t,e),s(t)}(Ke),H_=function(t){function a(t){var s,i;r(this,a),s=n(this,a);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=me.PUT,s.path="".concat(He(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ve(_e({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:te.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Ti.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return c(a,t),s(a)}(Qe),G_=function(e){function t(e){var a;r(this,t),a=n(this,t);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=me.DELETE,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),s(t)}(Qe),j_=function(e){function t(e){var a;r(this,t),a=n(this,t);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=me.POST,a.path="".concat(He(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),s(t)}(Qe),V_=function(e){function t(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=me.PUT,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return c(t,e),s(t)}(Qe),z_=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return c(t,e),s(t)}(Ke),B_=function(e){function t(e){var a,s=e.userId,i=e.channelUrl;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(ye,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return c(t,e),s(t)}(Qe),Q_=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return c(t,e),s(t)}(Ke),K_=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.channelType;return(a=n(this,t)).method=me.GET,a.path="".concat(He(i),"/").concat(encodeURIComponent(s),"/message_purge_offset"),a}return c(t,e),s(t)}(Qe),W_=function(e){function t(e,a){var s;r(this,t),s=n(this,t,[e,a]);var i=a.message_purge_offset;return s.messageDeletionTimestamp=i,s}return c(t,e),s(t)}(Ke);e.CountPreference=void 0,(k_=e.CountPreference||(e.CountPreference={})).ALL="all",k_.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",k_.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",k_.OFF="off",e.HiddenState=void 0,(b_=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",b_.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",b_.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Y_,Z_=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T,I;(r(this,a),(i=n(this,a,[t,s]))._unreadMemberStateMap=new Map,i._undeliveredMemberStateMap=new Map,i._typingStatus=new Map,i._lastMemberCountUpdated=0,i._typingStarted=0,i._typingEnded=0,i._hasBotInfo={general:!1,ai:!1},i.isDistinct=!1,i.isSuper=!1,i.isBroadcast=!1,i.isExclusive=!1,i.isPublic=!1,i.isDiscoverable=!0,i.isChatNotification=!1,i.isAccessCodeRequired=!1,i.isPushEnabled=!1,i.unreadMessageCount=0,i.unreadMentionCount=0,i.totalUnreadReplyCount=0,i.members=[],i.memberCount=0,i.joinedMemberCount=0,i.hiddenState=e.HiddenState.UNHIDDEN,i.lastMessage=null,i.messageOffsetTimestamp=0,i.messageSurvivalSeconds=-1,i.myMemberState=e.MemberState.NONE,i.myRole=e.Role.NONE,i.myMutedState=e.MutedState.UNMUTED,i.myLastRead=0,i.myCountPreference=e.CountPreference.ALL,i.myPushTriggerOption=e.PushTriggerOption.DEFAULT,i.inviter=null,i.invitedAt=0,i.joinedAt=0,i.lastPinnedMessage=null,i._latestMessageInfo=null,i._pinnedMessagesUpdatedAt=0,i._myMutedRemainingTime=-1,i._messageDeletionTimestamp=0,i.channelType=e.ChannelType.GROUP,i.isDistinct=null!==(o=s.is_distinct)&&void 0!==o&&o,i.isSuper=null!==(u=s.is_super)&&void 0!==u&&u,i.isBroadcast=null!==(c=s.is_broadcast)&&void 0!==c&&c,i.isExclusive=null!==(l=s.is_exclusive)&&void 0!==l&&l,i.isPublic=null!==(d=s.is_public)&&void 0!==d&&d,i.isDiscoverable=null!==(h=s.is_discoverable)&&void 0!==h?h:i.isPublic,i.isChatNotification=null!==(f=s.is_chat_notification)&&void 0!==f&&f,i.isAccessCodeRequired=null!==(p=s.is_access_code_required)&&void 0!==p&&p,i.isPushEnabled=null!==(_=s.is_push_enabled)&&void 0!==_&&_,Array.isArray(s.members))&&(I=i.members).push.apply(I,v(s.members.map((function(e){return new xp(i._iid,e)}))));return i.memberCount=null!==(m=s.member_count)&&void 0!==m?m:0,i.joinedMemberCount=null!==(g=s.joined_member_count)&&void 0!==g?g:0,i.hiddenState=L(e.HiddenState,s.hidden_state)?s.hidden_state:e.HiddenState.UNHIDDEN,i.messageOffsetTimestamp=null!==(y=s.ts_message_offset)&&void 0!==y?y:0,i.messageSurvivalSeconds=null!==(E=s.message_survival_seconds)&&void 0!==E?E:-1,i.lastMessage=s.last_message?No(i._iid,Object.assign({channel_type:i.channelType},s.last_message)):null,s.read_receipt&&Object.keys(s.read_receipt).forEach((function(e){R("number",s.read_receipt[e])&&i._updateUnreadMemberState(e,s.read_receipt[e])})),s.delivery_receipt&&Object.keys(s.delivery_receipt).forEach((function(e){R("number",s.delivery_receipt[e])&&i._updateUndeliveredMemberState(e,s.delivery_receipt[e])})),i.myMemberState=L(e.MemberState,s.member_state)?s.member_state:e.MemberState.NONE,i.myRole=L(e.Role,s.my_role)?s.my_role:e.Role.NONE,L(e.MutedState,s.is_muted)?i.myMutedState=s.is_muted:R("boolean",s.is_muted)?i.myMutedState=s.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:i.myMutedState=e.MutedState.UNMUTED,i.myCountPreference=L(e.CountPreference,s.count_preference)?s.count_preference:e.CountPreference.ALL,i.myPushTriggerOption=L(e.PushTriggerOption,s.push_trigger_option)?s.push_trigger_option:e.PushTriggerOption.ALL,i.myLastRead=null!==(k=s.user_last_read)&&void 0!==k?k:0,i.inviter=s.inviter?new _s(i._iid,s.inviter):null,i.invitedAt=null!==(b=s.invited_at)&&void 0!==b?b:0,i.joinedAt=null!==(C=s.joined_ts)&&void 0!==C?C:0,i._updateUnreadCount(null!==(w=s.unread_message_count)&&void 0!==w?w:0,null!==(x=s.unread_mention_count)&&void 0!==x?x:0),i.totalUnreadReplyCount=null!==(S=s.total_unread_thread_message_count)&&void 0!==S?S:0,i.lastPinnedMessage=s.latest_pinned_message?No(i._iid,Object.assign({channel_type:i.channelType},s.latest_pinned_message)):null,s.latest_message&&(i._latestMessageInfo={messageId:s.latest_message.message_id,createdAt:s.latest_message.created_at}),i._hasBotInfo={general:!!s.has_bot,ai:!!s.has_ai_bot},i._messageDeletionTimestamp=null!==(T=s.message_purge_offset)&&void 0!==T?T:0,i}return c(a,t),s(a,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=i(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=i(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"messageDeletionTimestamp",get:function(){return this._messageDeletionTimestamp}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=vi.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof yo&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt<t.createdAt||this.lastMessage.createdAt===t.createdAt&&this.lastMessage.messageId===t.messageId&&this.lastMessage.updatedAt<t.updatedAt}},{key:"_tryUpdateLastMessageAndCallEvents",value:function(t,n){var r=vi.of(this._iid).dispatcher,a=Jv.of(this._iid);this._updateLastMessage(n),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new Qp({channels:[t],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}}))}},{key:"_shouldUpdateUnreadCountWith",value:function(t){var n=vi.of(this._iid).appInfo;switch(null==n?void 0:n.unreadCountThreadingPolicy){case e.UnreadCountThreadingPolicy.NONE:case e.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case e.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof yo&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=vi.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n<t)&&(this._unreadMemberStateMap.set(e,t),vi.of(this._iid).sdkState.userId===e&&(this.myLastRead=t),!0)}},{key:"_updateUndeliveredMemberState",value:function(e,t){var n=this._undeliveredMemberStateMap.get(e);return(!n||n<t)&&(this._undeliveredMemberStateMap.set(e,t),!0)}},{key:"_updateTypingStatus",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=vi.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return hs(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new __(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new C_(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ph(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof xp?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof yo&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=vi.of(this._iid).sdkState,a=t.createdAt,s=0,o=i(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)<a&&s++}}catch(e){o.e(e)}finally{o.f()}return s}return 0}},{key:"getUndeliveredMemberCount",value:function(t){if(t instanceof yo&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=vi.of(this._iid).sdkState,a=t.createdAt,s=0,o=i(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUndeliveredMemberState[u.userId]||0)<a&&s++}}catch(e){o.e(e)}finally{o.f()}return s}return 0}},{key:"getReadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=vi.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof yo?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o>=e.createdAt&&s.push(i)}})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=vi.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof yo?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o<e.createdAt&&s.push(i)}})),s}},{key:"getReadStatus",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=vi.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new Di(e._iid,{channel_url:e.url,channel_type:e.channelType,user:xp.payloadify(a),ts:null!=s?s:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=vi.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new Sp(e._iid,{channel_url:e.url,channel_type:e.channelType,user:xp.payloadify(a),ts:null!=s?s:0})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=vi.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Jp({channelUrl:this.url}),n.next=4,a.send(i);case 4:return o=n.sent,u=o.as($p),c=u.channel,this._update(c),t||s.dispatch(new Qp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=vi.of(this._iid),r.dispatcher.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=vi.of(this._iid),r.dispatcher.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},m_),t),ps(g_(r)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new S_(Object.assign({channelUrl:this.url},r)),n.next=6,i.send(o);case 6:return u=n.sent,c=u.as(T_),l=c.channel,this._update(l),s.dispatch(new Qp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(e.every((function(e){return e instanceof _s}))).throw(M.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(F("string",t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=r.sessionManager,o=new Cv({channelUrl:this.url,userIds:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(wv),l=c.channel,this._update(l),a.dispatch(new Qp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:i.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("string",t,!0)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.dispatcher,s=r.sdkState,i=r.requestQueue,o=new gv({channelUrl:this.url,userId:s.userId,accessCode:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(yv),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Qp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=vi.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new kv({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,s.send(i);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("string",t,!0)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.dispatcher,s=r.sdkState,i=r.requestQueue,o=new w_({channelUrl:this.url,userId:s.userId,accessCode:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(x_),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Qp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Sv({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(s);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new au,s=vi.of(this._iid).dispatcher,i=nf.of(this._iid);return p(a,"sendUserMessage",this,3)([t]).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){i.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Jv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=vi.of(this._iid),i=a.dispatcher,r.next=3,s.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Jv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),i.dispatch(new Qp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Jv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),i.dispatch(new Wi({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new au,s=vi.of(this._iid).dispatcher,i=nf.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([t]).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Jv.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new au,s=vi.of(this._iid).dispatcher,i=nf.of(this._iid);return p(a,"sendFileMessage",this,3)([t]).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Jv.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Nl,s=vi.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Jv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=vi.of(this._iid),i=a.dispatcher,r.next=3,s.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Jv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),i.dispatch(new Qp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Jv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),i.dispatch(new Wi({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new au,s=vi.of(this._iid).dispatcher,i=nf.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([t]).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Jv.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new Qp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof yo&&(a=vi.of(this._iid),a.dispatcher.dispatch(new $i({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Iv),t),ps(Nv(r)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Av(Object.assign({channelUrl:this.url,userId:i.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(Mv),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),s.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.dispatcher,a=n.requestQueue,s=new N_({channelUrl:this.url}),t.next=4,a.send(s);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new I_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.sdkState,a=n.dispatcher,s=n.requestQueue,i=new Ri({channelUrl:this.url}),t.next=4,s.send(i);case 4:o=t.sent,u=o.as(Li),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Jv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new zv({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=vi.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,s=new Ov({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=vi.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,s=new Rv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},oh),e),ps(function(e){return hu(e)&&R("number",e.scheduledAt,!0)}(e)).throw(M.invalidParameters);var t=new au;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},L_),t),ps(P_(r)).throw(M.invalidParameters),a=vi.of(this._iid),s=a.requestQueue,i=new H_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,s.send(i);case 6:return o=n.sent,u=o.as(Pc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},uh),e),ps(function(e){return iu(e)&&R("number",e.scheduledAt)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(M.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new au;return Ss(2).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);Pa((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(s));case 1:case"end":return e.stop()}}),e)})))}))})),G(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},D_),t),ps(R_(r)).throw(M.invalidParameters),!G(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new F_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),s=vi.of(this._iid),i=s.requestQueue,n.next=9,i.send(a);case 9:return o=n.sent,u=o.as(q_),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new G_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=vi.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new j_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=vi.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new B_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Q_),o=i.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(L(e.PushTriggerOption,t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.dispatcher,s=r.sdkState,i=r.requestQueue,o=new V_({userId:s.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(z_),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(L(e.CountPreference,t)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.dispatcher,s=r.sdkState,i=r.requestQueue,o=new A_({channelUrl:this.url,userId:s.userId,countPreference:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(M_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=vi.of(this._iid),r=n.dispatcher,a=n.requestQueue,s=n.sdkState,i=new U_({channelUrl:this.url,locale:s.localeForChatbot}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(O_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt<c&&(this.lastMessage=null),this._updateUnreadCount(0,0),this.totalUnreadReplyCount=0,r.dispatch(new Qp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY},isWebSocketEventComing:!0})),t.abrupt("return",this);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,l,h,f;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!G(e.file)){t.next=11;break}return n=vi.of(this._iid),r=n.requestQueue,a=new gi({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,r.send(a);case 5:s=t.sent,i=s.as(yi),o=i.url,u=i.fileSize,c=void 0===u?e.fileSize:u,l=i.thumbnails,h=i.requireAuth,f=void 0!==h&&h,e.fileUrl=o,e.fileSize=c,e.requireAuth=f,e._thumbnails=l;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"resendMessage",value:function(e,t){var n,r=this;if(ps(e instanceof yo&&!e.scheduledInfo&&e.isResendable).throw(M.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:du(e),s=new au;return this._sendUserMessage(a,Sl.RESEND,e.reqId).onPending((function(e){s._trigger(e)})).onFailed((function(e,t){s._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),s._trigger(e)})),s}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ps(i).throw(M.invalidParameters);var o=yu(e,t),u=new au;return this._sendFileMessage(o,Sl.RESEND,e.reqId).onPending((function(e){u._trigger(e)})).onFailed((function(e,t){u._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),u._trigger(e)})),u}if(e.isMultipleFilesMessage()){var c=e.messageParams,l=new Nl;return this._sendMultipleFilesMessage(c,Sl.RESEND,e.reqId).onPending((function(e){l._trigger(e)})).onFailed((function(e,t){l._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),l._trigger(e)})).onFileUploaded((function(e,t,n,r){l._triggerOnFileUploaded(e,t,n,r)})),l}}},{key:"copyMessage",value:function(t,n){var r=this;if(ps(t instanceof Pl&&n instanceof yo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters),n.isUserMessage()){ps(!n.poll).throw(M.notSupportedError);var a=cu(n),s=new au;return t._sendUserMessage(a).onPending((function(e){s._trigger(e)})).onFailed((function(e,t){s._triggerFailed(e,t)})).onSucceeded((function(e){t.isGroupChannel()&&r._tryUpdateLastMessageAndCallEvents(t,e),s._trigger(e)})),s}if(n.isFileMessage()){var i=mu(n),o=new au;return t._sendFileMessage(i).onPending((function(e){o._trigger(e)})).onFailed((function(e,t){o._triggerFailed(e,t)})).onSucceeded((function(e){t.isGroupChannel()&&r._tryUpdateLastMessageAndCallEvents(t,e),o._trigger(e)})),o}if(n.isMultipleFilesMessage()){if(t.isGroupChannel()){var u=function(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:_e(Object.assign(Object.assign({},t),{isReplyToChannel:!1,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:t.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}(n),c=new Nl;return t._sendMultipleFilesMessage(u,Sl.COPY).onPending((function(e){c._trigger(e)})).onFailed((function(e,t){c._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(t,e),c._trigger(e)})).onFileUploaded((function(e,t,n,r){c._triggerOnFileUploaded(e,t,n,r)})),c}throw M.channelTypeNotSupportedError}}},{key:"getMessageDeletionTimestamp",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=t.dispatcher,a=new K_({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(a);case 4:return s=e.sent,i=s.as(W_).messageDeletionTimestamp,this._messageDeletionTimestamp=i,r.dispatch(new Wp({channel:this})),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,total_unread_thread_message_count:e.totalUnreadReplyCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return xp.payloadify(e)})),last_message:e.lastMessage?Io(e.lastMessage):null,inviter:e.inviter?_s.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?Io(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot,message_purge_offset:e.messageDeletionTimestamp})))}}])}(Pl),X_={},J_=function(){function t(n){var a=this,s=n._iid,i=n.limit,o=void 0===i?100:i;r(this,t),this.ref=0,this._iid=s,this._limit=o;var u,c=vi.of(this._iid),l=c.sdkState,h=c.dispatcher,f=c.logger,p=c.cacheContext,_=c.statManager;this._metadataKey=(u=l.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var m=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new vp(m,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c,h,m,g,y,E,k,b,C;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(r=this._metadata)||void 0===r?void 0:r.completed){t.next=44;break}if(m={includeEmpty:!0,includeMetaData:!0,hiddenChannelFilter:e.HiddenChannelFilter.ALL,order:e.GroupChannelListOrder.CHRONOLOGICAL},t.prev=6,m.order!==e.GroupChannelListOrder.LATEST_LAST_MESSAGE){t.next=18;break}return t.prev=8,t.next=11,p.preference.get(Za(l.appId));case 11:g=t.sent,m.includeChatNotification=Boolean(g),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),m.includeChatNotification=!1;case 18:return y=Jv.of(this._iid),t.next=21,y.getMyGroupChannels(null!==(s=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==s?s:"",m,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);case 21:return E=t.sent,k=E.channels,b=E.token,h.hasNext=k.length>=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(i=p.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Ba)if(e.stateType===qa.CONNECTED)a.resume();else a.pause()}))}return s(t,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Zv({})}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Zv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=vi.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){vi.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete X_[this._iid])}}],[{key:"of",value:function(e){return X_[e]||(X_[e]=new t({_iid:e})),X_[e].ref++,X_[e]}},{key:"clear",value:function(e){X_[e]&&(X_[e].close(),delete X_[e])}}])}(),$_={},em=function(){function t(n){var a=this,s=n._iid;r(this,t),this.ref=0,this._iid=s;var i,o=vi.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(i=c.userId,"sendbird:".concat(i,"@groupchannel/changelogs.meta")),this._subscribers=new he;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new vp(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,l,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,i={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Za(c.appId));case 9:o=t.sent,i.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),i.includeChatNotification=!1;case 16:return l=Jv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",i,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),s.hasNext=m,s.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",s),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new ot({type:Be.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",s);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof Ba)if(e.stateType===qa.CONNECTED)a.resume();else a.pause()}))}return s(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=vi.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=vi.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){vi.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete $_[this._iid])}}],[{key:"of",value:function(e){return $_[e]||($_[e]=new t({_iid:e})),$_[e].ref++,$_[e]}},{key:"clear",value:function(e){$_[e]&&($_[e].close(),delete $_[e])}}])}(),tm=function(t,n){var r,a,s,i;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name;default:return null!==(i=null===(s=t.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:t.createdAt}},nm=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},rm=function(e,t,n){if(e.length>0){for(var r=nm(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a<s;){var o=am(e[i],t,n);if(o>0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:am(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},am=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var s=t.name.localeCompare(n.name);return 0===s?t.createdAt-n.createdAt:s;default:return 0}},sm=function(){return s((function t(n,a){var s=this,i=a.filter,o=void 0===i?new Ip:i,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(le()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=vi.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=J_.of(n),this._backgroundSync.resume()),this._changelogSync=em.of(n),this._changelogSync.resume(),Jv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(Bp(n)){var r=e.filter((function(e){return s.filter.match(e,_.userId)})),a=e.filter((function(e){return!s.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&s._addChannelsToView(r,t),a.length>0&&s._removeChannelsFromView(a,t)}},onRemove:function(e,t){s._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof Ba&&(e.stateType===qa.CONNECTED?s._isGetRemoteChannelsSucceeded||E(s,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===qa.LOGOUT&&s.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=i(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=nm(this.channels,h);f>=0&&this.channels.splice(f,1);var p=rm(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!s&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=i(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=nm(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}Bp(n.source)&&Pa((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],s=i(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(s.s();!(n=s.n()).done;)o()}catch(e){s.e(e)}finally{s.f()}return Bp(t.source)&&a.length>0&&Pa((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Jv.of(this._iid),n=this.channels.length>0?tm(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Jv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,_e(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=vi.of(this._iid),s=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!s.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new ei({type:Be.FEATURE_LOCALCACHE,data:{use_local_cache:s.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!s.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,Fa((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=i(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=nm(c,f))>=0?c[p]=f:(v=rm(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=i(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Jv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),im=function(t){function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(s=n(this,a)).method=me.GET,s.path=be,s.params=ve(_e({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:d,channel_urls:h,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:E,show_metadata:k})),s}return c(a,t),s(a)}(Qe),om=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Z_(e,t)}))),s.ts="number"==typeof u?u:0,s}return c(t,e),s(t)}(Ke);e.MembershipFilter=void 0,(Y_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Y_.JOINED="joined";var um,cm=function(t){function a(t,s){var i,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(i=n(this,a,[t,s])).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.channelNameContainsFilter=null,i.membershipFilter=e.MembershipFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,i.includeEmpty=null!==(o=s.includeEmpty)&&void 0!==o&&o,i.includeFrozen=null===(u=s.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=s.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=s.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(d=s.customTypesFilter)&&void 0!==d?d:null,i.customTypeStartsWithFilter=null!==(h=s.customTypeStartsWithFilter)&&void 0!==h?h:null,i.channelNameContainsFilter=null!==(f=s.channelNameContainsFilter)&&void 0!==f?f:null,i.membershipFilter=null!==(p=s.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,i.superChannelFilter=null!==(v=s.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,i.metadataKey=null!==(_=s.metadataKey)&&void 0!==_?_:null,i.metadataValues=null!==(m=s.metadataValues)&&void 0!==m?m:null,i.metadataOrderKeyFilter=null!==(g=s.metadataOrderKeyFilter)&&void 0!==g?g:null,i.metadataValueStartsWith=null!==(y=s.metadataValueStartsWith)&&void 0!==y?y:null,i.order=null!==(E=s.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,i}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("boolean",this.includeEmpty)&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&R("string",this.customTypeStartsWithFilter,!0)&&L(e.MembershipFilter,this.membershipFilter)&&L(e.SuperChannelFilter,this.superChannelFilter)&&L(e.PublicGroupChannelListOrder,this.order)&&R("string",this.metadataOrderKeyFilter,!0)&&R("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&R("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=vi.of(this._iid),r=n.requestQueue,a=new im(_e(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return s=e.sent,i=s.as(om),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(Tu),lm=s((function e(){r(this,e),this.onUserMuted=_t,this.onUserUnmuted=_t,this.onUserBanned=_t,this.onUserUnbanned=_t,this.onChannelChanged=_t,this.onChannelDeleted=_t,this.onChannelFrozen=_t,this.onChannelUnfrozen=_t,this.onOperatorUpdated=_t,this.onChannelMemberCountChanged=_t,this.onMetaDataCreated=_t,this.onMetaDataUpdated=_t,this.onMetaDataDeleted=_t,this.onMetaCounterCreated=_t,this.onMetaCounterUpdated=_t,this.onMetaCounterDeleted=_t,this.onMessageReceived=_t,this.onMessageUpdated=_t,this.onMessageDeleted=_t,this.onMentionReceived=_t,this.onReactionUpdated=_t,this.onThreadInfoUpdated=_t})),dm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=_t,e.onUserLeft=_t,e.onUserReceivedInvitation=_t,e.onUserDeclinedInvitation=_t,e.onChannelHidden=_t,e.onUnreadMemberStatusUpdated=_t,e.onUndeliveredMemberStatusUpdated=_t,e.onTypingStatusUpdated=_t,e.onPollUpdated=_t,e.onPollVoted=_t,e.onPollDeleted=_t,e.onPinnedMessageUpdated=_t,e}return c(t,e),s(t)}(lm),hm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),s(t)}(dm),fm=function(e){function t(e){var a;r(this,t);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=me.GET,a.path="".concat(Me),a.params=ve(_e({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),s(t)}(Qe),pm=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return No(e,t)})),s}return c(t,e),s(t)}(Ke),vm=function(t){function a(t,s){var i,o,u,c,l,d;return r(this,a),(i=n(this,a,[t,s])).channelUrl=null,i.order=null,i.reverse=!1,i.scheduledStatus=null,i.messageTypeFilter=e.MessageTypeFilter.ALL,i.channelUrl=null!==(o=s.channelUrl)&&void 0!==o?o:null,i.order=null!==(u=s.order)&&void 0!==u?u:null,i.reverse=null!==(c=s.reverse)&&void 0!==c&&c,i.scheduledStatus=null!==(l=s.scheduledStatus)&&void 0!==l?l:null,i.messageTypeFilter=null!==(d=s.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,i}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R("string",this.channelUrl,!0)&&(L(e.ScheduledMessageListOrder,this.order)||null===this.order)&&R("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&L(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new fm(_e(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(pm),i=s.scheduledMessages,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Tu),_m=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),s(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Jv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:s,requestQueue:i,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new sm(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new qv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new cm(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vm(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ps(R("string",e)&&t instanceof hm).throw(M.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ps(R("string",e)).throw(M.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Dp),t),ps(R("string",e)&&Rp(r)).throw(M.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Dp),t),ps(R("number",e)&&Rp(r)).throw(M.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Lp),e),ps(Pp(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Up),e),ps(Op(n)).throw(M.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Up),e),ps(Op(n)).throw(M.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function i(){var o;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o=Object.assign(Object.assign({},Up),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:s}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,i.abrupt("return",this.createChannel(o));case 3:case"end":return i.stop()}}),i,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ps(F("string",e)).throw(M.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(_i),mm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),s(t,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return!!e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._channels.get(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}])}(ss),gm={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},ym=function(e){return F("string",e.operatorUserIds,!0)&&(R("string",e.coverUrlOrImage,!0)||G(e.coverUrlOrImage,!0))&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&(R("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&R("boolean",e.isEphemeral,!0)},Em=function(e){function t(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,t),(a=n(this,t)).method=me.GET,a.path="".concat(i?xe:we,"/").concat(encodeURIComponent(s)),a.params={show_pinned_messages:!0},a}return c(t,e),s(t)}(Qe),km=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Pm(e,a),s}return c(t,e),s(t)}(Ke),bm=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=me.POST,a.path=we,a.params=ve(_e({channel_url:s,cover_url:R("string",i)?i:null,cover_file:G(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),s(t)}(Qe),Cm=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),s(t)}(Xe),wm=function(e){function t(e,a,s){var i,o,u;return r(this,t),i=n(this,t,[e,"SYEV",s]),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new _s(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return c(t,e),s(t)}(mv),xm=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),s(t)}(Xe),Sm=function(e){function t(e,a,s){var i,o,u;return r(this,t),i=n(this,t,[e,"EXIT",s]),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new _s(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return c(t,e),s(t)}(mv),Tm={},Im=function(t){function a(t,s){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},s),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=_t,o.unsubscribeChannelEvent=_t,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new mm(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ze)o._handleEvent(e).catch((function(e){if(A(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof Ba&&e.stateType===qa.CONNECTED){var t,n=i(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),Tm[t]||(Tm[t]=o),o}return c(a,t),s(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=fs(e);return new Pm(this._iid,Pm.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,M,U,O,D,R,L,P,F,q,H,G,j,V,z,B,Q,K,W,Y,Z,X,J,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Ue,Oe,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(xc):"FILE"===t.code?r=t.as(Do):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(jv)),!r){n.next=13;break}if(s=(a=r).message,o=a.isMentioned,s.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(s.channelUrl,!0);case 11:u=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,s),o&&r.onMentionReceived&&r.onMentionReceived(u,s))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(Tc):"FEDI"===t.code?c=t.as(Nc):"AEDI"===t.code&&(c=t.as(Vv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt<h.updatedAt&&(p.lastPinnedMessage=h,v=!0),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=i(this._openChannelHandlers.values());try{for(r.s();!(a=r.n()).done;)s=a.value,this._openChannelCache.isEnteredChannel(p.url)&&(v&&(null===(t=s.onPinnedMessageUpdated)||void 0===t||t.call(s,p),null===(n=s.onChannelChanged)||void 0===n||n.call(s,p)),s.onMessageUpdated&&s.onMessageUpdated(p,h),f>0&&s.onMentionReceived&&s.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(pt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(Qv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(Kv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:N=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(N.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(N,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(Wv),U=M.openChannelMemberCounts,O=[],D=i(U),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&O.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(O.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(O);case 72:G=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(Yv),V=j.event,z=j.status,B=j.channelUrl,Q=j.channelType,!B||Q!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:K=n.sent,this._dispatcher.dispatch(new to({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Pa(z===ho?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(K,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(K,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as($c),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new no({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(mv),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===Tp.CHANNEL_ENTER?96:n.t2===Tp.CHANNEL_EXIT?103:n.t2===Tp.CHANNEL_OPERATOR_UPDATE?110:n.t2===Tp.USER_CHANNEL_MUTE||n.t2===Tp.USER_CHANNEL_UNMUTE?118:n.t2===Tp.USER_CHANNEL_BAN||n.t2===Tp.USER_CHANNEL_UNBAN?125:n.t2===Tp.CHANNEL_FREEZE||n.t2===Tp.CHANNEL_UNFREEZE?132:n.t2===Tp.CHANNEL_DELETED?140:n.t2===Tp.CHANNEL_PROP_CHANGED?147:n.t2===Tp.CHANNEL_META_DATA_CHANGED?152:n.t2===Tp.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===Tp.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as(wm),re=ne.participantCount,ae=ne.user,se=te._updateParticipantCount(re,ee.ts),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),se&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return ie=n.sent,oe=t.as(Sm),ue=oe.participantCount,ce=oe.user,le=ie._updateParticipantCount(ue,ee.ts),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ie,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ie)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(Pv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===Tp.USER_CHANNEL_MUTE,_e=t.as(ve?lc:hc),me=_e.user,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===Tp.USER_CHANNEL_BAN,Ee=t.as(ye?pc:_c),ke=Ee.user,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as(gc),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen&&e.onChannelFrozen(be):e.onChannelUnfrozen&&e.onChannelUnfrozen(be)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Yu),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Ue=n.sent,Oe=t.as(ic),De=Oe.created,Re=Oe.updated,Le=Oe.deleted,Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ue,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ue,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ue,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(Hv),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Pa((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!A(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,s,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ps(R("string",e)).throw(M.invalidParameters),r=new Em({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,s=a.as(km),i=s.channel,n.next=8,this.upsertChannelsToCache([i]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},gm),e),ps(ym(n)).throw(M.invalidParameters),r=new bm(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,s=a.as(km),i=s.channel,this.upsertChannelsToCache([i]),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Tm[e]}}])}(Gv),Nm={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Am=function(e){return F("string",e.operatorUserIds,!0)&&(R("string",e.coverUrlOrImage,!0)||G(e.coverUrlOrImage,!0))&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)},Mm=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.token,o=e.limit;return(a=n(this,t)).method=me.GET,a.path="".concat(we,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return c(t,e),s(t)}(Qe),Um=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new ru(e,t)})),s}return c(t,e),s(t)}(Ke),Om=function(t){function a(t,s,i){return r(this,a),n(this,a,[t,s,e.ChannelType.OPEN,i])}return c(a,t),s(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Mm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Um),i=s.participants,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",i);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(Iu),Dm=function(e){function t(e){var a;r(this,t);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=me.PUT,a.path="".concat(we,"/").concat(encodeURIComponent(s)),a.params=ve(_e({cover_url:R("string",i)?i:null,cover_file:G(i)?i:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),s(t)}(Qe),Rm=function(e){function t(e,a){var s;return r(this,t),(s=n(this,t,[e,a])).channel=new Pm(e,a),s}return c(t,e),s(t)}(Ke),Lm=function(e){function t(e){var a;r(this,t);var s=e.channelUrl;return(a=n(this,t)).method=me.DELETE,a.path="".concat(we,"/").concat(encodeURIComponent(s)),a}return c(t,e),s(t)}(Qe),Pm=function(t){function a(t,s){var i,o;return r(this,a),(i=n(this,a,[t,s]))._lastParticipantCountUpdated=0,i.participantCount=0,i.operators=[],i.lastPinnedMessage=null,i._pinnedMessagesUpdatedAt=0,i.channelType=e.ChannelType.OPEN,i.participantCount=null!==(o=s.participant_count)&&void 0!==o?o:0,i.operators=Array.isArray(s.operators)?s.operators.map((function(e){return new _s(t,e)})):[],i.lastPinnedMessage=s.latest_pinned_message?No(i._iid,Object.assign({channel_type:i.channelType},s.latest_pinned_message)):null,i}return c(a,t),s(a,[{key:"serialize",value:function(){return hs(this)}},{key:"isOperator",value:function(e){return e instanceof _s?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Om(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Im.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new Cm({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,s=a.as(wm),i=s.participantCount,o=s.ts,this._updateParticipantCount(i,o),Im.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new xm({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,s=a.as(Sm),i=s.participantCount,o=s.ts,this._updateParticipantCount(i,o),Im.of(this._iid).setExitedToCache(this),xh.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,s,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Nm),e),ps(Am(n)).throw(M.invalidParameters),r=vi.of(this._iid),a=r.requestQueue,s=new Dm(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(s);case 6:return i=t.sent,o=i.as(Rm),u=o.channel,this._update(u),c=Im.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function s(){var i;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=Object.assign(Object.assign({},Nm),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),s.abrupt("return",this.updateChannel(i));case 2:case"end":return s.stop()}}),s,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=vi.of(this._iid),n=t.requestQueue,r=new Lm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=Im.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,s,i,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,s=!0,i=!0),s&&Im.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Im.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,s,i,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,s=!0,i=!0),s&&Im.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Im.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return ve(_e(Object.assign(Object.assign({},Pl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return _s.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?Io(e.lastPinnedMessage):null})))}}])}(Pl),Fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=_t,e.onUserExited=_t,e.onChannelParticipantCountChanged=_t,e.onPollUpdated=_t,e.onPollVoted=_t,e.onPollDeleted=_t,e.onPinnedMessageUpdated=_t,e}return c(t,e),s(t)}(lm),qm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),s(t)}(Fm),Hm=function(e){function t(e){var a;r(this,t);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=me.GET,a.path=we,a.params=ve({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),s(t)}(Qe),Gm=function(e){function t(e,a){var s;r(this,t),(s=n(this,t,[e,a])).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Pm(e,t)}))),s.ts="number"==typeof u?u:null,s}return c(t,e),s(t)}(Ke),jm=function(e){function t(e,a){var s,i,o,u,c,l;return r(this,t),(s=n(this,t,[e,a])).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=a.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,s}return c(t,e),s(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.nameKeyword,!0)&&R("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,s,i,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=vi.of(this._iid),n=t.requestQueue,r=new Hm(_e(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,s=a.as(Gm),i=s.channels,o=s.token,this._token=o,this._hasNext=!!o,u=Im.of(this._iid),e.next=15,u.upsertChannelsToCache(i);case 15:return this._isLoading=!1,e.abrupt("return",i);case 17:return e.abrupt("return",[]);case 20:throw M.queryInProgress;case 21:e.next=24;break;case 23:throw M.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(Tu),Vm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),s(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Im(e,{sdkState:r,dispatcher:a,requestQueue:i,logger:o,cacheContext:c,sessionManager:s})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jm(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function s(){var i;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return(i=Object.assign({},gm)).name=e,i.coverUrlOrImage=t,i.data=n,i.operatorUserIds=r,i.customType=a,s.abrupt("return",this._manager.createChannel(i));case 7:case"end":return s.stop()}}),s,this)})))}}])}(_i),zm=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=vi.of(e),s=a.dispatcher,i=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):i.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(M.requestCanceled)},_.onerror=function(e){r(M.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new Ke(e,t))}catch(i){r(M.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var i=new M(a);if(i.isSessionExpiredError){if(s.dispatch(new Ye({reason:i.code,message:i.message})),!(_ instanceof Je)){var o=new dt;return s.dispatch(new rt({request:_,deferred:o,error:i})),o.promise}}else i.isSessionInvalidatedError&&s.dispatch(new Ye({reason:i.code,message:i.message}));r(i)}else r(M.requestFailed)}catch(i){r(M.requestFailed)}},s.on((function(e){e instanceof ht&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(M.xmlHttpRequestNotSupported)}))}});um=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=r(e);if(t){var i=r(this).constructor;n=Reflect.construct(a,arguments,i)}else n=a.apply(this,arguments);return function(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}(this,n)}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var a=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=r(e)););return e}(e,t);if(a){var s=Object.getOwnPropertyDescriptor(a,t);return s.get?s.get.call(arguments.length<3?e:n):s.value}},o.apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}var l=function(){function t(){e(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return n(t,[{key:"addEventListener",value:function(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var n=this.listeners[e],r=0,a=n.length;r<a;r++)if(n[r].callback===t)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(e){var t=this;if(e.type in this.listeners){for(var n,r=this.listeners[e.type].slice(),a=function(){n=r[s];try{n.callback.call(t,e)}catch(e){Promise.resolve().then((function(){throw e}))}n.options&&n.options.once&&t.removeEventListener(e.type,n.callback)},s=0,i=r.length;s<i;s++)a();return!e.defaultPrevented}}}]),t}(),d=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(d,t);var u=i(d);function d(){var t;return e(this,d),(t=u.call(this)).listeners||l.call(s(t)),Object.defineProperty(s(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(s(t),"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(s(t),"reason",{value:void 0,writable:!0,configurable:!0}),t}return n(d,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(e){"abort"===e.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,e)),o(r(d.prototype),"dispatchEvent",this).call(this,e)}},{key:"throwIfAborted",value:function(){var e=this.aborted,t=this.reason;if(e)throw void 0===t?"Aborted":t}}],[{key:"timeout",value:function(e){var t=new h;return setTimeout((function(){return t.abort(new DOMException("This signal is timeout in ".concat(e,"ms"),"TimeoutError"))}),e),t.signal}},{key:"any",value:function(e){var t=new h;function n(){t.abort(this.reason),function(){var t,r=c(e);try{for(r.s();!(t=r.n()).done;)t.value.removeEventListener("abort",n)}catch(e){r.e(e)}finally{r.f()}}()}var r,a=c(e);try{for(a.s();!(r=a.n()).done;){var s=r.value;if(s.aborted){t.abort(s.reason);break}s.addEventListener("abort",n)}}catch(e){a.e(e)}finally{a.f()}return t.signal}}]),d}(l),h=function(){function t(){e(this,t),Object.defineProperty(this,"signal",{value:new d,writable:!0,configurable:!0})}return n(t,[{key:"abort",value:function(e){var t;try{t=new Event("abort")}catch(e){"undefined"!=typeof document?document.createEvent?(t=document.createEvent("Event")).initEvent("abort",!1,!1):(t=document.createEventObject()).type="abort":t={type:"abort",bubbles:!1,cancelable:!1}}var n=e;if(void 0===n)if("undefined"==typeof document)(n=new Error("This operation was aborted")).name="AbortError";else try{(n=new DOMException("signal is aborted without reason")).name="AbortError"}catch(e){(n=new Error("This operation was aborted")).name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):"function"==typeof e.Request&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}"undefined"!=typeof Symbol&&Symbol.toStringTag&&(h.prototype[Symbol.toStringTag]="AbortController",d.prototype[Symbol.toStringTag]="AbortSignal"),function(e){if(f(e))if(e.fetch){var t=function(e){"function"==typeof e&&(e={fetch:e});var t=e,n=t.fetch,r=t.Request,a=void 0===r?n.Request:r,s=t.AbortController,i=t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,o=void 0!==i&&i;if(!f({fetch:n,Request:a,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:n,Request:u};var u=a;(u&&!u.prototype.hasOwnProperty("signal")||o)&&((u=function(e,t){var n;t&&t.signal&&(n=t.signal,delete t.signal);var r=new a(e,t);return n&&Object.defineProperty(r,"signal",{writable:!1,enumerable:!1,configurable:!0,value:n}),r}).prototype=a.prototype);var c=n;return{fetch:function(e,t){var n=u&&u.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(n){var r;try{r=new DOMException("Aborted","AbortError")}catch(e){(r=new Error("Aborted")).name="AbortError"}if(n.aborted)return Promise.reject(r);var a=new Promise((function(e,t){n.addEventListener("abort",(function(){return t(r)}),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([a,c(e,t)])}return c(e,t)},Request:u}}(e),n=t.fetch,r=t.Request;e.fetch=n,e.Request=r,Object.defineProperty(e,"AbortController",{writable:!0,enumerable:!1,configurable:!0,value:h}),Object.defineProperty(e,"AbortSignal",{writable:!0,enumerable:!1,configurable:!0,value:d})}else console.warn("fetch() is not available, cannot install abortcontroller-polyfill")}("undefined"!=typeof self?self:global)},"function"==typeof define&&define.amd?define(um):um();var Bm=Object.freeze({__proto__:null}),Qm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},Km="URLSearchParams"in Qm,Wm="Symbol"in Qm&&"iterator"in Symbol,Ym="FileReader"in Qm&&"Blob"in Qm&&function(){try{return new Blob,!0}catch(e){return!1}}(),Zm="FormData"in Qm,Xm="ArrayBuffer"in Qm;if(Xm)var Jm=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],$m=ArrayBuffer.isView||function(e){return e&&Jm.indexOf(Object.prototype.toString.call(e))>-1};function eg(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function tg(e){return"string"!=typeof e&&(e=String(e)),e}function ng(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Wm&&(t[Symbol.iterator]=function(){return t}),t}function rg(e){this.map={},e instanceof rg?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function ag(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function sg(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function ig(e){var t=new FileReader,n=sg(t);return t.readAsArrayBuffer(e),n}function og(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function ug(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Ym&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Zm&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Km&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Xm&&Ym&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=og(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Xm&&(ArrayBuffer.prototype.isPrototypeOf(e)||$m(e))?this._bodyArrayBuffer=og(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Km&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Ym&&(this.blob=function(){var e=ag(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=ag(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(Ym)return this.blob().then(ig);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,s=ag(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=sg(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},Zm&&(this.formData=function(){return this.text().then(dg)}),this.json=function(){return this.text().then(JSON.parse)},this}rg.prototype.append=function(e,t){e=eg(e),t=tg(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},rg.prototype.delete=function(e){delete this.map[eg(e)]},rg.prototype.get=function(e){return e=eg(e),this.has(e)?this.map[e]:null},rg.prototype.has=function(e){return this.map.hasOwnProperty(eg(e))},rg.prototype.set=function(e,t){this.map[eg(e)]=tg(t)},rg.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},rg.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),ng(e)},rg.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),ng(e)},rg.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),ng(e)},Wm&&(rg.prototype[Symbol.iterator]=rg.prototype.entries);var cg=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function lg(e,t){if(!(this instanceof lg))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,a=(t=t||{}).body;if(e instanceof lg){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new rg(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new rg(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),cg.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in Qm)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function dg(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function hg(e,t){if(!(this instanceof hg))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new rg(t.headers),this.url=t.url||"",this._initBody(e)}lg.prototype.clone=function(){return new lg(this,{body:this._bodyInit})},ug.call(lg.prototype),ug.call(hg.prototype),hg.prototype.clone=function(){return new hg(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new rg(this.headers),url:this.url})},hg.error=function(){var e=new hg(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var fg=[301,302,303,307,308];hg.redirect=function(e,t){if(-1===fg.indexOf(t))throw new RangeError("Invalid status code");return new hg(null,{status:t,headers:{location:e}})};var pg=Qm.DOMException;try{new pg}catch(Rn){(pg=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),pg.prototype.constructor=pg}function vg(e,t){return new Promise((function(n,r){var a=new lg(e,t);if(a.signal&&a.signal.aborted)return r(new pg("Aborted","AbortError"));var s=new XMLHttpRequest;function i(){s.abort()}if(s.onload=function(){var e,t,r={statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new rg,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(s.status<200||s.status>599)?r.status=200:r.status=s.status,r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;setTimeout((function(){n(new hg(i,r))}),0)},s.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},s.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},s.onabort=function(){setTimeout((function(){r(new pg("Aborted","AbortError"))}),0)},s.open(a.method,function(e){try{return""===e&&Qm.location.href?Qm.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&(Ym?s.responseType="blob":Xm&&(s.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof rg||Qm.Headers&&t.headers instanceof Qm.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(eg(e)),s.setRequestHeader(e,tg(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&s.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){s.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",i),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",i)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}vg.polyfill=!0,Qm.fetch||(Qm.fetch=vg,Qm.Headers=rg,Qm.Request=lg,Qm.Response=hg);var _g="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};_g.fetch||(_g.fetch=vg);var mg=Object.freeze({__proto__:null});e.AdminMessage=bo,e.AppInfo=rs,e.AppleCriticalAlertOptions=Ti,e.ApplicationUserListQuery=Ql,e.BannedUserListQuery=Fu,e.BaseChannel=Pl,e.BaseMessage=go,e.BlockedUserListQuery=Yl,e.CachedChannelInfo=W,e.ConnectionHandler=Gl,e.DeliveryStatus=Sp,e.Emoji=Fl,e.EmojiCategory=ql,e.EmojiContainer=Hl,e.Feedback=Ni,e.FileMessage=Ao,e.FriendListQuery=Jl,e.GroupChannel=Z_,e.GroupChannelCollection=sm,e.GroupChannelEventSource=zp,e.GroupChannelFilter=Ip,e.GroupChannelHandler=hm,e.GroupChannelListQuery=qv,e.GroupChannelModule=_m,e.LocalCacheConfig=Y,e.Member=xp,e.MemberListQuery=C_,e.MemoryStore=Kd,e.MessageCollection=__,e.MessageCollectionInitHandler=p_,e.MessageEventSource=Qi,e.MessageFilter=ah,e.MessageForm=io,e.MessageFormItem=oo,e.MessageMetaArray=Mi,e.MessageModule=jh,e.MessageRequestHandler=au,e.MessageReviewInfo=wo,e.MessageSearchQuery=Dh,e.MultipleFilesMessage=So,e.MultipleFilesMessageRequestHandler=Nl,e.MutedUserListQuery=Ru,e.NotificationInfo=Ya,e.OGImage=xi,e.OGMetaData=Si,e.OpenChannel=Pm,e.OpenChannelHandler=qm,e.OpenChannelListQuery=jm,e.OpenChannelModule=Vm,e.OperatorListQuery=Mu,e.Participant=ru,e.ParticipantListQuery=Om,e.PinnedMessage=Al,e.PinnedMessageListQuery=Ol,e.Plugin=Co,e.PreviousMessageListQuery=Uu,e.PublicGroupChannelListQuery=cm,e.ReactedUserInfo=Ci,e.Reaction=wi,e.ReactionEvent=bi,e.ReadStatus=Di,e.ReportCategoryInfo=li,e.RestrictedUser=nu,e.RestrictionInfo=tu,e.ScheduledMessageListQuery=vm,e.SendbirdChat=_p,e.SendbirdChatOptions=V,e.SendbirdError=M,e.Sender=Ai,e.SessionHandler=jl,e.ThreadInfo=Ei,e.ThreadInfoUpdateEvent=Sh,e.ThreadedParentMessageListQuery=Ph,e.Thumbnail=mi,e.UIKitConfigInfo=Xa,e.UploadedFileInfo=ro,e.User=_s,e.UserEventHandler=Vl,e.UserMessage=xo,Object.defineProperty(e,"__esModule",{value:!0})}));