UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

16 lines (14 loc) 81.6 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(t,o)};var t=function(){return(t=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function o(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function n(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function r(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var n,r,i=o.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return s}function i(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e}var s,a=25,u="system_admin";!function(e){if(!(e instanceof Object)||Array.isArray(e))throw new Error("keyMirror(...): Argument must be an object.");var t={};for(var o in e)e.hasOwnProperty(o)&&(t[o]=o)}({TOTAL_USERS:null,TOTAL_INACTIVE_USERS:null,TOTAL_PUBLIC_CHANNELS:null,TOTAL_PRIVATE_GROUPS:null,TOTAL_POSTS:null,TOTAL_TEAMS:null,TOTAL_FILE_POSTS:null,TOTAL_HASHTAG_POSTS:null,TOTAL_IHOOKS:null,TOTAL_OHOOKS:null,TOTAL_COMMANDS:null,TOTAL_SESSIONS:null,POST_PER_DAY:null,BOT_POST_PER_DAY:null,USERS_WITH_POSTS_PER_DAY:null,RECENTLY_ACTIVE_USERS:null,NEWLY_CREATED_USERS:null,TOTAL_WEBSOCKET_CONNECTIONS:null,TOTAL_MASTER_DB_CONNECTIONS:null,TOTAL_READ_DB_CONNECTIONS:null,DAILY_ACTIVE_USERS:null,MONTHLY_ACTIVE_USERS:null,REGISTERED_USERS:null});var d,c={INVITE_USER:"invite_user",ADD_USER_TO_TEAM:"add_user_to_team",USE_SLASH_COMMANDS:"use_slash_commands",MANAGE_SLASH_COMMANDS:"manage_slash_commands",MANAGE_OTHERS_SLASH_COMMANDS:"manage_others_slash_commands",CREATE_PUBLIC_CHANNEL:"create_public_channel",CREATE_PRIVATE_CHANNEL:"create_private_channel",MANAGE_PUBLIC_CHANNEL_MEMBERS:"manage_public_channel_members",MANAGE_PRIVATE_CHANNEL_MEMBERS:"manage_private_channel_members",READ_PUBLIC_CHANNEL_GROUPS:"read_public_channel_groups",READ_PRIVATE_CHANNEL_GROUPS:"read_private_channel_groups",ASSIGN_SYSTEM_ADMIN_ROLE:"assign_system_admin_role",MANAGE_ROLES:"manage_roles",MANAGE_TEAM_ROLES:"manage_team_roles",MANAGE_CHANNEL_ROLES:"manage_channel_roles",MANAGE_SYSTEM:"manage_system",CREATE_DIRECT_CHANNEL:"create_direct_channel",CREATE_GROUP_CHANNEL:"create_group_channel",MANAGE_PUBLIC_CHANNEL_PROPERTIES:"manage_public_channel_properties",MANAGE_PRIVATE_CHANNEL_PROPERTIES:"manage_private_channel_properties",LIST_PUBLIC_TEAMS:"list_public_teams",JOIN_PUBLIC_TEAMS:"join_public_teams",LIST_PRIVATE_TEAMS:"list_private_teams",JOIN_PRIVATE_TEAMS:"join_private_teams",LIST_TEAM_CHANNELS:"list_team_channels",JOIN_PUBLIC_CHANNELS:"join_public_channels",DELETE_PUBLIC_CHANNEL:"delete_public_channel",CONVERT_PUBLIC_CHANNEL_TO_PRIVATE:"convert_public_channel_to_private",CONVERT_PRIVATE_CHANNEL_TO_PUBLIC:"convert_private_channel_to_public",DELETE_PRIVATE_CHANNEL:"delete_private_channel",EDIT_OTHER_USERS:"edit_other_users",READ_CHANNEL:"read_channel",READ_PUBLIC_CHANNEL:"read_public_channel",ADD_REACTION:"add_reaction",REMOVE_REACTION:"remove_reaction",REMOVE_OTHERS_REACTIONS:"remove_others_reactions",PERMANENT_DELETE_USER:"permanent_delete_user",UPLOAD_FILE:"upload_file",GET_PUBLIC_LINK:"get_public_link",MANAGE_WEBHOOKS:"manage_webhooks",MANAGE_OTHERS_WEBHOOKS:"manage_others_webhooks",MANAGE_INCOMING_WEBHOOKS:"manage_incoming_webhooks",MANAGE_OTHERS_INCOMING_WEBHOOKS:"manage_others_incoming_webhooks",MANAGE_OUTGOING_WEBHOOKS:"manage_outgoing_webhooks",MANAGE_OTHERS_OUTGOING_WEBHOOKS:"manage_others_outgoing_webhooks",MANAGE_OAUTH:"manage_oauth",MANAGE_SYSTEM_WIDE_OAUTH:"manage_system_wide_oauth",CREATE_POST:"create_post",CREATE_POST_PUBLIC:"create_post_public",EDIT_POST:"edit_post",EDIT_OTHERS_POSTS:"edit_others_posts",DELETE_POST:"delete_post",DELETE_OTHERS_POSTS:"delete_others_posts",REMOVE_USER_FROM_TEAM:"remove_user_from_team",CREATE_TEAM:"create_team",MANAGE_TEAM:"manage_team",IMPORT_TEAM:"import_team",VIEW_TEAM:"view_team",LIST_USERS_WITHOUT_TEAM:"list_users_without_team",CREATE_USER_ACCESS_TOKEN:"create_user_access_token",READ_USER_ACCESS_TOKEN:"read_user_access_token",REVOKE_USER_ACCESS_TOKEN:"revoke_user_access_token",MANAGE_JOBS:"manage_jobs",MANAGE_EMOJIS:"manage_emojis",MANAGE_OTHERS_EMOJIS:"manage_others_emojis",CREATE_EMOJIS:"create_emojis",DELETE_EMOJIS:"delete_emojis",DELETE_OTHERS_EMOJIS:"delete_others_emojis",VIEW_MEMBERS:"view_members",INVITE_GUEST:"invite_guest",PROMOTE_GUEST:"promote_guest",DEMOTE_TO_GUEST:"demote_to_guest",USE_CHANNEL_MENTIONS:"use_channel_mentions",USE_GROUP_MENTIONS:"use_group_mentions",READ_OTHER_USERS_TEAMS:"read_other_users_teams",EDIT_BRAND:"edit_brand",READ_JOBS:"read_jobs",DOWNLOAD_COMPLIANCE_EXPORT_RESULT:"download_compliance_export_result",SYSCONSOLE_READ_ABOUT:"sysconsole_read_about",SYSCONSOLE_WRITE_ABOUT:"sysconsole_write_about",SYSCONSOLE_READ_BILLING:"sysconsole_read_billing",SYSCONSOLE_WRITE_BILLING:"sysconsole_write_billing",SYSCONSOLE_READ_REPORTING:"sysconsole_read_reporting",SYSCONSOLE_WRITE_REPORTING:"sysconsole_write_reporting",SYSCONSOLE_READ_USERMANAGEMENT_USERS:"sysconsole_read_user_management_users",SYSCONSOLE_WRITE_USERMANAGEMENT_USERS:"sysconsole_write_user_management_users",SYSCONSOLE_READ_USERMANAGEMENT_GROUPS:"sysconsole_read_user_management_groups",SYSCONSOLE_WRITE_USERMANAGEMENT_GROUPS:"sysconsole_write_user_management_groups",SYSCONSOLE_READ_USERMANAGEMENT_TEAMS:"sysconsole_read_user_management_teams",SYSCONSOLE_WRITE_USERMANAGEMENT_TEAMS:"sysconsole_write_user_management_teams",SYSCONSOLE_READ_USERMANAGEMENT_CHANNELS:"sysconsole_read_user_management_channels",SYSCONSOLE_WRITE_USERMANAGEMENT_CHANNELS:"sysconsole_write_user_management_channels",SYSCONSOLE_READ_USERMANAGEMENT_PERMISSIONS:"sysconsole_read_user_management_permissions",SYSCONSOLE_WRITE_USERMANAGEMENT_PERMISSIONS:"sysconsole_write_user_management_permissions",SYSCONSOLE_READ_USERMANAGEMENT_SYSTEM_ROLES:"sysconsole_read_user_management_system_roles",SYSCONSOLE_WRITE_USERMANAGEMENT_SYSTEM_ROLES:"sysconsole_write_user_management_system_roles",SYSCONSOLE_READ_ENVIRONMENT:"sysconsole_read_environment",SYSCONSOLE_WRITE_ENVIRONMENT:"sysconsole_write_environment",SYSCONSOLE_READ_SITE:"sysconsole_read_site",SYSCONSOLE_WRITE_SITE:"sysconsole_write_site",SYSCONSOLE_READ_AUTHENTICATION:"sysconsole_read_authentication",SYSCONSOLE_WRITE_AUTHENTICATION:"sysconsole_write_authentication",SYSCONSOLE_READ_PLUGINS:"sysconsole_read_plugins",SYSCONSOLE_WRITE_PLUGINS:"sysconsole_write_plugins",SYSCONSOLE_READ_INTEGRATIONS:"sysconsole_read_integrations",SYSCONSOLE_WRITE_INTEGRATIONS:"sysconsole_write_integrations",SYSCONSOLE_READ_COMPLIANCE:"sysconsole_read_compliance",SYSCONSOLE_WRITE_COMPLIANCE:"sysconsole_write_compliance",SYSCONSOLE_READ_EXPERIMENTAL:"sysconsole_read_experimental",SYSCONSOLE_WRITE_EXPERIMENTAL:"sysconsole_write_experimental",CHANNEL_MODERATED_PERMISSIONS:{CREATE_POST:"create_post",CREATE_REACTIONS:"create_reactions",MANAGE_MEMBERS:"manage_members",USE_CHANNEL_MENTIONS:"use_channel_mentions"},MANAGE_BOTS:"manage_bots",MANAGE_OTHERS_BOTS:"manage_others_bots",SYSCONSOLE_READ_PERMISSIONS:[],SYSCONSOLE_WRITE_PERMISSIONS:[],MANAGE_SHARED_CHANNELS:"manage_shared_channels",MANAGE_REMOTE_CLUSTERS:"manage_remote_clusters",SYSCONSOLE_ANCILLARY_PERMISSIONS:{}};function h(e,t){return e===t}function _(e,t,o){if(null===t||null===o||t.length!==o.length)return!1;for(var n=t.length,r=0;r<n;r++)if(!e(t[r],o[r]))return!1;return!0}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,o=null,n=null;return function(){return _(t,o,arguments)||(n=e.apply(null,arguments)),o=arguments,n}}function p(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var o=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+o+"]")}return t}function m(e){for(var t=arguments.length,o=Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=0,s=n.pop(),a=p(n),u=e.apply(void 0,[function(){return i++,s.apply(null,arguments)}].concat(o)),d=e((function(){for(var e=[],t=a.length,o=0;o<t;o++)e.push(a[o].apply(null,arguments));return u.apply(null,e)}));return d.resultFunc=s,d.dependencies=a,d.recomputations=function(){return i},d.resetRecomputations=function(){return i=0},d}}c.SYSCONSOLE_READ_PERMISSIONS=[c.SYSCONSOLE_READ_ABOUT,c.SYSCONSOLE_READ_BILLING,c.SYSCONSOLE_READ_REPORTING,c.SYSCONSOLE_READ_USERMANAGEMENT_USERS,c.SYSCONSOLE_READ_USERMANAGEMENT_GROUPS,c.SYSCONSOLE_READ_USERMANAGEMENT_TEAMS,c.SYSCONSOLE_READ_USERMANAGEMENT_CHANNELS,c.SYSCONSOLE_READ_USERMANAGEMENT_PERMISSIONS,c.SYSCONSOLE_READ_ENVIRONMENT,c.SYSCONSOLE_READ_SITE,c.SYSCONSOLE_READ_AUTHENTICATION,c.SYSCONSOLE_READ_PLUGINS,c.SYSCONSOLE_READ_INTEGRATIONS,c.SYSCONSOLE_READ_COMPLIANCE,c.SYSCONSOLE_READ_EXPERIMENTAL],c.SYSCONSOLE_WRITE_PERMISSIONS=[c.SYSCONSOLE_WRITE_ABOUT,c.SYSCONSOLE_WRITE_BILLING,c.SYSCONSOLE_WRITE_REPORTING,c.SYSCONSOLE_WRITE_USERMANAGEMENT_USERS,c.SYSCONSOLE_WRITE_USERMANAGEMENT_GROUPS,c.SYSCONSOLE_WRITE_USERMANAGEMENT_TEAMS,c.SYSCONSOLE_WRITE_USERMANAGEMENT_CHANNELS,c.SYSCONSOLE_WRITE_USERMANAGEMENT_PERMISSIONS,c.SYSCONSOLE_WRITE_ENVIRONMENT,c.SYSCONSOLE_WRITE_SITE,c.SYSCONSOLE_WRITE_AUTHENTICATION,c.SYSCONSOLE_WRITE_PLUGINS,c.SYSCONSOLE_WRITE_INTEGRATIONS,c.SYSCONSOLE_WRITE_COMPLIANCE,c.SYSCONSOLE_WRITE_EXPERIMENTAL],c.SYSCONSOLE_ANCILLARY_PERMISSIONS=((s={})[c.SYSCONSOLE_READ_USERMANAGEMENT_CHANNELS]=[c.READ_PUBLIC_CHANNEL,c.READ_CHANNEL,c.READ_PUBLIC_CHANNEL_GROUPS,c.READ_PRIVATE_CHANNEL_GROUPS],s[c.SYSCONSOLE_READ_USERMANAGEMENT_USERS]=[c.READ_OTHER_USERS_TEAMS],s[c.SYSCONSOLE_READ_USERMANAGEMENT_TEAMS]=[c.LIST_PRIVATE_TEAMS,c.LIST_PUBLIC_TEAMS,c.VIEW_TEAM],s[c.SYSCONSOLE_WRITE_COMPLIANCE]=[c.MANAGE_JOBS],s[c.SYSCONSOLE_READ_COMPLIANCE]=[c.READ_JOBS,c.DOWNLOAD_COMPLIANCE_EXPORT_RESULT],s[c.SYSCONSOLE_READ_ENVIRONMENT]=[c.READ_JOBS],s[c.SYSCONSOLE_READ_AUTHENTICATION]=[c.READ_JOBS],s[c.SYSCONSOLE_READ_REPORTING]=[c.VIEW_TEAM],s[c.SYSCONSOLE_WRITE_USERMANAGEMENT_USERS]=[c.EDIT_OTHER_USERS,c.DEMOTE_TO_GUEST,c.PROMOTE_GUEST],s[c.SYSCONSOLE_WRITE_USERMANAGEMENT_CHANNELS]=[c.MANAGE_TEAM,c.MANAGE_PUBLIC_CHANNEL_PROPERTIES,c.MANAGE_PRIVATE_CHANNEL_PROPERTIES,c.MANAGE_PRIVATE_CHANNEL_MEMBERS,c.MANAGE_PUBLIC_CHANNEL_MEMBERS,c.DELETE_PRIVATE_CHANNEL,c.DELETE_PUBLIC_CHANNEL,c.MANAGE_CHANNEL_ROLES,c.CONVERT_PUBLIC_CHANNEL_TO_PRIVATE,c.CONVERT_PRIVATE_CHANNEL_TO_PUBLIC],s[c.SYSCONSOLE_WRITE_USERMANAGEMENT_TEAMS]=[c.MANAGE_TEAM,c.MANAGE_TEAM_ROLES,c.REMOVE_USER_FROM_TEAM,c.JOIN_PRIVATE_TEAMS,c.JOIN_PUBLIC_TEAMS,c.ADD_USER_TO_TEAM],s[c.SYSCONSOLE_WRITE_USERMANAGEMENT_GROUPS]=[c.MANAGE_TEAM,c.MANAGE_PRIVATE_CHANNEL_MEMBERS,c.MANAGE_PUBLIC_CHANNEL_MEMBERS,c.CONVERT_PUBLIC_CHANNEL_TO_PRIVATE,c.CONVERT_PRIVATE_CHANNEL_TO_PUBLIC],s[c.SYSCONSOLE_WRITE_ENVIRONMENT]=[c.MANAGE_JOBS],s[c.SYSCONSOLE_WRITE_SITE]=[c.EDIT_BRAND],s),function(e){e.SYNCABLE_TYPE_TEAM="team",e.SYNCABLE_TYPE_CHANNEL="channel"}(d||(d={})),m(g);var l=function(e,t,o){if(null===e!=(null===t))return!1;var n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;var i=typeof e;return i===typeof t&&(function(e){return"function"!==e&&"object"!==e}(i)?o?o(e,t):e===t:n?function(e,t,o){var n=e.length;if(n!==t.length)return!1;if(o){for(var r=0;r<n;r++)if(!o(e[r],t[r]))return!1}else for(r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}(e,t,o):function(e,t,o){var n=0,r=0;if(o)for(var i in e){if(e.hasOwnProperty(i)&&!o(e[i],t[i]))return!1;n++}else for(var i in e){if(e.hasOwnProperty(i)&&e[i]!==t[i])return!1;n++}for(var i in t)t.hasOwnProperty(i)&&r++;return n===r}(e,t,o))};m((function(e){var t=null,o=null;return function(){if(!l(t,arguments)){var n=Reflect.apply(e,null,arguments);l(o,n)||(o=n)}return t=arguments,o}})),m(g,l);function f(e){var t=Object.keys(e);if(0===t.length)return"";for(var o="?",n=0;n<t.length;n++){var r=t[n];o+=r+"="+encodeURIComponent(e[r]),n<t.length-1&&(o+="&")}return o}function E(e){return t=u,e.split(" ").includes(t);var t}var R={},S={},v=function(e,t){if(void 0===t&&(t={headers:{}}),e=e||t.url||"","GET"===t.method||!t.method){var o=S[e],n=R[""+e+o];return o&&(t.headers["If-None-Match"]=o),fetch(e,t).then((function(t){if(304===t.status)return n.clone();if(200===t.status){var o=t.headers.get("Etag");o&&(R[""+e+o]=t.clone(),S[e]=o)}return t}))}return Reflect.apply(fetch,void 0,[e,t])},O=require("form-data"),y=function(){function e(){var e=this;this.logToConsole=!1,this.serverVersion="",this.clusterId="",this.token="",this.csrf="",this.url="",this.urlVersion="/api/v4",this.userAgent=null,this.enableLogging=!1,this.defaultHeaders={},this.userId="",this.diagnosticId="",this.includeCookies=!0,this.translations={connectionError:"There appears to be a problem with your internet connection.",unknownError:"We received an unexpected status code from the server."},this.createUser=function(t,o,n,r){e.trackEvent("api","api_users_create");var i={};return o&&(i.t=o),n&&(i.iid=n),r&&(i.r=r),e.doFetch(""+e.getUsersRoute()+f(i),{method:"post",body:JSON.stringify(t)})},this.patchMe=function(t){return e.doFetch(e.getUserRoute("me")+"/patch",{method:"put",body:JSON.stringify(t)})},this.patchUser=function(t){return e.trackEvent("api","api_users_patch"),e.doFetch(e.getUserRoute(t.id)+"/patch",{method:"put",body:JSON.stringify(t)})},this.updateUser=function(t){return e.trackEvent("api","api_users_update"),e.doFetch(""+e.getUserRoute(t.id),{method:"put",body:JSON.stringify(t)})},this.promoteGuestToUser=function(t){return e.trackEvent("api","api_users_promote_guest_to_user"),e.doFetch(e.getUserRoute(t)+"/promote",{method:"post"})},this.demoteUserToGuest=function(t){return e.trackEvent("api","api_users_demote_user_to_guest"),e.doFetch(e.getUserRoute(t)+"/demote",{method:"post"})},this.updateUserRoles=function(t,o){return e.trackEvent("api","api_users_update_roles"),e.doFetch(e.getUserRoute(t)+"/roles",{method:"put",body:JSON.stringify({roles:o})})},this.updateUserMfa=function(t,o,n){var r={activate:o};return o&&(r.code=n),e.doFetch(e.getUserRoute(t)+"/mfa",{method:"put",body:JSON.stringify(r)})},this.updateUserPassword=function(t,o,n){return e.trackEvent("api","api_users_newpassword"),e.doFetch(e.getUserRoute(t)+"/password",{method:"put",body:JSON.stringify({current_password:o,new_password:n})})},this.resetUserPassword=function(t,o){return e.trackEvent("api","api_users_reset_password"),e.doFetch(e.getUsersRoute()+"/password/reset",{method:"post",body:JSON.stringify({token:t,new_password:o})})},this.getKnownUsers=function(){return e.trackEvent("api","api_get_known_users"),e.doFetch(e.getUsersRoute()+"/known",{method:"get"})},this.sendPasswordResetEmail=function(t){return e.trackEvent("api","api_users_send_password_reset"),e.doFetch(e.getUsersRoute()+"/password/reset/send",{method:"post",body:JSON.stringify({email:t})})},this.updateUserActive=function(t,o){return e.trackEvent("api","api_users_update_active"),e.doFetch(e.getUserRoute(t)+"/active",{method:"put",body:JSON.stringify({active:o})})},this.uploadProfileImage=function(t,o){e.trackEvent("api","api_users_update_profile_picture");var n=new O;n.append("image",o);var r={method:"post",body:n};return n.getBoundary&&(r.headers={"Content-Type":"multipart/form-data; boundary="+n.getBoundary()}),e.doFetch(e.getUserRoute(t)+"/image",r)},this.setDefaultProfileImage=function(t){return e.trackEvent("api","api_users_set_default_profile_picture"),e.doFetch(e.getUserRoute(t)+"/image",{method:"delete"})},this.verifyUserEmail=function(t){return e.doFetch(e.getUsersRoute()+"/email/verify",{method:"post",body:JSON.stringify({token:t})})},this.updateMyTermsOfServiceStatus=function(t,o){return e.doFetch(e.getUserRoute("me")+"/terms_of_service",{method:"post",body:JSON.stringify({termsOfServiceId:t,accepted:o})})},this.getTermsOfService=function(){return e.doFetch(e.getBaseRoute()+"/terms_of_service",{method:"get"})},this.createTermsOfService=function(t){return e.doFetch(e.getBaseRoute()+"/terms_of_service",{method:"post",body:JSON.stringify({text:t})})},this.sendVerificationEmail=function(t){return e.doFetch(e.getUsersRoute()+"/email/verify/send",{method:"post",body:JSON.stringify({email:t})})},this.login=function(t,o,n,r,i){void 0===n&&(n=""),void 0===r&&(r=""),void 0===i&&(i=!1),e.trackEvent("api","api_users_login"),i&&e.trackEvent("api","api_users_login_ldap");var s={device_id:r,login_id:t,password:o,token:n};return i&&(s.ldap_only="true"),e.doFetch(e.getUsersRoute()+"/login",{method:"post",body:JSON.stringify(s)})},this.loginById=function(t,o,n,r){void 0===n&&(n=""),void 0===r&&(r=""),e.trackEvent("api","api_users_login");var i={device_id:r,id:t,password:o,token:n};return e.doFetch(e.getUsersRoute()+"/login",{method:"post",body:JSON.stringify(i)})},this.logout=function(){return o(e,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this.trackEvent("api","api_users_logout"),[4,this.doFetchWithResponse(this.getUsersRoute()+"/logout",{method:"post"})];case 1:return(e=t.sent().response).ok&&(this.token=""),this.serverVersion="",[2,e]}}))}))},this.getProfiles=function(o,n,r){return void 0===o&&(o=0),void 0===n&&(n=60),void 0===r&&(r={}),e.trackEvent("api","api_profiles_get"),e.doFetch(""+e.getUsersRoute()+f(t({page:o,per_page:n},r)),{method:"get"})},this.getProfilesByIds=function(t,o){return void 0===o&&(o={}),e.trackEvent("api","api_profiles_get_by_ids"),e.doFetch(e.getUsersRoute()+"/ids"+f(o),{method:"post",body:JSON.stringify(t)})},this.getProfilesByUsernames=function(t){return e.trackEvent("api","api_profiles_get_by_usernames"),e.doFetch(e.getUsersRoute()+"/usernames",{method:"post",body:JSON.stringify(t)})},this.getProfilesInTeam=function(o,n,r,i,s){return void 0===n&&(n=0),void 0===r&&(r=60),void 0===i&&(i=""),void 0===s&&(s={}),e.trackEvent("api","api_profiles_get_in_team",{team_id:o,sort:i}),e.doFetch(""+e.getUsersRoute()+f(t(t({},s),{in_team:o,page:n,per_page:r,sort:i})),{method:"get"})},this.getProfilesNotInTeam=function(t,o,n,r){void 0===n&&(n=0),void 0===r&&(r=60),e.trackEvent("api","api_profiles_get_not_in_team",{team_id:t,group_constrained:o});var i={not_in_team:t,page:n,per_page:r};return o&&(i.group_constrained=!0),e.doFetch(""+e.getUsersRoute()+f(i),{method:"get"})},this.getProfilesWithoutTeam=function(o,n,r){return void 0===o&&(o=0),void 0===n&&(n=60),void 0===r&&(r={}),e.trackEvent("api","api_profiles_get_without_team"),e.doFetch(""+e.getUsersRoute()+f(t(t({},r),{without_team:1,page:o,per_page:n})),{method:"get"})},this.getProfilesInChannel=function(o,n,r,i,s){var a;return void 0===n&&(n=0),void 0===r&&(r=60),void 0===i&&(i=""),void 0===s&&(s={}),e.trackEvent("api","api_profiles_get_in_channel",{channel_id:o}),a=function(e,t,o,n){if(void 0===t&&(t=0),void 0===o&&(o=0),void 0===n&&(n=0),!e||"string"!=typeof e)return!1;var r=e.split("."),i=parseInt(r[0],10),s=parseInt(r[1]||"0",10),a=parseInt(r[2]||"0",10);return i>t||!(i<t)&&(s>o||!(s<o)&&(a>n||!(a<n)))}(e.getServerVersion(),4,7)?{in_channel:o,page:n,per_page:r,sort:i}:{in_channel:o,page:n,per_page:r},e.doFetch(""+e.getUsersRoute()+f(t(t({},a),s)),{method:"get"})},this.getProfilesInGroupChannels=function(t){return e.trackEvent("api","api_profiles_get_in_group_channels",{channelsIds:t}),e.doFetch(e.getUsersRoute()+"/group_channels",{method:"post",body:JSON.stringify(t)})},this.getProfilesNotInChannel=function(t,o,n,r,i){void 0===r&&(r=0),void 0===i&&(i=60),e.trackEvent("api","api_profiles_get_not_in_channel",{team_id:t,channel_id:o,group_constrained:n});var s={in_team:t,not_in_channel:o,page:r,per_page:i};return n&&(s.group_constrained=!0),e.doFetch(""+e.getUsersRoute()+f(s),{method:"get"})},this.getProfilesInGroup=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(""+e.getUsersRoute()+f({in_group:t,page:o,per_page:n}),{method:"get"})},this.getMe=function(){return e.doFetch(""+e.getUserRoute("me"),{method:"get"})},this.getUser=function(t){return e.doFetch(""+e.getUserRoute(t),{method:"get"})},this.getUserByUsername=function(t){return e.doFetch(e.getUsersRoute()+"/username/"+t,{method:"get"})},this.getUserByEmail=function(t){return e.doFetch(e.getUsersRoute()+"/email/"+t,{method:"get"})},this.getProfilePictureUrl=function(t,o){var n={};return o&&(n._=o),e.getUserRoute(t)+"/image"+f(n)},this.getDefaultProfilePictureUrl=function(t){return e.getUserRoute(t)+"/image/default"},this.autocompleteUsers=function(t,o,n,r){return void 0===r&&(r={limit:a}),e.doFetch(e.getUsersRoute()+"/autocomplete"+f({in_team:o,in_channel:n,name:t,limit:r.limit}),{method:"get"})},this.getSessions=function(t){return e.doFetch(e.getUserRoute(t)+"/sessions",{method:"get"})},this.revokeSession=function(t,o){return e.doFetch(e.getUserRoute(t)+"/sessions/revoke",{method:"post",body:JSON.stringify({session_id:o})})},this.revokeAllSessionsForUser=function(t){return e.doFetch(e.getUserRoute(t)+"/sessions/revoke/all",{method:"post"})},this.revokeSessionsForAllUsers=function(){return e.doFetch(e.getUsersRoute()+"/sessions/revoke/all",{method:"post"})},this.getUserAudits=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(e.getUserRoute(t)+"/audits"+f({page:o,per_page:n}),{method:"get"})},this.checkUserMfa=function(t){return e.doFetch(e.getUsersRoute()+"/mfa",{method:"post",body:JSON.stringify({login_id:t})})},this.generateMfaSecret=function(t){return e.doFetch(e.getUserRoute(t)+"/mfa/generate",{method:"post"})},this.attachDevice=function(t){return e.doFetch(e.getUsersRoute()+"/sessions/device",{method:"put",body:JSON.stringify({device_id:t})})},this.searchUsers=function(o,n){return e.trackEvent("api","api_search_users"),e.doFetch(e.getUsersRoute()+"/search",{method:"post",body:JSON.stringify(t({term:o},n))})},this.getStatusesByIds=function(t){return e.doFetch(e.getUsersRoute()+"/status/ids",{method:"post",body:JSON.stringify(t)})},this.getStatus=function(t){return e.doFetch(e.getUserRoute(t)+"/status",{method:"get"})},this.updateStatus=function(t){return e.doFetch(e.getUserRoute(t.user_id)+"/status",{method:"put",body:JSON.stringify(t)})},this.updateCustomStatus=function(t){return e.doFetch(e.getUserRoute("me")+"/status/custom",{method:"put",body:JSON.stringify(t)})},this.unsetCustomStatus=function(){return e.doFetch(e.getUserRoute("me")+"/status/custom",{method:"delete"})},this.removeRecentCustomStatus=function(t){return e.doFetch(e.getUserRoute("me")+"/status/custom/recent",{method:"delete",body:JSON.stringify(t)})},this.switchEmailToOAuth=function(t,o,n,r){return void 0===r&&(r=""),e.trackEvent("api","api_users_email_to_oauth"),e.doFetch(e.getUsersRoute()+"/login/switch",{method:"post",body:JSON.stringify({current_service:"email",new_service:t,email:o,password:n,mfa_code:r})})},this.switchOAuthToEmail=function(t,o,n){return e.trackEvent("api","api_users_oauth_to_email"),e.doFetch(e.getUsersRoute()+"/login/switch",{method:"post",body:JSON.stringify({current_service:t,new_service:"email",email:o,new_password:n})})},this.switchEmailToLdap=function(t,o,n,r,i){return void 0===i&&(i=""),e.trackEvent("api","api_users_email_to_ldap"),e.doFetch(e.getUsersRoute()+"/login/switch",{method:"post",body:JSON.stringify({current_service:"email",new_service:"ldap",email:t,password:o,ldap_id:n,new_password:r,mfa_code:i})})},this.switchLdapToEmail=function(t,o,n,r){return void 0===r&&(r=""),e.trackEvent("api","api_users_ldap_to_email"),e.doFetch(e.getUsersRoute()+"/login/switch",{method:"post",body:JSON.stringify({current_service:"ldap",new_service:"email",email:o,password:t,new_password:n,mfa_code:r})})},this.getAuthorizedOAuthApps=function(t){return e.doFetch(e.getUserRoute(t)+"/oauth/apps/authorized",{method:"get"})},this.authorizeOAuthApp=function(t,o,n,r,i){return e.doFetch(e.url+"/oauth/authorize",{method:"post",body:JSON.stringify({client_id:o,response_type:t,redirect_uri:n,state:r,scope:i})})},this.deauthorizeOAuthApp=function(t){return e.doFetch(e.url+"/oauth/deauthorize",{method:"post",body:JSON.stringify({client_id:t})})},this.createUserAccessToken=function(t,o){return e.trackEvent("api","api_users_create_access_token"),e.doFetch(e.getUserRoute(t)+"/tokens",{method:"post",body:JSON.stringify({description:o})})},this.getUserAccessToken=function(t){return e.doFetch(e.getUsersRoute()+"/tokens/"+t,{method:"get"})},this.getUserAccessTokensForUser=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(e.getUserRoute(t)+"/tokens"+f({page:o,per_page:n}),{method:"get"})},this.getUserAccessTokens=function(t,o){return void 0===t&&(t=0),void 0===o&&(o=60),e.doFetch(e.getUsersRoute()+"/tokens"+f({page:t,per_page:o}),{method:"get"})},this.revokeUserAccessToken=function(t){return e.trackEvent("api","api_users_revoke_access_token"),e.doFetch(e.getUsersRoute()+"/tokens/revoke",{method:"post",body:JSON.stringify({token_id:t})})},this.disableUserAccessToken=function(t){return e.doFetch(e.getUsersRoute()+"/tokens/disable",{method:"post",body:JSON.stringify({token_id:t})})},this.enableUserAccessToken=function(t){return e.doFetch(e.getUsersRoute()+"/tokens/enable",{method:"post",body:JSON.stringify({token_id:t})})},this.createTeam=function(t){return e.trackEvent("api","api_teams_create"),e.doFetch(""+e.getTeamsRoute(),{method:"post",body:JSON.stringify(t)})},this.deleteTeam=function(t){return e.trackEvent("api","api_teams_delete"),e.doFetch(""+e.getTeamRoute(t),{method:"delete"})},this.updateTeam=function(t){return e.trackEvent("api","api_teams_update_name",{team_id:t.id}),e.doFetch(""+e.getTeamRoute(t.id),{method:"put",body:JSON.stringify(t)})},this.patchTeam=function(t){return e.trackEvent("api","api_teams_patch_name",{team_id:t.id}),e.doFetch(e.getTeamRoute(t.id)+"/patch",{method:"put",body:JSON.stringify(t)})},this.regenerateTeamInviteId=function(t){return e.trackEvent("api","api_teams_regenerate_invite_id",{team_id:t}),e.doFetch(e.getTeamRoute(t)+"/regenerate_invite_id",{method:"post"})},this.updateTeamScheme=function(o,n){var r={scheme_id:n};return e.trackEvent("api","api_teams_update_scheme",t({team_id:o},r)),e.doFetch(""+e.getTeamSchemeRoute(o),{method:"put",body:JSON.stringify(r)})},this.checkIfTeamExists=function(t){return e.doFetch(e.getTeamNameRoute(t)+"/exists",{method:"get"})},this.getTeams=function(t,o,n){return void 0===t&&(t=0),void 0===o&&(o=60),void 0===n&&(n=!1),e.doFetch(""+e.getTeamsRoute()+f({page:t,per_page:o,include_total_count:n}),{method:"get"})},this.searchTeams=function(o,n){return e.trackEvent("api","api_search_teams"),e.doFetch(e.getTeamsRoute()+"/search",{method:"post",body:JSON.stringify(t({term:o},n))})},this.getTeam=function(t){return e.doFetch(e.getTeamRoute(t),{method:"get"})},this.getTeamByName=function(t){return e.trackEvent("api","api_teams_get_team_by_name"),e.doFetch(e.getTeamNameRoute(t),{method:"get"})},this.getMyTeams=function(){return e.doFetch(e.getUserRoute("me")+"/teams",{method:"get"})},this.getTeamsForUser=function(t){return e.doFetch(e.getUserRoute(t)+"/teams",{method:"get"})},this.getMyTeamMembers=function(){return e.doFetch(e.getUserRoute("me")+"/teams/members",{method:"get"})},this.getMyTeamUnreads=function(){return e.doFetch(e.getUserRoute("me")+"/teams/unread",{method:"get"})},this.getTeamMembers=function(o,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=60),e.doFetch(""+e.getTeamMembersRoute(o)+f(t({page:n,per_page:r},i)),{method:"get"})},this.getTeamMembersForUser=function(t){return e.doFetch(e.getUserRoute(t)+"/teams/members",{method:"get"})},this.getTeamMember=function(t,o){return e.doFetch(""+e.getTeamMemberRoute(t,o),{method:"get"})},this.getTeamMembersByIds=function(t,o){return e.doFetch(e.getTeamMembersRoute(t)+"/ids",{method:"post",body:JSON.stringify(o)})},this.addToTeam=function(t,o){e.trackEvent("api","api_teams_invite_members",{team_id:t});var n={user_id:o,team_id:t};return e.doFetch(""+e.getTeamMembersRoute(t),{method:"post",body:JSON.stringify(n)})},this.addToTeamFromInvite=function(t,o){void 0===t&&(t=""),void 0===o&&(o=""),e.trackEvent("api","api_teams_invite_members");var n=f({token:t,invite_id:o});return e.doFetch(e.getTeamsRoute()+"/members/invite"+n,{method:"post"})},this.addUsersToTeam=function(t,o){e.trackEvent("api","api_teams_batch_add_members",{team_id:t,count:o.length});var n=[];return o.forEach((function(e){return n.push({team_id:t,user_id:e})})),e.doFetch(e.getTeamMembersRoute(t)+"/batch",{method:"post",body:JSON.stringify(n)})},this.addUsersToTeamGracefully=function(t,o){e.trackEvent("api","api_teams_batch_add_members",{team_id:t,count:o.length});var n=[];return o.forEach((function(e){return n.push({team_id:t,user_id:e})})),e.doFetch(e.getTeamMembersRoute(t)+"/batch?graceful=true",{method:"post",body:JSON.stringify(n)})},this.joinTeam=function(t){var o=f({invite_id:t});return e.doFetch(e.getTeamsRoute()+"/members/invite"+o,{method:"post"})},this.removeFromTeam=function(t,o){return e.trackEvent("api","api_teams_remove_members",{team_id:t}),e.doFetch(""+e.getTeamMemberRoute(t,o),{method:"delete"})},this.getTeamStats=function(t){return e.doFetch(e.getTeamRoute(t)+"/stats",{method:"get"})},this.getTotalUsersStats=function(){return e.doFetch(e.getUsersRoute()+"/stats",{method:"get"})},this.getFilteredUsersStats=function(t){return e.doFetch(e.getUsersRoute()+"/stats/filtered"+f(t),{method:"get"})},this.invalidateAllEmailInvites=function(){return e.doFetch(e.getTeamsRoute()+"/invites/email",{method:"delete"})},this.getTeamInviteInfo=function(t){return e.doFetch(e.getTeamsRoute()+"/invite/"+t,{method:"get"})},this.updateTeamMemberRoles=function(t,o,n){return e.trackEvent("api","api_teams_update_member_roles",{team_id:t}),e.doFetch(e.getTeamMemberRoute(t,o)+"/roles",{method:"put",body:JSON.stringify({roles:n})})},this.sendEmailInvitesToTeam=function(t,o){return e.trackEvent("api","api_teams_invite_members",{team_id:t}),e.doFetch(e.getTeamRoute(t)+"/invite/email",{method:"post",body:JSON.stringify(o)})},this.sendEmailGuestInvitesToChannels=function(t,o,n,r){return e.trackEvent("api","api_teams_invite_guests",{team_id:t,channel_ids:o}),e.doFetch(e.getTeamRoute(t)+"/invite-guests/email",{method:"post",body:JSON.stringify({emails:n,channels:o,message:r})})},this.sendEmailInvitesToTeamGracefully=function(t,o){return e.trackEvent("api","api_teams_invite_members",{team_id:t}),e.doFetch(e.getTeamRoute(t)+"/invite/email?graceful=true",{method:"post",body:JSON.stringify(o)})},this.sendEmailGuestInvitesToChannelsGracefully=function(t,r,i,s){return o(e,void 0,void 0,(function(){return n(this,(function(e){return this.trackEvent("api","api_teams_invite_guests",{team_id:t,channel_ids:r}),[2,this.doFetch(this.getTeamRoute(t)+"/invite-guests/email?graceful=true",{method:"post",body:JSON.stringify({emails:i,channels:r,message:s})})]}))}))},this.importTeam=function(t,o,n){var r=new O;r.append("file",o,o.name),r.append("filesize",o.size),r.append("importFrom",n);var i={method:"post",body:r};return r.getBoundary&&(i.headers={"Content-Type":"multipart/form-data; boundary="+r.getBoundary()}),e.doFetch(e.getTeamRoute(t)+"/import",i)},this.getTeamIconUrl=function(t,o){var n={};return o&&(n._=o),e.getTeamRoute(t)+"/image"+f(n)},this.setTeamIcon=function(t,o){e.trackEvent("api","api_team_set_team_icon");var n=new O;n.append("image",o);var r={method:"post",body:n};return n.getBoundary&&(r.headers={"Content-Type":"multipart/form-data; boundary="+n.getBoundary()}),e.doFetch(e.getTeamRoute(t)+"/image",r)},this.removeTeamIcon=function(t){return e.trackEvent("api","api_team_remove_team_icon"),e.doFetch(e.getTeamRoute(t)+"/image",{method:"delete"})},this.updateTeamMemberSchemeRoles=function(t,o,n,r){var i={scheme_user:n,scheme_admin:r};return e.doFetch(e.getTeamRoute(t)+"/members/"+o+"/schemeRoles",{method:"put",body:JSON.stringify(i)})},this.getAllChannels=function(t,o,n,r,i,s){void 0===t&&(t=0),void 0===o&&(o=60),void 0===n&&(n=""),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===s&&(s=!1);var a={page:t,per_page:o,not_associated_to_group:n,exclude_default_channels:r,include_total_count:i,include_deleted:s};return e.doFetch(""+e.getChannelsRoute()+f(a),{method:"get"})},this.createChannel=function(t){return e.trackEvent("api","api_channels_create",{team_id:t.team_id}),e.doFetch(""+e.getChannelsRoute(),{method:"post",body:JSON.stringify(t)})},this.createDirectChannel=function(t){return e.trackEvent("api","api_channels_create_direct"),e.doFetch(e.getChannelsRoute()+"/direct",{method:"post",body:JSON.stringify(t)})},this.createGroupChannel=function(t){return e.trackEvent("api","api_channels_create_group"),e.doFetch(e.getChannelsRoute()+"/group",{method:"post",body:JSON.stringify(t)})},this.deleteChannel=function(t){return e.trackEvent("api","api_channels_delete",{channel_id:t}),e.doFetch(""+e.getChannelRoute(t),{method:"delete"})},this.unarchiveChannel=function(t){return e.trackEvent("api","api_channels_unarchive",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/restore",{method:"post"})},this.updateChannel=function(t){return e.trackEvent("api","api_channels_update",{channel_id:t.id}),e.doFetch(""+e.getChannelRoute(t.id),{method:"put",body:JSON.stringify(t)})},this.convertChannelToPrivate=function(t){return e.trackEvent("api","api_channels_convert_to_private",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/convert",{method:"post"})},this.updateChannelPrivacy=function(t,o){return e.trackEvent("api","api_channels_update_privacy",{channel_id:t,privacy:o}),e.doFetch(e.getChannelRoute(t)+"/privacy",{method:"put",body:JSON.stringify({privacy:o})})},this.patchChannel=function(t,o){return e.trackEvent("api","api_channels_patch",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/patch",{method:"put",body:JSON.stringify(o)})},this.updateChannelNotifyProps=function(t){return e.trackEvent("api","api_users_update_channel_notifications",{channel_id:t.channel_id}),e.doFetch(e.getChannelMemberRoute(t.channel_id,t.user_id)+"/notify_props",{method:"put",body:JSON.stringify(t)})},this.updateChannelScheme=function(o,n){var r={scheme_id:n};return e.trackEvent("api","api_channels_update_scheme",t({channel_id:o},r)),e.doFetch(""+e.getChannelSchemeRoute(o),{method:"put",body:JSON.stringify(r)})},this.getChannel=function(t){return e.trackEvent("api","api_channel_get",{channel_id:t}),e.doFetch(""+e.getChannelRoute(t),{method:"get"})},this.getChannelByName=function(t,o,n){return void 0===n&&(n=!1),e.doFetch(e.getTeamRoute(t)+"/channels/name/"+o+"?include_deleted="+n,{method:"get"})},this.getChannelByNameAndTeamName=function(t,o,n){return void 0===n&&(n=!1),e.trackEvent("api","api_channel_get_by_name_and_teamName",{include_deleted:n}),e.doFetch(e.getTeamNameRoute(t)+"/channels/name/"+o+"?include_deleted="+n,{method:"get"})},this.getChannels=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(e.getTeamRoute(t)+"/channels"+f({page:o,per_page:n}),{method:"get"})},this.getArchivedChannels=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(e.getTeamRoute(t)+"/channels/deleted"+f({page:o,per_page:n}),{method:"get"})},this.getMyChannels=function(t,o){return void 0===o&&(o=!1),e.doFetch(e.getUserRoute("me")+"/teams/"+t+"/channels"+f({include_deleted:o}),{method:"get"})},this.getMyChannelMember=function(t){return e.doFetch(""+e.getChannelMemberRoute(t,"me"),{method:"get"})},this.getMyChannelMembers=function(t){return e.doFetch(e.getUserRoute("me")+"/teams/"+t+"/channels/members",{method:"get"})},this.getChannelMembers=function(t,o,n){return void 0===o&&(o=0),void 0===n&&(n=60),e.doFetch(""+e.getChannelMembersRoute(t)+f({page:o,per_page:n}),{method:"get"})},this.getChannelTimezones=function(t){return e.doFetch(e.getChannelRoute(t)+"/timezones",{method:"get"})},this.getChannelMember=function(t,o){return e.doFetch(""+e.getChannelMemberRoute(t,o),{method:"get"})},this.getChannelMembersByIds=function(t,o){return e.doFetch(e.getChannelMembersRoute(t)+"/ids",{method:"post",body:JSON.stringify(o)})},this.addToChannel=function(t,o,n){void 0===n&&(n=""),e.trackEvent("api","api_channels_add_member",{channel_id:o});var r={user_id:t,channel_id:o,post_root_id:n};return e.doFetch(""+e.getChannelMembersRoute(o),{method:"post",body:JSON.stringify(r)})},this.removeFromChannel=function(t,o){return e.trackEvent("api","api_channels_remove_member",{channel_id:o}),e.doFetch(""+e.getChannelMemberRoute(o,t),{method:"delete"})},this.updateChannelMemberRoles=function(t,o,n){return e.doFetch(e.getChannelMemberRoute(t,o)+"/roles",{method:"put",body:JSON.stringify({roles:n})})},this.getChannelStats=function(t){return e.doFetch(e.getChannelRoute(t)+"/stats",{method:"get"})},this.getChannelModerations=function(t){return e.doFetch(e.getChannelRoute(t)+"/moderations",{method:"get"})},this.patchChannelModerations=function(t,o){return e.doFetch(e.getChannelRoute(t)+"/moderations/patch",{method:"put",body:JSON.stringify(o)})},this.getChannelMemberCountsByGroup=function(t,o){return e.doFetch(e.getChannelRoute(t)+"/member_counts_by_group?include_timezones="+o,{method:"get"})},this.viewMyChannel=function(t,o){var n={channel_id:t,prev_channel_id:o};return e.doFetch(e.getChannelsRoute()+"/members/me/view",{method:"post",body:JSON.stringify(n)})},this.autocompleteChannels=function(t,o){return e.doFetch(e.getTeamRoute(t)+"/channels/autocomplete"+f({name:o}),{method:"get"})},this.autocompleteChannelsForSearch=function(t,o){return e.doFetch(e.getTeamRoute(t)+"/channels/search_autocomplete"+f({name:o}),{method:"get"})},this.searchChannels=function(t,o){return e.doFetch(e.getTeamRoute(t)+"/channels/search",{method:"post",body:JSON.stringify({term:o})})},this.searchArchivedChannels=function(t,o){return e.doFetch(e.getTeamRoute(t)+"/channels/search_archived",{method:"post",body:JSON.stringify({term:o})})},this.searchAllChannels=function(o,n){void 0===n&&(n={});var r=t({term:o},n),i=Boolean(n.include_deleted);return e.doFetch(e.getChannelsRoute()+"/search?include_deleted="+i,{method:"post",body:JSON.stringify(r)})},this.searchGroupChannels=function(t){return e.doFetch(e.getChannelsRoute()+"/group/search",{method:"post",body:JSON.stringify({term:t})})},this.updateChannelMemberSchemeRoles=function(t,o,n,r){var i={scheme_user:n,scheme_admin:r};return e.doFetch(e.getChannelRoute(t)+"/members/"+o+"/schemeRoles",{method:"put",body:JSON.stringify(i)})},this.getChannelCategories=function(t,o){return e.doFetch(""+e.getChannelCategoriesRoute(t,o),{method:"get"})},this.createChannelCategory=function(t,o,n){return e.doFetch(""+e.getChannelCategoriesRoute(t,o),{method:"post",body:JSON.stringify(n)})},this.updateChannelCategories=function(t,o,n){return e.doFetch(""+e.getChannelCategoriesRoute(t,o),{method:"put",body:JSON.stringify(n)})},this.getChannelCategoryOrder=function(t,o){return e.doFetch(e.getChannelCategoriesRoute(t,o)+"/order",{method:"get"})},this.updateChannelCategoryOrder=function(t,o,n){return e.doFetch(e.getChannelCategoriesRoute(t,o)+"/order",{method:"put",body:JSON.stringify(n)})},this.getChannelCategory=function(t,o,n){return e.doFetch(e.getChannelCategoriesRoute(t,o)+"/"+n,{method:"get"})},this.updateChannelCategory=function(t,o,n){return e.doFetch(e.getChannelCategoriesRoute(t,o)+"/"+n.id,{method:"put",body:JSON.stringify(n)})},this.deleteChannelCategory=function(t,o,n){return e.doFetch(e.getChannelCategoriesRoute(t,o)+"/"+n,{method:"delete"})},this.createPost=function(t){return o(e,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return[4,this.doFetch(""+this.getPostsRoute(),{method:"post",body:JSON.stringify(t)})];case 1:return e=n.sent(),o={channel_id:e.channel_id,post_id:e.id,user_actual_id:e.user_id,root_id:e.root_id},this.trackEvent("api","api_posts_create",o),null!=e.root_id&&""!==e.root_id&&this.trackEvent("api","api_posts_replied",o),[2,e]}}))}))},this.updatePost=function(t){return e.trackEvent("api","api_posts_update",{channel_id:t.channel_id,post_id:t.id}),e.doFetch(""+e.getPostRoute(t.id),{method:"put",body:JSON.stringify(t)})},this.getPost=function(t){return e.doFetch(""+e.getPostRoute(t),{method:"get"})},this.patchPost=function(t){return e.trackEvent("api","api_posts_patch",{channel_id:t.channel_id,post_id:t.id}),e.doFetch(e.getPostRoute(t.id)+"/patch",{method:"put",body:JSON.stringify(t)})},this.deletePost=function(t){return e.trackEvent("api","api_posts_delete"),e.doFetch(""+e.getPostRoute(t),{method:"delete"})},this.getPostThread=function(t,o,n,r){return void 0===o&&(o=!0),void 0===n&&(n=!1),void 0===r&&(r=!1),e.doFetch(e.getPostRoute(t)+"/thread"+f({skipFetchThreads:!o,collapsedThreads:n,collapsedThreadsExtended:r}),{method:"get"})},this.getPosts=function(t,o,n,r,i,s){return void 0===o&&(o=0),void 0===n&&(n=60),void 0===r&&(r=!0),void 0===i&&(i=!1),void 0===s&&(s=!1),e.doFetch(e.getChannelRoute(t)+"/posts"+f({page:o,per_page:n,skipFetchThreads:!r,collapsedThreads:i,collapsedThreadsExtended:s}),{method:"get"})},this.getPostsUnread=function(t,o,n,r,i,s,a){return void 0===n&&(n=30),void 0===r&&(r=30),void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===a&&(a=!1),e.doFetch(e.getUserRoute(o)+"/channels/"+t+"/posts/unread"+f({limit_after:n,limit_before:r,skipFetchThreads:!i,collapsedThreads:s,collapsedThreadsExtended:a}),{method:"get"})},this.getPostsSince=function(t,o,n,r,i){return void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===i&&(i=!1),e.doFetch(e.getChannelRoute(t)+"/posts"+f({since:o,skipFetchThreads:!n,collapsedThreads:r,collapsedThreadsExtended:i}),{method:"get"})},this.getPostsBefore=function(t,o,n,r,i,s,a){return void 0===n&&(n=0),void 0===r&&(r=60),void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===a&&(a=!1),e.trackEvent("api","api_posts_get_before",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/posts"+f({before:o,page:n,per_page:r,skipFetchThreads:!i,collapsedThreads:s,collapsedThreadsExtended:a}),{method:"get"})},this.getPostsAfter=function(t,o,n,r,i,s,a){return void 0===n&&(n=0),void 0===r&&(r=60),void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===a&&(a=!1),e.trackEvent("api","api_posts_get_after",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/posts"+f({after:o,page:n,per_page:r,skipFetchThreads:!i,collapsedThreads:s,collapsedThreadsExtended:a}),{method:"get"})},this.getUserThreads=function(t,o,n){void 0===t&&(t="me");var r=n.before,i=void 0===r?"":r,s=n.after,a=void 0===s?"":s,u=n.pageSize,d=void 0===u?60:u,c=n.extended,h=void 0!==c&&c,_=n.deleted,g=void 0!==_&&_,p=n.unread,m=void 0!==p&&p,l=n.since,E=void 0===l?0:l;return e.doFetch(""+e.getUserThreadsRoute(t,o)+f({before:i,after:a,pageSize:d,extended:h,deleted:g,unread:m,since:E}),{method:"get"})},this.getUserThread=function(t,o,n,r){void 0===r&&(r=!1);var i=""+e.getUserThreadRoute(t,o,n);return e.doFetch(""+i+f({extended:r}),{method:"get"})},this.getThreadMentionCountsByChannel=function(t,o){var n=e.getUserThreadsRoute(t,o)+"/mention_counts";return e.doFetch(n,{method:"get"})},this.updateThreadsReadForUser=function(t,o){var n=e.getUserThreadsRoute(t,o)+"/read";return e.doFetch(n,{method:"put"})},this.updateThreadReadForUser=function(t,o,n,r){var i=e.getUserThreadRoute(t,o,n)+"/read/"+r;return e.doFetch(i,{method:"put"})},this.updateThreadFollowForUser=function(t,o,n,r){var i=e.getUserThreadRoute(t,o,n)+"/following";return e.doFetch(i,{method:r?"put":"delete"})},this.getFileInfosForPost=function(t){return e.doFetch(e.getPostRoute(t)+"/files/info",{method:"get"})},this.getFlaggedPosts=function(t,o,n,r,i){return void 0===o&&(o=""),void 0===n&&(n=""),void 0===r&&(r=0),void 0===i&&(i=60),e.trackEvent("api","api_posts_get_flagged",{team_id:n}),e.doFetch(e.getUserRoute(t)+"/posts/flagged"+f({channel_id:o,team_id:n,page:r,per_page:i}),{method:"get"})},this.getPinnedPosts=function(t){return e.trackEvent("api","api_posts_get_pinned",{channel_id:t}),e.doFetch(e.getChannelRoute(t)+"/pinned",{method:"get"})},this.markPostAsUnread=function(t,o){return e.trackEvent("api","api_post_set_unread_post"),e.doFetch(e.getUserRoute(t)+"/posts/"+o+"/set_unread",{method:"post"})},this.pinPost=function(t){return e.trackEvent("api","api_posts_pin"),e.doFetch(e.getPostRoute(t)+"/pin",{method:"post"})},this.unpinPost=function(t){return e.trackEvent("api","api_posts_unpin"),e.doFetch(e.getPostRoute(t)+"/unpin",{method:"post"})},this.addReaction=function(t,o,n){return e.trackEvent("api","api_reactions_save",{post_id:o}),e.doFetch(""+e.getReactionsRoute(),{method:"post",body:JSON.stringify({user_id:t,post_id:o,emoji_name:n})})},this.removeReaction=function(t,o,n){return e.trackEvent("api","api_reactions_delete",{post_id:o}),e.doFetch(e.getUserRoute(t)+"/posts/"+o+"/reactions/"+n,{method:"delete"})},this.getReactionsForPost=function(t){return e.doFetch(e.getPostRoute(t)+"/reactions",{method:"get"})},this.searchPostsWithParams=function(t,o){return e.trackEvent("api","api_posts_search",{team_id:t}),e.doFetch(e.getTeamRoute(t)+"/posts/search",{method:"post",body:JSON.stringify(o)})},this.searchPosts=function(t,o,n){return e.searchPostsWithParams(t,{terms:o,is_or_search:n})},this.getOpenGraphMetadata=function(t){return e.doFetch(e.getBaseRoute()+"/opengraph",{method:"post",body:JSON.stringify({url:t})})},this.doPostAction=function(t,o,n){return void 0===n&&(n=""),e.doPostActionWithCookie(t,o,"",n)},this.doPostActionWithCookie=function(t,o,n,r){void 0===r&&(r=""),r?e.trackEvent("api","api_interactive_messages_menu_selected"):e.trackEvent("api","api_interactive_messages_button_clicked");var i={selected_option:r};return""!==n&&(i.cookie=n),e.doFetch(e.getPostRoute(t)+"/actions/"+encodeURIComponent(o),{method:"post",body:JSON.stringify(i)})},this.uploadFile=function(t,o){e.trackEvent("api","api_files_upload");var n={method:"post",body:t};return o&&(n.headers={"Content-Type":"multipart/form-data; boundary="+o}),e.doFetch(""+e.getFilesRoute(),n)},this.getFilePublicLink=function(t){return e.doFetch(e.getFileRoute(t)+"/link",{method:"get"})},this.savePreferences=function(t,o){return e.doFetch(""+e.getPreferencesRoute(t),{method:"put",body:JSON.stringify(o)})},this.getMyPreferences=function(){return e.doFetch(""+e.getPreferencesRoute("me"),{method:"get"})},this.deletePreferences=function(t,o){return e.doFetch(e.getPreferencesRoute(t)+"/delete",{method:"post",body:JSON.stringify(o)})},this.ping=function(){return e.doFetch(e.getBaseRoute()+"/system/ping?time="+Date.now(),{method:"get"})},this.upgradeToEnterprise=function(){return o(e,void 0,void 0,(function(){return n(this,(function(e){return[2,this.doFetch(this.getBaseRoute()+"/upgrade_to_enterprise",{method:"post"})]}))}))},this.upgradeToEnterpriseStatus=function(){return o(e,void 0,void 0,(function(){return n(this,(function(e){return[2,this.doFetch(this.getBaseRoute()+"/upgrade_to_enterprise/status",{method:"get"})]}))}))},this.restartServer=function(){return o(e,void 0,void 0,(function(){return n(this,(function(e){return[2,this.doFetch(this.getBaseRoute()+"/restart",{method:"post"})]}))}))},this.logClientError=function(t,o){void 0===o&&(o="ERROR");var n=e.getBaseRoute()+"/logs";if(!e.enableLogging)throw new N(e.getUrl(),{message:"Logging disabled.",url:n});return e.doFetch(n,{method:"post",body:JSON.stringify({message:t,level:o})})},this.getClientConfigOld=function(){return e.doFetch(e.getBaseRoute()+"/config/client?format=old",{method:"get"})},this.getClientLicenseOld=function(){return e.doFetch(e.getBaseRoute()+"/license/client?format=old",{method:"get"})},this.getWarnMetricsStatus=function(){return o(e,void 0,void 0,(function(){return n(this,(function(e){return[2,this.doFetch(this.getBaseRoute()+"/warn_metrics/status",{method:"get"})]}))}))},this.sendWarnMetricAck=function(t,r){return o(e,void 0,void 0,(function(){return n(this,(function(e){return[2,this.doFetch(this.getBaseRoute()+"/warn_metrics/ack/"+encodeURI(t),{method:"post",body:JSON.stringify({forceAck:r})})]}))}))},this.getTranslations=function(t){return e.doFet