comprodls-sdk 2.67.1 → 2.68.0-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.ComproDLS=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b,c){return new e(a,b,c)}function e(a,b,c){c=c||{},a=a||"production",b=b||"global",this.token=null,this.orgId=null,this.traceid=c.traceid;try{if(t.DEFAULT_HOSTS=t.REALM_HOSTS[b.toUpperCase()][a.toUpperCase()],!t.DEFAULT_HOSTS)throw"Invalid Environment"}catch(d){var e,f=t.REALM_HOSTS[b.toUpperCase()];throw f?f[a.toUpperCase()]||(e=new Error("Invalid Environment: "+a)):e=new Error("Invalid Realm: "+b),e}if(this.config=t,this.environment=a,c.orgid&&c.token){var e=z.authWithToken(c.orgid,c.token,{});if(e)throw e;this.token=c.token,this.orgId=c.orgid}else c.orgid&&(this.orgId=c.orgid)}var f=a("./token"),g=a("./helpers"),h=a("./services/auth"),i=a("./services/authextn"),j=a("./services/activity"),k=a("./services/analytics"),l=a("./services/collab"),m=a("./services/product"),n=a("./services/xapi"),o=a("./services/attempts"),p=a("./services/pushX"),q=a("./services/pub"),r=a("./services/spaces"),s=a("./services/spacesextn"),t=a("./config"),u=a("./open_access"),v=a("./services/superuser"),w=a("./services/invitations"),x=a("./services/workflows"),y=a("./services/integrations"),z=a("./token/validations"),A=a("./services/drive"),B=a("./services/taxonomy"),C=a("./services/rules"),D=a("./services/datasyncmanager");c.init=d,e.prototype.authWithCredentials=f.authWithCredentials,e.prototype.authWithToken=f.authWithToken,e.prototype.authWithExtUser=f.authWithExtUser,e.prototype.getClassEnrolmentsStat=u.getClassEnrolmentsStat,e.prototype.getSingleInvitation=u.getSingleInvitation,e.prototype.request=g.api.genericAPICaller,e.prototype.Auth=h,e.prototype.AuthExtn=i,e.prototype.Activity=j,e.prototype.Analytics=k,e.prototype.Collab=l,e.prototype.Product=m,e.prototype.Xapi=n,e.prototype.Attempts=o,e.prototype.Pub=q,e.prototype.PushX=p,e.prototype.Spaces=r,e.prototype.SpacesExtn=s,e.prototype.Superuser=v,e.prototype.Invitations=w,e.prototype.Workflows=x,e.prototype.Integrations=y,e.prototype.Drive=A,e.prototype.Taxonomy=B,e.prototype.Rules=C,e.prototype.Datasyncmanager=D},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/authextn":17,"./services/collab":18,"./services/datasyncmanager":19,"./services/drive":20,"./services/integrations":21,"./services/invitations":22,"./services/product":23,"./services/pub":24,"./services/pushX":25,"./services/rules":27,"./services/spaces":28,"./services/spacesextn":29,"./services/superuser":30,"./services/taxonomy":31,"./services/workflows":32,"./services/xapi":33,"./token":34,"./token/validations":35}],2:[function(a,b,c){c.REALM_HOSTS={GLOBAL:{PROD1:{PUB:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-drive"}},ASGARD:{THOR:{PUB:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-drive"}},CUP:{ALPHA:{PUB:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-drive"},PROD1:{PUB:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-drive"},QA:{PUB:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-drive"},HFX:{PUB:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-drive"},REL:{PUB:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-drive"}}},c.AUTH_API_URLS={getSettings:"/org/{orgId}/settings",getTokenAPI:"/auth/{orgId}/token",getExtUserTokenAPI:"/auth/{orgId}/ext-users/token",userInfoAPI:"/org/{orgId}/users/{userId}",pisImportAPI:"/org/{orgId}/pis_imports",getAllUsersAPI:"/org/{orgId}/users/all",updateUserRoleAPI:"/org/{orgId}/users/{userId}/update-role",getSettingsField:"/org/{orgId}/settings/{field}",getClassUsersAPI:"/org/{orgId}/class/{classId}/users",getUserClassesAPI:"/org/{orgId}/users/{userId}/classes",getUserClassesV2API:"/org/{orgid}/users/{userid}/class-enrollments",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",updateUserSpace:"/accounts/{accountid}/ext-users/{extuserid}/spaces/{spacekey}",getInvitationsByEmail:"/accounts/{accountid}/invitations-by-email",generateSpaceCode:"/accounts/{accountid}/space-code/generate",changeSpaceCode:"/accounts/{accountid}/space-code/{spacecode}/change",updateInstituteTitle:"/accounts/{accountId}/institute-spaces/{instituteSpaceCode}",getAllInstitutions:"/su/accounts/{accountid}/spaces",getInstitution:"/su/accounts/{accountid}/spaces/{spacecode}",provisionSpacesToSuperAdmin:"/su/accounts/{accountid}/superadmin/provision-spaces",sendInvitations:"/org/{orgId}/invitations",getMultiInvitations:"/org/{orgId}/invitations",getSingleInvitation:"/org/{orgId}/invitations/{invitationId}",revokeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/revoke",completeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/complete",resendSingleInvitation:"/org/{orgId}/invitations/{invitationid}/resend",createAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths",deleteAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths/{assignedPathId}",workflows:"/accounts/{accountid}/workflows",getAllWorkflowOfAUser:"/accounts/{accountid}/workflows/workflows-by-user",getAWorkflow:"/accounts/{accountid}/workflows/{workflowid}",acceptAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/accept",processAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/process",revokeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/revoke",completeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/complete",allGroups:"/org/{orgId}/groups",aParticularGroup:"/org/{orgId}/groups/{groupId}",getAllMembersOfAGroup:"/org/{orgId}/groups/{groupId}/memberships",getAllGroupMembersByPath:"/org/{orgId}/groups/memberships",userGroupMembership:"/org/{orgId}/groups/{groupId}/enroll-user/multi",getMyAllMemberships:"/org/{orgId}/users/{userId}/groups",archiveAParticularGroup:"/org/{orgId}/groups/{groupId}/archive",unarchiveAParticularGroup:"/org/{orgId}/groups/{groupId}/unarchive",showcaseItems:"/org/{orgId}/classes/{classId}/showcase/item",createDataSyncManager:"/accounts/{accountid}/data-sync-managers",dataSyncManager:"/accounts/{accountid}/data-sync-managers/{dsmid}",getAllDataSyncManagersOfAGroup:"/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers",createOrGetGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks",updateOrDeleteGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}",gradebookColumns:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns",getAllClassesOfAComponent:"/org/{orgId}/components/{component_code}/classes",removeAllGradebookColumnsOfCustomComponent:"/org/{orgId}/gradebook/columns/custom-components/{component_code}",customComponents:"/org/{orgid}/custom-components",particularCustomComponent:"/org/{orgid}/custom-components/{custom_component_code}"},c.AUTHEXTN_API_URLS={gradeFormat:"/org/{orgid}/gradeformats",particularGradeFormat:"/org/{orgid}/gradeformats/{gradeformat_id}",classGradeformatAssociation:"/org/{orgid}/classes/{classid}/associate-gradeformats/{gradeformat_id}",classGradeformats:"/org/{orgid}/classes/{classid}/gradeformats",gradeformatClasses:"/org/{orgid}/gradeformats/{gradeformat_id}/classes",entitleBulkUsersToProducts:"/accounts/{accountid}/entitle-users/bulk",userAssignedPaths:"/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi",particularClass:"/org/{orgId}/classes/{classId}",orgProductEntitlement:"/org/{orgid}/org-entitlements",setupUser:"/accounts/{accountId}/user/setup"},c.ACTIVITY_API_URLS={newAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/start",activityDetailsAPI:"/{orgId}/products/{productId}/activities/{activityId}",existingAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}",userResponseAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/response",submitAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/submit"},c.ANALYTICS_API_URLS={archiveUserAnalytics:"/{orgId}/archive/user/product",getOrgAnalyticsStat:"/{orgId}/organization/{type}/stat",getAnalyticProductItems:"/{orgId}/user/product/progress/items",getAnalyticProductSummary:"/{orgId}/user/product/progress/summary",getExternalDataForUserAnalyticItem:"/{orgId}/user/product/progress/items/external-data",searchUserProductAnalytics:"/{orgId}/user/product/progress/search",getAnalyticProductById:"/{orgId}/user/product/userprogress/{userProgressId}",getArchivedUserAnalytics:"/{orgId}/archive",getClassAnalytics:"/{orgId}/class/{analyticsDataType}/{type}",getClassEnrolmentsStat:"/{orgId}/class/enrolments/stat",getClassRecord:"/{orgId}/class/product/class-record",getClassRecordItemAggregations:"/{orgId}/class/product/item-aggregations",getClassProductRecentPendingSubmissions:"/{orgId}/class/product/recent-pending-submissions",getStudentsWithEvaluatedOnce:"/{orgId}/class/product/students-with-evaluations",getShowcaseRecordOfAClass:"/{orgId}/class/showcase",getGroupRecord:"/{orgId}/class/group/product/group-record",getClassGroupsRecentPendingSubmissions:"/{orgId}/class/group/product/recent-pending-submissions",getGroupsWithEvaluatedOnce:"/{orgId}/class/group/product/groups-with-evaluations",getClassRecordUserAggregations:"/{orgId}/class/product/user-aggregations",getUserClassRecentSubmissions:"/{orgId}/user/product/class/recent-submissions",appState:"/{orgId}/user/product/progress/state",getUserProductAllState:"/{orgId}/user/product/progress/state/all",updateUserProductMultiState:"/{orgId}/user/product/progress/state/multi",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",timeseriesAnalytics:"/progress/timeseries",getClassCustomComponentRecord:"/{orgId}/class/custom-component/class-record",getClassCustomComponentUserSubmission:"/{orgId}/class/custom-component/class-record/evaluations",getCrossProductAggregation:"/{orgId}/class/cross-product-aggregation"},c.COLLAB_API_URLS={postsInClassAPI:"/{orgId}/post/classes/{classId}",postsInProductAPI:"/{orgId}/post/products/{productId}",getMyFollowers:"/{orgId}/connections/me/followers",getUsersFollowedByMe:"/{orgId}/connections/me/following",connectionURL:"/{orgId}/connections/me/follow/{userId}"},c.PRODUCT_API_URLS={getProductAPI:"/accounts/{accountId}/products/{productCode}",getEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements",getMicroEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements/micro",getAllBundles:"/accounts/{accountId}/bundles",getSingleBundle:"/accounts/{accountId}/bundles/{bundleCode}",getAllProductFamilies:"/accounts/{accountId}/families",getSingleProductFamily:"/accounts/{accountId}/families/{familyCode}"},c.XAPI_API_URLS={postMultiStatements:"/{orgId}/statements/multi",postExternalMultiStatements:"/{orgId}/external/statements/multi",resetUserProductProgress:"/accounts/{accountId}/progress/user/product/reset"},c.ATTEMPTS_API_URLS={userAttempts:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts",getUserAttemptStatsForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/stats",getUserAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/{attemptId}",getUserFirstAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/first",getUserLastAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last",getUserActivityMeta:"/org/{orgId}/user/{userId}/activities/{activityId}/meta"},c.PUB_API_URLS={promoteAPI:"/{orgId}/products/{productcode}/promote",registerProductAPI:"/{orgId}/products/register",ingestByCodeAPI:"/{orgId}/products/{productcode}/ingest",createBundle:"/{orgid}/stage/{stage}/bundles",updateBundle:"/{orgid}/stage/{stage}/bundles/{bundleCode}",getAllBundles:"/{orgid}/bundles",getSingleBundle:"/{orgid}/bundles/{bundleCode}",createProductFamily:"/{orgid}/stage/{stage}/families",updateProductFamily:"/{orgid}/stage/{stage}/families/{familyCode}",getSingleProductFamily:"/{orgid}/families/{familyCode}",getAllProductFamilies:"/{orgid}/families"},c.PUSHX_API_URLS={grantByUserOrgId:"/orgs/{orgId}/grants",grantByAccountId:"/accounts/{accountId}/grants"},c.INTEGRATIONS_API_URLS={getGetStreamCredentials:"/accounts/{accountId}/getstream/credentials",queryDataFromSearch:"/search/indices/{index}",auditTrail:"/accounts/{accountId}/audit-trail",customEvents:"/accounts/{accountId}/custom-events",schedules:"/accounts/{accountId}/context/{context}/schedule",particularSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},c.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents",documents:"/accounts/{accountid}/users/{userid}/documents/multi"},c.TAXONOMY_API_URLS={associateTagsWithEntity:"/org/{orgId}/taxonomy/associate-tags-with-entity",tags:"/org/{orgId}/context/{context}/taxonomy/{taxonomyId}/tags"},c.RULES_API_URLS={rules:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules",particularRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}",updateRuleDisplay:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}/update-rule-display",getUserRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/users/{userId}/rules"}},{}],3:[function(a,b,c){c.api=a("./lib/api"),c.errors=a("./lib/errors"),c.utils=a("./lib/utils"),c.validations=a("./lib/validator")},{"./lib/api":5,"./lib/errors":7,"./lib/utils":8,"./lib/validator":9}],4:[function(a,b,c){function d(a){var b=a.data,c=b.roles;if(Array.isArray(c)){var d={};for(var e in c)d[c[e]]=[];b.roles=d}return b}function e(a){var b=a.data;if(b.hasOwnProperty("pk")===!1)return b;var c={uuid:b.classid,type:"group"};Object.assign(c,b);var d=b["class"].instructor.first_name,e=b["class"].instructor.last_name;return c["class"].instructor.uuid=b["class"].instructor.dls_user_id,(d||e)&&(c["class"].instructor.name=d?d:"",e&&(c["class"].instructor.name+=d?" "+e:e)),c}function f(a){var b=a.data;for(var c in b){var d=b[c],e=d.first_name,f=d.last_name;(e||f)&&(d.name=e?e:"",f&&(d.name+=e?" "+f:f)),d.uuid=d.dls_user_id,d.username&&(d.ext_username=d.username),d.username=d.userid+"--ACCOUNT"}return b}function g(a){var b=a.err,c=a.type,d=new i(c,b);return b.response&&b.response.body&&b.response.body.meta&&b.response.body.meta.body&&(d.message="Elasticsearch Error. Please refer data field for more information",d.data=b.response.body.meta.body),d}var h=a("../errors"),i=h.DLSError;b.exports={convertUserResponse:d,convertClassResponse:e,convertEnrollmetsResponse:f,convertElasticsearchErrResponse:g}},{"../errors":7}],5:[function(a,b,c){function d(a,b,c,d){var e=this,f=i.defer(),j=o.genericAPICaller(a,b,c,d)||l.validations.isAuthenticated(e.orgId,e.token);if(j)f.reject(j);else{var c=k.DEFAULT_HOSTS[a.toUpperCase()]+c;"DELETE"===b&&(b="DEL");var p=h(b,c);p=g(p,e.token),Object.keys(d).length&&(p="GET"===b||"HEAD"===b?p.query(d):p.send(d)),p.end(function(a,b){a?(a=new n(m.ERROR_TYPES.API_ERROR,a),f.reject(a)):f.resolve(b.body)})}return f.promise}function e(a,b){return j(a,b)}function f(a,b){var c="";return"undefined"!=typeof b&&null!==b&&(c="?classId="+b),a+c}function g(a,b){return a.set("Authorization",b.access_token)}var h=a("superagent"),i=a("q"),j=a("string-template"),k=a("../../../config"),l=a("../../../helpers"),m=a("../errors"),n=m.DLSError,o=a("./validations");c.genericAPICaller=d,c.constructAPIUrl=e,c.setupAPIToken=g,c.addClassIdQueryParam=f},{"../../../config":2,"../../../helpers":3,"../errors":7,"./validations":6,q:46,"string-template":48,superagent:49}],6:[function(a,b,c){function d(a,b,c,d){var f={apiName:a,method:b,url:c,params:d},g={apiName:{isString:!0,presence:!0,inclusion:{within:["AUTH","PRODUCT","COLLAB","ANALYTICS","ACTIVITY","XAPI"],message:"^Enter a valid API Name"}},method:{isString:!0,presence:!0,inclusion:{within:["GET","POST","PUT","DELETE"],message:"^Enter a valid HTTP method"}},url:{isString:!0,presence:!0,format:{pattern:"^/.*$",message:"^Url should start with a /"}},params:{isObject:!0}};return e(f,g)}var e=a("../validator").validate;c.genericAPICaller=d},{"../validator":9}],7:[function(a,b,c){function d(a,b){if(this.type=a,a===f.API_ERROR){var c,d;if(void 0!=b.response){if(c=b.response.body.message||b.response.body.dbErrorBody||b.response.body.code,d=b.response.body.dbErrorDescription,b.response.body.results&&b.response.body.results.errors){c="";for(var e in b.response.body.results.errors)c+=b.response.body.results.errors[e].message+" "}b.response.body.server&&(this.server=b.response.body.server)}else c=b.message?b.message:"",d=b.description?b.description:"";this.message=c,this.description=d}else a===f.PUSHX_ERROR?(this.message=b.message,this.data=b):(this.message=b.message?b.message:"",this.description=b.description?b.description:"",delete b.message,delete b.description,this.data=b);a!==f.API_ERROR&&a!==f.PUSHX_ERROR||(this.httpcode=b.status)}function e(a,b){a===g.PUSHX?(this.category=g.PUSHX,this.type=f.CHANNEL_SUBSCRIPTION,this.status=h.ERROR,this.message=b.message,this.data=b,this.httpcode=b.errorDetails&&b.errorDetails.statusCode?b.errorDetails.statusCode:500):this.message="PUSHXError called for incorrect category."}var f={API_ERROR:"API_ERROR",SDK_ERROR:"SDK_ERROR",CHANNEL_SUBSCRIPTION:"CHANNEL_SUBSCRIPTION"},g={PUSHX:"PUSHX"},h={ERROR:"ERROR"};c.DLSError=d,c.PUSHXError=e,c.ERROR_TYPES=f,c.ERROR_CATEGORY=g},{}],8:[function(a,b,c){c.isBrowser="undefined"!=typeof window},{}],9:[function(a,b,c){function d(a,b){var c={},d=f(a,b);if(d)for(var e in d)return c.message=c.description=d[e][0],c=new h(g.ERROR_TYPES.SDK_ERROR,c)}function e(a,b){var c={organization:a,token:b},e={organization:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}},token:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}}};return d(c,e)}var f=a("validate.js"),g=a("./errors"),h=g.DLSError;c.validate=d,c.isAuthenticated=e,f.validators.isString=function(a,b){if(!f.isString(a))return b.message||"is not a valid string"},f.validators.isObject=function(a,b){if(!f.isObject(a))return b.message||"is not a valid object"},f.validators.contains=function(a,b){if(f.isArray(b)){for(var c in b)if(!a||!a.hasOwnProperty(b[c]))return b.message||"does not contain "+b[c]}else if(f.isString(b)&&(!a||!a.hasOwnProperty(b)))return b.message||"does not contain "+b}},{"./errors":7,"validate.js":53}],10:[function(a,b,c){function d(a,b){var c=this,d=f.defer(),e={};if(a&&b&&b.classid){var j=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.getClassEnrolmentsStat;j=h.api.constructAPIUrl(j,{orgId:a});var k=g.get(j).query(b);c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){a?(a=new i(h.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else e.message=e.description="Mandatory params not found in request body : [orgid, classid]",e=new i(h.errors.ERROR_TYPES.SDK_ERROR,e),d.reject(e);return d.promise}function e(a,b){var c=this,d={},e=f.defer();if(a&&b&&b.context_id&&b.context&&b.invitationid){var j=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.getSingleInvitation;j=h.api.constructAPIUrl(j,{orgId:a,invitationId:b.invitationid});var k={context:b.context,context_id:b.context_id},l=g.get(j).query(k);c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){a?(d=new i(h.errors.ERROR_TYPES.API_ERROR,a),e.reject(d)):e.resolve(b.body)})}else d.message=d.description="organizationId or context_id or context or invitationid not found in request options.",d=new i(h.errors.ERROR_TYPES.SDK_ERROR,d),e.reject(d);return e.promise}var f=a("q"),g=a("superagent"),h=a("../helpers"),i=h.errors.DLSError;c.getClassEnrolmentsStat=d,c.getSingleInvitation=e},{"../helpers":3,q:46,superagent:49}],11:[function(a,b,c){function d(a,b,c){if(!(this instanceof d)){var e=new d(a,b,c);return e.token=this.token,e.orgId=this.orgId,e.config=this.config,e}this.productId=a,this.activityId=b,this.classId=c}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError;a("extend");b.exports=d;var i=a("./attempt");d.prototype.getDetails=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.ACTIVITY+a.config.ACTIVITY_API_URLS.activityDetailsAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.activity=d,b.resolve(e)}})}return b.promise},d.prototype.loadAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.getAttemptInfo()},d.prototype.getAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b},d.prototype.newAttempt=function(a){var b=new i(this.productId,this.activityId,null,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.start(a)},d.prototype.getAllQuestions=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.questions=d.items,b.resolve(e)}})}return b.promise},d.prototype.getQuestionsCount=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d={count:c.body.items.length},e=new Object;e.count=d,b.resolve(e)}})}return b.promise}},{"../../helpers":3,"./attempt":12,extend:42,q:46,superagent:49}],12:[function(a,b,c){function d(a,b,c,e,f,g){function h(){return this.authCredentials}function i(a){this.authCredentials=a}this.productId=a,this.activityId=b,this.attemptId=c,this.classId=f,this.config=g;d.prototype.getAuthCredentials=function(){return h()},d.prototype.setAuthCredentials=function(a,b){var c=new Object;c.orgId=a,c.token=b,i(c)}}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError,i=a("extend");b.exports=d,d.prototype.start=function(a){var b=this,c=this.getAuthCredentials().orgId,d=this.getAuthCredentials().token,j=f.defer(),k=g.validations.isAuthenticated(c,d);if(k)j.reject(k);else{var l=b.config.DEFAULT_HOSTS.ACTIVITY+b.config.ACTIVITY_API_URLS.newAttemptAPI;l=g.api.constructAPIUrl(l,{orgId:c,productId:b.productId,activityId:b.activityId}),l=g.api.addClassIdQueryParam(l,b.classId),void 0!=a&&null!=a||(a={});var m=e.post(l).send(a);m=g.api.setupAPIToken(m,d),b.traceid&&m.set("X-Amzn-Trace-Id",b.traceid),m.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),j.reject(a);else{var d=c.body;b.attemptId=d.uuid,i(!0,b,d);var e=new Object;e.attempt=b,j.resolve(e)}})}return j.promise},d.prototype.getAttemptInfo=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),j=g.validations.isAuthenticated(a,b);
1
+ !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.ComproDLS=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b,c){return new e(a,b,c)}function e(a,b,c){c=c||{},a=a||"production",b=b||"global",this.token=null,this.orgId=null,this.traceid=c.traceid;try{if(t.DEFAULT_HOSTS=t.REALM_HOSTS[b.toUpperCase()][a.toUpperCase()],!t.DEFAULT_HOSTS)throw"Invalid Environment"}catch(d){var e,f=t.REALM_HOSTS[b.toUpperCase()];throw f?f[a.toUpperCase()]||(e=new Error("Invalid Environment: "+a)):e=new Error("Invalid Realm: "+b),e}if(this.config=t,this.environment=a,c.orgid&&c.token){var e=z.authWithToken(c.orgid,c.token,{});if(e)throw e;this.token=c.token,this.orgId=c.orgid}else c.orgid&&(this.orgId=c.orgid)}var f=a("./token"),g=a("./helpers"),h=a("./services/auth"),i=a("./services/authextn"),j=a("./services/activity"),k=a("./services/analytics"),l=a("./services/collab"),m=a("./services/product"),n=a("./services/xapi"),o=a("./services/attempts"),p=a("./services/pushX"),q=a("./services/pub"),r=a("./services/spaces"),s=a("./services/spacesextn"),t=a("./config"),u=a("./open_access"),v=a("./services/superuser"),w=a("./services/invitations"),x=a("./services/workflows"),y=a("./services/integrations"),z=a("./token/validations"),A=a("./services/drive"),B=a("./services/taxonomy"),C=a("./services/rules"),D=a("./services/datasyncmanager");c.init=d,e.prototype.authWithCredentials=f.authWithCredentials,e.prototype.authWithToken=f.authWithToken,e.prototype.authWithExtUser=f.authWithExtUser,e.prototype.getClassEnrolmentsStat=u.getClassEnrolmentsStat,e.prototype.getSingleInvitation=u.getSingleInvitation,e.prototype.request=g.api.genericAPICaller,e.prototype.Auth=h,e.prototype.AuthExtn=i,e.prototype.Activity=j,e.prototype.Analytics=k,e.prototype.Collab=l,e.prototype.Product=m,e.prototype.Xapi=n,e.prototype.Attempts=o,e.prototype.Pub=q,e.prototype.PushX=p,e.prototype.Spaces=r,e.prototype.SpacesExtn=s,e.prototype.Superuser=v,e.prototype.Invitations=w,e.prototype.Workflows=x,e.prototype.Integrations=y,e.prototype.Drive=A,e.prototype.Taxonomy=B,e.prototype.Rules=C,e.prototype.Datasyncmanager=D},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/authextn":17,"./services/collab":18,"./services/datasyncmanager":19,"./services/drive":20,"./services/integrations":21,"./services/invitations":22,"./services/product":23,"./services/pub":24,"./services/pushX":25,"./services/rules":27,"./services/spaces":28,"./services/spacesextn":29,"./services/superuser":30,"./services/taxonomy":31,"./services/workflows":32,"./services/xapi":33,"./token":34,"./token/validations":35}],2:[function(a,b,c){c.REALM_HOSTS={GLOBAL:{PROD1:{PUB:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-drive"}},ASGARD:{THOR:{PUB:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-drive"}},CUP:{ALPHA:{PUB:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-drive"},PROD1:{PUB:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-drive"},QA:{PUB:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-drive"},HFX:{PUB:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-drive"},REL:{PUB:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-drive"}}},c.AUTH_API_URLS={getSettings:"/org/{orgId}/settings",getTokenAPI:"/auth/{orgId}/token",getExtUserTokenAPI:"/auth/{orgId}/ext-users/token",userInfoAPI:"/org/{orgId}/users/{userId}",pisImportAPI:"/org/{orgId}/pis_imports",getAllUsersAPI:"/org/{orgId}/users/all",updateUserRoleAPI:"/org/{orgId}/users/{userId}/update-role",getSettingsField:"/org/{orgId}/settings/{field}",getClassUsersAPI:"/org/{orgId}/class/{classId}/users",getUserClassesAPI:"/org/{orgId}/users/{userId}/classes",getUserClassesV2API:"/org/{orgid}/users/{userid}/class-enrollments",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",updateUserSpace:"/accounts/{accountid}/ext-users/{extuserid}/spaces/{spacekey}",getInvitationsByEmail:"/accounts/{accountid}/invitations-by-email",generateSpaceCode:"/accounts/{accountid}/space-code/generate",changeSpaceCode:"/accounts/{accountid}/space-code/{spacecode}/change",updateInstituteTitle:"/accounts/{accountId}/institute-spaces/{instituteSpaceCode}",getAllInstitutions:"/su/accounts/{accountid}/spaces",getInstitution:"/su/accounts/{accountid}/spaces/{spacecode}",provisionSpacesToSuperAdmin:"/su/accounts/{accountid}/superadmin/provision-spaces",sendInvitations:"/org/{orgId}/invitations",getMultiInvitations:"/org/{orgId}/invitations",getSingleInvitation:"/org/{orgId}/invitations/{invitationId}",revokeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/revoke",completeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/complete",resendSingleInvitation:"/org/{orgId}/invitations/{invitationid}/resend",createAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths",deleteAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths/{assignedPathId}",workflows:"/accounts/{accountid}/workflows",getAllWorkflowOfAUser:"/accounts/{accountid}/workflows/workflows-by-user",getAWorkflow:"/accounts/{accountid}/workflows/{workflowid}",acceptAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/accept",processAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/process",revokeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/revoke",completeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/complete",allGroups:"/org/{orgId}/groups",aParticularGroup:"/org/{orgId}/groups/{groupId}",getAllMembersOfAGroup:"/org/{orgId}/groups/{groupId}/memberships",getAllGroupMembersByPath:"/org/{orgId}/groups/memberships",userGroupMembership:"/org/{orgId}/groups/{groupId}/enroll-user/multi",getMyAllMemberships:"/org/{orgId}/users/{userId}/groups",archiveAParticularGroup:"/org/{orgId}/groups/{groupId}/archive",unarchiveAParticularGroup:"/org/{orgId}/groups/{groupId}/unarchive",showcaseItems:"/org/{orgId}/classes/{classId}/showcase/item",createDataSyncManager:"/accounts/{accountid}/data-sync-managers",dataSyncManager:"/accounts/{accountid}/data-sync-managers/{dsmid}",getAllDataSyncManagersOfAGroup:"/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers",createOrGetGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks",updateOrDeleteGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}",gradebookColumns:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns",getAllClassesOfAComponent:"/org/{orgId}/components/{component_code}/classes",removeAllGradebookColumnsOfCustomComponent:"/org/{orgId}/gradebook/columns/custom-components/{component_code}",customComponents:"/org/{orgid}/custom-components",particularCustomComponent:"/org/{orgid}/custom-components/{custom_component_code}"},c.AUTHEXTN_API_URLS={gradeFormat:"/org/{orgid}/gradeformats",particularGradeFormat:"/org/{orgid}/gradeformats/{gradeformat_id}",classGradeformatAssociation:"/org/{orgid}/classes/{classid}/associate-gradeformats/{gradeformat_id}",classGradeformats:"/org/{orgid}/classes/{classid}/gradeformats",gradeformatClasses:"/org/{orgid}/gradeformats/{gradeformat_id}/classes",entitleBulkUsersToProducts:"/accounts/{accountid}/entitle-users/bulk",userAssignedPaths:"/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi",particularClass:"/org/{orgId}/classes/{classId}",orgProductEntitlement:"/org/{orgid}/org-entitlements",setupUser:"/accounts/{accountId}/user/setup"},c.ACTIVITY_API_URLS={newAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/start",activityDetailsAPI:"/{orgId}/products/{productId}/activities/{activityId}",existingAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}",userResponseAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/response",submitAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/submit"},c.ANALYTICS_API_URLS={archiveUserAnalytics:"/{orgId}/archive/user/product",getOrgAnalyticsStat:"/{orgId}/organization/{type}/stat",getAnalyticProductItems:"/{orgId}/user/product/progress/items",getAnalyticProductSummary:"/{orgId}/user/product/progress/summary",getExternalDataForUserAnalyticItem:"/{orgId}/user/product/progress/items/external-data",searchUserProductAnalytics:"/{orgId}/user/product/progress/search",getAnalyticProductById:"/{orgId}/user/product/userprogress/{userProgressId}",getArchivedUserAnalytics:"/{orgId}/archive",getClassAnalytics:"/{orgId}/class/{analyticsDataType}/{type}",getClassEnrolmentsStat:"/{orgId}/class/enrolments/stat",getClassRecord:"/{orgId}/class/product/class-record",getClassRecordItemAggregations:"/{orgId}/class/product/item-aggregations",getClassProductRecentPendingSubmissions:"/{orgId}/class/product/recent-pending-submissions",getStudentsWithEvaluatedOnce:"/{orgId}/class/product/students-with-evaluations",getShowcaseRecordOfAClass:"/{orgId}/class/showcase",getGroupRecord:"/{orgId}/class/group/product/group-record",getClassGroupsRecentPendingSubmissions:"/{orgId}/class/group/product/recent-pending-submissions",getGroupsWithEvaluatedOnce:"/{orgId}/class/group/product/groups-with-evaluations",getClassRecordUserAggregations:"/{orgId}/class/product/user-aggregations",getUserClassRecentSubmissions:"/{orgId}/user/product/class/recent-submissions",appState:"/{orgId}/user/product/progress/state",getUserProductAllState:"/{orgId}/user/product/progress/state/all",updateUserProductMultiState:"/{orgId}/user/product/progress/state/multi",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",timeseriesAnalytics:"/progress/timeseries",getClassCustomComponentRecord:"/{orgId}/class/custom-component/class-record",getClassCustomComponentUserSubmission:"/{orgId}/class/custom-component/class-record/evaluations",getCrossProductAggregation:"/{orgId}/class/cross-product-aggregation"},c.COLLAB_API_URLS={postsInClassAPI:"/{orgId}/post/classes/{classId}",postsInProductAPI:"/{orgId}/post/products/{productId}",getMyFollowers:"/{orgId}/connections/me/followers",getUsersFollowedByMe:"/{orgId}/connections/me/following",connectionURL:"/{orgId}/connections/me/follow/{userId}"},c.PRODUCT_API_URLS={getProductAPI:"/accounts/{accountId}/products/{productCode}",getEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements",getMicroEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements/micro",getAllBundles:"/accounts/{accountId}/bundles",getSingleBundle:"/accounts/{accountId}/bundles/{bundleCode}",getAllProductFamilies:"/accounts/{accountId}/families",getSingleProductFamily:"/accounts/{accountId}/families/{familyCode}"},c.XAPI_API_URLS={postMultiStatements:"/{orgId}/statements/multi",postExternalMultiStatements:"/{orgId}/external/statements/multi",resetUserProductProgress:"/accounts/{accountId}/progress/user/product/reset"},c.ATTEMPTS_API_URLS={userAttempts:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts",getUserAttemptStatsForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/stats",getUserAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/{attemptId}",getUserFirstAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/first",getUserLastAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last",getUserActivityMeta:"/org/{orgId}/user/{userId}/activities/{activityId}/meta"},c.PUB_API_URLS={promoteAPI:"/{orgId}/products/{productcode}/promote",registerProductAPI:"/{orgId}/products/register",ingestByCodeAPI:"/{orgId}/products/{productcode}/ingest",createBundle:"/{orgid}/stage/{stage}/bundles",updateBundle:"/{orgid}/stage/{stage}/bundles/{bundleCode}",getAllBundles:"/{orgid}/bundles",getSingleBundle:"/{orgid}/bundles/{bundleCode}",createProductFamily:"/{orgid}/stage/{stage}/families",updateProductFamily:"/{orgid}/stage/{stage}/families/{familyCode}",getSingleProductFamily:"/{orgid}/families/{familyCode}",getAllProductFamilies:"/{orgid}/families"},c.PUSHX_API_URLS={grantByUserOrgId:"/orgs/{orgId}/grants",grantByAccountId:"/accounts/{accountId}/grants"},c.INTEGRATIONS_API_URLS={getGetStreamCredentials:"/accounts/{accountId}/getstream/credentials",queryDataFromSearch:"/search/indices/{index}",auditTrail:"/accounts/{accountId}/audit-trail",customEvents:"/accounts/{accountId}/custom-events",schedules:"/accounts/{accountId}/context/{context}/schedule",particularSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},c.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents",documents:"/accounts/{accountid}/users/{userid}/documents/multi"},c.TAXONOMY_API_URLS={associateTagsWithEntity:"/org/{orgId}/taxonomy/associate-tags-with-entity",tags:"/org/{orgId}/context/{context}/taxonomy/{taxonomyId}/tags"},c.RULES_API_URLS={rules:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules",particularRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}",updateRuleDisplay:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}/update-rule-display",getUserRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/users/{userId}/rules"}},{}],3:[function(a,b,c){c.api=a("./lib/api"),c.errors=a("./lib/errors"),c.utils=a("./lib/utils"),c.validations=a("./lib/validator")},{"./lib/api":5,"./lib/errors":7,"./lib/utils":8,"./lib/validator":9}],4:[function(a,b,c){function d(a){var b=a.data,c=b.roles;if(Array.isArray(c)){var d={};for(var e in c)d[c[e]]=[];b.roles=d}return b}function e(a){var b=a.data;if(b.hasOwnProperty("pk")===!1)return b;var c={uuid:b.classid,type:"group"};Object.assign(c,b);var d=b["class"].instructor.first_name,e=b["class"].instructor.last_name;return c["class"].instructor.uuid=b["class"].instructor.dls_user_id,(d||e)&&(c["class"].instructor.name=d?d:"",e&&(c["class"].instructor.name+=d?" "+e:e)),c}function f(a){var b=a.data;for(var c in b){var d=b[c],e=d.first_name,f=d.last_name;(e||f)&&(d.name=e?e:"",f&&(d.name+=e?" "+f:f)),d.uuid=d.dls_user_id,d.username&&(d.ext_username=d.username),d.username=d.userid+"--ACCOUNT"}return b}function g(a){var b=a.err,c=a.type,d=new i(c,b);return b.response&&b.response.body&&b.response.body.meta&&b.response.body.meta.body&&(d.message="Elasticsearch Error. Please refer data field for more information",d.data=b.response.body.meta.body),d}var h=a("../errors"),i=h.DLSError;b.exports={convertUserResponse:d,convertClassResponse:e,convertEnrollmetsResponse:f,convertElasticsearchErrResponse:g}},{"../errors":7}],5:[function(a,b,c){function d(a,b,c,d){var e=this,f=i.defer(),j=o.genericAPICaller(a,b,c,d)||l.validations.isAuthenticated(e.orgId,e.token);if(j)f.reject(j);else{var c=k.DEFAULT_HOSTS[a.toUpperCase()]+c;"DELETE"===b&&(b="DEL");var p=h(b,c);p=g(p,e.token),Object.keys(d).length&&(p="GET"===b||"HEAD"===b?p.query(d):p.send(d)),p.end(function(a,b){a?(a=new n(m.ERROR_TYPES.API_ERROR,a),f.reject(a)):f.resolve(b.body)})}return f.promise}function e(a,b){return j(a,b)}function f(a,b){var c="";return"undefined"!=typeof b&&null!==b&&(c="?classId="+b),a+c}function g(a,b){return a.set("Authorization",b.access_token)}var h=a("superagent"),i=a("q"),j=a("string-template"),k=a("../../../config"),l=a("../../../helpers"),m=a("../errors"),n=m.DLSError,o=a("./validations");c.genericAPICaller=d,c.constructAPIUrl=e,c.setupAPIToken=g,c.addClassIdQueryParam=f},{"../../../config":2,"../../../helpers":3,"../errors":7,"./validations":6,q:46,"string-template":48,superagent:49}],6:[function(a,b,c){function d(a,b,c,d){var f={apiName:a,method:b,url:c,params:d},g={apiName:{isString:!0,presence:!0,inclusion:{within:["AUTH","PRODUCT","COLLAB","ANALYTICS","ACTIVITY","XAPI"],message:"^Enter a valid API Name"}},method:{isString:!0,presence:!0,inclusion:{within:["GET","POST","PUT","DELETE"],message:"^Enter a valid HTTP method"}},url:{isString:!0,presence:!0,format:{pattern:"^/.*$",message:"^Url should start with a /"}},params:{isObject:!0}};return e(f,g)}var e=a("../validator").validate;c.genericAPICaller=d},{"../validator":9}],7:[function(a,b,c){function d(a,b){if(this.type=a,a===f.API_ERROR){var c,d;if(void 0!=b.response){if(c=b.response.body.message||b.response.body.dbErrorBody||b.response.body.code,d=b.response.body.dbErrorDescription,b.response.body.results&&b.response.body.results.errors){c="";for(var e in b.response.body.results.errors)c+=b.response.body.results.errors[e].message+" "}b.response.body.server&&(this.server=b.response.body.server)}else c=b.message?b.message:"",d=b.description?b.description:"";this.message=c,this.description=d}else a===f.PUSHX_ERROR?(this.message=b.message,this.data=b):(this.message=b.message?b.message:"",this.description=b.description?b.description:"",delete b.message,delete b.description,this.data=b);a!==f.API_ERROR&&a!==f.PUSHX_ERROR||(this.httpcode=b.status)}function e(a,b){a===g.PUSHX?(this.category=g.PUSHX,this.type=f.CHANNEL_SUBSCRIPTION,this.status=h.ERROR,this.message=b.message,this.data=b,this.httpcode=b.errorDetails&&b.errorDetails.statusCode?b.errorDetails.statusCode:500):this.message="PUSHXError called for incorrect category."}var f={API_ERROR:"API_ERROR",SDK_ERROR:"SDK_ERROR",CHANNEL_SUBSCRIPTION:"CHANNEL_SUBSCRIPTION"},g={PUSHX:"PUSHX"},h={ERROR:"ERROR"};c.DLSError=d,c.PUSHXError=e,c.ERROR_TYPES=f,c.ERROR_CATEGORY=g},{}],8:[function(a,b,c){c.isBrowser="undefined"!=typeof window},{}],9:[function(a,b,c){function d(a,b){var c={},d=f(a,b);if(d)for(var e in d)return c.message=c.description=d[e][0],c=new h(g.ERROR_TYPES.SDK_ERROR,c)}function e(a,b){var c={organization:a,token:b},e={organization:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}},token:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}}};return d(c,e)}var f=a("validate.js"),g=a("./errors"),h=g.DLSError;c.validate=d,c.isAuthenticated=e,f.validators.isString=function(a,b){if(!f.isString(a))return b.message||"is not a valid string"},f.validators.isObject=function(a,b){if(!f.isObject(a))return b.message||"is not a valid object"},f.validators.contains=function(a,b){if(f.isArray(b)){for(var c in b)if(!a||!a.hasOwnProperty(b[c]))return b.message||"does not contain "+b[c]}else if(f.isString(b)&&(!a||!a.hasOwnProperty(b)))return b.message||"does not contain "+b}},{"./errors":7,"validate.js":50}],10:[function(a,b,c){function d(a,b){var c=this,d=f.defer(),e={};if(a&&b&&b.classid){var j=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.getClassEnrolmentsStat;j=h.api.constructAPIUrl(j,{orgId:a});var k=g.get(j).query(b);c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){a?(a=new i(h.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else e.message=e.description="Mandatory params not found in request body : [orgid, classid]",e=new i(h.errors.ERROR_TYPES.SDK_ERROR,e),d.reject(e);return d.promise}function e(a,b){var c=this,d={},e=f.defer();if(a&&b&&b.context_id&&b.context&&b.invitationid){var j=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.getSingleInvitation;j=h.api.constructAPIUrl(j,{orgId:a,invitationId:b.invitationid});var k={context:b.context,context_id:b.context_id},l=g.get(j).query(k);c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){a?(d=new i(h.errors.ERROR_TYPES.API_ERROR,a),e.reject(d)):e.resolve(b.body)})}else d.message=d.description="organizationId or context_id or context or invitationid not found in request options.",d=new i(h.errors.ERROR_TYPES.SDK_ERROR,d),e.reject(d);return e.promise}var f=a("q"),g=a("superagent"),h=a("../helpers"),i=h.errors.DLSError;c.getClassEnrolmentsStat=d,c.getSingleInvitation=e},{"../helpers":3,q:46,superagent:49}],11:[function(a,b,c){function d(a,b,c){if(!(this instanceof d)){var e=new d(a,b,c);return e.token=this.token,e.orgId=this.orgId,e.config=this.config,e}this.productId=a,this.activityId=b,this.classId=c}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError;a("extend");b.exports=d;var i=a("./attempt");d.prototype.getDetails=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.ACTIVITY+a.config.ACTIVITY_API_URLS.activityDetailsAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.activity=d,b.resolve(e)}})}return b.promise},d.prototype.loadAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.getAttemptInfo()},d.prototype.getAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b},d.prototype.newAttempt=function(a){var b=new i(this.productId,this.activityId,null,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.start(a)},d.prototype.getAllQuestions=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.questions=d.items,b.resolve(e)}})}return b.promise},d.prototype.getQuestionsCount=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d={count:c.body.items.length},e=new Object;e.count=d,b.resolve(e)}})}return b.promise}},{"../../helpers":3,"./attempt":12,extend:42,q:46,superagent:49}],12:[function(a,b,c){function d(a,b,c,e,f,g){function h(){return this.authCredentials}function i(a){this.authCredentials=a}this.productId=a,this.activityId=b,this.attemptId=c,this.classId=f,this.config=g;d.prototype.getAuthCredentials=function(){return h()},d.prototype.setAuthCredentials=function(a,b){var c=new Object;c.orgId=a,c.token=b,i(c)}}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError,i=a("extend");b.exports=d,d.prototype.start=function(a){var b=this,c=this.getAuthCredentials().orgId,d=this.getAuthCredentials().token,j=f.defer(),k=g.validations.isAuthenticated(c,d);if(k)j.reject(k);else{var l=b.config.DEFAULT_HOSTS.ACTIVITY+b.config.ACTIVITY_API_URLS.newAttemptAPI;l=g.api.constructAPIUrl(l,{orgId:c,productId:b.productId,activityId:b.activityId}),l=g.api.addClassIdQueryParam(l,b.classId),void 0!=a&&null!=a||(a={});var m=e.post(l).send(a);m=g.api.setupAPIToken(m,d),b.traceid&&m.set("X-Amzn-Trace-Id",b.traceid),m.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),j.reject(a);else{var d=c.body;b.attemptId=d.uuid,i(!0,b,d);var e=new Object;e.attempt=b,j.resolve(e)}})}return j.promise},d.prototype.getAttemptInfo=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),j=g.validations.isAuthenticated(a,b);
2
2
  if(j)d.reject(j);else{var k=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.existingAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),k=g.api.addClassIdQueryParam(k,c.classId);var l=e.get(k);l=g.api.setupAPIToken(l,b),c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var e=b.body;c.attemptId=e.uuid,i(!0,c,e);var f=new Object;f.attempt=c,d.resolve(f)}})}return d.promise},d.prototype.getState=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),i=g.validations.isAuthenticated(a,b);if(i)d.reject(i);else{var j=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.existingAttemptAPI;j=g.api.constructAPIUrl(j,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),j=g.api.addClassIdQueryParam(j,c.classId);var k=e.get(j);k=g.api.setupAPIToken(k,b),c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var c=b.body,e=new Object;e.state=c.data.savedstate.state,d.resolve(e)}})}return d.promise},d.prototype.saveState=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.existingAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l=e.put(k).send(a);l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise},d.prototype.getUserResponse=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),i=g.validations.isAuthenticated(a,b);if(i)d.reject(i);else{var j=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.userResponseAPI;j=g.api.constructAPIUrl(j,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),j=g.api.addClassIdQueryParam(j,c.classId);var k=e.get(j);k=g.api.setupAPIToken(k,b),c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var c=b.body,e=new Object;e.userresponse=c,d.resolve(e)}})}return d.promise},d.prototype.saveUserResponse=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.userResponseAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l=e.put(k).send(a);l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise},d.prototype.submit=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.submitAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l;l=void 0==a||null==a?e.post(k).send({}):e.post(k).send(a),l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise}},{"../../helpers":3,extend:42,q:46,superagent:49}],13:[function(a,b,c){b.exports=a("./activity")},{"./activity":11}],14:[function(a,b,c){function d(){return{archiveUserAnalytics:i.bind(this),getArchivedUserAnalytics:A.bind(this),getOrgAnalyticsStat:e.bind(this),getClassAnalytics:z.bind(this),getClassProductRecentPendingSubmissions:r.bind(this),getClassRecordUserAggregations:y.bind(this),getClassRecord:s.bind(this),getClassRecordItemAggregations:t.bind(this),getShowcaseRecordOfAClass:u.bind(this),getGroupRecord:v.bind(this),getClassGroupsRecentPendingSubmissions:w.bind(this),getGroupsWithEvaluatedOnce:x.bind(this),getUserProductAnalytics:f.bind(this),getUserProductAnalyticById:g.bind(this),getExternalDataForUserAnalyticItem:h.bind(this),searchUserProductAnalytics:j.bind(this),getUserClassRecentSubmissions:k.bind(this),getStudentsWithEvaluatedOnce:l.bind(this),getAppState:m.bind(this),updateAppState:n.bind(this),deleteAppState:o.bind(this),getUserProductAllState:p.bind(this),updateUserProductMultiState:q.bind(this),getQuestionProgressByLearningObjective:B.bind(this),getAllAssignedPathsOfClass:C.bind(this),getMyAssignedPathsOfClass:E.bind(this),getUserAssignedPathsOfClass:F.bind(this),getAssignedPathAnalytics:D.bind(this),getMyParticularAssignedPathOfClass:G.bind(this),getParticularAssignedPathOfClass:H.bind(this),getTimeseriesAnalytics:I.bind(this),postProgressTimeseries:J.bind(this),getClassCustomComponentRecord:K.bind(this),getClassCustomComponentUserSubmission:L.bind(this),getCrossProductAggregation:M.bind(this)}}function e(a){var b=this,c=N.defer(),d={};if(a&&a.type)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{d={};var e=["users","classes"];if(e.indexOf(a.type)>-1){var f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getOrgAnalyticsStat;f=Q.api.constructAPIUrl(f,{orgId:b.orgId,type:a.type});var g={};a&&(a.range&&(g.range=a.range),a.start&&(g.start=a.start),a.end&&(g.end=a.end),a.role&&(g.role=a.role),a.shadow&&(g.shadow=a.shadow));var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Type: "+a.type+" is not supported",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="type not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=N.defer(),d={};if(a&&a.type&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=["items","summary"],f=b.config.DEFAULT_HOSTS.ANALYTICS;if(e.indexOf(a.type)>-1){switch(a.type){case"items":f+=b.config.ANALYTICS_API_URLS.getAnalyticProductItems;break;case"summary":f+=b.config.ANALYTICS_API_URLS.getAnalyticProductSummary}f=Q.api.constructAPIUrl(f,{orgId:b.orgId});var g={userid:a.userid,productcode:a.productcode};a.classid&&(g.classid=a.classid),a.itemcode&&(g.itemcode=a.itemcode),a.metrics&&(g.metrics=a.metrics),a.history&&(g.history=a.history),a.group&&(g.group=a.group),a.externalData&&(g.externalData=a.externalData),a.expiredView&&"items"===a.type&&(g.expiredView=a.expiredView);var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description=a.type+" is not a valid value of option 'type'",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="Required parameter 'type' or 'userid' or 'productcode' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=N.defer(),d={};if(a&&a.userprogressid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAnalyticProductById;e=Q.api.constructAPIUrl(e,{orgId:b.orgId,userProgressId:a.userprogressid});var f=O.get(e);f=Q.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameter 'userprogressid' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=N.defer(),d={};if(a&&a.ext_user_id&&a.productcode&&a.itemcode&&(a.submission_order||a.ext_link_id)&&a.part)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={ext_user_id:a.ext_user_id,productcode:a.productcode,itemcode:a.itemcode,part:a.part};a.submission_order&&(f.submission_order=a.submission_order),a.ext_link_id&&(f.ext_link_id=a.ext_link_id),a.classid&&(f.classid=a.classid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'ext_user_id' or 'productcode' or 'itemcode' or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c={},d=N.defer();if(a&&a.userid&&a.productid)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e={},f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.archiveUserAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId}),a.userid&&(e.userid=a.userid),a.productid&&(e.productid=a.productid),a.classid&&(e.classid=a.classid);var g=O.post(f).query(e).set("Content-Type","application/json");g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter [userid, productid] not found in request options",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function j(a){var b=this,c={},d=N.defer();if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e={},f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.searchUserProductAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId}),a.userid&&(e.userid=a.userid),a.productid&&(e.productid=a.productid),a.classid&&(e.classid=a.classid),a.lookup&&(e.lookup=a.lookup),a.cursor&&(e.cursor=a.cursor),a.limit&&(e.limit=a.limit);var g=O.get(f).query(e);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function k(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode&&a.userid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid,productcode:a.productcode};a.gradingStatus&&(f.gradingStatus=a.gradingStatus);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode", "userid"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function m(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.key&&(f.key=a.key);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode&&a.appdata)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode);var g=O.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'appdata' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.key&&(f.key=a.key);var g=O["delete"](e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserProductAllState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.model&&(f.model=a.model),a.key&&(f.key=a.key);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function q(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode&&a.data)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.updateUserProductMultiState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid);var g=O.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.data);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)})}else d.message=d.description="Required parameters 'userid' or 'data' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function r(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode};a.details&&(f.details=a.details),a.limit&&(f.limit=a.limit);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userids:a.userids,includeContext:a.includeContext},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,"item-code":a["item-code"]},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.productcode&&(f.productcode=a.productcode),a.groupid&&(f.groupid=a.groupid),a["item-code"]&&(f["item-code"]=a["item-code"]),a.id&&(f.id=a.id);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode&&a.groupid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,groupid:a.groupid};a.itemcode&&(f.itemcode=a.itemcode),a.history&&(f.history=a.history);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode or groupid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function w(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode};a.details&&(f.details=a.details),a.limit&&(f.limit=a.limit);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function y(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userid:a.userid},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function z(a){var b=this,c=N.defer(),d={};if(a&&a.type&&a.analyticsDataType&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else if(d={},!a.range&&!a.interval||a.range&&"stat"===a.type||a.interval&&"timeseries"===a.type){var e=["enrolments","logins"];if(e.indexOf(a.analyticsDataType)>-1){var f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId,type:a.type,analyticsDataType:a.analyticsDataType});var g={classid:a.classid};a&&(a.range&&(g.range=a.range),a.start&&(g.start=a.start),a.end&&(g.end=a.end),a.interval&&(g.interval=a.interval));var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="analyticsDataType: "+a.analyticsDataType+" is not supported",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description='Range should be defined for type - "stat" and Interval should be defined for type - "timeseries"',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);else d.message=d.description='Required options ["type", "analyticsDataType", "classid"] not found in request options',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function A(a){var b=this,c=N.defer(),d={};if(a&&a.useranalyticid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getArchivedUserAnalytics;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={useranalyticid:a.useranalyticid};a&&(a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit));var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Mandatory field 'useranalyticid' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){for(var b={},c=0;c<a.length;c++)for(var d=a[c]["learning-objectives"],e=0;e<d.length;e++){var f,g,h;if(b[d[e]]){var i=b[d[e]];f=a[c].__analytics,"correct"===f.statusEvaluation&&(g=i.status.correct,i.status.correct=g+1);var j=i.status.total;i.status.total=j+1,h={"question-code":a[c].questionCode,analytics:f},i.questions.push(h),b[d[e]]=i}else{g=0,f=a[c].__analytics,"correct"===f.statusEvaluation&&g++;var k={status:{correct:g,total:1},questions:[]};h={"question-code":a[c].questionCode,analytics:f},k.questions.push(h),b[d[e]]=k}}return b}function C(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,status_not_started:a.status_not_started,status_active:a.status_active,status_expired:a.status_expired,limit:a.limit,cursor:a.cursor},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function D(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.productcode){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,assignedpathid:a.assignedPathId,ext_assignedpathid:a.ext_assignedpathid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function E(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.expiredView&&(f.expiredView=a.expiredView),a.status_not_started&&(f.status_not_started=a.status_not_started),a.status_active&&(f.status_active=a.status_active),a.status_expired&&(f.status_expired=a.status_expired);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function F(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.expiredView&&(f.expiredView=a.expiredView),a.status_not_started&&(f.status_not_started=a.status_not_started),a.status_active&&(f.status_active=a.status_active),a.status_expired&&(f.status_expired=a.status_expired);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function G(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={assignedpathid:a.assignedPathId,classid:a.classid,userid:a.userid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.assignedpathid&&(f.assignedpathid=a.assignedpathid),a.ext_assignedpathid&&(f.ext_assignedpathid=a.ext_assignedpathid),a.expiredView&&(f.expiredView=a.expiredView);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function H(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&(a.assignedpathid||a.ext_assignedpathid)){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.assignedpathid&&(f.assignedpathid=a.assignedpathid),a.ext_assignedpathid&&(f.ext_assignedpathid=a.ext_assignedpathid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body.entities[0])})}else d={},d.message=d.description="Mandatory params - 'classid', 'assignedpathid'/'ext_assignedpathid' not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function I(a){var b,c=this,d=N.defer();if(a&&a.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.timeseriesAnalytics,f={query:a.query};a.cursor&&(f.cursor=a.cursor);var g=O.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(S).end(function(a,c){a?(b=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else b={},b.message=b.description="Mandatory params query not found in request options.",b=new R(Q.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function J(a){var b,c=this,d=N.defer();if(a&&a.body&&a.body.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.timeseriesAnalytics,f=O.post(e).send(a.body);if(a.cursor){var g={cursor:a.cursor};f.query(g)}c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(S).end(function(a,c){a?(b=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else b={},b.message=b.description="Mandatory options.body.query not found in request options.",b=new R(Q.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function K(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassCustomComponentRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.custom_component_code&&(f.custom_component_code=a.custom_component_code);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){
3
3
  a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.message=a.response.res.text,c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.custom_component_code&&a.userid&&a.item_code)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,userid:a.userid,custom_component_code:a.custom_component_code,item_code:a.item_code},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.message=a.response.res.text,c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or custom-component-code or userid or item-code not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getCrossProductAggregation;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.userid&&(f.userid=a.userid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var N=a("q"),O=a("superagent"),P=a("agentkeepalive"),Q=a("../../helpers"),R=Q.errors.DLSError;b.exports=d;var S=new P({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],15:[function(a,b,c){function d(){return{getUserAllAttemptsForActivity:e.bind(this),createUserAttemptForActivity:f.bind(this),getUserAttemptStatsForActivity:g.bind(this),getUserAttemptForActivity:h.bind(this),getUserFirstAttemptForActivity:i.bind(this),getUserLastAttemptForActivity:j.bind(this),updateUserAttemptForActivity:k.bind(this),getUserActivityMeta:l.bind(this)}}function e(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.allorgs&&(f.allorgs=a.allorgs),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid),a.productcode&&(f.productcode=a.productcode),a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function f(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f=n.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or body not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.allorgs&&(f.allorgs=a.allorgs),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.attemptid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid,attemptId:a.attemptid});var f={};a.details&&(f.details=a.details);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or attemptid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.details&&(f.details=a.details),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.details&&(f.details=a.details),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);console.log(e,f,g),c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function k(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.attemptid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid,attemptId:a.attemptid});var f=a.body,g=n.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or attemptid or body not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function l(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserActivityMeta;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var m=a("q"),n=a("superagent"),o=a("../../helpers"),p=o.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],16:[function(a,b,c){function d(){return{pisImport:m.bind(this),getAllUsers:g.bind(this),getAllUsersV2:h.bind(this),getUserProfile:e.bind(this),deleteUserProfile:f.bind(this),updateUserRole:i.bind(this),getUserClasses:j.bind(this),getUserClassesV2:k.bind(this),getClassUsers:l.bind(this),enrollUsertoClass:B.bind(this),enrollSelftoClass:C.bind(this),enrollMultiUserstoClass:D.bind(this),unEnrollMultiUserstoClass:E.bind(this),unEnrollUsertoClass:F.bind(this),getOrgSettings:n.bind(this),updateOrgSettings:o.bind(this),generateClassCode:p.bind(this),getAllJobs:q.bind(this),getJob:r.bind(this),createClass:H.bind(this),updateClass:I.bind(this),createMultipleClasses:J.bind(this),deleteClass:K.bind(this),cloneClass:aa.bind(this),getAllClasses:s.bind(this),getParticularClass:t.bind(this),getParticularShadowClass:u.bind(this),createClassProductAssociation:v.bind(this),removeClassProductAssociation:w.bind(this),createMultiClassProductAssociations:x.bind(this),addItemsToShowcaseOfAClass:$.bind(this),deleteItemsFromShowcaseOfAClass:_.bind(this),getClassAppdata:y.bind(this),putClassAppdata:z.bind(this),deleteClassAppdata:A.bind(this),encodeURLParameter:G.bind(this),createAssignedPath:L.bind(this),deleteAssignedPath:M.bind(this),updateAssignedPath:N.bind(this),createGroup:O.bind(this),getAllGroupsByPath:P.bind(this),getAGroup:Q.bind(this),updateGroup:R.bind(this),deleteGroup:S.bind(this),getAllMembersOfAGroup:T.bind(this),getAllGroupMembersByPath:U.bind(this),createMultiUserGroupMembership:V.bind(this),deleteMultiUserGroupMembership:W.bind(this),getMyAllMemberships:Z.bind(this),archiveGroup:X.bind(this),unarchiveGroup:Y.bind(this),createGradebookMeta:ba.bind(this),updateGradebookMeta:ca.bind(this),deleteGradebookMeta:da.bind(this),getParticularGradebookMetaOfAClass:ea.bind(this),getAllGradebooksMetaOfAClass:fa.bind(this),addGradebookColumns:ga.bind(this),updateMultipleGradebookColumns:ha.bind(this),removeGradebookColumns:ia.bind(this),getParticularColumnOfAGradebook:ja.bind(this),getAllColumnsOfAGradebook:ka.bind(this),getAllClassesOfAComponent:la.bind(this),removeAllGradebookColumnsOfCustomComponent:ma.bind(this),createCustomComponent:na.bind(this),updateCustomComponent:oa.bind(this),deleteCustomComponent:pa.bind(this),getParticularCustomComponent:qa.bind(this),getAllCustomComponents:ra.bind(this)}}function e(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e="me";a&&a.userid&&(e=a.userid);var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userInfoAPI;f=va.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={},h=ta.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=va.api.setupAPIToken(h,b.token),h.end(function(a,b){if(a)a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=wa.convertUserResponse({data:b.body});c.resolve(d)}})}return c.promise}function f(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a.userid){var e=a.userid,f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userInfoAPI;f=va.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g=ta["delete"](f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameter userid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e='orgid:"'+b.orgId+'"';if(a.lookup&&a["lookup-operator"]){var f=a.lookup;f=f.replace(/ext_/gi,"");var g=f.split(",").map(function(a){var b=a.trim(),c=b.split(":");return b="("+b+" OR "+c[0]+".keyword:"+c[1]+")"});e=e+" AND ("+g.join(" "+a["lookup-operator"]+" ")+")"}if(a.role){var h=a.role,i=h.split(",").map(function(a){return a.trim()});for(var j in i)i[j]="roles:"+i[j];e=e+" AND ("+i.join(" OR ")+")"}a.search&&(e=e+' AND (email:"'+a.search+'" OR first_name:"'+a.search+'" OR last_name:"'+a.search+'" OR username:"'+a.search+'" OR userid:"'+a.search+'")');var k=a.sortField||"";k=k.replace(/ext_/gi,"").split(",").shift().trim()||"last_name";var l=a.sortOrder||"asc";"created"!==k&&(k+=".keyword");var m={},n=[];m[k]=l,n.push(m);var o={query:{query_string:{query:e}},sort:n};a.cursor&&(o.search_after=JSON.parse(a.cursor)),a.limit?o.size=a.limit:a.limit=10;var p=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;p=va.api.constructAPIUrl(p,{index:"users"});var q={query:JSON.stringify(o)},r=ta.get(p).query(q);b.traceid&&r.set("X-Amzn-Trace-Id",b.traceid),r=va.api.setupAPIToken(r,b.token),r.end(function(d,e){if(d){var f={type:va.errors.ERROR_TYPES.API_ERROR,err:d},g=wa.convertElasticsearchErrResponse(f);c.reject(g)}else{var h={entities:[]};if(h.count=e.body.hits.hits.length,h.count&&a.limit===h.count){var i=e.body.hits.hits[e.body.hits.hits.length-1].sort;h.cursor=JSON.stringify(i)}for(var j in e.body.hits.hits){var k=e.body.hits.hits[j]._source,l={uuid:k.dls_user_id,name:k.first_name+" "+k.last_name,email:k.email||k.ext_email,username:k.userid+"--ACCOUNT",created:k.created,org:{id:b.orgId}};k.roles&&(l.roles=k.roles),k.provision_method&&(l.provision_method=k.provision_method),k.first_name&&(l.first_name=k.first_name),k.last_name&&(l.last_name=k.last_name),k.ext_parent_id&&(l.ext_parent_id=k.ext_parent_id),k.username&&(l.ext_username=k.username),k.userid&&(l.ext_user_id=k.userid),k.address&&(l.address=k.address),h.entities.push(l)}c.resolve(h)}})}return c.promise}function h(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e={query:{bool:{must:[]}},size:a.limit||10},f='orgid:"'+b.orgId+'"';if(a.role){var g,h;g=a.role,h=g.split(",").map(function(a){return a.trim()});for(var i in h)h[i]="roles:"+h[i];f=f+" AND ("+h.join(" OR ")+")"}if(e.query.bool.must.push({query_string:{query:f}}),a.lookup&&a["lookup-operator"]){var j,k;j=a.lookup.replace(/ext_/gi,""),k=j.split(",");var l={bool:{}};for(var m in k){var n,o,p=k[m].trim(),q=p.split(":"),r={wildcard:{}};if(n=q[0]+".keyword",o=q[1],"email.keyword"===n?r.wildcard[n]={value:o,case_insensitive:!0}:r.wildcard[n]={value:o,case_insensitive:!1},"OR"!==a["lookup-operator"]){var s="The value 'AND' for the field 'lookup-operator' is currently NOT supported";return d={},d.message=d.description=s,d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d),c.promise}l.bool.should||(l.bool.should=[]),l.bool.should.push(r)}e.query.bool.must.push(l)}var t,u,v={},w=[];t=a.sortField||"last_name",u=a.sortOrder||"asc",t=t.replace(/ext_/gi,"").split(",").shift().trim(),"created"!==t&&(t+=".keyword"),v[t]=u,w.push(v),e.sort=w,a.cursor&&(e.search_after=JSON.parse(a.cursor));var x=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;x=va.api.constructAPIUrl(x,{index:"users"});var y={query:JSON.stringify(e)},z=ta.get(x).query(y);b.traceid&&z.set("X-Amzn-Trace-Id",b.traceid),z=va.api.setupAPIToken(z,b.token),z.end(function(d,e){if(d){var f={type:va.errors.ERROR_TYPES.API_ERROR,err:d},g=wa.convertElasticsearchErrResponse(f);c.reject(g)}else{var h={entities:[],count:e.body.hits.hits.length};if(h.count&&a.limit===h.count){var i=e.body.hits.hits[e.body.hits.hits.length-1].sort;h.cursor=JSON.stringify(i)}for(var j in e.body.hits.hits){var k=e.body.hits.hits[j]._source,l={uuid:k.dls_user_id,name:k.first_name+" "+k.last_name,email:k.email||k.ext_email,username:k.userid+"--ACCOUNT",created:k.created,org:{id:b.orgId}};k.roles&&(l.roles=k.roles),k.provision_method&&(l.provision_method=k.provision_method),k.first_name&&(l.first_name=k.first_name),k.last_name&&(l.last_name=k.last_name),k.ext_parent_id&&(l.ext_parent_id=k.ext_parent_id),k.username&&(l.ext_username=k.username),k.userid&&(l.ext_user_id=k.userid),k.address&&(l.address=k.address),h.entities.push(l)}c.resolve(h)}})}return c.promise}function i(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.userid&&a.target_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserRoleAPI;e=va.api.constructAPIUrl(e,{orgId:b.orgId,userId:a.userid});var f={ext_data:a.ext_data,target_role:a.target_role},g=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)})}else{var h={};h.message=h.description="Mandatory parameter options, userid or target_role, not found in request options.",h=new xa(va.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function j(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e="me";a&&a.userid&&(e=a.userid);var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserClassesAPI;f=va.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={};a&&(a.search&&(g.search="title:"+a.search),a.details&&(g.details=a.details),a.enrollmentType&&(g.enrollmentType=a.enrollmentType),a.sortField&&(g.sortField=a.sortField),a.sortOrder&&(g.sortOrder=a.sortOrder),a.cursor&&(g.cursor=a.cursor),a.limit&&(g.limit=a.limit),a.teacherId&&(g.lookup="class.class.instructor.uuid:"+a.teacherId),a.bundleDetails&&(g.bundleDetails=a.bundleDetails));var h=ta.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=va.api.setupAPIToken(h,b.token),h.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function k(a){var b=this,c=b.orgId,d=b.token,e=sa.defer(),f=va.validations.isAuthenticated(c,d);if(f)e.reject(f);else if(a&&a.userid){var g=a.userid,h=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserClassesV2API;h=va.api.constructAPIUrl(h,{orgid:c,userid:g});var i={};a&&(void 0!==a.shadow&&(i.shadow=a.shadow),void 0!==a.hidden&&(i.hidden=a.hidden),a.status_active&&(i.status_active=a.status_active),a.status_ended&&(i.status_ended=a.status_ended),a.status_expired&&(i.status_expired=a.status_expired),a.details&&(i.details=a.details),a.bundleDetails&&(i.bundleDetails=a.bundleDetails),a.limit&&(i.limit=a.limit),a.cursor&&(i.cursor=a.cursor));var j=ta.get(h).query(i);b.traceid&&j.set("X-Amzn-Trace-Id",b.traceid),j=va.api.setupAPIToken(j,d),j.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),e.reject(a)):e.resolve(b.body)})}else f={},f.message=f.description="Required parameter 'userid' is not found in request options.",f=new xa(va.errors.ERROR_TYPES.SDK_ERROR,f),e.reject(f);return e.promise}function l(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getClassUsersAPI;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={};a.search&&(f.search=a.search),a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit),a.sortField&&(f.sortField=a.sortField),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=ta.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):(b.body.entities=wa.convertEnrollmetsResponse({data:b.body.entities}),c.resolve(b.body))})}else d={},d.message=d.description="Required parameter classid is not defined.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function m(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.pisImportAPI;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f,g={};a&&(a.extension&&(g.extension=a.extension),a.import_type&&(g.import_type=a.import_type),a.upfile&&(f=a.upfile));var h=ta.post(e).query(g).set("Content-Type","multipart/form-data").attach("upfile",f);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=va.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function n(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettings;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a&&a.field&&(e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettingsField,e=va.api.constructAPIUrl(e,{orgId:b.orgId,field:a.field}));var g=ta.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function o(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettings;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f=ta.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.body&&(a.body.sis&&!a.body.sis.productid&&(a.body.sis.productid=[]),f.send(a.body)),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function p(a){var b,c=this,d=sa.defer();if(a&&a.classid)if(b=va.validations.isAuthenticated(c.orgId,c.token))d.reject(b);else{var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.generateClassCode;e=va.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f=ta.post(e);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f=va.api.setupAPIToken(f,c.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="classid not found in request options.",b=new xa(va.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function q(a){var b=this,c=sa.defer();if(a&&a.accountId&&a.extUserId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllJobs;d=va.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId});var e={};a.jobType&&(e.jobType=a.jobType),a.details&&(e.details=a.details);var f=ta.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="accountId or extUserId not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function r(a){var b=this,c=sa.defer();if(a&&a.accountId&&a.extUserId&&a.jobId&&a.jobType){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getJob;d=va.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId,jobId:a.jobId});var e={jobType:a.jobType},f=ta.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="accountId or extUserId or jobType or jobId or not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function s(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e='orgid:"'+b.orgId+'"';if(a.lookup&&a["lookup-operator"]){var f=a.lookup,g=f.split(",").map(function(a){var b=a.trim(),c=b.split(":");return b="("+c[0]+".keyword:"+c[1]+")"});e+=" AND ("+g.join(" "+a["lookup-operator"]+" ")+")"}a.search&&(e=e+' AND (title:"'+a.search+'" OR class.instructor.first_name:"'+a.search+'" OR class.instructor.last_name:"'+a.search+'" OR description:"'+a.search+'")');var h=a.sortField||"";h=h.replace(/ext_/gi,"").split(",").shift().trim()||"created","enddate"!==h&&"startdate"!==h||(h="class."+h),"title"===h&&(h+=".keyword"),"tagname_1"===h&&(h+=".keyword");var i=a.sortOrder||"desc",j={},k=[];j[h]=i,k.push(j);var l={query:{query_string:{query:e}},sort:k};a.cursor&&(l.search_after=JSON.parse(a.cursor)),a.limit?l.size=a.limit:a.limit=10;var m=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;m=va.api.constructAPIUrl(m,{index:"classes"});var n={query:JSON.stringify(l)},o=ta.get(m).query(n);b.traceid&&o.set("X-Amzn-Trace-Id",b.traceid),o=va.api.setupAPIToken(o,b.token),o.agent(ya).end(function(b,d){if(b){var e={type:va.errors.ERROR_TYPES.API_ERROR,err:b},f=wa.convertElasticsearchErrResponse(e);c.reject(f)}else{var g={entities:[]};if(g.count=d.body.hits.hits.length,g.count&&a.limit===g.count){var h=d.body.hits.hits[d.body.hits.hits.length-1].sort;g.cursor=JSON.stringify(h)}for(var i in d.body.hits.hits){var j=d.body.hits.hits[i]._source,k={uuid:j.classid,created:j.created,modified:j.modified,path:j.path,category:j.category,"class":{enddate:j["class"].enddate,instructor:{name:j["class"].instructor.first_name+" "+j["class"].instructor.last_name,last_name:j["class"].instructor.last_name,first_name:j["class"].instructor.first_name,uuid:j["class"].instructor.dls_user_id,email:j["class"].instructor.email,username:j["class"].instructor.userid+"--ACCOUNT"},startdate:j["class"].startdate},"class.settings.active":j["class.settings.active"],class_code:j.class_code,class_ownership:j.class_ownership||{owner_status:"ENROLLED",model:"STRICT"},description:j.description,provision_method:j["class"].provision_method,title:j.title,analyticsharingmodel:j.analyticsharingmodel,analytics_score_aggregation_type:j.analytics_score_aggregation_type,hidden:j.hidden,studentCount:j.studentCount,teacherCount:j.teacherCount};j.limits&&(k.limits=j.limits),j.hasOwnProperty("assignedPathCount")&&(k.assignedPathCount=j.assignedPathCount);for(var l=1;l<=10;l++){var m="tagid_"+l;j[m]&&(k[m]=j[m],k["tagname_"+l]=j["tagname_"+l],k["taglookup_"+l]=j["taglookup_"+l])}g.entities.push(k)}c.resolve(g)}})}return c.promise}function t(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getParticularClassAPI;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=ta.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.ext_classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getParticularShadowClassAPI;e=va.api.constructAPIUrl(e,{orgId:b.orgId,extClassId:a.ext_classid});var f=ta.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="ext_classid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.productcode){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classProductAssociation;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId or productcode not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function w(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.productcode){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classProductAssociation;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f={},g=ta["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId or productcode not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=sa.defer(),c=this,d=va.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classId&&a.productcodes){var e=c.config.DEFAULT_HOSTS.AUTH,f=c.config.AUTH_API_URLS.multiClassProductAssociations,g=e+f,h={productcodes:a.productcodes};g=va.api.constructAPIUrl(g,{orgId:c.orgId,classId:a.classId});var i=ta.post(g).set("Content-Type","application/json").set("Accept","application/json").send(h);c.traceid&&i.set("X-Amzn-Trace-Id",c.traceid),i=va.api.setupAPIToken(i,c.token),i.end(function(a,c){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(d)):b.resolve(c.body)})}else d={},d.message=d.description="Missing mandaotry fields 'classId' or 'productcodes' in request.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function y(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=ta.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.appdata){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid or appdata not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function A(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){var b=this,c={},d=sa.defer();if(a&&a.classid&&a.userid)if(c=va.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),
4
4
  d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or userid not found in request options",c=new xa(va.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function C(a){var b=this,c={},d=sa.defer();if(a&&a.classid)if(c=va.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollSelftoClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={classrole:a.classrole},g=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid not found in request options",c=new xa(va.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function D(a){var b=this,c={},d=sa.defer();if(a&&a.classid&&a.users)if(c=va.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or users array not found in request options",c=new xa(va.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function E(a){var b=this,c={},d=sa.defer();if(a&&a.classid&&a.users)if(c=va.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=ta["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or users array not found in request options",c=new xa(va.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function F(a){var b=this,c={},d=sa.defer();if(a&&a.classid&&a.userid)if(c=va.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=ta["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or userid not found in request options",c=new xa(va.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function G(a){var b={};for(var c in a)b[a[c]]=encodeURIComponent(a[c]);return b}function H(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f={title:a.title,startdate:a.startdate,enddate:a.enddate};a.description&&(f.description=a.description),a.class_ownership&&(f.class_ownership=a.class_ownership),a.ext_data&&(f.ext_data=a.ext_data),a.analyticsharingmodel&&(f.analyticsharingmodel=a.analyticsharingmodel),a.limits&&(f.limits=a.limits);var g=ta.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){if(a)a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=wa.convertClassResponse({data:b.body});c.resolve(d)}})}else d={},d.message=d.description="title or startdate or enddate not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function I(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.specificClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=ta.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameter 'classid' is not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function J(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a.classes&&a.classes.length>0||a.clone_classes&&a.clone_classes.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createMultipleClasses;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f=ta.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameters - [classes, clone_classes], not found in request options",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function K(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.specificClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=ta["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or body not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.data&&a.data.title&&a.data.items&&a.data.items.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createAssignedPath;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.data);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - title or classid or items not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.deleteAssignedPath;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedpathid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function N(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.deleteAssignedPath;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=ta.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.data&&f.send(a.data),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedpathid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function O(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.allGroups;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="title or startdate or enddate not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function P(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.path){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.allGroups;e=va.api.constructAPIUrl(e,{orgId:b.orgId});var f={path:a.path};a.cursor&&(f.cursor=a.cursor);var g=ta.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - path not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Q(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=va.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=ta.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function R(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=va.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function S(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=va.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function T(a){var b=this,c=sa.defer(),d={},e=va.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllMembersOfAGroup;f=va.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),a.cursor&&(d.cursor=a.cursor);var g=ta.get(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId not found in request options.",e=new xa(va.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function U(a){var b=this,c=sa.defer(),d={},e=va.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.path){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllGroupMembersByPath;f=va.api.constructAPIUrl(f,{orgId:b.orgId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=ta.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - path not found in request options.",e=new xa(va.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function V(a){var b=this,c=sa.defer(),d={},e=va.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId&&a.body&&a.body.users&&a.body.users.length>0){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userGroupMembership;f=va.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=ta.post(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",e=new xa(va.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function W(a){var b=this,c=sa.defer(),d={},e=va.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId&&a.body&&a.body.users&&a.body.users.length>0){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userGroupMembership;f=va.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=ta["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",e=new xa(va.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function X(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.archiveAParticularGroup;e=va.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - groupId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Y(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.unarchiveAParticularGroup;e=va.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - groupId not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Z(a){var b=this,c=sa.defer(),d={},e=va.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.userId&&a.path){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getMyAllMemberships;f=va.api.constructAPIUrl(f,{orgId:b.orgId,userId:a.userId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=ta.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - userId or path not found in request options.",e=new xa(va.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function $(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.showcaseItems;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=ta.post(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classId or body not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function _(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.showcaseItems;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=va.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classId or body not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function aa(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate&&a.instructor&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.cloneClass;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=ta.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="title or startdate or enddate or instructor or classid not found in request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function ba(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createOrGetGradebookMeta;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - classid or body not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ca(a){var b=sa.defer(),c=this,d={},e=va.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.classid&&a.gradebook_id&&a.body)if(0!==Object.keys(a.body).length){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;f=va.api.constructAPIUrl(f,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var g=a.body,h=ta.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=va.api.setupAPIToken(h,c.token),h.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Body of the request cannot be empty.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);else d.message=d.description="Mandatory params: classid, gradebook_id or body not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function da(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - classid or gradebook_id not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ea(a){var b=sa.defer(),c=this,d=va.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.createOrGetGradebookMeta;e=va.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f={gradebook_id:a.gradebook_id},g=ta.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=va.api.setupAPIToken(g,c.token),g.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):c.body.entities?b.resolve(c.body.entities[0]):b.resolve()})}else{var h={};h.message=h.description="Mandatory params: classid or gradebook_id not found in request options.",h=new xa(va.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function fa(a){var b=sa.defer(),c=this,d=va.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.createOrGetGradebookMeta;e=va.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f={};a.cursor&&(f.cursor=a.cursor);var g=ta.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=va.api.setupAPIToken(g,c.token),g.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: classid not found in request options.",h=new xa(va.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function ga(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.gradebookColumns;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - classid, gradebook_id or body not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ha(a){var b=sa.defer(),c=this,d={},e=va.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.classid&&a.gradebook_id&&a.body&&a.body.columns){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;f=va.api.constructAPIUrl(f,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var g=a.body,h=ta.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=va.api.setupAPIToken(h,c.token),h.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: classid, gradebook_id, body or body.columns not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function ia(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.gradebookColumns;e=va.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=ta["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - classid, gradebook_id or body not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ja(a){var b=sa.defer(),c=this,d=va.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.column_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;e=va.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f={column_id:a.column_id},g=ta.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=va.api.setupAPIToken(g,c.token),g.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body.entities[0])})}else{var h={};h.message=h.description="Mandatory params: classid, gradebook_id or column_id not found in request options.",h=new xa(va.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function ka(a){var b=sa.defer(),c=this,d=va.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;e=va.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f={};a.cursor&&(f.cursor=a.cursor);var g=ta.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=va.api.setupAPIToken(g,c.token),g.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: classid or gradebook_id not found in request options.",h=new xa(va.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function la(a){var b=sa.defer(),c=this,d={},e=va.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.component_code){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.getAllClassesOfAComponent;f=va.api.constructAPIUrl(f,{orgId:c.orgId,component_code:a.component_code});var g={};a.cursor&&(g.cursor=a.cursor);var h=ta.get(f).query(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=va.api.setupAPIToken(h,c.token),h.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: component_code not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function ma(a){var b=sa.defer(),c=this,d={},e=va.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.component_code){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.removeAllGradebookColumnsOfCustomComponent;f=va.api.constructAPIUrl(f,{orgId:c.orgId,component_code:a.component_code});var g=ta["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=va.api.setupAPIToken(g,c.token),g.agent(ya).end(function(a,c){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: component_code not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function na(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.customComponents;e=va.api.constructAPIUrl(e,{orgid:b.orgId});var f=ta.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - 'body' not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function oa(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code&&a.body)if(0===Object.keys(a.body).length)d.message=d.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=va.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=a.body,g=ta.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",d=new xa(va.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function pa(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=va.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=ta["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){if(a){var d=new xa(va.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - 'custom_component_code' not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function qa(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=va.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=ta.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=va.api.setupAPIToken(f,b.token),f.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params: 'custom_component_code' not found in request options.",g=new xa(va.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ra(a){var b=this,c=sa.defer(),d=va.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.customComponents;e=va.api.constructAPIUrl(e,{orgid:b.orgId});var f={};a&&a.cursor&&(f.cursor=a.cursor);var g=ta.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),
5
5
  g=va.api.setupAPIToken(g,b.token),g.agent(ya).end(function(a,b){a?(a=new xa(va.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}var sa=a("q"),ta=a("superagent"),ua=a("agentkeepalive"),va=a("../../helpers"),wa=a("../../helpers/lib/api/converter"),xa=va.errors.DLSError;b.exports=d;var ya=new ua({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:46,superagent:49}],17:[function(a,b,c){function d(a){return this.accountId=a,{createGradeformat:e.bind(this),updateGradeformat:f.bind(this),deleteGradeformat:g.bind(this),getAllGradeformats:i.bind(this),getParticularGradeformat:h.bind(this),associateGradeformatToClass:j.bind(this),unassociateGradeformatFromClass:k.bind(this),updateClassGradeformatAssociation:l.bind(this),getParticularGradeformatOfAClass:m.bind(this),getAllGradeformatsOfAClass:n.bind(this),getClassesOfAGradeformat:o.bind(this),createUserAssignedPathEnrollments:p.bind(this),deleteUserAssignedPathEnrollments:q.bind(this),getParticularClassV2:r.bind(this),createOrgProductEntitlement:s.bind(this),updateOrgProductEntitlement:t.bind(this),getParticularOrgProductEntitlement:u.bind(this),getAllOrgProductEntitlements:v.bind(this),setupUser:w.bind(this)}}function e(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.gradeFormat;e=z.api.constructAPIUrl(e,{orgid:b.orgId});var f=y.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - body not found in request options.",g=new B(z.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=x.defer(),c=this,d={},e=z.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.gradeformat_id&&a.body)if(0!==Object.keys(a.body).length){var f=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.particularGradeFormat;f=z.api.constructAPIUrl(f,{orgid:c.orgId,gradeformat_id:a.gradeformat_id});var g=a.body,h=y.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=z.api.setupAPIToken(h,c.token),h.agent(C).end(function(a,c){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Body of the request cannot be empty.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);else d.message=d.description="Mandatory params: gradeformat_id or body not found in the request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function g(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.particularGradeFormat;e=z.api.constructAPIUrl(e,{orgid:b.orgId,gradeformat_id:a.gradeformat_id});var f=y["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - gradeformat_id not found in request options.",g=new B(z.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=x.defer(),c=this,d=z.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.gradeformat_id){var e=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.gradeFormat;e=z.api.constructAPIUrl(e,{orgid:c.orgId});var f={gradeformat_id:a.gradeformat_id},g=y.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=z.api.setupAPIToken(g,c.token),g.agent(C).end(function(a,c){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body.entities[0])})}else{var h={};h.message=h.description="Mandatory params: gradeformat_id not found in request options.",h=new B(z.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function i(a){var b=x.defer(),c=this,d=z.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else{var e=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.gradeFormat;e=z.api.constructAPIUrl(e,{orgid:c.orgId});var f={};a&&a.cursor&&(f.cursor=a.cursor);var g=y.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=z.api.setupAPIToken(g,c.token),g.agent(C).end(function(a,c){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}return b.promise}function j(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=y.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or gradeformat_id or body not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=y["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or gradeformat_id not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=a.body,g=y.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: classid or gradeformat_id or body not found in the request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function m(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformats;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid});var f={gradeformat_id:a.gradeformat_id},g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body.entities[0])})}else d={},d.message=d.description="Mandatory params: classid or gradeformat_id not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformats;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid});var f={};a.cursor&&(f.cursor=a.cursor);var g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: classid not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.gradeformatClasses;e=z.api.constructAPIUrl(e,{orgid:b.orgId,gradeformat_id:a.gradeformat_id});var f={};a.cursor&&(f.cursor=a.cursor);var g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: gradeformat_id not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.userAssignedPaths;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,assignedpathid:a.assignedpathid});var f=y.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param: classid, assignedpathid, body not found in request options.",g=new B(z.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function q(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.userAssignedPaths;e=z.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,assignedpathid:a.assignedpathid});var f=y["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=z.api.setupAPIToken(f,b.token),f.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param: classid, assignedpathid, body not found in request options.",g=new B(z.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function r(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.particularClass;e=z.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f={productDetails:a.productDetails,bundleDetails:a.bundleDetails},g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory field 'classId' not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=x.defer();if(b.orgId)if(a&&a.productcode){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=z.api.constructAPIUrl(d,{orgid:b.orgId});var e=y.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param: productcode not found in request options.",f=new B(z.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}else{var f={};f.message=f.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",f=new B(z.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function t(a){var b=this,c=x.defer();if(b.orgId)if(a&&a.productcode){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=z.api.constructAPIUrl(d,{orgid:b.orgId});var e=y.put(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(C).end(function(a,b){if(a){var d=new B(z.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param: productcode not found in request options.",f=new B(z.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}else{var f={};f.message=f.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",f=new B(z.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.productcode){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;e=z.api.constructAPIUrl(e,{orgid:b.orgId});var f={productcode:a.productcode},g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory field 'productcode' not found in request options.",d=new B(z.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c=x.defer(),d=z.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;e=z.api.constructAPIUrl(e,{orgid:b.orgId});var f={productcode:a.productcode};a.status&&(f.status=a.status),a.hasOwnProperty("expired")&&(f.expired=a.expired),a.cursor&&(f.cursor=a.cursor);var g=y.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=z.api.setupAPIToken(g,b.token),g.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function w(a){var b=this,c=x.defer();if(a&&a.ext_user_id&&a.workflow_type){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.setupUser;d=z.api.constructAPIUrl(d,{accountId:b.accountId});var e=y.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(C).end(function(a,b){a?(a=new B(z.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory field 'ext_user_id' or 'workflow_type' not found in the request options.",err=new B(z.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}var x=a("q"),y=a("superagent"),z=a("../../helpers"),A=a("agentkeepalive"),B=z.errors.DLSError;b.exports=d;var C=new A({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],18:[function(a,b,c){function d(){return{getPostsInClass:e.bind(this),createPostInClass:f.bind(this),getPostsInProduct:g.bind(this),createPostInProduct:h.bind(this),getMyFollowers:i.bind(this),getUsersFollowedByMe:j.bind(this),followUser:k.bind(this),unfollowUser:l.bind(this)}}function e(a){var b=this,c=o.defer(),d={};if(a&&a.classid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInClassAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "classid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=o.defer(),d={};if(a&&a.verb&&a.classid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInClassAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={verb:a.verb};a.post&&(f.post=a.post),a.name&&(f.name=a.name),a.email&&(f.email=a.email),a.userid&&(f.userid=a.userid);var g=n.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "verb" or "classid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=o.defer(),d={};if(a&&a.productid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInProductAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,productId:a.productid});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "productid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=o.defer(),d={};if(a&&a.verb&&a.productid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInProductAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,productId:a.productid});var f={verb:a.verb};a.post&&(f.post=a.post),a.name&&(f.name=a.name),a.email&&(f.email=a.email),a.userid&&(f.userid=a.userid);var g=n.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "verb" or "productid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=o.defer(),d={};if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.getMyFollowers;e=p.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}return c.promise}function j(a){var b=this,c=o.defer(),d={};if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.getUsersFollowedByMe;e=p.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}return c.promise}function k(a){var b=o.defer();return m(this.orgId,this.token,this.config,a,"create").then(function(a){b.resolve(a)})["catch"](function(a){b.reject(a)}).done(),b.promise}function l(a){var b=o.defer();return m(this.orgId,this.token,this.config,a,"delete").then(function(a){b.resolve(a)})["catch"](function(a){b.reject(a)}).done(),b.promise}function m(a,b,c,d,e){var f=o.defer(),g={};if(d&&d.userid)if(g=p.validations.isAuthenticated(a,b))f.reject(g);else{var h=c.DEFAULT_HOSTS.COLLAB+c.COLLAB_API_URLS.connectionURL;h=p.api.constructAPIUrl(h,{orgId:a,userId:d.userid});var i;"create"===e?i=n.post(h).set("Content-Type","application/json"):"delete"===e&&(i=n["delete"](h).set("Content-Type","application/json")),i=p.api.setupAPIToken(i,b),i.end(function(a,b){a?(g=new q(p.errors.ERROR_TYPES.API_ERROR,a),f.reject(g)):f.resolve(b.body)})}else g.message=g.description='Mandatory parameter "userid" not found in request options',g=new q(p.errors.ERROR_TYPES.SDK_ERROR,g),f.reject(g);return f.promise}var n=a("superagent"),o=a("q"),p=a("../../helpers"),q=p.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],19:[function(a,b,c){function d(a){return this.accountId=a,{createDataSyncManager:e.bind(this),updateDataSyncManager:f.bind(this),deleteDataSyncManager:g.bind(this),getParticularDataSyncManager:h.bind(this),getAllDataSyncManagersOfAGroup:i.bind(this)}}function e(a){var b=this,c=j.defer();if(a&&a.body){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createDataSyncManager;d=m.api.constructAPIUrl(d,{accountid:b.accountId});var e=k.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function f(a){var b=j.defer(),c=this;if(a&&a.dsmid&&a.body){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.dataSyncManager,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsmid:a.dsmid});var g=a.body,h=k.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var i={};i.message=i.description="Mandatory params: dsmid, body not found in the request options.",i=new n(m.errors.ERROR_TYPES.SDK_ERROR,i),b.reject(i)}return b.promise}function g(a){var b=this,c=j.defer();if(a&&a.dsmid&&a.body){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.dataSyncManager;d=m.api.constructAPIUrl(d,{accountid:b.accountId,dsmid:a.dsmid});var e=k["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory params - dsmid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=j.defer(),c=this;if(a&&a.dsmid){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.dataSyncManager,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsmid:a.dsmid});var g=k.get(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: dsmid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function i(a){var b=j.defer(),c=this;if(a&&a.dsm_groupid){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.getAllDataSyncManagersOfAGroup,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsm_groupid:a.dsm_groupid});var g=k.get(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: dsm_groupid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}var j=a("q"),k=a("superagent"),l=a("agentkeepalive"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d;var o=new l({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],20:[function(a,b,c){function d(){return{getAParticularDocument:e.bind(this),getAllDocumentsInAFolder:f.bind(this),createMultipleDocuments:g.bind(this),updateMultipleDocuments:h.bind(this),deleteMultipleDocuments:i.bind(this)}}function e(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.documentid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAParticularDocument,e={accountid:a.accountid,extuserid:a.extuserid,documentid:a.documentid};d=m.api.constructAPIUrl(d,e);var f={folderid:a.folderid},g=k.get(d).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var h={};h.message=h.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function f(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAllDocumentsInAFolder;d=m.api.constructAPIUrl(d,{accountid:a.accountid,extuserid:a.extuserid});var e={folderid:a.folderid};a.classid&&(e.classid=a.classid),a.productcode&&(e.productcode=a.productcode),a.assigned_path_id&&(e.assigned_path_id=a.assigned_path_id),a["item-code"]&&(e["item-code"]=a["item-code"]),a.cursor&&(e.cursor=a.cursor);var f=k.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - accountid or extuserid or folderid not found in request options.",g=new n(m.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function g(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.body){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.documents;d=m.api.constructAPIUrl(d,{accountid:a.accountid,userid:a.extuserid});var e=k.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - accountid, extuserid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=j.defer(),c=this,d={};if(a&&a.accountid&&a.extuserid&&a.body){var e=c.config.DEFAULT_HOSTS.DRIVE+c.config.DRIVE_API_URLS.documents;e=m.api.constructAPIUrl(e,{accountid:a.accountid,userid:a.extuserid});var f=k.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory param - accountid, extuserid or body not found in the request options.",d=new n(m.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function i(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.body){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.documents;d=m.api.constructAPIUrl(d,{accountid:a.accountid,userid:a.extuserid});var e=k["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - accountid, extuserid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}var j=a("q"),k=a("superagent"),l=a("agentkeepalive"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d;var o=new l({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],21:[function(a,b,c){function d(a){return this.accountId=a,{getGetStreamCredentials:e.bind(this),queryDataFromSearch:f.bind(this),getAuditTrailForAttempts:g.bind(this),getAuditTrailForEntitlements:h.bind(this),getAuditTrailForMicroEntitlements:i.bind(this),publishCustomEvents:j.bind(this),createSchedule:k.bind(this),getSchedule:l.bind(this),updateSchedule:m.bind(this),deleteSchedule:n.bind(this)}}function e(){var a,b=this,c=o.defer(),d=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;d=r.api.constructAPIUrl(d,{accountId:b.accountId});var e=p.post(d).set("Content-Type","application/json").set("Accept","application/json").send();return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(b,d){b?(a=new t(r.errors.ERROR_TYPES.API_ERROR,b),c.reject(a)):c.resolve(d)}),c.promise}function f(a){var b,c=this,d=o.defer();if(a&&a.index&&a.query){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.queryDataFromSearch;e=r.api.constructAPIUrl(e,{index:a.index});var f={query:a.query},g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){if(a){var c={type:r.errors.ERROR_TYPES.API_ERROR,err:a},e=s.convertElasticsearchErrResponse(c);d.reject(e)}else d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - index, type or query not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode&&a["item-code"]){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ATTEMPT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode+"#"+a["item-code"],action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, action, userid, productcode or item-code not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ENTITLEMENT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode,type:"entitlement",action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, userid or productcode not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode&&a.context){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ENTITLEMENT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode+"#"+a.context,type:"micro-entitlement",action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, action, userid, productcode or context not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise;
6
6
  }function j(a){var b,c=o.defer(),d=this;if(a&&a.events){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.customEvents;e=r.api.constructAPIUrl(e,{accountId:d.accountId});var f=p.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory params - events not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function k(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.body&&Object.keys(a.body).length>0&&a.body.scheduleid&&a.body.actorid&&a.body.category&&a.body.schedule_time){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f=p.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or body(scheduleid or actorid or category or schedule_time) not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function l(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f={};a.cursor&&(f.cursor=a.cursor),a.category&&(f.category=a.category),a.scheduleid&&(f.scheduleid=a.scheduleid);var g=p.get(e).query(f);d.traceid&&g.set("X-Amzn-Trace-Id",d.traceid),g.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory params - accountid or context not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function m(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.scheduleid&&a.body&&Object.keys(a.body).length>0&&a.body.actorid&&a.body.category){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.particularSchedule;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=p.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or scheduleid or body(category or actorid) not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function n(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.scheduleid&&a.body){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.particularSchedule;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=p["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.agent(u).end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or scheduleid or body not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}var o=a("q"),p=a("superagent"),q=a("agentkeepalive"),r=a("../../helpers"),s=a("../../helpers/lib/api/converter"),t=r.errors.DLSError;b.exports=d;var u=new q({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:46,superagent:49}],22:[function(a,b,c){function d(){return{sendInvitations:e.bind(this),getMultiInvitations:f.bind(this),revokeSingleInvitation:g.bind(this),completeSingleInvitation:h.bind(this),resendSingleInvitation:i.bind(this)}}function e(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.created&&a.invitation_data){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.sendInvitations;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);f=l.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="One or more required field(s) missing: context, created or invitation_data",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getMultiInvitations;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f={context_id:a.context_id};a.context&&(f.context=a.context),a.status&&(f.status=a.status),a.cursor&&(f.cursor=a.cursor);var g=k.get(e).query(f);g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id&&a.invitationid&&a.context){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.revokeSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g=k["delete"](e).query(f);g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id&&a.invitationid&&a.context){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.completeSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g=k.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send({});g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.invitationid&&a.context&&a.context_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.resendSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g={};a.space_title&&(g.space_title=a.space_title);var h=k.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(g);h=l.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var j=a("q"),k=a("superagent"),l=a("../../helpers"),m=l.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],23:[function(a,b,c){function d(a){return this.accountId=a,{getProduct:e.bind(this),getGlobalEntitlementsForAUser:f.bind(this),getMicroEntitlementsForAUser:g.bind(this),getAllBundles:h.bind(this),getSingleBundle:i.bind(this),getSingleProductFamily:k.bind(this),getAllProductFamilies:j.bind(this)}}function e(a){var b=m.defer(),c=this,d={};if(a&&a.productcode){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getProductAPI;e=n.api.constructAPIUrl(e,{accountId:c.accountId,productCode:a.productcode});var f={};a.details&&(f.details=a.details),a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,c){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="productcode not found in request options",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function f(a){var b=this,c=m.defer();if(a&&a.extUserId){var d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getEntitlementsOfAUser;d=n.api.constructAPIUrl(d,{accountId:b.accountId,extUserId:a.extUserId});var e={};a.productDetails&&(e.productDetails=a.productDetails),a.bundleDetails&&(e.bundleDetails=a.bundleDetails);var f=l.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory parameter extUserId not found in request options",g=new o(n.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function g(a){var b=this,c=m.defer();if(a&&a.extuserid&&a.productcode){var d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;d=n.api.constructAPIUrl(d,{accountId:b.accountId,extUserId:a.extuserid});var e={};e.productcode=a.productcode,a.context&&(e.context=a.context),a.feature_key&&(e.feature_key=a.feature_key),a.cursor&&(e.cursor=a.cursor);var f=l.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory parameter extuserid or productcodenot found in request options",g=new o(n.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=m.defer(),d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getAllBundles;d=n.api.constructAPIUrl(d,{accountId:b.accountId});var e={};a&&a.stage&&(e.stage=a.stage);var f=l.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function i(a){var b,c=this,d=m.defer();if(a&&a["bundle-code"]){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getSingleBundle;e=n.api.constructAPIUrl(e,{accountId:c.accountId,bundleCode:a["bundle-code"]});var f={};a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter bundle-code not found in request options",b=new o(n.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b=this,c=m.defer(),d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getAllProductFamilies;d=n.api.constructAPIUrl(d,{accountId:b.accountId});var e={};a&&a.stage&&(e.stage=a.stage);var f=l.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function k(a){var b,c=this,d=m.defer();if(a&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getSingleProductFamily;e=n.api.constructAPIUrl(e,{accountId:c.accountId,familyCode:a["family-code"]});var f={};a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter family-code not found in request options",b=new o(n.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var l=a("superagent"),m=a("q"),n=a("../../helpers"),o=n.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],24:[function(a,b,c){function d(){return{promoteProduct:e.bind(this),registerProduct:f.bind(this),ingestProduct:g.bind(this),createBundle:h.bind(this),updateBundle:i.bind(this),getAllBundles:j.bind(this),getSingleBundle:k.bind(this),createProductFamily:l.bind(this),updateProductFamily:m.bind(this),getSingleProductFamily:n.bind(this),getAllProductFamilies:o.bind(this)}}function e(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.promoteAPI;d=r.api.constructAPIUrl(d,{orgId:b.orgId,productcode:a.productcode});var e={source:{},target:{}};a&&(a.source&&a.source.stage&&(e.source.stage=a.source.stage),a.target&&(a.target.org&&(e.target.org=a.target.org),a.target.stage&&(e.target.stage=a.target.stage)),a.externalrefid&&(e.externalrefid=a.externalrefid));var f=p.post(d).send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)}),c.promise}function f(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.registerProductAPI;d=r.api.constructAPIUrl(d,{orgId:b.orgId});var e={};a&&(a.targetorg&&(e.targetorgid=a.targetorg),a.repositorytype&&(e.repositorytype=a.repositorytype),a.producttitle&&(e.producttitle=a.producttitle),a.producttype&&(e.producttype=a.producttype),a.productcode&&(e.productcode=a.productcode),a.github&&(e.github=a.github),a.s3&&(e.s3=a.s3),a.externalrefid&&(e.externalrefid=a.externalrefid),a["bundle-codes"]&&(e["bundle-codes"]=a["bundle-codes"]));var f=p.post(d).send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)}),c.promise}function g(a){var b,c=this,d=q.defer();a&&a.productcode&&(b=a.productcode);var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.ingestByCodeAPI;e=r.api.constructAPIUrl(e,{orgId:c.orgId,productcode:b});var f={};a&&(a.branchref&&(f.branchref=a.branchref),a.externalrefid&&(f.externalrefid=a.externalrefid),a["bundle-codes"]&&(f["bundle-codes"]=a["bundle-codes"]));var g=p.post(e).send(f);return c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b)}),d.promise}function h(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["bundle-code"]&&a.body&&a.body.title&&a.body.products){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.createBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage}),a.body["bundle-code"]=a["bundle-code"];var f=p.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or bundle-code or title or products not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["bundle-code"]&&a.body&&a.body.products){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.updateBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage,bundleCode:a["bundle-code"]});var f=p.put(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or bundle-code or products not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.getAllBundles;d=r.api.constructAPIUrl(d,{orgid:b.orgId});var e={};a&&a.stage&&(e.stage=a.stage);var f=p.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function k(a){var b,c=this,d=q.defer();if(a&&a["bundle-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.getSingleBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,bundleCode:a["bundle-code"]});var f={};a&&a.stage&&(f.stage=a.stage);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter bundle-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function l(a){var b,c=this,d=q.defer();if(a&&a.stage&&a.body&&a.body["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.createProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage});var f=p.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function m(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.updateProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage,familyCode:a["family-code"]});var f=p.put(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function n(a){var b,c=this,d=q.defer();if(a&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.getSingleProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,familyCode:a["family-code"]});var f={};a.stage&&(f.stage=a.stage);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function o(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.getAllProductFamilies;d=r.api.constructAPIUrl(d,{orgid:b.orgId});var e={};a&&a.stage&&(e.stage=a.stage);var f=p.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}var p=a("superagent"),q=a("q"),r=a("../../helpers"),s=r.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],25:[function(a,b,c){function d(){var a=m();return{connect:e.bind(this,a),cleanup:f.bind(this,a),grantByUserOrgId:g.bind(this),grantByAccountId:h.bind(this),grantByAccountIdOnExtUserId:i.bind(this)}}function e(a,b){var c=!0;if(c&&!b.userid){var d={};throw d.message=d.description="Mandatory parameter userid not found in request options.",d=new n(l.errors.ERROR_TYPES.PUSHX_ERROR,d)}return a.setup({userid:b.userid,pubnub:{publishKey:b.publishKey,subscribeKey:b.subscribeKey,authKey:b.authKey,ssl:!0}})}function f(a){a.cleanup()}function g(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByUserOrgId;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json"),g={};a.authKey&&(g.authKey=a.authKey),f.send(g),f=l.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function h(a){var b=this,c={},d=j.defer();if(a.accountId&&a.refId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={refId:a.refId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'refId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function i(a){var b=this,c={},d=j.defer();if(a.accountId&&a.extUserId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={extUserId:a.extUserId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'extUserId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}var j=a("q"),k=a("superagent"),l=a("../../helpers"),m=a("./pubnubClientWrapper"),n=l.errors.DLSError;b.exports=d},{"../../helpers":3,"./pubnubClientWrapper":26,q:46,superagent:49}],26:[function(a,b,c){var d=a("pubnub"),e=a("events").EventEmitter,f=a("../../helpers"),g=f.errors.PUSHXError,h="$";b.exports=function(){"use strict";var a,b,c=new e,i=[],j={},k=!1,l=function(){return{on:function(a,b){var d,e=[];a.orgid||a.userid||a.accountid||a.productid||a.classid?(a.accountid?e.push("a-"+a.accountid):(a.orgid&&e.push("o-"+a.orgid),a.userid&&e.push("u-"+a.userid),a.productid&&e.push("p-"+a.productid),a.classid&&e.push("c-"+a.classid)),d=e.join(h)+h+a.channel,i.includes(d)||(i.push(d),j[d]={status:"pending"},c.on(d,b),p(d))):"pushx_status"!==a.channel||k||(c.on(a.channel,b),k=!0)},getMySubscriptionStatus:o}},m=function(a){var b=a.subscribedChannel,d=a.message;c.emit(b,d)},n=function(a){var b,d,e=[];switch(a.category){case"PNConnectedCategory":if("PNSubscribeOperation"===a.operation){e=a.subscribedChannels;for(var h in e)j[e[h]]&&(j[e[h]].status="subscribed");d={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:a.subscribedChannels},message:"Success: Subscribed successfully."}},c.emit("pushx_status",d)}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===a.operation){var i={payload:JSON.parse(a.errorData.response.text).payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:a.operation,category:a.category,statusCode:a.statusCode}};e=i.payload.channels;for(var k in e)j[e[k]]&&(j[e[k]].status="error",j[e[k]].error=b);b=new g(f.errors.ERROR_CATEGORY.PUSHX,i),c.emit("pushx_status",b)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":b={message:"PushX Error",status:a.statusCode,pushXError:a},b=new g(f.errors.ERROR_CATEGORY.PUSHX,b),c.emit("pushx_status",b)}},o=function(){return JSON.parse(JSON.stringify(j))},p=function(b){a.subscribe({channels:[b]})},q=function(c){function e(){b=c,a.addListener({message:function(a){m(a)},status:function(a){n(a)}})}var f=c.pubnub;return f.uuid=c.userid,a||!f?new Error("Already Initialized"):(a=new d(f),e(),l())},r=function(){a&&(a.unsubscribeAll(),a.stop(),i=[],k=!1,j={}),a=void 0};return{setup:q,cleanup:r}}},{"../../helpers":3,events:41,pubnub:45}],27:[function(a,b,c){function d(){return{getRules:e.bind(this),getParticularRule:f.bind(this),getUserRule:g.bind(this),updateRuleDisplay:h.bind(this),createRule:i.bind(this),updateRule:j.bind(this),deleteRule:k.bind(this)}}function e(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.rules;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType});var f={cursor:a.cursor},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="context or ruleType not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="context or ruleType or ruleId not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=l.defer();if(a&&a.orgId&&a.context&&a.ruleType&&a.userId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.getUserRule;d=n.api.constructAPIUrl(d,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,userId:a.userId});var e=m.get(d).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e=n.api.setupAPIToken(e,b.token),e.agent(q).end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory params - orgId or context or ruleType or userId not found in request options.",f=new p(n.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId&&a.body&&a.body.rule_display){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.updateRuleDisplay;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId or body.rule_display not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.rules;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType});var f=m.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or body not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function j(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId or body not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m["delete"](e);f=n.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d={},d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var l=a("q"),m=a("superagent"),n=a("../../helpers"),o=a("agentkeepalive"),p=n.errors.DLSError;b.exports=d;var q=new o({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],28:[function(a,b,c){function d(a){return this.accountId=a,{getUserSpaces:e.bind(this),validateSpaceCode:f.bind(this),validateClassCode:g.bind(this),generateSpaceCode:h.bind(this),changeSpaceCode:i.bind(this),joinInstituteSpace:j.bind(this),provisionSpacesToStudent:k.bind(this),provisionSpacesToTeacher:l.bind(this),provisionBulkSpaces:m.bind(this),shadowProvision:n.bind(this),entitleUserToProduct:o.bind(this),unentitleUserToProduct:p.bind(this),revokeMicroEntitlementOfAUser:s.bind(this),microEntitleUserToProduct:q.bind(this),bulkMicroEntitleProductToUser:r.bind(this),enrollUserInClass:v.bind(this),getExtProduct:t.bind(this),getSpaceDetails:u.bind(this),updateUserInformation:w.bind(this),updateUserSpace:x.bind(this),getInvitationsByEmail:y.bind(this),updateInstituteTitle:z.bind(this)}}function e(a){var b=this,c=A.defer();if(a&&a.extuserid){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserSpaces;d=D.api.constructAPIUrl(d,{accountid:b.accountId,extuserid:a.extuserid});var e={};a.spaceRole&&(e.spaceRole=a.spaceRole),a.spaceType&&(e.spaceType=a.spaceType),a.spaceOrgContext&&(e.spaceOrgContext=a.spaceOrgContext),a.details&&(e.details=a.details),a.cursor&&(e.cursor=a.cursor);var f=B.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="extuserid not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=this,c=A.defer();if(a&&a.spaceCodeBody&&a.spaceCodeBody.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.spaceCodeBody);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="spaceCodeBody or space_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=A.defer();if(a&&a.classCodeBody&&a.classCodeBody.class_code){
7
7
  var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateClassCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.details&&(e.details=a.details);var f=B.post(d).set("Content-Type","application/json").set("Accept","application/json").query(e).send(a.classCodeBody);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="classCodeBody or class_code not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=A.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.generateSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)}),c.promise}function i(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.changeSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId,spacecode:a.spacecode});var e={ext_user_id:a.ext_user_id};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=B.put(d).set("Content-Type","application/json").set("Accept","application/json").send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b)})}else{var g={};g.message=g.description="Mandatory parameter options, ext_user_id or spacecode, not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function j(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&a.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.joinInstituteSpace;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or ext_role or space_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function k(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id&&a.ext_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToStudent;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="ext_user_id or ext_role not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToTeacher;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory parameters [rxt_user_id, ext_role] not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function m(a){var b=this,c=A.defer(),d=D.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.users&&a.space_title){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionBulkSpaces;e=D.api.constructAPIUrl(e,{orgId:b.orgId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=D.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameters: space_title or users not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id&&a.ext_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.shadowProvision;e=D.api.constructAPIUrl(e,{orgId:b.orgId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.agent(F).end(function(a,b){a?(a=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Mandatory parameters: ext_user_id or ext_role not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&(a.productcode||a.ext_product_id)){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.entitleUserToProduct;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_role' and either of 'ext_product_id' or 'productcode' must be present.",f.message=f.description,f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function p(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.productcode&&a.ext_actor_id&&void 0!==a.audit){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.entitleUserToProduct;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){if(a){var d=new E(D.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_actor_id', 'productcode' and 'audit' must be present",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function q(a){var b=this,c=A.defer(),d=!0,e={description:"",message:""};if(a&&a.ext_user_id&&a.context&&a.feature_key&&a.feature_id||(d=!1,e.description="ext_user_id or context or feature_key or feature_id not found in request options. "),d&&(a.productcode||a.ext_product_id)){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.microEntitleUserToProduct;f=D.api.constructAPIUrl(f,{accountId:b.accountId});var g=B.post(f).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(e=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b.body)})}else a.productcode||a.ext_product_id||(e.description+="Either of ext_product_id or productcode must be present in request options."),e.message=e.description,e=new E(D.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function r(a){var b=this,c=A.defer();if(a&&a["micro-entitlements"]){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.bulkMicroEntitleProductToUser;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.description="Missing mandatory keys in request options. 'micro-entitlements' must be present.",f.message=f.description,f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function s(a){var b=this,c=A.defer(),d={description:"",message:""};if(a&&a.ext_user_id&&a.context&&a.feature_key&&a.ext_actor_id&&void 0!==a.audit&&(a.productcode||a.ext_product_id)){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.microEntitleUserToProduct;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f=B["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.description="ext_user_id or context or feature_key or ext_actor_id or audit field not found or is empty in request options. Either productcode or ext_product_id must be provided.",d.message=d.description,d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=A.defer();if(a&&a.ext_product_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getExtProductAPI;d=D.api.constructAPIUrl(d,{accountId:b.accountId,extProductId:a.ext_product_id});var e=B.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_product_id not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=A.defer();if(a&&a.spacekey){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSpaceDetails;d=D.api.constructAPIUrl(d,{accountId:b.accountId,spacekey:a.spacekey});var e={orgid:b.orgId},f=B.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=D.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="spacekey not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function v(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&a.class_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUserInClass;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or ext_role or class_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function w(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserInformation;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f={ext_user_id:a.ext_user_id};a.ref_id&&(f.ref_id=a.ref_id),a.ext_email&&(f.ext_email=a.ext_email),a.ext_first_name&&(f.ext_first_name=a.ext_first_name),a.ext_last_name&&(f.ext_last_name=a.ext_last_name),a.address&&(f.address=a.address);var g=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters not found in request options: ["ext_user_id"]',d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b,c=this,d=A.defer();if(a&&a.extuserid&&a.spacekey&&a.body){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.updateUserSpace;e=D.api.constructAPIUrl(e,{accountid:c.accountId,extuserid:a.extuserid,spacekey:a.spacekey});var f=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(F).end(function(a,c){a?(b=new E(D.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else{var g={};g.message=g.description="Missing mandatory params: 'extuserid' or 'spacekey' or 'body' not found in the request options.",b=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),d.reject(b)}return d.promise}function y(a){var b=this,c=A.defer(),d={};if(a&&a.email){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInvitationsByEmail;e=D.api.constructAPIUrl(e,{accountid:b.accountId});var f={email:a.email};a.status&&(f.status=a.status);var g=B.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="email not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=this,c=A.defer(),d={};if(a&&a.space_code&&a.body&&a.body.ext_actor_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateInstituteTitle;e=D.api.constructAPIUrl(e,{accountId:b.accountId,instituteSpaceCode:a.space_code});var f=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="space_code or ext_actor_id not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var A=a("q"),B=a("superagent"),C=a("agentkeepalive"),D=a("../../helpers"),E=D.errors.DLSError;b.exports=d;var F=new C({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],29:[function(a,b,c){function d(a){return this.accountId=a,{entitleBulkUsersToProducts:e.bind(this)}}function e(a){var b=this,c=f.defer();if(a&&a.users&&a.ext_actor_id){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.entitleBulkUsersToProducts;d=i.api.constructAPIUrl(d,{accountid:b.accountId});var e=g.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(k).end(function(a,b){if(a){var d=new j(i.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var h={};h.description="Mandatory params: 'users', 'ext_actor_id' not found in request options.",h.message=h.description,h=new j(i.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}var f=a("q"),g=a("superagent"),h=a("agentkeepalive"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d;var k=new h({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],30:[function(a,b,c){function d(a){return this.accountId=a,{getAllInstitutions:e.bind(this),getInstitution:f.bind(this),provisionSpacesToSuperAdmin:g.bind(this)}}function e(a){var b=this,c=h.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllInstitutions;d=j.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a&&(a.lookup&&(e.lookup=a.lookup),a.cursor&&(e.cursor=a.cursor),a.limit&&(e.limit=a.limit));var f=i.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function f(a){var b=this,c=h.defer();if(a&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInstitution;d=j.api.constructAPIUrl(d,{accountid:b.accountId,spacecode:a.spacecode});var e=i.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="spacecode not found in request options.",f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=h.defer();if(a&&a.ext_user_id&&a.ext_role&&a.ext_email&&a.ext_first_name&&a.ext_last_name){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToSuperAdmin;d=j.api.constructAPIUrl(d,{accountid:b.accountId});var e=i.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="Missing required input data",f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}var h=a("q"),i=a("superagent"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],31:[function(a,b,c){function d(){return{associateTagsWithEntity:e.bind(this),createTags:f.bind(this),updateTags:g.bind(this),deleteTags:h.bind(this),getTag:i.bind(this),getTagHierarchy:j.bind(this),getAllTags:k.bind(this)}}function e(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.entity_type&&a.entity_id&&a.tags){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.associateTagsWithEntity;e=n.api.constructAPIUrl(e,{orgId:b.orgId});var f=m.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="entity_id or entity_type or tags not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.body&&a.body.tags&&a.body.tags.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f=m.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or body.tags(min. 1 tag) not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.body&&a.body.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={};a.tagid&&(f.tagid=a.tagid);var g=m["delete"](e).query(f);g=n.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!1,tagid:a.tagid},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function j(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!0,tagid:a.tagid},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!0},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var l=a("q"),m=a("superagent"),n=a("../../helpers"),o=n.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],32:[function(a,b,c){function d(a){return this.accountId=a,{createWorkflow:e.bind(this),getAllWorkflow:f.bind(this),getAllWorkflowOfAUser:g.bind(this),getAWorkflow:h.bind(this),acceptAWorkflow:i.bind(this),processAWorkflow:j.bind(this),revokeAWorkflow:k.bind(this),completeAWorkflow:l.bind(this),updateWorkflowRequest:m.bind(this)}}function e(a){var b=this,c=n.defer();if(a&&a.ext_user_id&&a.workflow_type){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.workflows;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e=o.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or workflow_type not found in request options.",f=new q(p.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function f(a){var b=this,c=n.defer();if(a&&a.workflow_type&&a.status){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.workflows;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e={workflow_type:a.workflow_type,status:a.status};a.start&&(e.start=a.start),a.end&&(e.end=a.end),a.cursor&&(e.cursor=a.cursor);var f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function g(a){var b=this,c=n.defer();if(a&&a.workflow_type&&a.status&&a.ext_user_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllWorkflowOfAUser;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e={workflow_type:a.workflow_type,status:a.status,ext_user_id:a.ext_user_id};a.start&&(e.start=a.start),a.end&&(e.end=a.end),a.cursor&&(e.cursor=a.cursor);var f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status, ext_user_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function h(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e={context_id:a.context_id},f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function i(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.acceptAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function j(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id&&a.body.org_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.processAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body, body.context_id, body.org_id in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function k(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.revokeAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function l(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.completeAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function m(a){var b=this,c=n.defer();if(a&&a.context_id&&a.body.ext_user_id&&a.body.workflow_type&&a.workflowid){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e={context_id:a.context_id},f=o.put(d).set("Content-Type","application/json").set("Accept","application/json").query(e).send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b)})}else{var g={};g.message=g.description="context_id or ext_user_id or workflow_type or workflowid not found in request options.",g=new q(p.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}var n=a("q"),o=a("superagent"),p=a("./../../helpers"),q=p.errors.DLSError;b.exports=d},{"./../../helpers":3,q:46,superagent:49}],33:[function(a,b,c){function d(a){return this.accountId=a,{postStatement:e.bind(this),postExternalStatements:f.bind(this),resetUserProductProgress:g.bind(this)}}function e(a){var b,c=this,d=h.defer(),e={};if(e=j.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.XAPI+c.config.XAPI_API_URLS.postMultiStatements,b=j.api.constructAPIUrl(b,{orgId:c.orgId});var f=a,g=i.post(b).send(f);g=j.api.setupAPIToken(g,c.token),c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function f(a){var b=this,c=h.defer(),d=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.postExternalMultiStatements;d=j.api.constructAPIUrl(d,{orgId:b.orgId});var e=i.post(d).send(a);return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function g(a){var b=this,c=h.defer(),d={};if(a&&a.userid&&a.productcode&&a.actorid){var e=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.resetUserProductProgress;e=j.api.constructAPIUrl(e,{accountId:b.accountId});var f=i["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="userid, productcode or actorid not found in request options.",d=new k(j.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var h=a("q"),i=a("superagent"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],34:[function(a,b,c){function d(a,b){var c=this,d=g.defer(),e=j.validateAuthWithExtUser(a,b);if(e)d.reject(e);else{var k=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getExtUserTokenAPI;k=h.api.constructAPIUrl(k,{orgId:a});var l={ext_user_id:b.ext_user_id};f.post(k).send(l).end(function(a,b){if(a)a=new i(h.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var e={access_token:b.body.access_token},f=b.body.user,g={token:e,user:f,metrics:b.body.metrics};c.token=e,c.orgId=f.org.id,d.resolve(g)}})}return d.promise}function e(a,b,c){var d=this,e=g.defer(),f=j.authWithToken(a,b,c);return f?e.reject(f):(d.token=b,d.orgId=a,c&&c.getuserdetails?d.Auth().getUserProfile().then(function(a){var b={token:d.token,user:a};e.resolve(b)},function(a){a=new i(h.errors.ERROR_TYPES.API_ERROR,a),e.reject(a)}):e.resolve(d.token)),e.promise}var f=a("superagent"),g=a("q"),h=a("../helpers"),i=h.errors.DLSError,j=a("./validations");c.authWithExtUser=d,c.authWithToken=e},{"../helpers":3,"./validations":35,q:46,superagent:49}],35:[function(a,b,c){function d(a,b,c){var d={organization:a,token:b,options:c},e={organization:{isString:!0,presence:!0},token:{isObject:!0,presence:!0,contains:["access_token"]},"token.access_token":{isString:!0,presence:!0},options:{isObject:!0}};return f(d,e)}function e(a,b){var c={organization:a,options:b},d={organization:{isString:!0,presence:!0},options:{isObject:!0,presence:!0,contains:["ext_user_id"]},"options.ext_user_id":{isString:!0,presence:!0}};return f(c,d)}var f=a("../helpers").validations.validate;c.authWithToken=d,c.validateAuthWithExtUser=e},{"../helpers":3}],36:[function(a,b,c){function d(){}b.exports=d,b.exports.HttpsAgent=d},{}],37:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:b<i?-1:b<i+10?b-i+26+26:b<k+26?b-k:b<j+26?b-j+26:void 0;
8
- }function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;d<g;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;e<g;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],38:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,b<0?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;c<b;c++)a[c]=0;return a}function h(a,b,c){"string"==typeof c&&""!==c||(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;e<d;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),b<0&&(b=0),c>this.length&&(c=this.length),c<=b)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;g<d;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;e<c;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(e+h<=c){var i,j,k,l;switch(h){case 1:f<128&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(l<55296||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&l<1114112&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if(b<=$)return String.fromCharCode.apply(String,a);for(var c="",d=0;d<b;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||b<0)&&(b=0),(!c||c<0||c>d)&&(c=d);for(var e="",f=b;f<c;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function H(a,b,c){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||b<g)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){b<0&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);e<f;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){b<0&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);e<f;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||b<f)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(c<0)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return a<16?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;g<d;g++){if(c=a.charCodeAt(g),c>55295&&c<57344){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(c<56320){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,c<128){if((b-=1)<0)break;f.push(c)}else if(c<2048){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(c<65536){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(c<1114112))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function T(a,b){for(var c,d,e,f=[],g=0;g<a.length&&!((b-=2)<0);g++)c=a.charCodeAt(g),d=c>>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;e<d&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);e<g&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),c<d?-1:d<c?1:0},f.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var d=new f(b),e=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(d,e),e+=g.length}return d},f.byteLength=s,f.prototype.toString=function(){var a=0|this.length;return 0===a?"":0===arguments.length?B(this,0,a):t.apply(this,arguments)},f.prototype.equals=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a||0===f.compare(this,a)},f.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),"<Buffer "+a+">"},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e<a.length;e++)if(a[c+e]===b[d===-1?0:e-d]){if(d===-1&&(d=e),e-d+1===b.length)return c+d}else d=-1;return-1}if(b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(b<0&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(c<0||b<0)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,a<0?(a+=c,a<0&&(a=0)):a>c&&(a=c),b<0?(b+=c,b<0&&(b=0)):b>c&&(b=c),b<a&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,(void 0));for(var g=0;g<e;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return d},f.prototype.readUIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a+--b],e=1;b>0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return e*=128,d>=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?(255-this[a]+1)*-1:this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f<c&&(e*=256);)this[b+f]=a/e&255;return b+c},f.prototype.writeUIntBE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=c-1,f=1;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=a<0?1:0;for(this[b]=255&a;++f<c&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=a<0?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),a<0&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&d<c&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(b<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("sourceStart out of bounds");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-b<d-c&&(d=a.length-b+c);var e,g=d-c;if(this===a&&c<b&&b<d)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(g<1e3||!f.TYPED_ARRAY_SUPPORT)for(e=0;e<g;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),c<b)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(b<0||b>=this.length)throw new RangeError("start out of bounds");if(c<0||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;d<c;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;d<c;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;b<c;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":37,ieee754:43,isarray:39}],39:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],40:[function(a,b,c){function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}"undefined"!=typeof b&&(b.exports=d),d.prototype.on=d.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=d.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks["$"+a];if(!c)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var d,e=0;e<c.length;e++)if(d=c[e],d===b||d.fn===b){c.splice(e,1);break}return 0===c.length&&delete this._callbacks["$"+a],this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){c=c.slice(0);for(var d=0,e=c.length;d<e;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],41:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||a<0||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;i<d;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(d<0)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],42:[function(a,b,c){"use strict";var d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=Object.defineProperty,g=Object.getOwnPropertyDescriptor,h=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===e.call(a)},i=function(a){if(!a||"[object Object]"!==e.call(a))return!1;var b=d.call(a,"constructor"),c=a.constructor&&a.constructor.prototype&&d.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!b&&!c)return!1;var f;for(f in a);return"undefined"==typeof f||d.call(a,f)},j=function(a,b){f&&"__proto__"===b.name?f(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},k=function(a,b){if("__proto__"===b){if(!d.call(a,b))return;if(g)return g(a,b).value}return a[b]};b.exports=function l(){var a,b,c,d,e,f,g=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof g&&(o=g,g=arguments[1]||{},m=2),(null==g||"object"!=typeof g&&"function"!=typeof g)&&(g={});m<n;++m)if(a=arguments[m],null!=a)for(b in a)c=k(g,b),d=k(a,b),g!==d&&(o&&d&&(i(d)||(e=h(d)))?(e?(e=!1,f=c&&h(c)?c:[]):f=c&&i(c)?c:{},j(g,{name:b,newValue:l(o,f,d)})):"undefined"!=typeof d&&j(g,{name:b,newValue:d}));return g}},{}],43:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=b<0||0===b&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],44:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],45:[function(b,c,d){(function(b,e){!function(b,e){"object"==typeof d&&"undefined"!=typeof c?c.exports=e():"function"==typeof a&&a.amd?a(e):(b="undefined"!=typeof globalThis?globalThis:b||self).PubNub=e()}(this,function(){"use strict";function a(a,b){function c(){this.constructor=a}if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");Z(a,b),a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function c(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){var b;a.done?e(a.value):(b=a.value,b instanceof c?b:new c(function(a){a(b)})).then(g,h)}i((d=d.apply(a,b||[])).next())})}function d(a,b){function c(a){return function(c){return function(a){if(d)throw new TypeError("Generator is already executing.");for(;h;)try{if(d=1,e&&(f=2&a[0]?e["return"]:a[0]?e["throw"]||((f=e["return"])&&f.call(e),0):e.next)&&!(f=f.call(e,a[1])).done)return f;switch(e=0,f&&(a=[2&a[0],f.value]),a[0]){case 0:case 1:f=a;break;case 4:return h.label++,{value:a[1],done:!1};case 5:h.label++,e=a[1],a=[0];continue;case 7:a=h.ops.pop(),h.trys.pop();continue;default:if(f=h.trys,!((f=f.length>0&&f[f.length-1])||6!==a[0]&&2!==a[0])){h=0;continue}if(3===a[0]&&(!f||a[1]>f[0]&&a[1]<f[3])){h.label=a[1];break}if(6===a[0]&&h.label<f[1]){h.label=f[1],f=a;break}if(f&&h.label<f[2]){h.label=f[2],h.ops.push(a);break}f[2]&&h.ops.pop(),h.trys.pop();continue}a=b.call(c,h)}catch(c){a=[6,c],e=0}finally{d=f=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}var d,e,f,g,h={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return g={next:c(0),"throw":c(1),"return":c(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g}function f(a){var b="function"==typeof Symbol&&Symbol.iterator,c=b&&a[b],d=0;if(c)return c.call(a);if(a&&"number"==typeof a.length)return{next:function(){return a&&d>=a.length&&(a=void 0),{value:a&&a[d++],done:!a}}};throw new TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(a,b){var c="function"==typeof Symbol&&a[Symbol.iterator];if(!c)return a;var d,e,f=c.call(a),g=[];try{for(;(void 0===b||b-- >0)&&!(d=f.next()).done;)g.push(d.value)}catch(a){e={error:a}}finally{try{d&&!d.done&&(c=f["return"])&&c.call(f)}finally{if(e)throw e.error}}return g}function h(a,b,c){if(c||2===arguments.length)for(var d,e=0,f=b.length;e<f;e++)!d&&e in b||(d||(d=Array.prototype.slice.call(b,0,e)),d[e]=b[e]);return a.concat(d||Array.prototype.slice.call(b))}function i(a){var b,c=[];for(b=0;b<a.length;b+=1)c[b/4|0]|=a[b]<<24-8*b;return pa.lib.WordArray.create(c,a.length)}function j(a){return encodeURIComponent(a).replace(/[!~*'()]/g,function(a){return"%".concat(a.charCodeAt(0).toString(16).toUpperCase())})}function k(a){return function(a){var b=[];return Object.keys(a).forEach(function(a){return b.push(a)}),b}(a).sort()}function l(a){return(b={message:a}).type="validationError",b.error=!0,b;var b}function m(a,b,c){return a.usePost&&a.usePost(b,c)?a.postURL(b,c):a.usePatch&&a.usePatch(b,c)?a.patchURL(b,c):a.useGetFile&&a.useGetFile(b,c)?a.getFileURL(b,c):a.getURL(b,c)}function n(a){if(a.sdkName)return a.sdkName;var b="PubNub-JS-".concat(a.sdkFamily);
9
- a.partnerId&&(b+="-".concat(a.partnerId)),b+="/".concat(a.getVersion());var c=a._getPnsdkSuffix(" ");return c.length>0&&(b+=c),b}function o(a,b,c){return b.usePost&&b.usePost(a,c)?"POST":b.usePatch&&b.usePatch(a,c)?"PATCH":b.useDelete&&b.useDelete(a,c)?"DELETE":b.useGetFile&&b.useGetFile(a,c)?"GETFILE":"GET"}function p(a,b,c,d,e){var f=a.config,g=a.crypto,h=o(a,e,d);c.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===e.getOperation()&&e.usePost&&e.usePost(a,d)&&(h="GET"),"GETFILE"===h&&(h="GET");var i="".concat(h,"\n").concat(f.publishKey,"\n").concat(b,"\n").concat(ta.signPamFromParams(c),"\n");if("POST"===h)i+="string"==typeof(j=e.postPayload(a,d))?j:JSON.stringify(j);else if("PATCH"===h){var j;i+="string"==typeof(j=e.patchPayload(a,d))?j:JSON.stringify(j)}var k="v2.".concat(g.HMACSHA256(i));k=(k=(k=k.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),c.signature=k}function q(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];var e=a.networking,f=a.config,g=a.telemetryManager,h=a.tokenManager,i=ja(),j=null,k=null,q={};b.getOperation()===wa.PNTimeOperation||b.getOperation()===wa.PNChannelGroupsOperation?j=c[0]:(q=c[0],j=c[1]),"undefined"==typeof Promise||j||(k=ta.createPromise());var r=b.validateParams(a,q);if(r)return j?j(l(r)):k?(k.reject(new Fa("Validation failed, check status for details",l(r))),k.promise):void 0;var s,t=b.prepareParams(a,q),u=m(b,a,q),v={url:u,operation:b.getOperation(),timeout:b.getRequestTimeout(a),headers:b.getRequestHeaders?b.getRequestHeaders():{},ignoreBody:"function"==typeof b.ignoreBody&&b.ignoreBody(a),forceBuffered:"function"==typeof b.forceBuffered?b.forceBuffered(a,q):null,abortSignal:"function"==typeof b.getAbortSignal?b.getAbortSignal(a,q):null};t.uuid=f.UUID,t.pnsdk=n(f);var w=g.operationsLatencyForRequest();if(Object.keys(w).length&&(t=$($({},t),w)),f.useInstanceId&&(t.instanceid=f.instanceId),f.useRequestId&&(t.requestid=i),b.isAuthSupported()){var x=h.getToken()||f.getAuthKey();x&&(t.auth=x)}f.secretKey&&p(a,u,t,q,b);var y=function(c,d){if(c.error)return b.handleError&&b.handleError(a,q,c),void(j?j(c):k&&k.reject(new Fa("PubNub call failed, check status for details",c)));g.stopLatencyMeasure(b.getOperation(),i);var e=b.handleResponse(a,d,q);"function"!=typeof(null==e?void 0:e.then)&&(e=Promise.resolve(e)),e.then(function(a){j?j(c,a):k&&k.fulfill(a)})["catch"](function(a){if(j){var c=a;b.getOperation()===wa.PNSubscribeOperation&&(c={statusCode:400,error:!0,operation:b.getOperation(),errorData:a,category:ua.PNUnknownCategory}),j(c,null)}else k&&k.reject(new Fa("PubNub call failed, check status for details",a))})};if(g.startLatencyMeasure(b.getOperation(),i),"POST"===o(a,b,q)){var z=b.postPayload(a,q);s=e.POST(t,z,v,y)}else"PATCH"===o(a,b,q)?(z=b.patchPayload(a,q),s=e.PATCH(t,z,v,y)):s="DELETE"===o(a,b,q)?e.DELETE(t,v,y):"GETFILE"===o(a,b,q)?e.GETFILE(t,v,y):e.GET(t,v,y);return b.getOperation()===wa.PNSubscribeOperation?s:k?k.promise:void 0}function r(a){var b=0;return a.join&&(b|=128),a.update&&(b|=64),a.get&&(b|=32),a["delete"]&&(b|=8),a.manage&&(b|=4),a.write&&(b|=2),a.read&&(b|=1),b}function s(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e}function t(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function u(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:null==b?void 0:b.apply(void 0,h([],g(c),!1))}};return c.type=a,c}function v(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:b.apply(void 0,h([],g(c),!1)),managed:!0}};return c.type=a,c.cancel={type:"CANCEL",payload:a,managed:!1},c}function w(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function x(a,b,c,d){var e;void 0===d&&(d=w()),z(a,"",0,[],void 0,0,d);try{e=0===xc.length?JSON.stringify(a,b,c):JSON.stringify(a,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var f=wc.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}}return e}function y(a,b,c,d){var e=Object.getOwnPropertyDescriptor(d,c);void 0!==e.get?e.configurable?(Object.defineProperty(d,c,{value:a}),wc.push([d,c,b,e])):xc.push([b,c,a]):(d[c]=a,wc.push([d,c,b]))}function z(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void y(vc,a,b,e);if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)z(a[h],h,h,d,a,f,g);else{var i=Object.keys(a);for(h=0;h<i.length;h++){var j=i[h];z(a[j],j,h,d,a,f,g)}}d.pop()}}function A(a,b){return a<b?-1:a>b?1:0}function B(a,b,c,d){void 0===d&&(d=w());var e,f=C(a,"",0,[],void 0,0,d)||a;try{e=0===xc.length?JSON.stringify(f,b,c):JSON.stringify(f,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var g=wc.pop();4===g.length?Object.defineProperty(g[0],g[1],g[3]):g[0][g[1]]=g[2]}}return e}function C(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void y(vc,a,b,e);try{if("function"==typeof a.toJSON)return}catch(a){return}if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)C(a[h],h,h,d,a,f,g);else{var i={},j=Object.keys(a).sort(A);for(h=0;h<j.length;h++){var k=j[h];C(a[k],k,h,d,a,f,g),i[k]=a[k]}if(void 0===e)return i;wc.push([e,b,a]),e[b]=i}d.pop()}}function D(a){return a=void 0!==a?a:function(a,b){return b},function(b,c){if(xc.length>0)for(var d=0;d<xc.length;d++){var e=xc[d];if(e[1]===b&&e[0]===c){c=e[2],xc.splice(d,1);break}}return a.call(this,b,c)}}function E(a){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function F(a){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function G(a){if(a)return function(a){for(var b in G.prototype)Object.prototype.hasOwnProperty.call(G.prototype,b)&&(a[b]=G.prototype[b]);return a}(a)}function H(a,b){var c;if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(c=function(a,b){if(a){if("string"==typeof a)return I(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?I(a,b):void 0}}(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:e}}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 f,g=!0,h=!1;return{s:function(){c=a[Symbol.iterator]()},n:function(){var a=c.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function I(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function J(a){if(a)return function(a){for(var b in J.prototype)Object.prototype.hasOwnProperty.call(J.prototype,b)&&(a[b]=J.prototype[b]);return a}(a)}function K(a){return function(a){if(Array.isArray(a))return L(a)}(a)||function(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}(a)||function(a,b){if(a){if("string"==typeof a)return L(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?L(a,b):void 0}}(a)||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 L(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function M(){this._defaults=[]}function N(a){var b=(new Date).getTime(),c=(new Date).toISOString(),d=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;d.log("<<<<<"),d.log("[".concat(c,"]"),"\n",a.url,"\n",a.qs),d.log("-----"),a.on("response",function(c){var e=(new Date).getTime()-b,f=(new Date).toISOString();d.log(">>>>>>"),d.log("[".concat(f," / ").concat(e,"]"),"\n",a.url,"\n",a.qs,"\n",c.text),d.log("-----")})}function O(a,b,c){var d=this;this._config.logVerbosity&&(a=a.use(N)),this._config.proxy&&this._modules.proxy&&(a=this._modules.proxy.call(this,a)),this._config.keepAlive&&this._modules.keepAlive&&(a=this._modules.keepAlive(a));var e=a;if(b.abortSignal)var f=b.abortSignal.subscribe(function(){e.abort(),f()});return!0===b.forceBuffered?e="undefined"==typeof Blob?e.buffer().responseType("arraybuffer"):e.responseType("arraybuffer"):!1===b.forceBuffered&&(e=e.buffer(!1)),(e=e.timeout(b.timeout)).on("abort",function(){return c({category:ua.PNUnknownCategory,error:!0,operation:b.operation,errorData:new Error("Aborted")},null)}),e.end(function(a,b){var e,f={};if(f.error=null!==a,f.operation=g.operation,b&&b.status&&(f.statusCode=b.status),a){if(a.response&&a.response.text&&!d._config.logVerbosity)try{f.errorData=JSON.parse(a.response.text)}catch(g){f.errorData=a}else f.errorData=a;return f.category=d._detectErrorCategory(a),c(f,null)}if(g.ignoreBody)e={headers:b.headers,redirects:b.redirects,response:b};else try{e=JSON.parse(b.text)}catch(a){return f.errorData=b,f.error=!0,c(f,null)}return e.error&&1===e.error&&e.status&&e.message&&e.service?(f.errorData=e,f.statusCode=e.status,f.error=!0,f.category=d._detectErrorCategory(f),c(f,null)):(e.error&&e.error.message&&(f.errorData=e.error),c(f,e))}),e}function P(a,b,e){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return c=kd.post(a),b.forEach(function(a){var b=a.key,d=a.value;c=c.field(b,d)}),c.attach("file",e,{contentType:"application/octet-stream"}),[4,c];case 1:return[2,d.sent()]}})})}function Q(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function R(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function S(a,b,c,d){var e=kd.post(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function T(a,b,c,d){var e=kd.patch(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function U(a,b,c){var d=kd["delete"](this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function V(a,b){var c=new Uint8Array(a.byteLength+b.byteLength);return c.set(new Uint8Array(a),0),c.set(new Uint8Array(b),a.byteLength),c.buffer}function W(a){return!(!navigator||!navigator.sendBeacon)&&void navigator.sendBeacon(a)}function X(a){for(var b=pa.enc.Base64.parse(a).words,c=new ArrayBuffer(4*b.length),d=new Uint8Array(c),e=0,f=0,g=0;g<b.length;g+=1){var h=b[g];d[f=4*g]=(4278190080&h)>>24,d[f+1]=(16711680&h)>>16,d[f+2]=(65280&h)>>8,d[f+3]=255&h}for(var i=f+3;i>=f;i-=1)0===d[i]&&e<3&&(e+=1);return e>0?d.buffer.slice(0,d.byteLength-e):d.buffer}function Y(a){var b=function(a){return a&&"object"==typeof a&&a.constructor===Object};if(!b(a))return a;var c={};return Object.keys(a).forEach(function(d){var e=function(a){return"string"==typeof a||a instanceof String}(d),f=d,g=a[d];Array.isArray(d)||e&&d.indexOf(",")>=0?f=(e?d.split(","):d).reduce(function(a,b){return a+=String.fromCharCode(b)},""):(function(a){return"number"==typeof a&&isFinite(a)}(d)||e&&!isNaN(d))&&(f=String.fromCharCode(e?parseInt(d,10):10)),c[f]=b(g)?Y(g):g}),c}var Z=function(a,b){return(Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])})(a,b)},$=function(){return $=Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c])Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},$.apply(this,arguments)},_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof b?b:"undefined"!=typeof self?self:{},aa={exports:{}};!function(a){!function(b,c){var d=Math.pow(2,-24),e=Math.pow(2,32),f=Math.pow(2,53),g={encode:function(a){function b(a){for(var b=k.byteLength,c=m+a;b<c;)b*=2;if(b!==k.byteLength){var d=l;k=new ArrayBuffer(b),l=new DataView(k);for(var e=m+3>>2,f=0;f<e;++f)l.setUint32(4*f,d.getUint32(4*f))}return j=a,l}function d(){m+=j}function g(a){d(b(1).setUint8(m,a))}function h(a){for(var c=b(a.length),e=0;e<a.length;++e)c.setUint8(m+e,a[e]);d()}function i(a,c){c<24?g(a<<5|c):c<256?(g(a<<5|24),g(c)):c<65536?(g(a<<5|25),function(a){d(b(2).setUint16(m,a))}(c)):c<4294967296?(g(a<<5|26),function(a){d(b(4).setUint32(m,a))}(c)):(g(a<<5|27),function(a){var c=a%e,f=(a-c)/e,g=b(8);g.setUint32(m,f),g.setUint32(m+4,c),d()}(c))}var j,k=new ArrayBuffer(256),l=new DataView(k),m=0;if(function q(a){var e;if(!1===a)return g(244);if(!0===a)return g(245);if(null===a)return g(246);if(a===c)return g(247);switch(typeof a){case"number":if(Math.floor(a)===a){if(0<=a&&a<=f)return i(0,a);if(-f<=a&&a<0)return i(1,-(a+1))}return g(251),function(a){d(b(8).setFloat64(m,a))}(a);case"string":var j=[];for(e=0;e<a.length;++e){var k=a.charCodeAt(e);k<128?j.push(k):k<2048?(j.push(192|k>>6),j.push(128|63&k)):k<55296?(j.push(224|k>>12),j.push(128|k>>6&63),j.push(128|63&k)):(k=(1023&k)<<10,k|=1023&a.charCodeAt(++e),k+=65536,j.push(240|k>>18),j.push(128|k>>12&63),j.push(128|k>>6&63),j.push(128|63&k))}return i(3,j.length),h(j);default:var l;if(Array.isArray(a))for(i(4,l=a.length),e=0;e<l;++e)q(a[e]);else if(a instanceof Uint8Array)i(2,a.length),h(a);else{var n=Object.keys(a);for(i(5,l=n.length),e=0;e<l;++e){var o=n[e];q(o),q(a[o])}}}}(a),"slice"in k)return k.slice(0,m);for(var n=new ArrayBuffer(m),o=new DataView(n),p=0;p<m;++p)o.setUint8(p,l.getUint8(p));return n},decode:function(a,b,f){function g(a,b){return q+=b,a}function h(b){return g(new Uint8Array(a,q,b),b)}function i(){return g(p.getUint8(q),1)}function j(){return g(p.getUint16(q),2)}function k(){return g(p.getUint32(q),4)}function l(){return 255===p.getUint8(q)&&(q+=1,!0)}function m(a){if(a<24)return a;if(24===a)return i();if(25===a)return j();if(26===a)return k();if(27===a)return k()*e+k();if(31===a)return-1;throw"Invalid length encoding"}function n(a){var b=i();if(255===b)return-1;var c=m(31&b);if(c<0||b>>5!==a)throw"Invalid indefinite length element";return c}function o(a,b){for(var c=0;c<b;++c){var d=i();128&d&&(d<224?(d=(31&d)<<6|63&i(),b-=1):d<240?(d=(15&d)<<12|(63&i())<<6|63&i(),b-=2):(d=(15&d)<<18|(63&i())<<12|(63&i())<<6|63&i(),b-=3)),d<65536?a.push(d):(d-=65536,a.push(55296|d>>10),a.push(56320|1023&d))}}var p=new DataView(a),q=0;"function"!=typeof b&&(b=function(a){return a}),"function"!=typeof f&&(f=function(){return c});var r=function s(){var a,e,k=i(),r=k>>5,t=31&k;if(7===r)switch(t){case 25:return function(){var a=new ArrayBuffer(4),b=new DataView(a),c=j(),e=32768&c,f=31744&c,g=1023&c;if(31744===f)f=261120;else if(0!==f)f+=114688;else if(0!==g)return g*d;return b.setUint32(0,e<<16|f<<13|g<<13),b.getFloat32(0)}();case 26:return g(p.getFloat32(q),4);case 27:return g(p.getFloat64(q),8)}if((e=m(t))<0&&(r<2||6<r))throw"Invalid length";switch(r){case 0:return e;case 1:return-1-e;case 2:if(e<0){for(var u=[],v=0;(e=n(r))>=0;)v+=e,u.push(h(e));var w=new Uint8Array(v),x=0;for(a=0;a<u.length;++a)w.set(u[a],x),x+=u[a].length;return w}return h(e);case 3:var y=[];if(e<0)for(;(e=n(r))>=0;)o(y,e);else o(y,e);return String.fromCharCode.apply(null,y);case 4:var z;if(e<0)for(z=[];!l();)z.push(s());else for(z=new Array(e),a=0;a<e;++a)z[a]=s();return z;case 5:var A={};for(a=0;a<e||e<0&&!l();++a)A[s()]=s();return A;case 6:return b(s(),e);case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return c;default:return f(e)}}}();if(q!==a.byteLength)throw"Remaining bytes";return r}};a.exports?a.exports=g:b.CBOR||(b.CBOR=g)}(_)}(aa);var ba=aa.exports,ca={exports:{}};!function(a,b){!function(a){function b(){var a,b,c="";for(a=0;a<32;a++)b=16*Math.random()|0,8!==a&&12!==a&&16!==a&&20!==a||(c+="-"),c+=(12===a?4:16===a?3&b|8:b).toString(16);return c}function c(a,b){var c=e[b||"all"];return c&&c.test(a)||!1}var d="0.1.0",e={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};b.isUUID=c,b.VERSION=d,a.uuid=b,a.isUUID=c}(b),null!==a&&(a.exports=b.uuid)}(ca,ca.exports);var da,ea,fa,ga,ha,ia=ca.exports,ja=function(){return ia.uuid?ia.uuid():ia()},ka=function(){function a(a){var b,c,d,e=a.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(ja()),this.secretKey=e.secretKey||e.secret_key,this.subscribeKey=e.subscribeKey||e.subscribe_key,this.publishKey=e.publishKey||e.publish_key,this.sdkName=e.sdkName,this.sdkFamily=e.sdkFamily,this.partnerId=e.partnerId,this.setAuthKey(e.authKey),this.setCipherKey(e.cipherKey),this.setFilterExpression(e.filterExpression),"string"!=typeof e.origin&&!Array.isArray(e.origin)&&void 0!==e.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");this.origin=e.origin||Array.from({length:20},function(a,b){return"ps".concat(b+1,".pndsn.com")}),this.secure=e.ssl||!1,this.restore=e.restore||!1,this.proxy=e.proxy,this.keepAlive=e.keepAlive,this.keepAliveSettings=e.keepAliveSettings,this.autoNetworkDetection=e.autoNetworkDetection||!1,this.dedupeOnSubscribe=e.dedupeOnSubscribe||!1,this.maximumCacheSize=e.maximumCacheSize||100,this.customEncrypt=e.customEncrypt,this.customDecrypt=e.customDecrypt,this.fileUploadPublishRetryLimit=null!==(b=e.fileUploadPublishRetryLimit)&&void 0!==b?b:5,this.useRandomIVs=null===(c=e.useRandomIVs)||void 0===c||c,this.enableSubscribeBeta=null!==(d=e.enableSubscribeBeta)&&void 0!==d&&d,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=e.logVerbosity||!1,this.suppressLeaveEvents=e.suppressLeaveEvents||!1,this.announceFailedHeartbeats=e.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=e.announceSuccessfulHeartbeats||!1,this.useInstanceId=e.useInstanceId||!1,this.useRequestId=e.useRequestId||!1,this.requestMessageCountThreshold=e.requestMessageCountThreshold,this.setTransactionTimeout(e.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(e.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(e.useSendBeacon||!0),e.presenceTimeout?this.setPresenceTimeout(e.presenceTimeout):this._presenceTimeout=300,null!=e.heartbeatInterval&&this.setHeartbeatInterval(e.heartbeatInterval),this.setUUID(e.uuid)}return a.prototype.getAuthKey=function(){return this.authKey},a.prototype.setAuthKey=function(a){return this.authKey=a,this},a.prototype.setCipherKey=function(a){return this.cipherKey=a,this},a.prototype.getUUID=function(){return this.UUID},a.prototype.setUUID=function(a){if(!a||"string"!=typeof a||0===a.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=a,this},a.prototype.getFilterExpression=function(){return this.filterExpression},a.prototype.setFilterExpression=function(a){return this.filterExpression=a,this},a.prototype.getPresenceTimeout=function(){return this._presenceTimeout},a.prototype.setPresenceTimeout=function(a){return a>=20?this._presenceTimeout=a:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},a.prototype.setProxy=function(a){this.proxy=a},a.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},a.prototype.setHeartbeatInterval=function(a){return this._heartbeatInterval=a,this},a.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},a.prototype.setSubscribeTimeout=function(a){return this._subscribeRequestTimeout=a,this},a.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},a.prototype.setTransactionTimeout=function(a){return this._transactionalRequestTimeout=a,this},a.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},a.prototype.setSendBeaconConfig=function(a){return this._useSendBeacon=a,this},a.prototype.getVersion=function(){return"7.0.1"},a.prototype._addPnsdkSuffix=function(a,b){this._PNSDKSuffix[a]=b},a.prototype._getPnsdkSuffix=function(a){var b=this;return Object.keys(this._PNSDKSuffix).reduce(function(c,d){return c+a+b._PNSDKSuffix[d]},"")},a}(),la=la||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,b){a=this.words=a||[],this.sigBytes=null!=b?b:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e<a;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-e%4*8&255)<<24-(d+e)%4*8;else if(65535<c.length)for(e=0;e<a;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d<b;d+=4)c.push(4294967296*a.random()|0);return new g.init(c,b)}}),h=c.enc={},i=h.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++){var e=b[d>>>2]>>>24-d%4*8&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-d%4*8&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f);if(b=(h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0))*f,e=a.min(4*b,e),b){for(var i=0;i<b;i+=f)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return new g.init(i,e)},clone:function(){var a=f.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=l.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}});var m=c.algo={};return c}(Math);!function(a){for(var b=la,c=(e=b.lib).WordArray,d=e.Hasher,e=b.algo,f=[],g=[],h=function(a){return 4294967296*(a-(0|a))|0},i=2,j=0;64>j;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[];e=e.SHA256=d.extend({_doReset:function(){this._hash=new c.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[14+(e+64>>>9<<4)]=a.floor(d/4294967296),c[15+(e+64>>>9<<4)]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}}),b.SHA256=d._createHelper(e),b.HmacSHA256=d._createHmacHelper(e)}(Math),ea=(da=la).enc.Utf8,da.algo.HMAC=da.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=ea.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),f=this._iKey=b.clone(),g=e.words,h=f.words,i=0;i<c;i++)g[i]^=1549556828,h[i]^=909522486;e.sigBytes=f.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher;return a=b.finalize(a),b.reset(),b.finalize(this._oKey.clone().concat(a))}}),ga=(fa=la).lib.WordArray,fa.enc.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp(),a=[];for(var e=0;e<c;e+=3)for(var f=(b[e>>>2]>>>24-e%4*8&255)<<16|(b[e+1>>>2]>>>24-(e+1)%4*8&255)<<8|b[e+2>>>2]>>>24-(e+2)%4*8&255,g=0;4>g&&e+.75*g<c;g++)a.push(d.charAt(f>>>6*(3-g)&63));if(b=d.charAt(64))for(;a.length%4;)a.push(b);return a.join("")},parse:function(a){var b=a.length,c=this._map;(d=c.charAt(64))&&-1!=(d=a.indexOf(d))&&(b=d);for(var d=[],e=0,f=0;f<b;f++)if(f%4){var g=c.indexOf(a.charAt(f-1))<<f%4*2,h=c.indexOf(a.charAt(f))>>>6-f%4*2;d[e>>>2]|=(g|h)<<24-e%4*8,e++}return ga.create(d,e)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(a){function b(a,b,c,d,e,f,g){return((a=a+(b&c|~b&d)+e+g)<<f|a>>>32-f)+b}function c(a,b,c,d,e,f,g){return((a=a+(b&d|c&~d)+e+g)<<f|a>>>32-f)+b}function d(a,b,c,d,e,f,g){return((a=a+(b^c^d)+e+g)<<f|a>>>32-f)+b}function e(a,b,c,d,e,f,g){return((a=a+(c^(b|~d))+e+g)<<f|a>>>32-f)+b}for(var f=la,g=(i=f.lib).WordArray,h=i.Hasher,i=f.algo,j=[],k=0;64>k;k++)j[k]=4294967296*a.abs(a.sin(k+1))|0;i=i.MD5=h.extend({_doReset:function(){this._hash=new g.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=a[i=f+g];a[i]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}g=this._hash.words;var i=a[f+0],k=(h=a[f+1],a[f+2]),l=a[f+3],m=a[f+4],n=a[f+5],o=a[f+6],p=a[f+7],q=a[f+8],r=a[f+9],s=a[f+10],t=a[f+11],u=a[f+12],v=a[f+13],w=a[f+14],x=a[f+15],y=b(y=g[0],B=g[1],A=g[2],z=g[3],i,7,j[0]),z=b(z,y,B,A,h,12,j[1]),A=b(A,z,y,B,k,17,j[2]),B=b(B,A,z,y,l,22,j[3]);y=b(y,B,A,z,m,7,j[4]),z=b(z,y,B,A,n,12,j[5]),A=b(A,z,y,B,o,17,j[6]),B=b(B,A,z,y,p,22,j[7]),y=b(y,B,A,z,q,7,j[8]),z=b(z,y,B,A,r,12,j[9]),A=b(A,z,y,B,s,17,j[10]),B=b(B,A,z,y,t,22,j[11]),y=b(y,B,A,z,u,7,j[12]),z=b(z,y,B,A,v,12,j[13]),A=b(A,z,y,B,w,17,j[14]),y=c(y,B=b(B,A,z,y,x,22,j[15]),A,z,h,5,j[16]),z=c(z,y,B,A,o,9,j[17]),A=c(A,z,y,B,t,14,j[18]),B=c(B,A,z,y,i,20,j[19]),y=c(y,B,A,z,n,5,j[20]),z=c(z,y,B,A,s,9,j[21]),A=c(A,z,y,B,x,14,j[22]),B=c(B,A,z,y,m,20,j[23]),y=c(y,B,A,z,r,5,j[24]),z=c(z,y,B,A,w,9,j[25]),A=c(A,z,y,B,l,14,j[26]),B=c(B,A,z,y,q,20,j[27]),y=c(y,B,A,z,v,5,j[28]),z=c(z,y,B,A,k,9,j[29]),A=c(A,z,y,B,p,14,j[30]),y=d(y,B=c(B,A,z,y,u,20,j[31]),A,z,n,4,j[32]),z=d(z,y,B,A,q,11,j[33]),A=d(A,z,y,B,t,16,j[34]),B=d(B,A,z,y,w,23,j[35]),y=d(y,B,A,z,h,4,j[36]),z=d(z,y,B,A,m,11,j[37]),A=d(A,z,y,B,p,16,j[38]),B=d(B,A,z,y,s,23,j[39]),y=d(y,B,A,z,v,4,j[40]),z=d(z,y,B,A,i,11,j[41]),A=d(A,z,y,B,l,16,j[42]),B=d(B,A,z,y,o,23,j[43]),y=d(y,B,A,z,r,4,j[44]),z=d(z,y,B,A,u,11,j[45]),A=d(A,z,y,B,x,16,j[46]),y=e(y,B=d(B,A,z,y,k,23,j[47]),A,z,i,6,j[48]),z=e(z,y,B,A,p,10,j[49]),A=e(A,z,y,B,w,15,j[50]),B=e(B,A,z,y,n,21,j[51]),y=e(y,B,A,z,u,6,j[52]),z=e(z,y,B,A,l,10,j[53]),A=e(A,z,y,B,s,15,j[54]),B=e(B,A,z,y,h,21,j[55]),y=e(y,B,A,z,q,6,j[56]),z=e(z,y,B,A,x,10,j[57]),A=e(A,z,y,B,o,15,j[58]),B=e(B,A,z,y,v,21,j[59]),y=e(y,B,A,z,m,6,j[60]),z=e(z,y,B,A,t,10,j[61]),A=e(A,z,y,B,k,15,j[62]),B=e(B,A,z,y,r,21,j[63]),g[0]=g[0]+y|0,g[1]=g[1]+B|0,g[2]=g[2]+A|0,g[3]=g[3]+z|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296);for(c[15+(e+64>>>9<<4)]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[14+(e+64>>>9<<4)]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),b.sigBytes=4*(c.length+1),this._process(),c=(b=this._hash).words,d=0;4>d;d++)e=c[d],c[d]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8);return b},clone:function(){var a=h.clone.call(this);return a._hash=this._hash.clone(),a}}),f.MD5=h._createHelper(i),f.HmacMD5=h._createHmacHelper(i)}(Math),function(){var a,b=la,c=(a=b.lib).Base,d=a.WordArray,e=(a=b.algo).EvpKDF=c.extend({cfg:c.extend({keySize:4,hasher:a.MD5,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){for(var c=(h=this.cfg).hasher.create(),e=d.create(),f=e.words,g=h.keySize,h=h.iterations;f.length<g;){i&&c.update(i);var i=c.update(a).finalize(b);c.reset();for(var j=1;j<h;j++)i=c.finalize(i),c.reset();e.concat(i)}return e.sigBytes=4*g,e}});b.EvpKDF=function(a,b,c){return e.create(c).compute(a,b)}}(),la.lib.Cipher||function(a){var b=(n=la).lib,c=b.Base,d=b.WordArray,e=b.BufferedBlockAlgorithm,f=n.enc.Base64,g=n.algo.EvpKDF,h=b.Cipher=e.extend({cfg:c.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){e.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){return a&&this._append(a),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?o:m).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?o:m).decrypt(a,b,c,d)}}}});b.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var i=n.mode={},j=function(a,b,c){var d=this._iv;d?this._iv=void 0:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=d[e]},k=(b.BlockCipherMode=c.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}})).extend();k.Encryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;j.call(this,a,b,d),c.encryptBlock(a,b),this._prevBlock=a.slice(b,b+d)}}),k.Decryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b),j.call(this,a,b,d),this._prevBlock=e}}),i=i.CBC=k,
10
- k=(n.pad={}).Pkcs7={pad:function(a,b){for(var c,e=(c=(c=4*b)-a.sigBytes%c)<<24|c<<16|c<<8|c,f=[],g=0;g<c;g+=4)f.push(e);c=d.create(f,c),a.concat(c)},unpad:function(a){a.sigBytes-=255&a.words[a.sigBytes-1>>>2]}},b.BlockCipher=h.extend({cfg:h.cfg.extend({mode:i,padding:k}),reset:function(){h.reset.call(this);var a=(b=this.cfg).iv,b=b.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=b.createEncryptor;else c=b.createDecryptor,this._minBufferSize=1;this._mode=c.call(b,this,a&&a.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var l=b.CipherParams=c.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(i=(n.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;return((a=a.salt)?d.create([1398893684,1701076831]).concat(a).concat(b):b).toString(f)},parse:function(a){var b=(a=f.parse(a)).words;if(1398893684==b[0]&&1701076831==b[1]){var c=d.create(b.slice(2,4));b.splice(0,4),a.sigBytes-=16}return l.create({ciphertext:a,salt:c})}},b.SerializableCipher=c.extend({cfg:c.extend({format:i}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);return b=e.finalize(b),e=e.cfg,l.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}})),n=(n.kdf={}).OpenSSL={execute:function(a,b,c,e){return e||(e=d.random(8)),a=g.create({keySize:b+c}).compute(a,e),c=d.create(a.words.slice(b),4*c),a.sigBytes=4*b,l.create({key:a,iv:c,salt:e})}},o=b.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:n}),encrypt:function(a,b,c,d){return c=(d=this.cfg.extend(d)).kdf.execute(c,a.keySize,a.ivSize),d.iv=c.iv,(a=m.encrypt.call(this,a,b,c.key,d)).mixIn(c),a},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt),d.iv=c.iv,m.decrypt.call(this,a,b,c.key,d)}})}(),function(){for(var a=la,b=a.lib.BlockCipher,c=a.algo,d=[],e=[],f=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=0;256>o;o++)n[o]=128>o?o<<1:o<<1^283;var p=0,q=0;for(o=0;256>o;o++){var r=(r=q^q<<1^q<<2^q<<3^q<<4)>>>8^255&r^99;d[p]=r,e[r]=p;var s=n[p],t=n[s],u=n[t],v=257*n[r]^16843008*r;f[p]=v<<24|v>>>8,g[p]=v<<16|v>>>16,h[p]=v<<8|v>>>24,i[p]=v,v=16843009*u^65537*t^257*s^16843008*p,j[r]=v<<24|v>>>8,k[r]=v<<16|v>>>16,l[r]=v<<8|v>>>24,m[r]=v,p?(p=s^n[n[n[u^s]]],q^=n[n[q]]):p=q=1}var w=[0,1,2,4,8,16,32,64,128,27,54];c=c.AES=b.extend({_doReset:function(){for(var a=(c=this._key).words,b=c.sigBytes/4,c=4*((this._nRounds=b+6)+1),e=this._keySchedule=[],f=0;f<c;f++)if(f<b)e[f]=a[f];else{var g=e[f-1];f%b?6<b&&4==f%b&&(g=d[g>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g]):(g=d[(g=g<<8|g>>>24)>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g],g^=w[f/b|0]<<24),e[f]=e[f-b]^g}for(a=this._invKeySchedule=[],b=0;b<c;b++)f=c-b,g=b%4?e[f]:e[f-4],a[b]=4>b||4>=f?g:j[d[g>>>24]]^k[d[g>>>16&255]]^l[d[g>>>8&255]]^m[d[255&g]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,f,g,h,i,d)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,j,k,l,m,e),c=a[b+1],a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;o<i;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++];m=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++],j=p,k=q,l=r}p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],m=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++],a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=m},keySize:8}),a.AES=b._createHelper(c)}(),la.mode.ECB=((ha=la.lib.BlockCipherMode.extend()).Encryptor=ha.extend({processBlock:function(a,b){this._cipher.encryptBlock(a,b)}}),ha.Decryptor=ha.extend({processBlock:function(a,b){this._cipher.decryptBlock(a,b)}}),ha);var ma,na,oa,pa=la,qa=function(){function a(a){var b=a.config;this._config=b,this._iv="0123456789012345",this._allowedKeyEncodings=["hex","utf8","base64","binary"],this._allowedKeyLengths=[128,256],this._allowedModes=["ecb","cbc"],this._defaultOptions={encryptKey:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}return a.prototype.HMACSHA256=function(a){return pa.HmacSHA256(a,this._config.secretKey).toString(pa.enc.Base64)},a.prototype.SHA256=function(a){return pa.SHA256(a).toString(pa.enc.Hex)},a.prototype._parseOptions=function(a){var b=a||{};return b.hasOwnProperty("encryptKey")||(b.encryptKey=this._defaultOptions.encryptKey),b.hasOwnProperty("keyEncoding")||(b.keyEncoding=this._defaultOptions.keyEncoding),b.hasOwnProperty("keyLength")||(b.keyLength=this._defaultOptions.keyLength),b.hasOwnProperty("mode")||(b.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(b.keyEncoding.toLowerCase())&&(b.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(b.keyLength,10))&&(b.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(b.mode.toLowerCase())&&(b.mode=this._defaultOptions.mode),b},a.prototype._decodeKey=function(a,b){return"base64"===b.keyEncoding?pa.enc.Base64.parse(a):"hex"===b.keyEncoding?pa.enc.Hex.parse(a):a},a.prototype._getPaddedKey=function(a,b){return a=this._decodeKey(a,b),b.encryptKey?pa.enc.Utf8.parse(this.SHA256(a).slice(0,32)):a},a.prototype._getMode=function(a){return"ecb"===a.mode?pa.mode.ECB:pa.mode.CBC},a.prototype._getIV=function(a){return"cbc"===a.mode?pa.enc.Utf8.parse(this._iv):null},a.prototype._getRandomIV=function(){return pa.lib.WordArray.random(16)},a.prototype.encrypt=function(a,b,c){return this._config.customEncrypt?this._config.customEncrypt(a):this.pnEncrypt(a,b,c)},a.prototype.decrypt=function(a,b,c){return this._config.customDecrypt?this._config.customDecrypt(a):this.pnDecrypt(a,b,c)},a.prototype.pnEncrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),e=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var f=this._getRandomIV(),g=pa.AES.encrypt(a,e,{iv:f,mode:d}).ciphertext;return f.clone().concat(g.clone()).toString(pa.enc.Base64)}var h=this._getIV(c);return pa.AES.encrypt(a,e,{iv:h,mode:d}).ciphertext.toString(pa.enc.Base64)||a},a.prototype.pnDecrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),f=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var g=i((k=e.from(a,"base64")).slice(0,16)),h=i(k.slice(16));try{var j=pa.AES.decrypt({ciphertext:h},f,{iv:g,mode:d}).toString(pa.enc.Utf8);return JSON.parse(j)}catch(a){return null}}else{g=this._getIV(c);try{var k=pa.enc.Base64.parse(a);return j=pa.AES.decrypt({ciphertext:k},f,{iv:g,mode:d}).toString(pa.enc.Utf8),JSON.parse(j)}catch(a){return null}}},a}(),ra=function(){function a(a){var b=a.timeEndpoint;this._timeEndpoint=b}return a.prototype.onReconnection=function(a){this._reconnectionCallback=a},a.prototype.startPolling=function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)},a.prototype.stopPolling=function(){clearInterval(this._timeTimer)},a.prototype._performTimeLoop=function(){var a=this;this._timeEndpoint(function(b){b.error||(clearInterval(a._timeTimer),a._reconnectionCallback())})},a}(),sa=function(){function a(a){var b=a.config;this.hashHistory=[],this._config=b}return a.prototype.getKey=function(a){var b=function(a){var b=0;if(0===a.length)return b;for(var c=0;c<a.length;c+=1)b=(b<<5)-b+a.charCodeAt(c),b&=b;return b}(JSON.stringify(a.payload)).toString(),c=a.publishMetaData.publishTimetoken;return"".concat(c,"-").concat(b)},a.prototype.isDuplicate=function(a){return this.hashHistory.includes(this.getKey(a))},a.prototype.addEntry=function(a){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(a))},a.prototype.clearHistory=function(){this.hashHistory=[]},a}(),ta={signPamFromParams:function(a){return k(a).map(function(b){return"".concat(b,"=").concat(j(a[b]))}).join("&")},endsWith:function(a,b){return-1!==a.indexOf(b,this.length-b.length)},createPromise:function(){var a,b;return{promise:new Promise(function(c,d){a=c,b=d}),reject:b,fulfill:a}},encodeString:j},ua={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},va=function(){function a(a){var b=a.subscribeEndpoint,c=a.leaveEndpoint,d=a.heartbeatEndpoint,e=a.setStateEndpoint,f=a.timeEndpoint,g=a.getFileUrl,h=a.config,i=a.crypto,j=a.listenerManager;this._listenerManager=j,this._config=h,this._leaveEndpoint=c,this._heartbeatEndpoint=d,this._setStateEndpoint=e,this._subscribeEndpoint=b,this._getFileUrl=g,this._crypto=i,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new ra({timeEndpoint:f}),this._dedupingManager=new sa({config:h})}return a.prototype.adaptStateChange=function(a,b){var c=this,d=a.state,e=a.channels,f=void 0===e?[]:e,g=a.channelGroups,h=void 0===g?[]:g;return f.forEach(function(a){a in c._channels&&(c._channels[a].state=d)}),h.forEach(function(a){a in c._channelGroups&&(c._channelGroups[a].state=d)}),this._setStateEndpoint({state:d,channels:f,channelGroups:h},b)},a.prototype.adaptPresenceChange=function(a){var b=this,c=a.connected,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f;c?(e.forEach(function(a){b._heartbeatChannels[a]={state:{}}}),g.forEach(function(a){b._heartbeatChannelGroups[a]={state:{}}})):(e.forEach(function(a){a in b._heartbeatChannels&&delete b._heartbeatChannels[a]}),g.forEach(function(a){a in b._heartbeatChannelGroups&&delete b._heartbeatChannelGroups[a]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:e,channelGroups:g},function(a){b._listenerManager.announceStatus(a)})),this.reconnect()},a.prototype.adaptSubscribeChange=function(a){var b=this,c=a.timetoken,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=a.withPresence,i=void 0!==h&&h,j=a.withHeartbeats,k=void 0!==j&&j;this._config.subscribeKey&&""!==this._config.subscribeKey?(c&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=c),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),e.forEach(function(a){b._channels[a]={state:{}},i&&(b._presenceChannels[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannels[a]={}),b._pendingChannelSubscriptions.push(a)}),g.forEach(function(a){b._channelGroups[a]={state:{}},i&&(b._presenceChannelGroups[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannelGroups[a]={}),b._pendingChannelGroupSubscriptions.push(a)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},a.prototype.adaptUnsubscribeChange=function(a,b){var c=this,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=[],i=[];e.forEach(function(a){a in c._channels&&(delete c._channels[a],h.push(a),a in c._heartbeatChannels&&delete c._heartbeatChannels[a]),a in c._presenceChannels&&(delete c._presenceChannels[a],h.push(a))}),g.forEach(function(a){a in c._channelGroups&&(delete c._channelGroups[a],i.push(a),a in c._heartbeatChannelGroups&&delete c._heartbeatChannelGroups[a]),a in c._presenceChannelGroups&&(delete c._presenceChannelGroups[a],i.push(a))}),0===h.length&&0===i.length||(!1!==this._config.suppressLeaveEvents||b||this._leaveEndpoint({channels:h,channelGroups:i},function(a){a.affectedChannels=h,a.affectedChannelGroups=i,a.currentTimetoken=c._currentTimetoken,a.lastTimetoken=c._lastTimetoken,c._listenerManager.announceStatus(a)}),0===Object.keys(this._channels).length&&0===Object.keys(this._presenceChannels).length&&0===Object.keys(this._channelGroups).length&&0===Object.keys(this._presenceChannelGroups).length&&(this._lastTimetoken=0,this._currentTimetoken=0,this._storedTimetoken=null,this._region=null,this._reconnectionManager.stopPolling()),this.reconnect())},a.prototype.unsubscribeAll=function(a){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},a)},a.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},a.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},a.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},a.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},a.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},a.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},a.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},a.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},a.prototype._performHeartbeatLoop=function(){var a=this,b=this.getHeartbeatChannels(),c=this.getHeartbeatChannelGroups(),d={};0===b.length&&0===c.length||(this.getSubscribedChannels().forEach(function(b){var c=a._channels[b].state;Object.keys(c).length&&(d[b]=c)}),this.getSubscribedChannelGroups().forEach(function(b){var c=a._channelGroups[b].state;Object.keys(c).length&&(d[b]=c)}),this._heartbeatEndpoint({channels:b,channelGroups:c,state:d},function(b){b.error&&a._config.announceFailedHeartbeats&&a._listenerManager.announceStatus(b),b.error&&a._config.autoNetworkDetection&&a._isOnline&&(a._isOnline=!1,a.disconnect(),a._listenerManager.announceNetworkDown(),a.reconnect()),!b.error&&a._config.announceSuccessfulHeartbeats&&a._listenerManager.announceStatus(b)}.bind(this)))},a.prototype._startSubscribeLoop=function(){var a=this;this._stopSubscribeLoop();var b={},c=[],d=[];if(Object.keys(this._channels).forEach(function(d){var e=a._channels[d].state;Object.keys(e).length&&(b[d]=e),c.push(d)}),Object.keys(this._presenceChannels).forEach(function(a){c.push("".concat(a,"-pnpres"))}),Object.keys(this._channelGroups).forEach(function(c){var e=a._channelGroups[c].state;Object.keys(e).length&&(b[c]=e),d.push(c)}),Object.keys(this._presenceChannelGroups).forEach(function(a){d.push("".concat(a,"-pnpres"))}),0!==c.length||0!==d.length){var e={channels:c,channelGroups:d,state:b,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(e,this._processSubscribeResponse.bind(this))}},a.prototype._processSubscribeResponse=function(a,b){var c=this;if(a.error){if(a.errorData&&"Aborted"===a.errorData.message)return;a.category===ua.PNTimeoutCategory?this._startSubscribeLoop():a.category===ua.PNNetworkIssuesCategory?(this.disconnect(),a.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){c._config.autoNetworkDetection&&!c._isOnline&&(c._isOnline=!0,c._listenerManager.announceNetworkUp()),c.reconnect(),c._subscriptionStatusAnnounced=!0;var b={category:ua.PNReconnectedCategory,operation:a.operation,lastTimetoken:c._lastTimetoken,currentTimetoken:c._currentTimetoken};c._listenerManager.announceStatus(b)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(a)):a.category===ua.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(a)):this._listenerManager.announceStatus(a)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=b.metadata.timetoken),!this._subscriptionStatusAnnounced){var d={};d.category=ua.PNConnectedCategory,d.operation=a.operation,d.affectedChannels=this._pendingChannelSubscriptions,d.subscribedChannels=this.getSubscribedChannels(),d.affectedChannelGroups=this._pendingChannelGroupSubscriptions,d.lastTimetoken=this._lastTimetoken,d.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(d),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var e=b.messages||[],f=this._config,g=f.requestMessageCountThreshold,h=f.dedupeOnSubscribe;if(g&&e.length>=g){var i={};i.category=ua.PNRequestMessageCountExceededCategory,i.operation=a.operation,this._listenerManager.announceStatus(i)}e.forEach(function(a){var b=a.channel,d=a.subscriptionMatch,e=a.publishMetaData;if(b===d&&(d=null),h){if(c._dedupingManager.isDuplicate(a))return;c._dedupingManager.addEntry(a)}if(ta.endsWith(a.channel,"-pnpres"))(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,b&&(i.channel=b.substring(0,b.lastIndexOf("-pnpres"))),d&&(i.subscription=d.substring(0,d.lastIndexOf("-pnpres"))),i.action=a.payload.action,i.state=a.payload.data,i.timetoken=e.publishTimetoken,i.occupancy=a.payload.occupancy,i.uuid=a.payload.uuid,i.timestamp=a.payload.timestamp,a.payload.join&&(i.join=a.payload.join),a.payload.leave&&(i.leave=a.payload.leave),a.payload.timeout&&(i.timeout=a.payload.timeout),c._listenerManager.announcePresence(i);else if(1===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=a.payload,c._listenerManager.announceSignal(i);else if(2===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message={event:a.payload.event,type:a.payload.type,data:a.payload.data},c._listenerManager.announceObjects(i),"user"===a.payload.type?c._listenerManager.announceUser(i):"space"===a.payload.type?c._listenerManager.announceSpace(i):"membership"===a.payload.type&&c._listenerManager.announceMembership(i);else if(3===a.messageType)(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,i.data={messageTimetoken:a.payload.data.messageTimetoken,actionTimetoken:a.payload.data.actionTimetoken,type:a.payload.data.type,uuid:a.issuingClientId,value:a.payload.data.value},i.event=a.payload.event,c._listenerManager.announceMessageAction(i);else if(4===a.messageType){(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId;var f=a.payload;if(c._config.cipherKey){var g=c._crypto.decrypt(a.payload);"object"==typeof g&&null!==g&&(f=g)}a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=f.message,i.file={id:f.file.id,name:f.file.name,url:c._getFileUrl({id:f.file.id,name:f.file.name,channel:b})},c._listenerManager.announceFile(i)}else{var i;(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,i.channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),c._config.cipherKey?i.message=c._crypto.decrypt(a.payload):i.message=a.payload,c._listenerManager.announceMessage(i)}}),this._region=b.metadata.region,this._startSubscribeLoop()}},a.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},a}(),wa={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},xa=function(){function a(a){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=a.maximumSamplesCount||this._maximumSamplesCount}return a.prototype.operationsLatencyForRequest=function(){var a=this,b={};return Object.keys(this._latencies).forEach(function(c){var d=a._latencies[c],e=a._averageLatency(d);e>0&&(b["l_".concat(c)]=e)}),b},a.prototype.startLatencyMeasure=function(a,b){a!==wa.PNSubscribeOperation&&b&&(this._trackedLatencies[b]=Date.now())},a.prototype.stopLatencyMeasure=function(a,b){if(a!==wa.PNSubscribeOperation&&b){var c=this._endpointName(a),d=this._latencies[c],e=this._trackedLatencies[b];d||(this._latencies[c]=[],d=this._latencies[c]),d.push(Date.now()-e),d.length>this._maximumSamplesCount&&d.splice(0,d.length-this._maximumSamplesCount),delete this._trackedLatencies[b]}},a.prototype._averageLatency=function(a){return Math.floor(a.reduce(function(a,b){return a+b},0)/a.length)},a.prototype._endpointName=function(a){var b=null;switch(a){case wa.PNPublishOperation:b="pub";break;case wa.PNSignalOperation:b="sig";break;case wa.PNHistoryOperation:case wa.PNFetchMessagesOperation:case wa.PNDeleteMessagesOperation:case wa.PNMessageCounts:b="hist";break;case wa.PNUnsubscribeOperation:case wa.PNWhereNowOperation:case wa.PNHereNowOperation:case wa.PNHeartbeatOperation:case wa.PNSetStateOperation:case wa.PNGetStateOperation:b="pres";break;case wa.PNAddChannelsToGroupOperation:case wa.PNRemoveChannelsFromGroupOperation:case wa.PNChannelGroupsOperation:case wa.PNRemoveGroupOperation:case wa.PNChannelsForGroupOperation:b="cg";break;case wa.PNPushNotificationEnabledChannelsOperation:case wa.PNRemoveAllPushNotificationsOperation:b="push";break;case wa.PNCreateUserOperation:case wa.PNUpdateUserOperation:case wa.PNDeleteUserOperation:case wa.PNGetUserOperation:case wa.PNGetUsersOperation:case wa.PNCreateSpaceOperation:case wa.PNUpdateSpaceOperation:case wa.PNDeleteSpaceOperation:case wa.PNGetSpaceOperation:case wa.PNGetSpacesOperation:case wa.PNGetMembersOperation:case wa.PNUpdateMembersOperation:case wa.PNGetMembershipsOperation:case wa.PNUpdateMembershipsOperation:b="obj";break;case wa.PNAddMessageActionOperation:case wa.PNRemoveMessageActionOperation:case wa.PNGetMessageActionsOperation:b="msga";break;case wa.PNAccessManagerGrant:case wa.PNAccessManagerAudit:b="pam";break;case wa.PNAccessManagerGrantToken:case wa.PNAccessManagerRevokeToken:b="pamv3";break;default:b="time"}return b},a}(),ya=function(){function a(a,b,c){this._payload=a,this._setDefaultPayloadStructure(),this.title=b,this.body=c}return Object.defineProperty(a.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{set:function(a){this._title=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{set:function(a){this._subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{set:function(a){this._body=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{set:function(a){this._badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{set:function(a){this._sound=a},enumerable:!1,configurable:!0}),a.prototype._setDefaultPayloadStructure=function(){},a.prototype.toObject=function(){return{}},a}(),za=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"configurations",{set:function(a){a&&a.length&&(this._configurations=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.aps.alert.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){a&&a.length&&(this._payload.aps.alert.subtitle=a,this._subtitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this._body},set:function(a){a&&a.length&&(this._payload.aps.alert.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this._badge},set:function(a){null!=a&&(this._payload.aps.badge=a,this._badge=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.aps.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},c.prototype.toObject=function(){var a=this,b=$({},this._payload),c=b.aps,d=c.alert;if(this._isSilent&&(c["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var e=[];this._configurations.forEach(function(b){e.push(a._objectFromAPNS2Configuration(b))}),e.length&&(b.pn_push=e)}return d&&Object.keys(d).length||delete c.alert,this._isSilent&&(delete c.alert,delete c.badge,delete c.sound,d={}),this._isSilent||Object.keys(d).length?b:null},c.prototype._objectFromAPNS2Configuration=function(a){var b=this;if(!a.targets||!a.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var c=[];a.targets.forEach(function(a){c.push(b._objectFromAPNSTarget(a))});var d=a.collapseId,e=a.expirationDate,f={auth_method:"token",targets:c,version:"v2"};return d&&d.length&&(f.collapse_id=d),e&&(f.expiration=e.toISOString()),f},c.prototype._objectFromAPNSTarget=function(a){if(!a.topic||!a.topic.length)throw new TypeError("Target 'topic' undefined.");var b=a.topic,c=a.environment,d=void 0===c?"development":c,e=a.excludedDevices,f=void 0===e?[]:e,g={topic:b,environment:d};return f.length&&(g.excluded_devices=f),g},c}(ya),Aa=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"backContent",{get:function(){return this._backContent},set:function(a){a&&a.length&&(this._payload.back_content=a,this._backContent=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"backTitle",{get:function(){return this._backTitle},set:function(a){a&&a.length&&(this._payload.back_title=a,this._backTitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"count",{get:function(){return this._count},set:function(a){null!=a&&(this._payload.count=a,this._count=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"type",{get:function(){return this._type},set:function(a){a&&a.length&&(this._payload.type=a,this._type=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this.backTitle},set:function(a){this.backTitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this.backContent},set:function(a){this.backContent=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this.count},set:function(a){this.count=a},enumerable:!1,configurable:!0}),c.prototype.toObject=function(){return Object.keys(this._payload).length?$({},this._payload):null},c}(ya),Ba=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.notification.title=a,
11
- this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this._body},set:function(a){a&&a.length&&(this._payload.notification.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.notification.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"icon",{get:function(){return this._icon},set:function(a){a&&a.length&&(this._payload.notification.icon=a,this._icon=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"tag",{get:function(){return this._tag},set:function(a){a&&a.length&&(this._payload.notification.tag=a,this._tag=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},c.prototype.toObject=function(){var a=$({},this._payload.data),b=null,c={};if(Object.keys(this._payload).length>2){var d=this._payload;d.notification,d.data;var e=function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(null!=a&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(d=Object.getOwnPropertySymbols(a);e<d.length;e++)b.indexOf(d[e])<0&&Object.prototype.propertyIsEnumerable.call(a,d[e])&&(c[d[e]]=a[d[e]])}return c}(d,["notification","data"]);a=$($({},a),e)}return this._isSilent?a.notification=this._payload.notification:b=this._payload.notification,Object.keys(a).length&&(c.data=a),b&&Object.keys(b).length&&(c.notification=b),Object.keys(c).length?c:null},c}(ya),Ca=function(){function a(a,b){this._payload={apns:{},mpns:{},fcm:{}},this._title=a,this._body=b,this.apns=new za(this._payload.apns,a,b),this.mpns=new Aa(this._payload.mpns,a,b),this.fcm=new Ba(this._payload.fcm,a,b)}return Object.defineProperty(a.prototype,"debugging",{set:function(a){this._debugging=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){this._subtitle=a,this.apns.subtitle=a,this.mpns.subtitle=a,this.fcm.subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{get:function(){return this._badge},set:function(a){this._badge=a,this.apns.badge=a,this.mpns.badge=a,this.fcm.badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{get:function(){return this._sound},set:function(a){this._sound=a,this.apns.sound=a,this.mpns.sound=a,this.fcm.sound=a},enumerable:!1,configurable:!0}),a.prototype.buildPayload=function(a){var b={};if(a.includes("apns")||a.includes("apns2")){this.apns._apnsPushType=a.includes("apns")?"apns":"apns2";var c=this.apns.toObject();c&&Object.keys(c).length&&(b.pn_apns=c)}if(a.includes("mpns")){var d=this.mpns.toObject();d&&Object.keys(d).length&&(b.pn_mpns=d)}if(a.includes("fcm")){var e=this.fcm.toObject();e&&Object.keys(e).length&&(b.pn_gcm=e)}return Object.keys(b).length&&this._debugging&&(b.pn_debug=!0),b},a}(),Da=function(){function a(){this._listeners=[]}return a.prototype.addListener=function(a){this._listeners.push(a)},a.prototype.removeListener=function(a){var b=[];this._listeners.forEach(function(c){c!==a&&b.push(c)}),this._listeners=b},a.prototype.removeAllListeners=function(){this._listeners=[]},a.prototype.announcePresence=function(a){this._listeners.forEach(function(b){b.presence&&b.presence(a)})},a.prototype.announceStatus=function(a){this._listeners.forEach(function(b){b.status&&b.status(a)})},a.prototype.announceMessage=function(a){this._listeners.forEach(function(b){b.message&&b.message(a)})},a.prototype.announceSignal=function(a){this._listeners.forEach(function(b){b.signal&&b.signal(a)})},a.prototype.announceMessageAction=function(a){this._listeners.forEach(function(b){b.messageAction&&b.messageAction(a)})},a.prototype.announceFile=function(a){this._listeners.forEach(function(b){b.file&&b.file(a)})},a.prototype.announceObjects=function(a){this._listeners.forEach(function(b){b.objects&&b.objects(a)})},a.prototype.announceUser=function(a){this._listeners.forEach(function(b){b.user&&b.user(a)})},a.prototype.announceSpace=function(a){this._listeners.forEach(function(b){b.space&&b.space(a)})},a.prototype.announceMembership=function(a){this._listeners.forEach(function(b){b.membership&&b.membership(a)})},a.prototype.announceNetworkUp=function(){var a={};a.category=ua.PNNetworkUpCategory,this.announceStatus(a)},a.prototype.announceNetworkDown=function(){var a={};a.category=ua.PNNetworkDownCategory,this.announceStatus(a)},a}(),Ea=function(){function a(a,b){this._config=a,this._cbor=b}return a.prototype.setToken=function(a){a&&a.length>0?this._token=a:this._token=void 0},a.prototype.getToken=function(){return this._token},a.prototype.extractPermissions=function(a){var b={read:!1,write:!1,manage:!1,"delete":!1,get:!1,update:!1,join:!1};return 128==(128&a)&&(b.join=!0),64==(64&a)&&(b.update=!0),32==(32&a)&&(b.get=!0),8==(8&a)&&(b["delete"]=!0),4==(4&a)&&(b.manage=!0),2==(2&a)&&(b.write=!0),1==(1&a)&&(b.read=!0),b},a.prototype.parseToken=function(a){var b=this,c=this._cbor.decodeToken(a);if(void 0!==c){var d=c.res.uuid?Object.keys(c.res.uuid):[],e=Object.keys(c.res.chan),f=Object.keys(c.res.grp),g=c.pat.uuid?Object.keys(c.pat.uuid):[],h=Object.keys(c.pat.chan),i=Object.keys(c.pat.grp),j={version:c.v,timestamp:c.t,ttl:c.ttl,authorized_uuid:c.uuid},k=d.length>0,l=e.length>0,m=f.length>0;(k||l||m)&&(j.resources={},k&&(j.resources.uuids={},d.forEach(function(a){j.resources.uuids[a]=b.extractPermissions(c.res.uuid[a])})),l&&(j.resources.channels={},e.forEach(function(a){j.resources.channels[a]=b.extractPermissions(c.res.chan[a])})),m&&(j.resources.groups={},f.forEach(function(a){j.resources.groups[a]=b.extractPermissions(c.res.grp[a])})));var n=g.length>0,o=h.length>0,p=i.length>0;return(n||o||p)&&(j.patterns={},n&&(j.patterns.uuids={},g.forEach(function(a){j.patterns.uuids[a]=b.extractPermissions(c.pat.uuid[a])})),o&&(j.patterns.channels={},h.forEach(function(a){j.patterns.channels[a]=b.extractPermissions(c.pat.chan[a])})),p&&(j.patterns.groups={},i.forEach(function(a){j.patterns.groups[a]=b.extractPermissions(c.pat.grp[a])}))),Object.keys(c.meta).length>0&&(j.meta=c.meta),j.signature=c.sig,j}},a}(),Fa=function(b){function c(a,c){var d=this.constructor,e=b.call(this,a)||this;return e.name=e.constructor.name,e.status=c,e.message=a,Object.setPrototypeOf(e,d.prototype),e}return a(c,b),c}(Error),Ga=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAddChannelsToGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{add:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),Ha=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveChannelsFromGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{remove:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),Ia=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Ja=Object.freeze({__proto__:null,getOperation:function(){return wa.PNChannelGroupsOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v1/channel-registration/sub-key/".concat(b.subscribeKey,"/channel-group")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{groups:b.payload.groups}}}),Ka=Object.freeze({__proto__:null,getOperation:function(){return wa.PNChannelsForGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{channels:b.payload.channels}}}),La=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,add:e.join(",")};return"apns2"===c&&delete(i=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Ma=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,remove:e.join(",")};return"apns2"===c&&delete(i=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Na=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(a,b){return{channels:b}}}),Oa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveAllPushNotificationsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c,"/remove"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c,"/remove")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(){return{}}}),Pa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNUnsubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/leave")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(){return{}}}),Qa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNWhereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d;return"/v2/presence/sub-key/".concat(c.subscribeKey,"/uuid/").concat(ta.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return b.payload?{channels:b.payload.channels}:{channels:[]}}}),Ra=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHeartbeatOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.state,f=void 0===e?{}:e,g=a.config,h={};return d.length>0&&(h["channel-group"]=d.join(",")),h.state=JSON.stringify(f),h.heartbeat=g.getPresenceTimeout(),h},handleResponse:function(){return{}}}),Sa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNGetStateOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d,f=b.channels,g=void 0===f?[]:f,h=g.length>0?g.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(h),"/uuid/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h={};return 1===e.length&&0===g.length?h[e[0]]=b.payload:h=b.payload,{channels:h}}}),Ta=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSetStateOperation},validateParams:function(a,b){var c=a.config,d=b.state,e=b.channels,f=void 0===e?[]:e,g=b.channelGroups,h=void 0===g?[]:g;return d?c.subscribeKey?0===f.length&&0===h.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/uuid/").concat(ta.encodeString(c.UUID),"/data")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.state,d=b.channelGroups,e=void 0===d?[]:d,f={};return f.state=JSON.stringify(c),e.length>0&&(f["channel-group"]=e.join(",")),f},handleResponse:function(a,b){return{state:b.payload}}}),Ua=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=b.channelGroups,g=void 0===f?[]:f,h="/v2/presence/sub-key/".concat(c.subscribeKey);if(e.length>0||g.length>0){var i=e.length>0?e.join(","):",";h+="/channel/".concat(ta.encodeString(i))}return h},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.includeUUIDs,f=void 0===e||e,g=b.includeState,h=void 0!==g&&g,i=b.queryParameters,j=void 0===i?{}:i,k={};return f||(k.disable_uuids=1),h&&(k.state=1),d.length>0&&(k["channel-group"]=d.join(",")),k=$($({},k),j)},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h=c.includeUUIDs,i=void 0===h||h,j=c.includeState,k=void 0!==j&&j;return e.length>1||g.length>0||0===g.length&&0===e.length?function(){var a={};return a.totalChannels=b.payload.total_channels,a.totalOccupancy=b.payload.total_occupancy,a.channels={},Object.keys(b.payload.channels).forEach(function(c){var d=b.payload.channels[c],e=[];return a.channels[c]={occupants:e,name:c,occupancy:d.occupancy},i&&d.uuids.forEach(function(a){k?e.push({state:a.state,uuid:a.uuid}):e.push({state:null,uuid:a})}),a}),a}():function(){var a={},c=[];return a.totalChannels=1,a.totalOccupancy=b.occupancy,a.channels={},a.channels[e[0]]={occupants:c,name:e[0],occupancy:b.occupancy},i&&b.uuids&&b.uuids.forEach(function(a){k?c.push({state:a.state,uuid:a.uuid}):c.push({state:null,uuid:a})}),a}()},handleError:function(a,b,c){402!==c.statusCode||this.getURL(a,b).includes("channel")||(c.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}}),Va=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAddMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.action,e=b.channel;return b.messageTimetoken?c.subscribeKey?e?d?d.value?d.type?d.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(a,b){var c=a.config,d=b.channel,e=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d),"/message/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(a,b){return b.action},handleResponse:function(a,b){return{data:b.data}}}),Wa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken;return b.messageTimetoken?e?c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken,f=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d),"/message/").concat(f,"/action/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{data:b.data}}}),Xa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNGetMessageActionsOperation},validateParams:function(a,b){var c=a.config,d=b.channel;return c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channel;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.limit,d=b.start,e=b.end,f={};return c&&(f.limit=c),d&&(f.start=d),e&&(f.end=e),f},handleResponse:function(a,b){var c={data:b.data,start:null,end:null};return c.data.length&&(c.end=c.data[c.data.length-1].actionTimetoken,c.start=c.data[0].actionTimetoken),c}}),Ya={getOperation:function(){return wa.PNListFilesOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"channel can't be empty"},getURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.limit&&(c.limit=b.limit),b.next&&(c.next=b.next),c},handleResponse:function(a,b){return{status:b.status,data:b.data,next:b.next,count:b.count}}},Za={getOperation:function(){return wa.PNGenerateUploadUrlOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/generate-upload-url")},postPayload:function(a,b){return{name:b.name}},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data,file_upload_request:b.file_upload_request}}},$a={getOperation:function(){return wa.PNPublishFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.fileId)?(null==b?void 0:b.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(a,b){var c=a.config,d=c.publishKey,e=c.subscribeKey,f=function(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e||""}(a,{message:b.message,file:{name:b.fileName,id:b.fileId}});return"/v1/files/publish-file/".concat(d,"/").concat(e,"/0/").concat(ta.encodeString(b.channel),"/0/").concat(ta.encodeString(f))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.ttl&&(c.ttl=b.ttl),void 0!==b.storeInHistory&&(c.store=b.storeInHistory?"1":"0"),b.meta&&"object"==typeof b.meta&&(c.meta=JSON.stringify(b.meta)),c},handleResponse:function(a,b){return{timetoken:b[2]}}},_a=function(a){var b=function(a){var b=this,e=a.generateUploadUrl,f=a.publishFile,g=a.modules,h=g.PubNubFile,i=g.config,j=g.cryptography,k=g.networking;return function(a){var g=a.channel,m=a.file,n=a.message,o=a.cipherKey,p=a.meta,q=a.ttl,r=a.storeInHistory;return c(b,void 0,void 0,function(){var a,b,c,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q;return d(this,function(d){switch(d.label){case 0:if(!g)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!m)throw new Fa("Validation failed, check status for details",l("file can't be empty"));return a=h.create(m),[4,e({channel:g,name:a.name})];case 1:return b=d.sent(),c=b.file_upload_request,s=c.url,t=c.form_fields,u=b.data,v=u.id,w=u.name,h.supportsEncryptFile&&(null!=o?o:i.cipherKey)?[4,j.encryptFile(null!=o?o:i.cipherKey,a,h)]:[3,3];case 2:a=d.sent(),d.label=3;case 3:x=t,a.mimeType&&(x=t.map(function(b){return"Content-Type"===b.key?{key:b.key,value:a.mimeType}:b})),d.label=4;case 4:return d.trys.push([4,18,,20]),h.supportsFileUri&&m.uri?(A=(z=k).POSTFILE,B=[s,x],[4,a.toFileUri()]):[3,7];case 5:return[4,A.apply(z,B.concat([d.sent()]))];case 6:return y=d.sent(),[3,17];case 7:return h.supportsFile?(D=(C=k).POSTFILE,E=[s,x],[4,a.toFile()]):[3,10];case 8:return[4,D.apply(C,E.concat([d.sent()]))];case 9:return y=d.sent(),[3,17];case 10:return h.supportsBuffer?(G=(F=k).POSTFILE,H=[s,x],[4,a.toBuffer()]):[3,13];case 11:return[4,G.apply(F,H.concat([d.sent()]))];case 12:return y=d.sent(),[3,17];case 13:return h.supportsBlob?(J=(I=k).POSTFILE,K=[s,x],[4,a.toBlob()]):[3,16];case 14:return[4,J.apply(I,K.concat([d.sent()]))];case 15:return y=d.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,20];case 18:return L=d.sent(),[4,(R=L.response,new Promise(function(a){var b="";R.on("data",function(a){b+=a.toString("utf8")}),R.on("end",function(){a(b)})}))];case 19:throw M=d.sent(),N=/<Message>(.*)<\/Message>/gi.exec(M),new Fa(N?"Upload to bucket failed: ".concat(N[1]):"Upload to bucket failed.",L);case 20:if(204!==y.status)throw new Fa("Upload to bucket was unsuccessful",y);O=i.fileUploadPublishRetryLimit,P=!1,Q={timetoken:"0"},d.label=21;case 21:return d.trys.push([21,23,,24]),[4,f({channel:g,message:n,fileId:v,fileName:w,meta:p,storeInHistory:r,ttl:q})];case 22:return Q=d.sent(),P=!0,[3,24];case 23:return d.sent(),O-=1,[3,24];case 24:if(!P&&O>0)return[3,21];d.label=25;case 25:if(P)return[2,{timetoken:Q.timetoken,id:v,name:w}];throw new Fa("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:g,id:v,name:w})}var R})})}}(a);return function(a,c){var d=b(a);return"function"==typeof c?(d.then(function(a){return c(null,a)})["catch"](function(a){return c(a,null)}),d):d}},ab=function(a,b){var c=b.channel,d=b.id,e=b.name,f=a.config,g=a.networking;if(!c)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!d)throw new Fa("Validation failed, check status for details",l("file id can't be empty"));if(!e)throw new Fa("Validation failed, check status for details",l("file name can't be empty"));var h="/v1/files/".concat(f.subscribeKey,"/channels/").concat(ta.encodeString(c),"/files/").concat(d,"/").concat(e),i={};i.uuid=f.getUUID(),i.pnsdk=n(f),f.getAuthKey()&&(i.auth=f.getAuthKey()),f.secretKey&&p(a,h,i,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var j=Object.keys(i).map(function(a){return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(i[a]))}).join("&");return""!==j?"".concat(g.getStandardOrigin()).concat(h,"?").concat(j):"".concat(g.getStandardOrigin()).concat(h)},bb={getOperation:function(){return wa.PNDownloadFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?(null==b?void 0:b.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b,e){var f=a.PubNubFile,g=a.config,h=a.cryptography;return c(void 0,void 0,void 0,function(){var a,c,i,j;return d(this,function(d){switch(d.label){case 0:return a=b.response.body,f.supportsEncryptFile&&(null!==(c=e.cipherKey)&&void 0!==c?c:g.cipherKey)?[4,h.decrypt(null!==(i=e.cipherKey)&&void 0!==i?i:g.cipherKey,a)]:[3,2];case 1:a=d.sent(),d.label=2;case 2:return[2,f.create({data:a,name:null!==(j=b.response.name)&&void 0!==j?j:e.name,mimeType:b.response.type})]}})})}},cb={getOperation:function(){return wa.PNListFilesOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.id)?(null==b?void 0:b.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status}}},db={getOperation:function(){return wa.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(h=b.page)||void 0===h?void 0:h.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,next:b.next,prev:b.prev}}},eb={getOperation:function(){return wa.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},fb={getOperation:function(){return wa.PNSetUUIDMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()));
12
- },patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},gb={getOperation:function(){return wa.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},hb={getOperation:function(){return wa.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(h=b.page)||void 0===h?void 0:h.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},ib={getOperation:function(){return wa.PNGetChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},jb={getOperation:function(){return wa.PNSetChannelMetadataOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},kb={getOperation:function(){return wa.PNRemoveChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},lb={getOperation:function(){return wa.PNGetMembersOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"UUID cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o,p={};return(null==b?void 0:b.include)&&(p.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&p.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&p.include.push("uuid.custom"),(null===(f=null===(e=b.include)||void 0===e?void 0:e.UUIDFields)||void 0===f||f)&&p.include.push("uuid"),p.include=p.include.join(",")),(null===(h=null==b?void 0:b.include)||void 0===h?void 0:h.totalCount)&&(p.count=null===(i=b.include)||void 0===i?void 0:i.totalCount),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.next)&&(p.start=null===(k=b.page)||void 0===k?void 0:k.next),(null===(l=null==b?void 0:b.page)||void 0===l?void 0:l.prev)&&(p.end=null===(m=b.page)||void 0===m?void 0:m.prev),(null==b?void 0:b.filter)&&(p.filter=b.filter),p.limit=null!==(n=null==b?void 0:b.limit)&&void 0!==n?n:100,(null==b?void 0:b.sort)&&(p.sort=Object.entries(null!==(o=b.sort)&&void 0!==o?o:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),p},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},mb={getOperation:function(){return wa.PNSetMembersOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.uuids)&&0!==(null==b?void 0:b.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/uuids")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.uuids.map(function(a){return"string"==typeof a?{uuid:{id:a}}:{uuid:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&m.include.push("uuid.custom"),(null===(e=b.include)||void 0===e?void 0:e.UUIDFields)&&m.include.push("uuid"),m.include=m.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(h=null==b?void 0:b.page)||void 0===h?void 0:h.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),(null==b?void 0:b.limit)&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},nb={getOperation:function(){return wa.PNGetMembershipsOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o={};return(null==b?void 0:b.include)&&(o.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&o.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&o.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&o.include.push("channel"),o.include=o.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(o.count=null===(h=b.include)||void 0===h?void 0:h.totalCount),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.next)&&(o.start=null===(j=b.page)||void 0===j?void 0:j.next),(null===(k=null==b?void 0:b.page)||void 0===k?void 0:k.prev)&&(o.end=null===(l=b.page)||void 0===l?void 0:l.prev),(null==b?void 0:b.filter)&&(o.filter=b.filter),o.limit=null!==(m=null==b?void 0:b.limit)&&void 0!==m?m:100,(null==b?void 0:b.sort)&&(o.sort=Object.entries(null!==(n=b.sort)&&void 0!==n?n:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),o},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},ob={getOperation:function(){return wa.PNSetMembershipsOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)||0===(null==b?void 0:b.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.channels.map(function(a){return"string"==typeof a?{channel:{id:a}}:{channel:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&m.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&m.include.push("channel"),m.include=m.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(h=null==b?void 0:b.page)||void 0===h?void 0:h.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),(null==b?void 0:b.limit)&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},pb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerAudit},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v2/auth/audit/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channel,d=b.channelGroup,e=b.authKeys,f=void 0===e?[]:e,g={};return c&&(g.channel=c),d&&(g["channel-group"]=d),f.length>0&&(g.auth=f.join(",")),g},handleResponse:function(a,b){return b.payload}}),qb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerGrant},validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?null==b.uuids||b.authKeys?null==b.uuids||null==b.channels&&null==b.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v2/auth/grant/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.channelGroups,f=void 0===e?[]:e,g=b.uuids,h=void 0===g?[]:g,i=b.ttl,j=b.read,k=void 0!==j&&j,l=b.write,m=void 0!==l&&l,n=b.manage,o=void 0!==n&&n,p=b.get,q=void 0!==p&&p,r=b.join,s=void 0!==r&&r,t=b.update,u=void 0!==t&&t,v=b.authKeys,w=void 0===v?[]:v,x=b["delete"],y={};return y.r=k?"1":"0",y.w=m?"1":"0",y.m=o?"1":"0",y.d=x?"1":"0",y.g=q?"1":"0",y.j=s?"1":"0",y.u=u?"1":"0",d.length>0&&(y.channel=d.join(",")),f.length>0&&(y["channel-group"]=f.join(",")),w.length>0&&(y.auth=w.join(",")),h.length>0&&(y["target-uuid"]=h.join(",")),(i||0===i)&&(y.ttl=i),y},handleResponse:function(){return{}}}),rb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerGrantToken},extractPermissions:r,validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?b.resources||b.patterns?(!b.resources||b.resources.uuids&&0!==Object.keys(b.resources.uuids).length||b.resources.channels&&0!==Object.keys(b.resources.channels).length||b.resources.groups&&0!==Object.keys(b.resources.groups).length)&&(!b.patterns||b.patterns.uuids&&0!==Object.keys(b.patterns.uuids).length||b.patterns.channels&&0!==Object.keys(b.patterns.channels).length||b.patterns.groups&&0!==Object.keys(b.patterns.groups).length)?void 0:"Missing values for either Resources or Patterns.":"Missing either Resources or Patterns.":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},postURL:function(a){var b=a.config;return"/v3/pam/".concat(b.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(a,b){return function(a,b){var c=b.ttl,d=b.resources,e=b.patterns,f=b.meta,g=b.authorized_uuid,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(d){var i=d.uuids,j=d.channels,k=d.groups;i&&Object.keys(i).forEach(function(a){h.permissions.resources.uuids[a]=r(i[a])}),j&&Object.keys(j).forEach(function(a){h.permissions.resources.channels[a]=r(j[a])}),k&&Object.keys(k).forEach(function(a){h.permissions.resources.groups[a]=r(k[a])})}if(e){var l=e.uuids,m=e.channels,n=e.groups;l&&Object.keys(l).forEach(function(a){h.permissions.patterns.uuids[a]=r(l[a])}),m&&Object.keys(m).forEach(function(a){h.permissions.patterns.channels[a]=r(m[a])}),n&&Object.keys(n).forEach(function(a){h.permissions.patterns.groups[a]=r(n[a])})}return(c||0===c)&&(h.ttl=c),f&&(h.permissions.meta=f),g&&(h.permissions.uuid="".concat(g)),h}(0,b)},handleResponse:function(a,b){return b.data.token}}),sb={getOperation:function(){return wa.PNAccessManagerRevokeToken},validateParams:function(a,b){return a.config.secretKey?b?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(a,b){var c=a.config;return"/v3/pam/".concat(c.subscribeKey,"/grant/").concat(ta.encodeString(b))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a){return{uuid:a.config.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},tb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPublishOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(a,b){var c=b.sendByPost;return void 0!==c&&c},getURL:function(a,b){var c=a.config,d=b.channel,e=s(a,b.message);return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0/").concat(ta.encodeString(e))},postURL:function(a,b){var c=a.config,d=b.channel;return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(a,b){return s(a,b.message)},prepareParams:function(a,b){var c=b.meta,d=b.replicate,e=void 0===d||d,f=b.storeInHistory,g=b.ttl,h={};return null!=f&&(h.store=f?"1":"0"),g&&(h.ttl=g),!1===e&&(h.norep="true"),c&&"object"==typeof c&&(h.meta=JSON.stringify(c)),h},handleResponse:function(a,b){return{timetoken:b[2]}}}),ub=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSignalOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(a,b){var c,d=a.config,e=b.channel,f=b.message,g=(c=f,JSON.stringify(c));return"/signal/".concat(d.publishKey,"/").concat(d.subscribeKey,"/0/").concat(ta.encodeString(e),"/0/").concat(ta.encodeString(g))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{timetoken:b[2]}}}),vb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHistoryOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channel,d=a.config;return"/v2/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e=b.reverse,f=b.count,g=void 0===f?100:f,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l={include_token:"true"};return l.count=g,c&&(l.start=c),d&&(l.end=d),i&&(l.string_message_token="true"),null!=e&&(l.reverse=e.toString()),k&&(l.include_meta="true"),l},handleResponse:function(a,b){var c={messages:[],startTimeToken:b[1],endTimeToken:b[2]};return Array.isArray(b[0])&&b[0].forEach(function(b){var d={timetoken:b.timetoken,entry:t(a,b.message)};b.meta&&(d.meta=b.meta),c.messages.push(d)}),c}}),wb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNDeleteMessagesOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(a,b){var c=b.channel,d=a.config;return"/v3/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e={};return c&&(e.start=c),d&&(e.end=d),e},handleResponse:function(a,b){return b.payload}}),xb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNMessageCounts},validateParams:function(a,b){var c=b.channels,d=b.timetoken,e=b.channelTimetokens,f=a.config;return c?d&&e?"timetoken and channelTimetokens are incompatible together":d&&e&&e.length>1&&c.length!==e.length?"Length of channelTimetokens and channels do not match":f.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channels,d=a.config,e=c.join(",");return"/v3/history/sub-key/".concat(d.subscribeKey,"/message-counts/").concat(ta.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.timetoken,d=b.channelTimetokens,e={};if(d&&1===d.length){var f=g(d,1)[0];e.timetoken=f}else d?e.channelsTimetoken=d.join(","):c&&(e.timetoken=c);return e},handleResponse:function(a,b){return{channels:b.channels}}}),yb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNFetchMessagesOperation},validateParams:function(a,b){var c=b.channels,d=b.includeMessageActions,e=void 0!==d&&d,f=a.config;if(!c||0===c.length)return"Missing channels";if(!f.subscribeKey)return"Missing Subscribe Key";if(e&&c.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.includeMessageActions,f=void 0!==e&&e,g=a.config,h=f?"history-with-actions":"history",i=d.length>0?d.join(","):",";return"/v3/".concat(h,"/sub-key/").concat(g.subscribeKey,"/channel/").concat(ta.encodeString(i))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels,d=b.start,e=b.end,f=b.includeMessageActions,g=b.count,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l=b.includeUuid,m=b.includeUUID,n=void 0===m||m,o=b.includeMessageType,p=void 0===o||o,q={};return q.max=g||(c.length>1||!0===f?25:100),d&&(q.start=d),e&&(q.end=e),i&&(q.string_message_token="true"),k&&(q.include_meta="true"),n&&!1!==l&&(q.include_uuid="true"),p&&(q.include_message_type="true"),q},handleResponse:function(a,b){var c={channels:{}};return Object.keys(b.channels||{}).forEach(function(d){c.channels[d]=[],(b.channels[d]||[]).forEach(function(b){var e={};e.channel=d,e.timetoken=b.timetoken,e.message=function(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}(a,b.message),e.messageType=b.message_type,e.uuid=b.uuid,b.actions&&(e.actions=b.actions,e.data=b.actions),b.meta&&(e.meta=b.meta),c.channels[d].push(e)})}),b.more&&(c.more=b.more),c}}),zb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(a,b){return{timetoken:b[0]}},validateParams:function(){}}),Ab=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(f),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=a.config,d=b.state,e=b.channelGroups,f=void 0===e?[]:e,g=b.timetoken,h=b.filterExpression,i=b.region,j={heartbeat:c.getPresenceTimeout()};return f.length>0&&(j["channel-group"]=f.join(",")),h&&h.length>0&&(j["filter-expr"]=h),Object.keys(d).length&&(j.state=JSON.stringify(d)),g&&(j.tt=g),i&&(j.tr=i),j},handleResponse:function(a,b){var c=[];b.m.forEach(function(a){var b={publishTimetoken:a.p.t,region:a.p.r},d={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,userMetadata:a.u,publishMetaData:b};c.push(d)});var d={timetoken:b.t.t,region:b.t.r};return{messages:c,metadata:d}}}),Bb={getOperation:function(){return wa.PNHandshakeOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)&&!(null==b?void 0:b.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=0,c},handleResponse:function(a,b){return{region:b.t.r,timetoken:b.t.t}}},Cb={getOperation:function(){return wa.PNReceiveMessagesOperation},validateParams:function(a,b){return(null==b?void 0:b.channels)||(null==b?void 0:b.channelGroups)?(null==b?void 0:b.timetoken)?(null==b?void 0:b.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(a,b){return b.abortSignal},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=b.timetoken,c.tr=b.region,c},handleResponse:function(a,b){var c=[];return b.m.forEach(function(a){var b={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,publishMetaData:{timetoken:a.p.t,region:a.p.r}};c.push(b)}),{messages:c,metadata:{region:b.t.r,timetoken:b.t.t}}}},Db=function(){function a(a){void 0===a&&(a=!1),this.sync=a,this.listeners=new Set}return a.prototype.subscribe=function(a){var b=this;return this.listeners.add(a),function(){b.listeners["delete"](a)}},a.prototype.notify=function(a){var b=this,c=function(){b.listeners.forEach(function(b){b(a)})};this.sync?c():setTimeout(c,0)},a}(),Eb=function(){function a(a){this.label=a,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return a.prototype.transition=function(a,b){var c;if(this.transitionMap.has(b.type))return null===(c=this.transitionMap.get(b.type))||void 0===c?void 0:c(a,b)},a.prototype.on=function(a,b){return this.transitionMap.set(a,b),this},a.prototype["with"]=function(a,b){return[this,a,null!=b?b:[]]},a.prototype.onEnter=function(a){return this.enterEffects.push(a),this},a.prototype.onExit=function(a){return this.exitEffects.push(a),this},a}(),Fb=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),c.prototype.describe=function(a){return new Eb(a)},c.prototype.start=function(a,b){this.currentState=a,this.currentContext=b,this.notify({type:"engineStarted",state:a,context:b})},c.prototype.transition=function(a){var b,c,d,e,h,i;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:a});var j=this.currentState.transition(this.currentContext,a);if(j){var k=g(j,3),l=k[0],m=k[1],n=k[2];try{for(var o=f(this.currentState.exitEffects),p=o.next();!p.done;p=o.next()){var q=p.value;this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}}catch(a){b={error:a}}finally{try{p&&!p.done&&(c=o["return"])&&c.call(o)}finally{if(b)throw b.error}}var r=this.currentState;this.currentState=l;var s=this.currentContext;this.currentContext=m,this.notify({type:"transitionDone",fromState:r,fromContext:s,toState:l,toContext:m,event:a});try{for(var t=f(n),u=t.next();!u.done;u=t.next())q=u.value,this.notify({type:"invocationDispatched",invocation:q})}catch(a){d={error:a}}finally{try{u&&!u.done&&(e=t["return"])&&e.call(t)}finally{if(d)throw d.error}}try{for(var v=f(this.currentState.enterEffects),w=v.next();!w.done;w=v.next())q=w.value,this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}catch(a){h={error:a}}finally{try{w&&!w.done&&(i=v["return"])&&i.call(v)}finally{if(h)throw h.error}}}},c}(Db),Gb=function(){function a(a){this.dependencies=a,this.instances=new Map,this.handlers=new Map}return a.prototype.on=function(a,b){this.handlers.set(a,b)},a.prototype.dispatch=function(a){if("CANCEL"!==a.type){var b=this.handlers.get(a.type);if(!b)throw new Error("Unhandled invocation '".concat(a.type,"'"));var c=b(a.payload,this.dependencies);a.managed&&this.instances.set(a.type,c),c.start()}else if(this.instances.has(a.payload)){var d=this.instances.get(a.payload);null==d||d.cancel(),this.instances["delete"](a.payload)}},a}(),Hb=function(b){function c(){var a=this.constructor,c=b.call(this,"The operation was aborted.")||this;return c.name="AbortError",Object.setPrototypeOf(c,a.prototype),c}return a(c,b),c}(Error),Ib=function(b){function c(){var a=null!==b&&b.apply(this,arguments)||this;return a._aborted=!1,a}return a(c,b),Object.defineProperty(c.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),c.prototype.throwIfAborted=function(){if(this._aborted)throw new Hb},c.prototype.abort=function(){this._aborted=!0,this.notify(new Hb)},c}(Db),Jb=function(b){function c(a,c,d){var e=b.call(this,a,c)||this;return e.asyncFunction=d,e.abortSignal=new Ib,e}return a(c,b),c.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies)},c.prototype.cancel=function(){this.abortSignal.abort()},c}(function(a,b){this.payload=a,this.dependencies=b}),Kb=function(a){return function(b,c){return new Jb(b,c,a)}},Lb=v("HANDSHAKE",function(a,b){return{channels:a,groups:b}}),Mb=v("RECEIVE_EVENTS",function(a,b,c){return{channels:a,groups:b,cursor:c}}),Nb=(na=function(a){return a},oa=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return{type:ma,payload:na.apply(void 0,h([],g(a),!1)),managed:!1}},oa.type=ma="EMIT_EVENTS",oa),Ob=v("RECONNECT",function(a){return a}),Pb=v("HANDSHAKE_RECONNECT",function(a){return a}),Qb=u("SUBSCRIPTION_CHANGE",function(a,b){return{channels:a,groups:b}}),Rb=u("DISCONNECT",function(){return{}}),Sb=u("RECONNECT",function(){return{}});u("RESTORE",function(a,b,c,d){return{channels:a,groups:b,timetoken:c,region:d}});var Tb=u("HANDSHAKING_SUCCESS",function(a){return a}),Ub=u("HANDSHAKING_FAILURE",function(a){return a}),Vb=u("HANDSHAKING_RECONNECTING_SUCCESS",function(a){return{cursor:a}}),Wb=u("HANDSHAKING_RECONNECTING_FAILURE",function(a){return a}),Xb=u("HANDSHAKING_RECONNECTING_GIVEUP",function(){return{}}),Yb=u("HANDSHAKING_RECONNECTING_RETRY",function(){return{}}),Zb=u("RECEIVING_SUCCESS",function(a,b){return{cursor:a,events:b}}),$b=u("RECEIVING_FAILURE",function(a){return a}),_b=u("RECONNECTING_SUCCESS",function(a,b){return{cursor:a,events:b}}),ac=u("RECONNECTING_FAILURE",function(a){return a}),bc=u("RECONNECTING_GIVEUP",function(){return{}}),cc=u("RECONNECTING_RETRY",function(){return{}}),dc=function(b){function e(a,e){var f=b.call(this,e)||this;return f.on(Lb.type,Kb(function(b,e,g){var h=g.handshake;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 2:return c=d.sent(),a.transition(Tb(c)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Ub(f))]:[3,4];case 4:return[2]}})})})),f.on(Mb.type,Kb(function(b,e,g){var h=g.receiveEvents;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 2:return c=d.sent(),a.transition(Zb(c.metadata,c.messages)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition($b(f))]:[3,4];case 4:return[2]}})})})),f.on(Nb.type,Kb(function(a,b,e){return e.receiveEvents,c(f,void 0,void 0,function(){return d(this,function(b){return a.length>0&&console.log(a),[2]})})})),f.on(Ob.type,Kb(function(b,e,g){var h=g.receiveEvents,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(bc())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 3:return c=d.sent(),[2,a.transition(_b(c.metadata,c.messages))];
13
- case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(ac(f))]:[3,5];case 5:return[2]}})})})),f.on(Pb.type,Kb(function(b,e,g){var h=g.handshake,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(Xb())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 3:return c=d.sent(),[2,a.transition(Vb(c.metadata))];case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Wb(f))]:[3,5];case 5:return[2]}})})})),f}return a(e,b),e}(Gb),ec=new Eb("STOPPED");ec.on(Qb.type,function(a,b){return ec["with"]({channels:b.payload.channels,groups:b.payload.groups})}),ec.on(Sb.type,function(a){return lc["with"]($({},a))});var fc=new Eb("HANDSHAKE_FAILURE");fc.on(Yb.type,function(a){return kc["with"]($($({},a),{attempts:0}))}),fc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var gc=new Eb("STOPPED");gc.on(Qb.type,function(a,b){return gc["with"]({channels:b.payload.channels,groups:b.payload.groups,cursor:a.cursor})}),gc.on(Sb.type,function(a){return jc["with"]($({},a))});var hc=new Eb("RECEIVE_FAILURE");hc.on(cc.type,function(a){return ic["with"]($($({},a),{attempts:0}))}),hc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var ic=new Eb("RECEIVE_RECONNECTING");ic.onEnter(function(a){return Ob(a)}),ic.onExit(function(){return Ob.cancel}),ic.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),ic.on(ac.type,function(a,b){return ic["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),ic.on(bc.type,function(a){return hc["with"]({groups:a.groups,channels:a.channels,cursor:a.cursor,reason:a.reason})}),ic.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var jc=new Eb("RECEIVING");jc.onEnter(function(a){return Mb(a.channels,a.groups,a.cursor)}),jc.onExit(function(){return Mb.cancel}),jc.on(Zb.type,function(a,b){return jc["with"]($($({},a),{cursor:b.payload.cursor}),[Nb(b.payload.events)])}),jc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):jc["with"]($($({},a),{channels:b.payload.channels,groups:b.payload.groups}))}),jc.on($b.type,function(a,b){return ic["with"]($($({},a),{attempts:0,reason:b.payload}))}),jc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var kc=new Eb("HANDSHAKE_RECONNECTING");kc.onEnter(function(a){return Pb(a)}),kc.onExit(function(){return Ob.cancel}),kc.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),kc.on(ac.type,function(a,b){return kc["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),kc.on(bc.type,function(a){return fc["with"]({groups:a.groups,channels:a.channels,reason:a.reason})}),kc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var lc=new Eb("HANDSHAKING");lc.onEnter(function(a){return Lb(a.channels,a.groups)}),lc.onExit(function(){return Lb.cancel}),lc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):lc["with"]({channels:b.payload.channels,groups:b.payload.groups})}),lc.on(Tb.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload})}),lc.on(Ub.type,function(a,b){return kc["with"]($($({},a),{attempts:0,reason:b.payload}))}),lc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var mc=new Eb("UNSUBSCRIBED");mc.on(Qb.type,function(a,b){return lc["with"]({channels:b.payload.channels,groups:b.payload.groups})});var nc=function(){function a(a){var b=this;this.engine=new Fb,this.channels=[],this.groups=[],this.dispatcher=new dc(this.engine,a),this.engine.subscribe(function(a){"invocationDispatched"===a.type&&b.dispatcher.dispatch(a.invocation)}),this.engine.start(mc,void 0)}return Object.defineProperty(a.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),a.prototype.subscribe=function(a){var b=a.channels,c=a.groups;this.channels=h(h([],g(this.channels),!1),g(null!=b?b:[]),!1),this.groups=h(h([],g(this.groups),!1),g(null!=c?c:[]),!1),this.engine.transition(Qb(this.channels,this.groups))},a.prototype.unsubscribe=function(a){var b=a.channels,c=a.groups;this.channels=this.channels.filter(function(a){var c;return null===(c=!(null==b?void 0:b.includes(a)))||void 0===c||c}),this.groups=this.groups.filter(function(a){var b;return null===(b=!(null==c?void 0:c.includes(a)))||void 0===b||b}),this.engine.transition(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.reconnect=function(){this.engine.transition(Sb())},a.prototype.disconnect=function(){this.engine.transition(Rb())},a}(),oc=function(){function a(a){var b=this,c=a.networking,d=a.cbor,e=new ka({setup:a});this._config=e;var f=new qa({config:e}),i=a.cryptography;c.init(e);var j=new Ea(e,d);this._tokenManager=j;var k=new xa({maximumSamplesCount:6e4});this._telemetryManager=k;var l={config:e,networking:c,crypto:f,cryptography:i,tokenManager:j,telemetryManager:k,PubNubFile:a.PubNubFile};this.File=a.PubNubFile,this.encryptFile=function(a,c){return i.encryptFile(a,c,b.File)},this.decryptFile=function(a,c){return i.decryptFile(a,c,b.File)};var m=q.bind(this,l,zb),n=q.bind(this,l,Pa),o=q.bind(this,l,Ra),p=q.bind(this,l,Ta),r=q.bind(this,l,Ab),s=new Da;if(this._listenerManager=s,this.iAmHere=q.bind(this,l,Ra),this.iAmAway=q.bind(this,l,Pa),this.setPresenceState=q.bind(this,l,Ta),this.handshake=q.bind(this,l,Bb),this.receiveMessages=q.bind(this,l,Cb),!0===e.enableSubscribeBeta){var t=new nc({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=t.subscribe.bind(t),this.unsubscribe=t.unsubscribe.bind(t),this.eventEngine=t}else{var u=new va({timeEndpoint:m,leaveEndpoint:n,heartbeatEndpoint:o,setStateEndpoint:p,subscribeEndpoint:r,crypto:l.crypto,config:l.config,listenerManager:s,getFileUrl:function(a){return ab(l,a)}});this.subscribe=u.adaptSubscribeChange.bind(u),this.unsubscribe=u.adaptUnsubscribeChange.bind(u),this.disconnect=u.disconnect.bind(u),this.reconnect=u.reconnect.bind(u),this.unsubscribeAll=u.unsubscribeAll.bind(u),this.getSubscribedChannels=u.getSubscribedChannels.bind(u),this.getSubscribedChannelGroups=u.getSubscribedChannelGroups.bind(u),this.setState=u.adaptStateChange.bind(u),this.presence=u.adaptPresenceChange.bind(u),this.destroy=function(a){u.unsubscribeAll(a),u.disconnect()}}this.addListener=s.addListener.bind(s),this.removeListener=s.removeListener.bind(s),this.removeAllListeners=s.removeAllListeners.bind(s),this.parseToken=j.parseToken.bind(j),this.setToken=j.setToken.bind(j),this.getToken=j.getToken.bind(j),this.channelGroups={listGroups:q.bind(this,l,Ja),listChannels:q.bind(this,l,Ka),addChannels:q.bind(this,l,Ga),removeChannels:q.bind(this,l,Ha),deleteGroup:q.bind(this,l,Ia)},this.push={addChannels:q.bind(this,l,La),removeChannels:q.bind(this,l,Ma),deleteDevice:q.bind(this,l,Oa),listChannels:q.bind(this,l,Na)},this.hereNow=q.bind(this,l,Ua),this.whereNow=q.bind(this,l,Qa),this.getState=q.bind(this,l,Sa),this.grant=q.bind(this,l,qb),this.grantToken=q.bind(this,l,rb),this.audit=q.bind(this,l,pb),this.revokeToken=q.bind(this,l,sb),this.publish=q.bind(this,l,tb),this.fire=function(a,c){return a.replicate=!1,a.storeInHistory=!1,b.publish(a,c)},this.signal=q.bind(this,l,ub),this.history=q.bind(this,l,vb),this.deleteMessages=q.bind(this,l,wb),this.messageCounts=q.bind(this,l,xb),this.fetchMessages=q.bind(this,l,yb),this.addMessageAction=q.bind(this,l,Va),this.removeMessageAction=q.bind(this,l,Wa),this.getMessageActions=q.bind(this,l,Xa),this.listFiles=q.bind(this,l,Ya);var v=q.bind(this,l,Za);this.publishFile=q.bind(this,l,$a),this.sendFile=_a({generateUploadUrl:v,publishFile:this.publishFile,modules:l}),this.getFileUrl=function(a){return ab(l,a)},this.downloadFile=q.bind(this,l,bb),this.deleteFile=q.bind(this,l,cb),this.objects={getAllUUIDMetadata:q.bind(this,l,db),getUUIDMetadata:q.bind(this,l,eb),setUUIDMetadata:q.bind(this,l,fb),removeUUIDMetadata:q.bind(this,l,gb),getAllChannelMetadata:q.bind(this,l,hb),getChannelMetadata:q.bind(this,l,ib),setChannelMetadata:q.bind(this,l,jb),removeChannelMetadata:q.bind(this,l,kb),getChannelMembers:q.bind(this,l,lb),setChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"set"},a)],g(c),!1))},removeChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"delete"},a)],g(c),!1))},getMemberships:q.bind(this,l,nb),setMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"set"},a)],g(c),!1))},removeMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"delete"},a)],g(c),!1))}},this.createUser=function(a){return b.objects.setUUIDMetadata({uuid:a.userId,data:a.data,include:a.include})},this.updateUser=this.createUser,this.removeUser=function(a){return b.objects.removeUUIDMetadata({uuid:null==a?void 0:a.userId})},this.fetchUser=function(a){return b.objects.getUUIDMetadata({uuid:null==a?void 0:a.userId,include:null==a?void 0:a.include})},this.fetchUsers=this.objects.getAllUUIDMetadata,this.createSpace=function(a){return b.objects.setChannelMetadata({channel:a.spaceId,data:a.data,include:a.include})},this.updateSpace=this.createSpace,this.removeSpace=function(a){return b.objects.removeChannelMetadata({channel:a.spaceId})},this.fetchSpace=function(a){return b.objects.getChannelMetadata({channel:a.spaceId,include:a.include})},this.fetchSpaces=this.objects.getAllChannelMetadata,this.time=m,this.stop=this.destroy,this.encrypt=f.encrypt.bind(f),this.decrypt=f.decrypt.bind(f),this.getAuthKey=l.config.getAuthKey.bind(l.config),this.setAuthKey=l.config.setAuthKey.bind(l.config),this.setCipherKey=l.config.setCipherKey.bind(l.config),this.getUUID=l.config.getUUID.bind(l.config),this.setUUID=l.config.setUUID.bind(l.config),this.getFilterExpression=l.config.getFilterExpression.bind(l.config),this.setFilterExpression=l.config.setFilterExpression.bind(l.config),this.setHeartbeatInterval=l.config.setHeartbeatInterval.bind(l.config),c.hasModule("proxy")&&(this.setProxy=function(a){l.config.setProxy(a),b.reconnect()})}return a.prototype.getVersion=function(){return this._config.getVersion()},a.prototype._addPnsdkSuffix=function(a,b){this._config._addPnsdkSuffix(a,b)},a.prototype.networkDownDetected=function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)},a.prototype.networkUpDetected=function(){this._listenerManager.announceNetworkUp(),this.reconnect()},a.notificationPayload=function(a,b){return new Ca(a,b)},a.generateUUID=function(){return ja()},a.OPERATIONS=wa,a.CATEGORIES=ua,a}(),pc=function(){function a(a){var b=this;this._modules={},Object.keys(a).forEach(function(c){b._modules[c]=a[c].bind(b)})}return a.prototype.init=function(a){this._config=a,Array.isArray(this._config.origin)?this._currentSubDomain=Math.floor(Math.random()*this._config.origin.length):this._currentSubDomain=0,this._coreParams={},this.shiftStandardOrigin()},a.prototype.nextOrigin=function(){var a=this._config.secure?"https://":"http://";if("string"==typeof this._config.origin)return"".concat(a).concat(this._config.origin);this._currentSubDomain+=1,this._currentSubDomain>=this._config.origin.length&&(this._currentSubDomain=0);var b=this._config.origin[this._currentSubDomain];return"".concat(a).concat(b)},a.prototype.hasModule=function(a){return a in this._modules},a.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},a.prototype.getStandardOrigin=function(){return this._standardOrigin},a.prototype.POSTFILE=function(a,b,c){return this._modules.postfile(a,b,c)},a.prototype.GETFILE=function(a,b,c){return this._modules.getfile(a,b,c)},a.prototype.POST=function(a,b,c,d){return this._modules.post(a,b,c,d)},a.prototype.PATCH=function(a,b,c,d){return this._modules.patch(a,b,c,d)},a.prototype.GET=function(a,b,c){return this._modules.get(a,b,c)},a.prototype.DELETE=function(a,b,c){return this._modules.del(a,b,c)},a.prototype._detectErrorCategory=function(a){if("ENOTFOUND"===a.code)return ua.PNNetworkIssuesCategory;if("ECONNREFUSED"===a.code)return ua.PNNetworkIssuesCategory;if("ECONNRESET"===a.code)return ua.PNNetworkIssuesCategory;if("EAI_AGAIN"===a.code)return ua.PNNetworkIssuesCategory;if(0===a.status||a.hasOwnProperty("status")&&void 0===a.status)return ua.PNNetworkIssuesCategory;if(a.timeout)return ua.PNTimeoutCategory;if("ETIMEDOUT"===a.code)return ua.PNNetworkIssuesCategory;if(a.response){if(a.response.badRequest)return ua.PNBadRequestCategory;if(a.response.forbidden)return ua.PNAccessDeniedCategory}return ua.PNUnknownCategory},a}(),qc=function(){function a(a,b){this._base64ToBinary=b,this._decode=a}return a.prototype.decodeToken=function(a){var b="";a.length%4==3?b="=":a.length%4==2&&(b="==");var c=a.replace(/-/gi,"+").replace(/_/gi,"/")+b,d=this._decode(this._base64ToBinary(c));if("object"==typeof d)return d},a}(),rc={exports:{}},sc={exports:{}};!function(a){function b(a){if(a)return function(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}(a)}a.exports=b,b.prototype.on=b.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=b.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c,d=this._callbacks["$"+a];if(!d)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var e=0;e<d.length;e++)if((c=d[e])===b||c.fn===b){d.splice(e,1);break}return 0===d.length&&delete this._callbacks["$"+a],this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){d=0;for(var e=(c=c.slice(0)).length;d<e;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length}}(sc);var tc=x;x["default"]=x,x.stable=B,x.stableStringify=B;var uc="[...]",vc="[Circular]",wc=[],xc=[],yc=String.prototype.replace,zc=/%20/g,Ac="RFC3986",Bc={"default":Ac,formatters:{RFC1738:function(a){return yc.call(a,zc,"+")},RFC3986:function(a){return String(a)}},RFC1738:"RFC1738",RFC3986:Ac},Cc=Bc,Dc=Object.prototype.hasOwnProperty,Ec=Array.isArray,Fc=function(){for(var a=[],b=0;b<256;++b)a.push("%"+((b<16?"0":"")+b.toString(16)).toUpperCase());return a}(),Gc=function(a,b){for(var c=b&&b.plainObjects?Object.create(null):{},d=0;d<a.length;++d)void 0!==a[d]&&(c[d]=a[d]);return c},Hc={arrayToObject:Gc,assign:function(a,b){return Object.keys(b).reduce(function(a,c){return a[c]=b[c],a},a)},combine:function(a,b){return[].concat(a,b)},compact:function(a){for(var b=[{obj:{o:a},prop:"o"}],c=[],d=0;d<b.length;++d)for(var e=b[d],f=e.obj[e.prop],g=Object.keys(f),h=0;h<g.length;++h){var i=g[h],j=f[i];"object"==typeof j&&null!==j&&-1===c.indexOf(j)&&(b.push({obj:f,prop:i}),c.push(j))}return function(a){for(;a.length>1;){var b=a.pop(),c=b.obj[b.prop];if(Ec(c)){for(var d=[],e=0;e<c.length;++e)void 0!==c[e]&&d.push(c[e]);b.obj[b.prop]=d}}}(b),a},decode:function(a,b,c){var d=a.replace(/\+/g," ");if("iso-8859-1"===c)return d.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(d)}catch(a){return d}},encode:function(a,b,c,d,e){if(0===a.length)return a;var f=a;if("symbol"==typeof a?f=Symbol.prototype.toString.call(a):"string"!=typeof a&&(f=String(a)),"iso-8859-1"===c)return escape(f).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});for(var g="",h=0;h<f.length;++h){var i=f.charCodeAt(h);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||e===Cc.RFC1738&&(40===i||41===i)?g+=f.charAt(h):i<128?g+=Fc[i]:i<2048?g+=Fc[192|i>>6]+Fc[128|63&i]:i<55296||i>=57344?g+=Fc[224|i>>12]+Fc[128|i>>6&63]+Fc[128|63&i]:(h+=1,i=65536+((1023&i)<<10|1023&f.charCodeAt(h)),g+=Fc[240|i>>18]+Fc[128|i>>12&63]+Fc[128|i>>6&63]+Fc[128|63&i])}return g},isBuffer:function(a){return!(!a||"object"!=typeof a||!(a.constructor&&a.constructor.isBuffer&&a.constructor.isBuffer(a)))},isRegExp:function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},maybeMap:function(a,b){if(Ec(a)){for(var c=[],d=0;d<a.length;d+=1)c.push(b(a[d]));return c}return b(a)},merge:function od(a,b,c){if(!b)return a;if("object"!=typeof b){if(Ec(a))a.push(b);else{if(!a||"object"!=typeof a)return[a,b];(c&&(c.plainObjects||c.allowPrototypes)||!Dc.call(Object.prototype,b))&&(a[b]=!0)}return a}if(!a||"object"!=typeof a)return[a].concat(b);var d=a;return Ec(a)&&!Ec(b)&&(d=Gc(a,c)),Ec(a)&&Ec(b)?(b.forEach(function(b,d){if(Dc.call(a,d)){var e=a[d];e&&"object"==typeof e&&b&&"object"==typeof b?a[d]=od(e,b,c):a.push(b)}else a[d]=b}),a):Object.keys(b).reduce(function(a,d){var e=b[d];return Dc.call(a,d)?a[d]=od(a[d],e,c):a[d]=e,a},d)}},Ic=Hc,Jc=Bc,Kc=Object.prototype.hasOwnProperty,Lc={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},Mc=Array.isArray,Nc=String.prototype.split,Oc=Array.prototype.push,Pc=function(a,b){Oc.apply(a,Mc(b)?b:[b])},Qc=Date.prototype.toISOString,Rc=Jc["default"],Sc={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Ic.encode,encodeValuesOnly:!1,format:Rc,formatter:Jc.formatters[Rc],indices:!1,serializeDate:function(a){return Qc.call(a)},skipNulls:!1,strictNullHandling:!1},Tc=function pd(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o,p=a;if("function"==typeof g?p=g(b,p):p instanceof Date?p=j(p):"comma"===c&&Mc(p)&&(p=Ic.maybeMap(p,function(a){return a instanceof Date?j(a):a})),null===p){if(d)return f&&!m?f(b,Sc.encoder,n,"key",k):b;p=""}if("string"==typeof(o=p)||"number"==typeof o||"boolean"==typeof o||"symbol"==typeof o||"bigint"==typeof o||Ic.isBuffer(p)){if(f){var q=m?b:f(b,Sc.encoder,n,"key",k);if("comma"===c&&m){for(var r=Nc.call(String(p),","),s="",t=0;t<r.length;++t)s+=(0===t?"":",")+l(f(r[t],Sc.encoder,n,"value",k));return[l(q)+"="+s]}return[l(q)+"="+l(f(p,Sc.encoder,n,"value",k))]}return[l(b)+"="+l(String(p))]}var u,v=[];if(void 0===p)return v;if("comma"===c&&Mc(p))u=[{value:p.length>0?p.join(",")||null:void 0}];else if(Mc(g))u=g;else{var w=Object.keys(p);u=h?w.sort(h):w}for(var x=0;x<u.length;++x){var y=u[x],z="object"==typeof y&&void 0!==y.value?y.value:p[y];if(!e||null!==z){var A=Mc(p)?"function"==typeof c?c(b,y):b:b+(i?"."+y:"["+y+"]");Pc(v,pd(z,A,c,d,e,f,g,h,i,j,k,l,m,n))}}return v},Uc=Hc,Vc=Object.prototype.hasOwnProperty,Wc=Array.isArray,Xc={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Uc.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Yc=function(a){return a.replace(/&#(\d+);/g,function(a,b){return String.fromCharCode(parseInt(b,10))})},Zc=function(a,b){return a&&"string"==typeof a&&b.comma&&a.indexOf(",")>-1?a.split(","):a},$c=function(a,b,c,d){if(a){var e=c.allowDots?a.replace(/\.([^.[]+)/g,"[$1]"):a,f=/(\[[^[\]]*])/g,g=c.depth>0&&/(\[[^[\]]*])/.exec(e),h=g?e.slice(0,g.index):e,i=[];if(h){if(!c.plainObjects&&Vc.call(Object.prototype,h)&&!c.allowPrototypes)return;i.push(h)}for(var j=0;c.depth>0&&null!==(g=f.exec(e))&&j<c.depth;){if(j+=1,!c.plainObjects&&Vc.call(Object.prototype,g[1].slice(1,-1))&&!c.allowPrototypes)return;i.push(g[1])}return g&&i.push("["+e.slice(g.index)+"]"),function(a,b,c,d){for(var e=d?b:Zc(b,c),f=a.length-1;f>=0;--f){var g,h=a[f];if("[]"===h&&c.parseArrays)g=[].concat(e);else{g=c.plainObjects?Object.create(null):{};var i="["===h.charAt(0)&&"]"===h.charAt(h.length-1)?h.slice(1,-1):h,j=parseInt(i,10);c.parseArrays||""!==i?!isNaN(j)&&h!==i&&String(j)===i&&j>=0&&c.parseArrays&&j<=c.arrayLimit?(g=[])[j]=e:"__proto__"!==i&&(g[i]=e):g={0:e}}e=g}return e}(i,b,c,d)}},_c={formats:Bc,parse:function(a,b){var c=function(a){if(!a)return Xc;if(null!==a.decoder&&void 0!==a.decoder&&"function"!=typeof a.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=void 0===a.charset?Xc.charset:a.charset;return{allowDots:void 0===a.allowDots?Xc.allowDots:!!a.allowDots,allowPrototypes:"boolean"==typeof a.allowPrototypes?a.allowPrototypes:Xc.allowPrototypes,arrayLimit:"number"==typeof a.arrayLimit?a.arrayLimit:Xc.arrayLimit,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Xc.charsetSentinel,comma:"boolean"==typeof a.comma?a.comma:Xc.comma,decoder:"function"==typeof a.decoder?a.decoder:Xc.decoder,delimiter:"string"==typeof a.delimiter||Uc.isRegExp(a.delimiter)?a.delimiter:Xc.delimiter,depth:"number"==typeof a.depth||!1===a.depth?+a.depth:Xc.depth,ignoreQueryPrefix:!0===a.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof a.interpretNumericEntities?a.interpretNumericEntities:Xc.interpretNumericEntities,parameterLimit:"number"==typeof a.parameterLimit?a.parameterLimit:Xc.parameterLimit,parseArrays:!1!==a.parseArrays,plainObjects:"boolean"==typeof a.plainObjects?a.plainObjects:Xc.plainObjects,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Xc.strictNullHandling}}(b);if(""===a||null==a)return c.plainObjects?Object.create(null):{};for(var d="string"==typeof a?function(a,b){var c,d={},e=b.ignoreQueryPrefix?a.replace(/^\?/,""):a,f=b.parameterLimit===1/0?void 0:b.parameterLimit,g=e.split(b.delimiter,f),h=-1,i=b.charset;if(b.charsetSentinel)for(c=0;c<g.length;++c)0===g[c].indexOf("utf8=")&&("utf8=%E2%9C%93"===g[c]?i="utf-8":"utf8=%26%2310003%3B"===g[c]&&(i="iso-8859-1"),h=c,c=g.length);for(c=0;c<g.length;++c)if(c!==h){var j,k,l=g[c],m=l.indexOf("]="),n=-1===m?l.indexOf("="):m+1;-1===n?(j=b.decoder(l,Xc.decoder,i,"key"),k=b.strictNullHandling?null:""):(j=b.decoder(l.slice(0,n),Xc.decoder,i,"key"),k=Uc.maybeMap(Zc(l.slice(n+1),b),function(a){return b.decoder(a,Xc.decoder,i,"value")})),k&&b.interpretNumericEntities&&"iso-8859-1"===i&&(k=Yc(k)),l.indexOf("[]=")>-1&&(k=Wc(k)?[k]:k),Vc.call(d,j)?d[j]=Uc.combine(d[j],k):d[j]=k}return d}(a,c):a,e=c.plainObjects?Object.create(null):{},f=Object.keys(d),g=0;g<f.length;++g){var h=f[g],i=$c(h,d[h],c,"string"==typeof a);e=Uc.merge(e,i,c)}return Uc.compact(e)},stringify:function(a,b){var c,d=a,e=function(a){if(!a)return Sc;if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");var b=a.charset||Sc.charset;if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var c=Jc["default"];if(void 0!==a.format){if(!Kc.call(Jc.formatters,a.format))throw new TypeError("Unknown format option provided.");c=a.format}var d=Jc.formatters[c],e=Sc.filter;return("function"==typeof a.filter||Mc(a.filter))&&(e=a.filter),{addQueryPrefix:"boolean"==typeof a.addQueryPrefix?a.addQueryPrefix:Sc.addQueryPrefix,allowDots:void 0===a.allowDots?Sc.allowDots:!!a.allowDots,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Sc.charsetSentinel,delimiter:void 0===a.delimiter?Sc.delimiter:a.delimiter,encode:"boolean"==typeof a.encode?a.encode:Sc.encode,encoder:"function"==typeof a.encoder?a.encoder:Sc.encoder,encodeValuesOnly:"boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:Sc.encodeValuesOnly,filter:e,format:c,formatter:d,serializeDate:"function"==typeof a.serializeDate?a.serializeDate:Sc.serializeDate,skipNulls:"boolean"==typeof a.skipNulls?a.skipNulls:Sc.skipNulls,sort:"function"==typeof a.sort?a.sort:null,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Sc.strictNullHandling}}(b);"function"==typeof e.filter?d=(0,e.filter)("",d):Mc(e.filter)&&(c=e.filter);var f,g=[];if("object"!=typeof d||null===d)return"";f=b&&b.arrayFormat in Lc?b.arrayFormat:b&&"indices"in b?b.indices?"indices":"repeat":"indices";var h=Lc[f];c||(c=Object.keys(d)),e.sort&&c.sort(e.sort);for(var i=0;i<c.length;++i){var j=c[i];e.skipNulls&&null===d[j]||Pc(g,Tc(d[j],j,h,e.strictNullHandling,e.skipNulls,e.encode?e.encoder:null,e.filter,e.sort,e.allowDots,e.serializeDate,e.format,e.formatter,e.encodeValuesOnly,e.charset))}var k=g.join(e.delimiter),l=!0===e.addQueryPrefix?"?":"";return e.charsetSentinel&&(l+="iso-8859-1"===e.charset?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),k.length>0?l+k:""}},ad=function(a){return null!==a&&"object"===E(a)},bd=ad,cd=G;G.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},G.prototype.parse=function(a){return this._parser=a,this},G.prototype.responseType=function(a){return this._responseType=a,this},G.prototype.serialize=function(a){return this._serializer=a,this},G.prototype.timeout=function(a){if(!a||"object"!==F(a))return this._timeout=a,this._responseTimeout=0,this._uploadTimeout=0,this;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))switch(b){case"deadline":this._timeout=a.deadline;break;case"response":this._responseTimeout=a.response;break;case"upload":this._uploadTimeout=a.upload;break;default:console.warn("Unknown timeout option",b)}return this},G.prototype.retry=function(a,b){return 0!==arguments.length&&!0!==a||(a=1),a<=0&&(a=0),this._maxRetries=a,this._retries=0,this._retryCallback=b,this};var dd=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),ed=new Set([408,413,429,500,502,503,504,521,522,524]);G.prototype._shouldRetry=function(a,b){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var c=this._retryCallback(a,b);if(!0===c)return!0;if(!1===c)return!1}catch(a){console.error(a)}if(b&&b.status&&ed.has(b.status))return!0;if(a){if(a.code&&dd.has(a.code))return!0;if(a.timeout&&"ECONNABORTED"===a.code)return!0;if(a.crossDomain)return!0}return!1},G.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},G.prototype.then=function(a,b){var c=this;if(!this._fullfilledPromise){var d=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(a,b){d.on("abort",function(){if(!(c._maxRetries&&c._maxRetries>c._retries))if(c.timedout&&c.timedoutError)b(c.timedoutError);else{var a=new Error("Aborted");a.code="ABORTED",a.status=c.status,a.method=c.method,a.url=c.url,b(a)}}),d.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},G.prototype["catch"]=function(a){return this.then(void 0,a)},G.prototype.use=function(a){return a(this),this},G.prototype.ok=function(a){if("function"!=typeof a)throw new Error("Callback required");return this._okCallback=a,this},G.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},G.prototype.get=function(a){return this._header[a.toLowerCase()]},G.prototype.getHeader=G.prototype.get,G.prototype.set=function(a,b){if(bd(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},G.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},G.prototype.field=function(a,b){if(null==a)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(bd(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.field(c,a[c]);return this}if(Array.isArray(b)){for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&this.field(a,b[d]);return this}if(null==b)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof b&&(b=String(b)),this._getFormData().append(a,b),this},G.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},G.prototype._auth=function(a,b,c,d){switch(c.type){case"basic":this.set("Authorization","Basic ".concat(d("".concat(a,":").concat(b))));break;case"auto":this.username=a,this.password=b;break;case"bearer":this.set("Authorization","Bearer ".concat(a))}return this},G.prototype.withCredentials=function(a){return void 0===a&&(a=!0),this._withCredentials=a,this},G.prototype.redirects=function(a){return this._maxRedirects=a,this},G.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw new TypeError("Invalid argument");return this._maxResponseSize=a,this},G.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},G.prototype.send=function(a){var b=bd(a),c=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(b&&!this._data)Array.isArray(a)?this._data=[]:this._isHost(a)||(this._data={});else if(a&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(b&&bd(this._data))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(this._data[d]=a[d]);else"string"==typeof a?(c||this.type("form"),(c=this._header["content-type"])&&(c=c.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===c?this._data?"".concat(this._data,"&").concat(a):a:(this._data||"")+a):this._data=a;return!b||this._isHost(a)||c||this.type("json"),this},G.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},G.prototype._finalizeQueryString=function(){var a=this._query.join("&");if(a&&(this.url+=(this.url.includes("?")?"&":"?")+a),this._query.length=0,this._sort){var b=this.url.indexOf("?");if(b>=0){var c=this.url.slice(b+1).split("&");"function"==typeof this._sort?c.sort(this._sort):c.sort(),this.url=this.url.slice(0,b)+"?"+c.join("&")}}},G.prototype._appendQueryString=function(){console.warn("Unsupported")},G.prototype._timeoutError=function(a,b,c){if(!this._aborted){var d=new Error("".concat(a+b,"ms exceeded"));d.timeout=b,d.code="ECONNABORTED",d.errno=c,this.timedout=!0,this.timedoutError=d,this.abort(),this.callback(d)}},G.prototype._setTimeouts=function(){var a=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){a._timeoutError("Timeout of ",a._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){a._timeoutError("Response timeout of ",a._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var fd={};
14
- fd.type=function(a){return a.split(/ *; */).shift()},fd.params=function(a){var b,c={},d=H(a.split(/ *; */));try{for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *= */),f=e.shift(),g=e.shift();f&&g&&(c[f]=g)}}catch(a){d.e(a)}finally{d.f()}return c},fd.parseLinks=function(a){var b,c={},d=H(a.split(/ *, */));try{for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *; */),f=e[0].slice(1,-1);c[e[1].split(/ *= */)[1].slice(1,-1)]=f}}catch(a){d.e(a)}finally{d.f()}return c},fd.cleanHeader=function(a,b){return delete a["content-type"],delete a["content-length"],delete a["transfer-encoding"],delete a.host,b&&(delete a.authorization,delete a.cookie),a};var gd=fd,hd=J;J.prototype.get=function(a){return this.header[a.toLowerCase()]},J.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=gd.type(b);var c=gd.params(b);for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(this[d]=c[d]);this.links={};try{a.link&&(this.links=gd.parseLinks(a.link))}catch(a){}},J.prototype._setStatusProperties=function(a){var b=a/100|0;this.statusCode=a,this.status=this.statusCode,this.statusType=b,this.info=1===b,this.ok=2===b,this.redirect=3===b,this.clientError=4===b,this.serverError=5===b,this.error=(4===b||5===b)&&this.toError(),this.created=201===a,this.accepted=202===a,this.noContent=204===a,this.badRequest=400===a,this.unauthorized=401===a,this.notAcceptable=406===a,this.forbidden=403===a,this.notFound=404===a,this.unprocessableEntity=422===a},["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"].forEach(function(a){M.prototype[a]=function(){for(var b=arguments.length,c=new Array(b),d=0;d<b;d++)c[d]=arguments[d];return this._defaults.push({fn:a,args:c}),this}}),M.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,K(b.args))})};var id=M;!function(a,b){function c(a){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function d(){}function e(a){if(!q(a))return a;var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(void 0!==c)if(null!==c)if(Array.isArray(c))c.forEach(function(c){f(a,b,c)});else if(q(c))for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&f(a,"".concat(b,"[").concat(d,"]"),c[d]);else a.push(encodeURI(b)+"="+encodeURIComponent(c));else a.push(encodeURI(b))}function g(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)-1===(c=(b=e[f]).indexOf("="))?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){return/[/+]json($|[^-\w])/i.test(a)}function i(a){this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var b=this.xhr.status;1223===b&&(b=204),this._setStatusProperties(b),this.headers=function(a){for(var b,c,d,e,f=a.split(/\r?\n/),g={},h=0,i=f.length;h<i;++h)-1!==(b=(c=f[h]).indexOf(":"))&&(d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e);return g}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&a._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function j(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a,b=null,d=null;try{d=new i(c)}catch(a){return(b=new Error("Parser is unable to parse the response")).parse=!0,b.original=a,c.xhr?(b.rawResponse=void 0===c.xhr.responseType?c.xhr.responseText:c.xhr.response,b.status=c.xhr.status?c.xhr.status:null,b.statusCode=b.status):(b.rawResponse=null,b.status=null),c.callback(b)}c.emit("response",d);try{c._isResponseOK(d)||(a=new Error(d.statusText||d.text||"Unsuccessful HTTP response"))}catch(b){a=b}a?(a.original=b,a.response=d,a.status=d.status,c.callback(a,d)):c.callback(null,d)})}function k(a,b,c){var d=t("DELETE",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}var l;"undefined"!=typeof window?l=window:"undefined"==typeof self?(console.warn("Using browser-only version of superagent in non-browser environment"),l=void 0):l=self;var m=sc.exports,n=tc,o=_c,p=cd,q=ad,r=hd,s=id;a.exports=function(a,c){return"function"==typeof c?new b.Request("GET",a).end(c):1===arguments.length?new b.Request("GET",a):new b.Request(a,c)};var t=b=a.exports;b.Request=j,t.getXHR=function(){if(l.XMLHttpRequest&&(!l.location||"file:"!==l.location.protocol||!l.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}throw new Error("Browser-only version of superagent could not find XHR")};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};t.serializeObject=e,t.parseString=g,t.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},t.serialize={"application/x-www-form-urlencoded":o.stringify,"application/json":n},t.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},r(i.prototype),i.prototype._parseBody=function(a){var b=t.parse[this.type];return this.req._parser?this.req._parser(this,a):(!b&&h(this.type)&&(b=t.parse["application/json"]),b&&a&&(a.length>0||a instanceof Object)?b(a):null)},i.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot ".concat(b," ").concat(c," (").concat(this.status,")"),e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},t.Response=i,m(j.prototype),p(j.prototype),j.prototype.type=function(a){return this.set("Content-Type",t.types[a]||a),this},j.prototype.accept=function(a){return this.set("Accept",t.types[a]||a),this},j.prototype.auth=function(a,b,d){1===arguments.length&&(b=""),"object"===c(b)&&null!==b&&(d=b,b=""),d||(d={type:"function"==typeof btoa?"basic":"auto"});var e=function(a){if("function"==typeof btoa)return btoa(a);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(a,b,d,e)},j.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},j.prototype.attach=function(a,b,c){if(b){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(a,b,c||b.name)}return this},j.prototype._getFormData=function(){return this._formData||(this._formData=new l.FormData),this._formData},j.prototype.callback=function(a,b){if(this._shouldRetry(a,b))return this._retry();var c=this._callback;this.clearTimeout(),a&&(this._maxRetries&&(a.retries=this._retries-1),this.emit("error",a)),c(a,b)},j.prototype.crossDomainError=function(){var a=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},j.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},j.prototype.ca=j.prototype.agent,j.prototype.buffer=j.prototype.ca,j.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},j.prototype.pipe=j.prototype.write,j.prototype._isHost=function(a){return a&&"object"===c(a)&&!Array.isArray(a)&&"[object Object]"!==Object.prototype.toString.call(a)},j.prototype.end=function(a){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=a||d,this._finalizeQueryString(),this._end()},j.prototype._setUploadTimeout=function(){var a=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){a._timeoutError("Upload timeout of ",a._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},j.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var a=this;this.xhr=t.getXHR();var b=this.xhr,c=this._formData||this._data;this._setTimeouts(),b.onreadystatechange=function(){var a=b.readyState;if(a>=2&&d._responseTimeoutTimer&&clearTimeout(d._responseTimeoutTimer),4===a){var c;try{c=b.status}catch(d){c=0}if(!c){if(d.timedout||d._aborted)return;return d.crossDomainError()}d.emit("end")}};var d=function(b,c){c.total>0&&(c.percent=c.loaded/c.total*100,100===c.percent&&clearTimeout(a._uploadTimeoutTimer)),c.direction=b,a.emit("progress",c)};if(this.hasListeners("progress"))try{b.addEventListener("progress",d.bind(null,"download")),b.upload&&b.upload.addEventListener("progress",d.bind(null,"upload"))}catch(a){}b.upload&&this._setUploadTimeout();try{this.username&&this.password?b.open(this.method,this.url,!0,this.username,this.password):b.open(this.method,this.url,!0)}catch(a){return this.callback(a)}if(this._withCredentials&&(b.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof c&&!this._isHost(c)){var e=this._header["content-type"],f=this._serializer||t.serialize[e?e.split(";")[0]:""];!f&&h(e)&&(f=t.serialize["application/json"]),f&&(c=f(c))}for(var g in this.header)null!==this.header[g]&&Object.prototype.hasOwnProperty.call(this.header,g)&&b.setRequestHeader(g,this.header[g]);this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(void 0===c?null:c)},t.agent=function(){return new s},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(a){s.prototype[a.toLowerCase()]=function(b,c){var d=new t.Request(a,b);return this._setDefaults(d),c&&d.end(c),d}}),s.prototype.del=s.prototype["delete"],t.get=function(a,b,c){var d=t("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.head=function(a,b,c){var d=t("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.options=function(a,b,c){var d=t("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.del=k,t["delete"]=k,t.patch=function(a,b,c){var d=t("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.post=function(a,b,c){var d=t("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.put=function(a,b,c){var d=t("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}}(rc,rc.exports);var jd,kd=rc.exports,ld=function(){function a(){}return Object.defineProperty(a.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),a.prototype.encrypt=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.encryptString(c,b)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}})})},a.prototype.decrypt=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.decryptString(c,b)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}})})},a.prototype.encryptFile=function(a,b,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.encryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,mimeType:"application/octet-stream",data:g})]}})})},a.prototype.decryptFile=function(a,b,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.decryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,data:g})]}})})},a.prototype.getKey=function(a){return c(this,void 0,void 0,function(){var b,c,f;return d(this,function(d){switch(d.label){case 0:return b=e.from(a),[4,crypto.subtle.digest("SHA-256",b.buffer)];case 1:return c=d.sent(),f=e.from(e.from(c).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",f,"AES-CBC",!0,["encrypt","decrypt"])]}})})},a.prototype.encryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c,e,f;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),e=V,f=[c.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,b)];case 1:return[2,e.apply(void 0,f.concat([d.sent()]))]}})})},a.prototype.decryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){return c=b.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:c},a,b.slice(16))]})})},a.prototype.encryptString=function(a,b){return c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),f=e.from(b).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,f)];case 1:return g=d.sent(),h=V(c.buffer,g),[2,e.from(h).toString("utf8")]}})})},a.prototype.decryptString=function(a,b){return c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=e.from(b),f=c.slice(0,16),g=c.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:f},a,g)];case 1:return h=d.sent(),[2,e.from(h).toString("utf8")]}})})},a.IV_LENGTH=16,a}(),md=(jd=function(){function a(a){if(a instanceof File)this.data=a,this.name=this.data.name,this.mimeType=this.data.type;else if(a.data){var b=a.data;this.data=new File([b],a.name,{type:a.mimeType}),this.name=a.name,a.mimeType&&(this.mimeType=a.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return a.create=function(a){return new this(a)},a.prototype.toBuffer=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toStream=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toFileUri=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in react native environments.")})})},a.prototype.toBlob=function(){return c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a.prototype.toArrayBuffer=function(){return c(this,void 0,void 0,function(){var a=this;return d(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if(d.result instanceof ArrayBuffer)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsArrayBuffer(a.data)})]})})},a.prototype.toString=function(){return c(this,void 0,void 0,function(){var a=this;return d(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if("string"==typeof d.result)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsBinaryString(a.data)})]})})},a.prototype.toFile=function(){return c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a}(),jd.supportsFile="undefined"!=typeof File,jd.supportsBlob="undefined"!=typeof Blob,jd.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,jd.supportsBuffer=!1,jd.supportsStream=!1,jd.supportsString=!0,jd.supportsEncryptFile=!0,jd.supportsFileUri=!1,jd),nd=function(b){function c(a){var c=this,d=a.listenToBrowserNetworkEvents,e=void 0===d||d;return a.sdkFamily="Web",a.networking=new pc({del:U,get:R,post:S,patch:T,sendBeacon:W,getfile:Q,postfile:P}),a.cbor=new qc(function(a){return Y(ba.decode(a))},X),a.PubNubFile=md,a.cryptography=new ld,c=b.call(this,a)||this,e&&(window.addEventListener("offline",function(){c.networkDownDetected()}),window.addEventListener("online",function(){c.networkUpDetected()})),c}return a(c,b),c}(oc);return nd})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b("buffer").Buffer)},{buffer:38}],46:[function(b,c,d){(function(b){!function(b){"use strict";if("function"==typeof bootstrap)bootstrap("promise",b);else if("object"==typeof d&&"object"==typeof c)c.exports=b();else if("function"==typeof a&&a.amd)a(b);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=b}else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var e="undefined"!=typeof window?window:self,f=e.Q;e.Q=b(),e.Q.noConflict=function(){return e.Q=f,this}}}(function(){"use strict";function a(a){return function(){return X.apply(a,arguments)}}function c(a){return a===Object(a)}function d(a){return"[object StopIteration]"===da(a)||a instanceof T}function e(a,b){if(Q&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&a.stack.indexOf(ea)===-1){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var e=c.join("\n"+ea+"\n");a.stack=f(e)}}function f(a){for(var b=a.split("\n"),c=[],d=0;d<b.length;++d){var e=b[d];i(e)||g(e)||!e||c.push(e)}return c.join("\n")}function g(a){return a.indexOf("(module.js:")!==-1||a.indexOf("(node.js:")!==-1}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===S&&d>=U&&d<=ja}function j(){if(Q)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return S=d[0],d[1]}}function k(a,b,c){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(b+" is deprecated, use "+c+" instead.",new Error("").stack),a.apply(a,arguments)}}function l(a){return a instanceof p?a:t(a)?C(a):B(a)}function m(){function a(a){b=a,f.source=a,Z(c,function(b,c){l.nextTick(function(){a.promiseDispatch.apply(a,c)})},void 0),c=void 0,d=void 0}var b,c=[],d=[],e=aa(m.prototype),f=aa(p.prototype);if(f.promiseDispatch=function(a,e,f){var g=Y(arguments);c?(c.push(g),"when"===e&&f[1]&&d.push(f[1])):l.nextTick(function(){b.promiseDispatch.apply(b,g)})},f.valueOf=function(){if(c)return f;var a=r(b);return s(a)&&(b=a),a},f.inspect=function(){return b?b.inspect():{state:"pending"}},l.longStackSupport&&Q)try{throw new Error}catch(g){f.stack=g.stack.substring(g.stack.indexOf("\n")+1)}return e.promise=f,e.resolve=function(c){b||a(l(c))},e.fulfill=function(c){b||a(B(c))},e.reject=function(c){b||a(A(c))},e.notify=function(a){b||Z(d,function(b,c){l.nextTick(function(){c(a)})},void 0)},e}function n(a){if("function"!=typeof a)throw new TypeError("resolver must be a function.");var b=m();try{a(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}return b.promise}function o(a){return n(function(b,c){for(var d=0,e=a.length;d<e;d++)l(a[d]).then(b,c)})}function p(a,b,c){void 0===b&&(b=function(a){return A(new Error("Promise does not support operation: "+a))}),void 0===c&&(c=function(){return{state:"unknown"}});var d=aa(p.prototype);if(d.promiseDispatch=function(c,e,f){var g;try{g=a[e]?a[e].apply(d,f):b.call(d,e,f)}catch(h){g=A(h)}c&&c(g)},d.inspect=c,c){var e=c();"rejected"===e.state&&(d.exception=e.reason),d.valueOf=function(){var a=c();return"pending"===a.state||"rejected"===a.state?d:a.value}}return d}function q(a,b,c,d){return l(a).then(b,c,d)}function r(a){if(s(a)){var b=a.inspect();if("fulfilled"===b.state)return b.value}return a}function s(a){return a instanceof p}function t(a){return c(a)&&"function"==typeof a.then}function u(a){return s(a)&&"pending"===a.inspect().state}function v(a){return!s(a)||"fulfilled"===a.inspect().state}function w(a){return s(a)&&"rejected"===a.inspect().state}function x(){fa.length=0,ga.length=0,ia||(ia=!0)}function y(a,c){ia&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){$(ga,a)!==-1&&(b.emit("unhandledRejection",c,a),ha.push(a))}),ga.push(a),c&&"undefined"!=typeof c.stack?fa.push(c.stack):fa.push("(no stack) "+c))}function z(a){if(ia){var c=$(ga,a);c!==-1&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){var d=$(ha,a);d!==-1&&(b.emit("rejectionHandled",fa[c],a),ha.splice(d,1))}),ga.splice(c,1),fa.splice(c,1))}}function A(a){var b=p({when:function(b){return b&&z(this),b?b(a):this}},function(){return this},function(){return{state:"rejected",reason:a}});return y(b,a),b}function B(a){return p({when:function(){return a},get:function(b){return a[b]},set:function(b,c){a[b]=c},"delete":function(b){delete a[b]},post:function(b,c){return null===b||void 0===b?a.apply(void 0,c):a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},keys:function(){return ca(a)}},void 0,function(){return{state:"fulfilled",value:a}})}function C(a){var b=m();return l.nextTick(function(){try{a.then(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}}),b.promise}function D(a){return p({isDef:function(){}},function(b,c){return J(a,b,c)},function(){return l(a).inspect()})}function E(a,b,c){return l(a).spread(b,c)}function F(a){return function(){function b(a,b){var g;if("undefined"==typeof StopIteration){try{g=c[a](b)}catch(h){return A(h)}return g.done?l(g.value):q(g.value,e,f)}try{g=c[a](b)}catch(h){return d(h)?l(h.value):A(h)}return q(g,e,f)}var c=a.apply(this,arguments),e=b.bind(b,"next"),f=b.bind(b,"throw");return e()}}function G(a){l.done(l.async(a)())}function H(a){throw new T(a)}function I(a){return function(){return E([this,K(arguments)],function(b,c){return a.apply(b,c)})}}function J(a,b,c){return l(a).dispatch(b,c)}function K(a){return q(a,function(a){var b=0,c=m();return Z(a,function(d,e,f){var g;s(e)&&"fulfilled"===(g=e.inspect()).state?a[f]=g.value:(++b,q(e,function(d){a[f]=d,0===--b&&c.resolve(a)},c.reject,function(a){c.notify({index:f,value:a})}))},void 0),0===b&&c.resolve(a),c.promise})}function L(a){if(0===a.length)return l.resolve();var b=l.defer(),c=0;return Z(a,function(d,e,f){function g(a){b.resolve(a)}function h(){c--,0===c&&b.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function i(a){b.notify({index:f,value:a})}var j=a[f];c++,q(j,g,h,i)},void 0),b.promise}function M(a){return q(a,function(a){return a=_(a,l),q(K(_(a,function(a){return q(a,V,V)})),function(){return a})})}function N(a){return l(a).allSettled()}function O(a,b){return l(a).then(void 0,void 0,b)}function P(a,b){return l(a).nodeify(b)}var Q=!1;try{throw new Error}catch(R){Q=!!R.stack}var S,T,U=j(),V=function(){},W=function(){function a(){for(var a,b;d.next;)d=d.next,a=d.task,d.task=void 0,b=d.domain,b&&(d.domain=void 0,b.enter()),c(a,b);for(;i.length;)a=i.pop(),c(a);f=!1}function c(b,c){try{b()}catch(d){if(h)throw c&&c.exit(),setTimeout(a,0),c&&c.enter(),d;setTimeout(function(){throw d},0)}c&&c.exit()}var d={task:void 0,next:null},e=d,f=!1,g=void 0,h=!1,i=[];if(W=function(a){e=e.next={task:a,domain:h&&b.domain,next:null},f||(f=!0,g())},"object"==typeof b&&"[object process]"===b.toString()&&b.nextTick)h=!0,g=function(){b.nextTick(a)};else if("function"==typeof setImmediate)g="undefined"!=typeof window?setImmediate.bind(window,a):function(){setImmediate(a)};else if("undefined"!=typeof MessageChannel){var j=new MessageChannel;j.port1.onmessage=function(){g=k,j.port1.onmessage=a,a()};var k=function(){j.port2.postMessage(0)};g=function(){setTimeout(a,0),k()}}else g=function(){setTimeout(a,0)};return W.runAfter=function(a){i.push(a),f||(f=!0,g())},W}(),X=Function.call,Y=a(Array.prototype.slice),Z=a(Array.prototype.reduce||function(a,b){var c=0,d=this.length;if(1===arguments.length)for(;;){if(c in this){b=this[c++];break}if(++c>=d)throw new TypeError}for(;c<d;c++)c in this&&(b=a(b,this[c],c));return b}),$=a(Array.prototype.indexOf||function(a){for(var b=0;b<this.length;b++)if(this[b]===a)return b;return-1}),_=a(Array.prototype.map||function(a,b){var c=this,d=[];return Z(c,function(e,f,g){d.push(a.call(b,f,g,c))},void 0),d}),aa=Object.create||function(a){function b(){}return b.prototype=a,new b},ba=a(Object.prototype.hasOwnProperty),ca=Object.keys||function(a){var b=[];for(var c in a)ba(a,c)&&b.push(c);return b},da=a(Object.prototype.toString);T="undefined"!=typeof ReturnValue?ReturnValue:function(a){this.value=a};var ea="From previous event:";l.resolve=l,l.nextTick=W,l.longStackSupport=!1,"object"==typeof b&&b&&b.env&&b.env.Q_DEBUG&&(l.longStackSupport=!0),l.defer=m,m.prototype.makeNodeResolver=function(){var a=this;return function(b,c){b?a.reject(b):arguments.length>2?a.resolve(Y(arguments,1)):a.resolve(c)}},l.Promise=n,l.promise=n,n.race=o,n.all=K,n.reject=A,n.resolve=l,l.passByCopy=function(a){return a},p.prototype.passByCopy=function(){return this},l.join=function(a,b){return l(a).join(b)},p.prototype.join=function(a){return l([this,a]).spread(function(a,b){if(a===b)return a;throw new Error("Can't join: not the same: "+a+" "+b)})},l.race=o,p.prototype.race=function(){return this.then(l.race)},l.makePromise=p,p.prototype.toString=function(){return"[object Promise]"},p.prototype.then=function(a,b,c){function d(b){try{return"function"==typeof a?a(b):b}catch(c){return A(c)}}function f(a){if("function"==typeof b){e(a,h);try{return b(a)}catch(c){return A(c)}}return A(a)}function g(a){return"function"==typeof c?c(a):a}var h=this,i=m(),j=!1;return l.nextTick(function(){h.promiseDispatch(function(a){j||(j=!0,i.resolve(d(a)))},"when",[function(a){j||(j=!0,i.resolve(f(a)))}])}),h.promiseDispatch(void 0,"when",[void 0,function(a){var b,c=!1;try{b=g(a)}catch(d){if(c=!0,!l.onerror)throw d;l.onerror(d)}c||i.notify(b)}]),i.promise},l.tap=function(a,b){return l(a).tap(b)},p.prototype.tap=function(a){return a=l(a),this.then(function(b){return a.fcall(b).thenResolve(b)})},l.when=q,p.prototype.thenResolve=function(a){return this.then(function(){return a})},l.thenResolve=function(a,b){return l(a).thenResolve(b)},p.prototype.thenReject=function(a){return this.then(function(){throw a})},l.thenReject=function(a,b){return l(a).thenReject(b)},l.nearer=r,l.isPromise=s,l.isPromiseAlike=t,l.isPending=u,p.prototype.isPending=function(){return"pending"===this.inspect().state},l.isFulfilled=v,p.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},l.isRejected=w,p.prototype.isRejected=function(){return"rejected"===this.inspect().state};var fa=[],ga=[],ha=[],ia=!0;l.resetUnhandledRejections=x,l.getUnhandledReasons=function(){return fa.slice()},l.stopUnhandledRejectionTracking=function(){x(),ia=!1},x(),l.reject=A,l.fulfill=B,l.master=D,l.spread=E,p.prototype.spread=function(a,b){return this.all().then(function(b){return a.apply(void 0,b)},b)},l.async=F,l.spawn=G,l["return"]=H,l.promised=I,l.dispatch=J,p.prototype.dispatch=function(a,b){var c=this,d=m();return l.nextTick(function(){c.promiseDispatch(d.resolve,a,b)}),d.promise},l.get=function(a,b){return l(a).dispatch("get",[b])},p.prototype.get=function(a){return this.dispatch("get",[a])},l.set=function(a,b,c){return l(a).dispatch("set",[b,c])},p.prototype.set=function(a,b){return this.dispatch("set",[a,b])},l.del=l["delete"]=function(a,b){return l(a).dispatch("delete",[b])},p.prototype.del=p.prototype["delete"]=function(a){return this.dispatch("delete",[a])},l.mapply=l.post=function(a,b,c){return l(a).dispatch("post",[b,c])},p.prototype.mapply=p.prototype.post=function(a,b){return this.dispatch("post",[a,b])},l.send=l.mcall=l.invoke=function(a,b){return l(a).dispatch("post",[b,Y(arguments,2)])},p.prototype.send=p.prototype.mcall=p.prototype.invoke=function(a){return this.dispatch("post",[a,Y(arguments,1)])},l.fapply=function(a,b){return l(a).dispatch("apply",[void 0,b])},p.prototype.fapply=function(a){return this.dispatch("apply",[void 0,a])},l["try"]=l.fcall=function(a){return l(a).dispatch("apply",[void 0,Y(arguments,1)])},p.prototype.fcall=function(){return this.dispatch("apply",[void 0,Y(arguments)])},l.fbind=function(a){var b=l(a),c=Y(arguments,1);return function(){return b.dispatch("apply",[this,c.concat(Y(arguments))])}},p.prototype.fbind=function(){var a=this,b=Y(arguments);return function(){return a.dispatch("apply",[this,b.concat(Y(arguments))])}},l.keys=function(a){return l(a).dispatch("keys",[])},p.prototype.keys=function(){return this.dispatch("keys",[])},l.all=K,p.prototype.all=function(){return K(this)},l.any=L,p.prototype.any=function(){return L(this)},l.allResolved=k(M,"allResolved","allSettled"),p.prototype.allResolved=function(){return M(this)},l.allSettled=N,p.prototype.allSettled=function(){return this.then(function(a){return K(_(a,function(a){function b(){return a.inspect()}return a=l(a),a.then(b,b)}))})},l.fail=l["catch"]=function(a,b){return l(a).then(void 0,b)},p.prototype.fail=p.prototype["catch"]=function(a){return this.then(void 0,a)},l.progress=O,p.prototype.progress=function(a){return this.then(void 0,void 0,a)},l.fin=l["finally"]=function(a,b){return l(a)["finally"](b)},p.prototype.fin=p.prototype["finally"]=function(a){return a=l(a),this.then(function(b){return a.fcall().then(function(){return b})},function(b){return a.fcall().then(function(){throw b})})},l.done=function(a,b,c,d){return l(a).done(b,c,d)},p.prototype.done=function(a,c,d){var f=function(a){l.nextTick(function(){if(e(a,g),!l.onerror)throw a;l.onerror(a)})},g=a||c||d?this.then(a,c,d):this;"object"==typeof b&&b&&b.domain&&(f=b.domain.bind(f)),g.then(void 0,f)},l.timeout=function(a,b,c){return l(a).timeout(b,c)},p.prototype.timeout=function(a,b){var c=m(),d=setTimeout(function(){b&&"string"!=typeof b||(b=new Error(b||"Timed out after "+a+" ms"),b.code="ETIMEDOUT"),c.reject(b)},a);return this.then(function(a){clearTimeout(d),c.resolve(a)},function(a){clearTimeout(d),c.reject(a)},c.notify),c.promise},l.delay=function(a,b){return void 0===b&&(b=a,a=void 0),l(a).delay(b)},p.prototype.delay=function(a){return this.then(function(b){var c=m();return setTimeout(function(){c.resolve(b)},a),c.promise})},l.nfapply=function(a,b){return l(a).nfapply(b)},p.prototype.nfapply=function(a){var b=m(),c=Y(a);return c.push(b.makeNodeResolver()),this.fapply(c).fail(b.reject),b.promise},l.nfcall=function(a){var b=Y(arguments,1);return l(a).nfapply(b)},p.prototype.nfcall=function(){var a=Y(arguments),b=m();return a.push(b.makeNodeResolver()),this.fapply(a).fail(b.reject),b.promise},l.nfbind=l.denodeify=function(a){var b=Y(arguments,1);return function(){var c=b.concat(Y(arguments)),d=m();return c.push(d.makeNodeResolver()),l(a).fapply(c).fail(d.reject),d.promise}},p.prototype.nfbind=p.prototype.denodeify=function(){var a=Y(arguments);return a.unshift(this),l.denodeify.apply(void 0,a)},l.nbind=function(a,b){var c=Y(arguments,2);return function(){function d(){return a.apply(b,arguments)}var e=c.concat(Y(arguments)),f=m();return e.push(f.makeNodeResolver()),l(d).fapply(e).fail(f.reject),f.promise}},p.prototype.nbind=function(){var a=Y(arguments,0);return a.unshift(this),l.nbind.apply(void 0,a)},l.nmapply=l.npost=function(a,b,c){
15
- return l(a).npost(b,c)},p.prototype.nmapply=p.prototype.npost=function(a,b){var c=Y(b||[]),d=m();return c.push(d.makeNodeResolver()),this.dispatch("post",[a,c]).fail(d.reject),d.promise},l.nsend=l.nmcall=l.ninvoke=function(a,b){var c=Y(arguments,2),d=m();return c.push(d.makeNodeResolver()),l(a).dispatch("post",[b,c]).fail(d.reject),d.promise},p.prototype.nsend=p.prototype.nmcall=p.prototype.ninvoke=function(a){var b=Y(arguments,1),c=m();return b.push(c.makeNodeResolver()),this.dispatch("post",[a,b]).fail(c.reject),c.promise},l.nodeify=P,p.prototype.nodeify=function(a){return a?void this.then(function(b){l.nextTick(function(){a(null,b)})},function(b){l.nextTick(function(){a(b)})}):this},l.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ja=j();return l})}).call(this,b("_process"))},{_process:44}],47:[function(a,b,c){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];d<e;)f=b.call(null,f,a[d],++d,a);return f}},{}],48:[function(a,b,c){function d(a){var b;if(2===arguments.length&&"object"==typeof arguments[1])b=arguments[1];else{b=new Array(arguments.length-1);for(var c=1;c<arguments.length;++c)b[c-1]=arguments[c]}return b&&b.hasOwnProperty||(b={}),a.replace(e,function(c,d,e){var f;return"{"===a[e-1]&&"}"===a[e+c.length]?d:(f=b.hasOwnProperty(d)?b[d]:null,null===f||void 0===f?"":f)})}var e=/\{([0-9a-zA-Z_]+)\}/g;b.exports=d},{}],49:[function(a,b,c){function d(){}function e(a){if(!s(a))return a;var b=[];for(var c in a)null!=a[c]&&f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(Array.isArray(c))return c.forEach(function(c){f(a,b,c)});if(s(c))for(var d in c)f(a,b+"["+d+"]",c[d]);else a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}function g(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)b=e[f],c=b.indexOf("="),c==-1?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;h<i;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e;return g}function i(a){return/[\/+]json\b/.test(a)}function j(a){return a.split(/ *; */).shift()}function k(a){return q(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function l(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this._setStatusProperties(this.xhr.status),this.header=this.headers=h(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function m(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a=null,b=null;try{b=new l(c)}catch(d){return a=new Error("Parser is unable to parse the response"),a.parse=!0,a.original=d,a.rawResponse=c.xhr&&c.xhr.responseText?c.xhr.responseText:null,a.statusCode=c.xhr&&c.xhr.status?c.xhr.status:null,c.callback(a)}if(c.emit("response",b),a)return c.callback(a,b);try{if(b.status>=200&&b.status<300)return c.callback(a,b);var e=new Error(b.statusText||"Unsuccessful HTTP response");e.original=a,e.response=b,e.status=b.status,c.callback(e,b)}catch(d){c.callback(d)}})}function n(a,b){var c=t("DELETE",a);return b&&c.end(b),c}var o,p=a("emitter"),q=a("reduce"),r=a("./request-base"),s=a("./is-object");o="undefined"!=typeof window?window:"undefined"!=typeof self?self:this;var t=b.exports=a("./request").bind(null,m);t.getXHR=function(){if(!(!o.XMLHttpRequest||o.location&&"file:"==o.location.protocol&&o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};t.serializeObject=e,t.parseString=g,t.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},t.serialize={"application/x-www-form-urlencoded":e,"application/json":JSON.stringify},t.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},l.prototype.get=function(a){return this.header[a.toLowerCase()]},l.prototype._setHeaderProperties=function(a){var b=this.header["content-type"]||"";this.type=j(b);var c=k(b);for(var d in c)this[d]=c[d]},l.prototype._parseBody=function(a){var b=t.parse[this.type];return!b&&i(this.type)&&(b=t.parse["application/json"]),b&&a&&(a.length||a instanceof Object)?b(a):null},l.prototype._setStatusProperties=function(a){1223===a&&(a=204);var b=a/100|0;this.status=this.statusCode=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=(4==b||5==b)&&this.toError(),this.accepted=202==a,this.noContent=204==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},l.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},t.Response=l,p(m.prototype);for(var v in r)m.prototype[v]=r[v];m.prototype.type=function(a){return this.set("Content-Type",t.types[a]||a),this},m.prototype.responseType=function(a){return this._responseType=a,this},m.prototype.accept=function(a){return this.set("Accept",t.types[a]||a),this},m.prototype.auth=function(a,b,c){switch(c||(c={type:"basic"}),c.type){case"basic":var d=btoa(a+":"+b);this.set("Authorization","Basic "+d);break;case"auto":this.username=a,this.password=b}return this},m.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},m.prototype.attach=function(a,b,c){return this._getFormData().append(a,b,c||b.name),this},m.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},m.prototype.callback=function(a,b){var c=this._callback;this.clearTimeout(),c(a,b)},m.prototype.crossDomainError=function(){var a=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},m.prototype._timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},m.prototype._appendQueryString=function(){var a=this._query.join("&");a&&(this.url+=~this.url.indexOf("?")?"&"+a:"?"+a)},m.prototype.end=function(a){var b=this,c=this.xhr=t.getXHR(),e=this._timeout,f=this._formData||this._data;this._callback=a||d,c.onreadystatechange=function(){if(4==c.readyState){var a;try{a=c.status}catch(d){a=0}if(0==a){if(b.timedout)return b._timeoutError();if(b._aborted)return;return b.crossDomainError()}b.emit("end")}};var g=function(a){a.total>0&&(a.percent=a.loaded/a.total*100),a.direction="download",b.emit("progress",a)};this.hasListeners("progress")&&(c.onprogress=g);try{c.upload&&this.hasListeners("progress")&&(c.upload.onprogress=g)}catch(h){}if(e&&!this._timer&&(this._timer=setTimeout(function(){b.timedout=!0,b.abort()},e)),this._appendQueryString(),this.username&&this.password?c.open(this.method,this.url,!0,this.username,this.password):c.open(this.method,this.url,!0),this._withCredentials&&(c.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof f&&!this._isHost(f)){var j=this._header["content-type"],k=this._serializer||t.serialize[j?j.split(";")[0]:""];!k&&i(j)&&(k=t.serialize["application/json"]),k&&(f=k(f))}for(var l in this.header)null!=this.header[l]&&c.setRequestHeader(l,this.header[l]);return this._responseType&&(c.responseType=this._responseType),this.emit("request",this),c.send("undefined"!=typeof f?f:null),this},t.Request=m,t.get=function(a,b,c){var d=t("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.head=function(a,b,c){var d=t("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.options=function(a,b,c){var d=t("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.del=n,t["delete"]=n,t.patch=function(a,b,c){var d=t("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.post=function(a,b,c){var d=t("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.put=function(a,b,c){var d=t("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}},{"./is-object":50,"./request":52,"./request-base":51,emitter:40,reduce:47}],50:[function(a,b,c){function d(a){return null!==a&&"object"==typeof a}b.exports=d},{}],51:[function(a,b,c){var d=a("./is-object");c.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},c.parse=function(a){return this._parser=a,this},c.serialize=function(a){return this._serializer=a,this},c.timeout=function(a){return this._timeout=a,this},c.then=function(a,b){if(!this._fullfilledPromise){var c=this;this._fullfilledPromise=new Promise(function(a,b){c.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},c.use=function(a){return a(this),this},c.get=function(a){return this._header[a.toLowerCase()]},c.getHeader=c.get,c.set=function(a,b){if(d(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},c.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},c.field=function(a,b){return this._getFormData().append(a,b),this},c.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},c.withCredentials=function(){return this._withCredentials=!0,this},c.redirects=function(a){return this._maxRedirects=a,this},c.toJSON=function(){return{method:this.method,url:this.url,data:this._data}},c._isHost=function(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}},c.send=function(a){var b=d(a),c=this._header["content-type"];if(b&&d(this._data))for(var e in a)this._data[e]=a[e];else"string"==typeof a?(c||this.type("form"),c=this._header["content-type"],"application/x-www-form-urlencoded"==c?this._data=this._data?this._data+"&"+a:a:this._data=(this._data||"")+a):this._data=a;return!b||this._isHost(a)?this:(c||this.type("json"),this)}},{"./is-object":50}],52:[function(a,b,c){function d(a,b,c){return"function"==typeof c?new a("GET",b).end(c):2==arguments.length?new a("GET",b):new a(b,c)}b.exports=d},{}],53:[function(b,c,d){(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};c.cleanAttributes!==!1&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return!!a&&(!(!e.isFunction(a.querySelectorAll)||!e.isFunction(a.querySelector))&&(!(!e.isObject(document)||a!==document)||("object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName)))},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1===0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return!!e.isDefined(a)&&(e.isArray(a)?a.indexOf(b)!==-1:b in a)},forEachKeyInKeypath:function(a,b,c){if(e.isString(b)){var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)}},getDeepObjectValue:function(a,b){if(e.isObject(a))return e.forEachKeyInKeypath(a,b,function(a,b){if(e.isObject(a))return a[b]})},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);return e.isString(d)?("^"===d[0]?d=d.slice(1):b.fullMessages!==!1&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),void c.push(e.extend({},a,{error:d}))):void c.push(a)}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=!!c||{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){if(b=e.extend({},this.options,b),e.isEmpty(a))return b.message||this.message||"can't be blank"},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&k<h&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return a<b},lessThanOrEqualTo:function(a,b){return a<=b}};if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var h="not"+e.capitalize(c),i=b[h]||this[h]||"must be %{type} %{count}";f.push(e.format(i,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):NaN,g=b.latest?this.parse(b.latest,b):NaN;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(f)&&a<f&&(c=this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;if(!e.isEmpty(a))return e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))";f?h="(?:localhost|"+h+")":g+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",g+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+h+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";var i=new RegExp(g,"i");return i.exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof d?d:null,"undefined"!=typeof c?c:null,"undefined"!=typeof a?a:null)},{}]},{},[1])(1)});
8
+ }function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;d<g;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;e<g;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],38:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,b<0?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;c<b;c++)a[c]=0;return a}function h(a,b,c){"string"==typeof c&&""!==c||(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;e<d;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),b<0&&(b=0),c>this.length&&(c=this.length),c<=b)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;g<d;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;e<c;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(e+h<=c){var i,j,k,l;switch(h){case 1:f<128&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(l<55296||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&l<1114112&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if(b<=$)return String.fromCharCode.apply(String,a);for(var c="",d=0;d<b;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||b<0)&&(b=0),(!c||c<0||c>d)&&(c=d);for(var e="",f=b;f<c;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function H(a,b,c){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||b<g)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){b<0&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);e<f;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){b<0&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);e<f;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||b<f)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(c<0)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return a<16?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;g<d;g++){if(c=a.charCodeAt(g),c>55295&&c<57344){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(c<56320){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,c<128){if((b-=1)<0)break;f.push(c)}else if(c<2048){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(c<65536){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(c<1114112))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function T(a,b){for(var c,d,e,f=[],g=0;g<a.length&&!((b-=2)<0);g++)c=a.charCodeAt(g),d=c>>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;e<d&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);e<g&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),c<d?-1:d<c?1:0},f.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var d=new f(b),e=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(d,e),e+=g.length}return d},f.byteLength=s,f.prototype.toString=function(){var a=0|this.length;return 0===a?"":0===arguments.length?B(this,0,a):t.apply(this,arguments)},f.prototype.equals=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a||0===f.compare(this,a)},f.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),"<Buffer "+a+">"},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e<a.length;e++)if(a[c+e]===b[d===-1?0:e-d]){if(d===-1&&(d=e),e-d+1===b.length)return c+d}else d=-1;return-1}if(b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(b<0&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(c<0||b<0)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,a<0?(a+=c,a<0&&(a=0)):a>c&&(a=c),b<0?(b+=c,b<0&&(b=0)):b>c&&(b=c),b<a&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,(void 0));for(var g=0;g<e;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return d},f.prototype.readUIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a+--b],e=1;b>0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return e*=128,d>=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?(255-this[a]+1)*-1:this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f<c&&(e*=256);)this[b+f]=a/e&255;return b+c},f.prototype.writeUIntBE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=c-1,f=1;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=a<0?1:0;for(this[b]=255&a;++f<c&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=a<0?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),a<0&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&d<c&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(b<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("sourceStart out of bounds");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-b<d-c&&(d=a.length-b+c);var e,g=d-c;if(this===a&&c<b&&b<d)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(g<1e3||!f.TYPED_ARRAY_SUPPORT)for(e=0;e<g;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),c<b)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(b<0||b>=this.length)throw new RangeError("start out of bounds");if(c<0||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;d<c;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;d<c;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;b<c;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":37,ieee754:43,isarray:39}],39:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],40:[function(a,b,c){function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}b.exports=d,d.prototype.on=d.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=d.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks["$"+a];if(!c)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var d,e=0;e<c.length;e++)if(d=c[e],d===b||d.fn===b){c.splice(e,1);break}return this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];if(c){c=c.slice(0);for(var d=0,e=c.length;d<e;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],41:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||a<0||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;i<d;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(d<0)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],42:[function(a,b,c){var d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=Object.defineProperty,g=Object.getOwnPropertyDescriptor,h=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===e.call(a)},i=function(a){"use strict";if(!a||"[object Object]"!==e.call(a))return!1;var b=d.call(a,"constructor"),c=a.constructor&&a.constructor.prototype&&d.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!b&&!c)return!1;var f;for(f in a);return"undefined"==typeof f||d.call(a,f)},j=function(a,b){f&&"__proto__"===b.name?f(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},k=function(a,b){if("__proto__"===b){if(!d.call(a,b))return;if(g)return g(a,b).value}return a[b]};b.exports=function l(){"use strict";var a,b,c,d,e,f,g=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof g&&(o=g,g=arguments[1]||{},m=2),(null==g||"object"!=typeof g&&"function"!=typeof g)&&(g={});m<n;++m)if(a=arguments[m],null!=a)for(b in a)c=k(g,b),d=k(a,b),g!==d&&(o&&d&&(i(d)||(e=h(d)))?(e?(e=!1,f=c&&h(c)?c:[]):f=c&&i(c)?c:{},j(g,{name:b,newValue:l(o,f,d)})):"undefined"!=typeof d&&j(g,{name:b,newValue:d}));return g}},{}],43:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=b<0||0===b&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],44:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],45:[function(b,c,d){(function(b,e){!function(b,e){"object"==typeof d&&"undefined"!=typeof c?c.exports=e():"function"==typeof a&&a.amd?a(e):(b="undefined"!=typeof globalThis?globalThis:b||self).PubNub=e()}(this,function(){"use strict";function a(a,b){function c(){this.constructor=a}if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");Z(a,b),a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function c(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){var b;a.done?e(a.value):(b=a.value,b instanceof c?b:new c(function(a){a(b)})).then(g,h)}i((d=d.apply(a,b||[])).next())})}function d(a,b){function c(a){return function(c){return function(a){if(d)throw new TypeError("Generator is already executing.");for(;h;)try{if(d=1,e&&(f=2&a[0]?e["return"]:a[0]?e["throw"]||((f=e["return"])&&f.call(e),0):e.next)&&!(f=f.call(e,a[1])).done)return f;switch(e=0,f&&(a=[2&a[0],f.value]),a[0]){case 0:case 1:f=a;break;case 4:return h.label++,{value:a[1],done:!1};case 5:h.label++,e=a[1],a=[0];continue;case 7:a=h.ops.pop(),h.trys.pop();continue;default:if(f=h.trys,!((f=f.length>0&&f[f.length-1])||6!==a[0]&&2!==a[0])){h=0;continue}if(3===a[0]&&(!f||a[1]>f[0]&&a[1]<f[3])){h.label=a[1];break}if(6===a[0]&&h.label<f[1]){h.label=f[1],f=a;break}if(f&&h.label<f[2]){h.label=f[2],h.ops.push(a);break}f[2]&&h.ops.pop(),h.trys.pop();continue}a=b.call(c,h)}catch(c){a=[6,c],e=0}finally{d=f=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}var d,e,f,g,h={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return g={next:c(0),"throw":c(1),"return":c(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g}function f(a){var b="function"==typeof Symbol&&Symbol.iterator,c=b&&a[b],d=0;if(c)return c.call(a);if(a&&"number"==typeof a.length)return{next:function(){return a&&d>=a.length&&(a=void 0),{value:a&&a[d++],done:!a}}};throw new TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(a,b){var c="function"==typeof Symbol&&a[Symbol.iterator];if(!c)return a;var d,e,f=c.call(a),g=[];try{for(;(void 0===b||b-- >0)&&!(d=f.next()).done;)g.push(d.value)}catch(a){e={error:a}}finally{try{d&&!d.done&&(c=f["return"])&&c.call(f)}finally{if(e)throw e.error}}return g}function h(a,b,c){if(c||2===arguments.length)for(var d,e=0,f=b.length;e<f;e++)!d&&e in b||(d||(d=Array.prototype.slice.call(b,0,e)),d[e]=b[e]);return a.concat(d||Array.prototype.slice.call(b))}function i(a){var b,c=[];for(b=0;b<a.length;b+=1)c[b/4|0]|=a[b]<<24-8*b;return pa.lib.WordArray.create(c,a.length)}function j(a){return encodeURIComponent(a).replace(/[!~*'()]/g,function(a){return"%".concat(a.charCodeAt(0).toString(16).toUpperCase())})}function k(a){return function(a){var b=[];return Object.keys(a).forEach(function(a){return b.push(a)}),b}(a).sort()}function l(a){return(b={message:a}).type="validationError",b.error=!0,b;var b}function m(a,b,c){return a.usePost&&a.usePost(b,c)?a.postURL(b,c):a.usePatch&&a.usePatch(b,c)?a.patchURL(b,c):a.useGetFile&&a.useGetFile(b,c)?a.getFileURL(b,c):a.getURL(b,c)}function n(a){if(a.sdkName)return a.sdkName;var b="PubNub-JS-".concat(a.sdkFamily);a.partnerId&&(b+="-".concat(a.partnerId)),b+="/".concat(a.getVersion());var c=a._getPnsdkSuffix(" ");
9
+ return c.length>0&&(b+=c),b}function o(a,b,c){return b.usePost&&b.usePost(a,c)?"POST":b.usePatch&&b.usePatch(a,c)?"PATCH":b.useDelete&&b.useDelete(a,c)?"DELETE":b.useGetFile&&b.useGetFile(a,c)?"GETFILE":"GET"}function p(a,b,c,d,e){var f=a.config,g=a.crypto,h=o(a,e,d);c.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===e.getOperation()&&e.usePost&&e.usePost(a,d)&&(h="GET"),"GETFILE"===h&&(h="GET");var i="".concat(h,"\n").concat(f.publishKey,"\n").concat(b,"\n").concat(ta.signPamFromParams(c),"\n");if("POST"===h)i+="string"==typeof(j=e.postPayload(a,d))?j:JSON.stringify(j);else if("PATCH"===h){var j;i+="string"==typeof(j=e.patchPayload(a,d))?j:JSON.stringify(j)}var k="v2.".concat(g.HMACSHA256(i));k=(k=(k=k.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),c.signature=k}function q(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];var e=a.networking,f=a.config,g=a.telemetryManager,h=a.tokenManager,i=ja(),j=null,k=null,q={};b.getOperation()===wa.PNTimeOperation||b.getOperation()===wa.PNChannelGroupsOperation?j=c[0]:(q=c[0],j=c[1]),"undefined"==typeof Promise||j||(k=ta.createPromise());var r=b.validateParams(a,q);if(r)return j?j(l(r)):k?(k.reject(new Fa("Validation failed, check status for details",l(r))),k.promise):void 0;var s,t=b.prepareParams(a,q),u=m(b,a,q),v={url:u,operation:b.getOperation(),timeout:b.getRequestTimeout(a),headers:b.getRequestHeaders?b.getRequestHeaders():{},ignoreBody:"function"==typeof b.ignoreBody&&b.ignoreBody(a),forceBuffered:"function"==typeof b.forceBuffered?b.forceBuffered(a,q):null,abortSignal:"function"==typeof b.getAbortSignal?b.getAbortSignal(a,q):null};t.uuid=f.UUID,t.pnsdk=n(f);var w=g.operationsLatencyForRequest();if(Object.keys(w).length&&(t=$($({},t),w)),f.useInstanceId&&(t.instanceid=f.instanceId),f.useRequestId&&(t.requestid=i),b.isAuthSupported()){var x=h.getToken()||f.getAuthKey();x&&(t.auth=x)}f.secretKey&&p(a,u,t,q,b);var y=function(c,d){if(c.error)return b.handleError&&b.handleError(a,q,c),void(j?j(c):k&&k.reject(new Fa("PubNub call failed, check status for details",c)));g.stopLatencyMeasure(b.getOperation(),i);var e=b.handleResponse(a,d,q);"function"!=typeof(null==e?void 0:e.then)&&(e=Promise.resolve(e)),e.then(function(a){j?j(c,a):k&&k.fulfill(a)})["catch"](function(a){if(j){var c=a;b.getOperation()===wa.PNSubscribeOperation&&(c={statusCode:400,error:!0,operation:b.getOperation(),errorData:a,category:ua.PNUnknownCategory}),j(c,null)}else k&&k.reject(new Fa("PubNub call failed, check status for details",a))})};if(g.startLatencyMeasure(b.getOperation(),i),"POST"===o(a,b,q)){var z=b.postPayload(a,q);s=e.POST(t,z,v,y)}else"PATCH"===o(a,b,q)?(z=b.patchPayload(a,q),s=e.PATCH(t,z,v,y)):s="DELETE"===o(a,b,q)?e.DELETE(t,v,y):"GETFILE"===o(a,b,q)?e.GETFILE(t,v,y):e.GET(t,v,y);return b.getOperation()===wa.PNSubscribeOperation?s:k?k.promise:void 0}function r(a){var b=0;return a.join&&(b|=128),a.update&&(b|=64),a.get&&(b|=32),a["delete"]&&(b|=8),a.manage&&(b|=4),a.write&&(b|=2),a.read&&(b|=1),b}function s(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e}function t(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function u(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:null==b?void 0:b.apply(void 0,h([],g(c),!1))}};return c.type=a,c}function v(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:b.apply(void 0,h([],g(c),!1)),managed:!0}};return c.type=a,c.cancel={type:"CANCEL",payload:a,managed:!1},c}function w(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function x(a,b,c,d){var e;void 0===d&&(d=w()),z(a,"",0,[],void 0,0,d);try{e=0===xc.length?JSON.stringify(a,b,c):JSON.stringify(a,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var f=wc.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}}return e}function y(a,b,c,d){var e=Object.getOwnPropertyDescriptor(d,c);void 0!==e.get?e.configurable?(Object.defineProperty(d,c,{value:a}),wc.push([d,c,b,e])):xc.push([b,c,a]):(d[c]=a,wc.push([d,c,b]))}function z(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void y(vc,a,b,e);if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)z(a[h],h,h,d,a,f,g);else{var i=Object.keys(a);for(h=0;h<i.length;h++){var j=i[h];z(a[j],j,h,d,a,f,g)}}d.pop()}}function A(a,b){return a<b?-1:a>b?1:0}function B(a,b,c,d){void 0===d&&(d=w());var e,f=C(a,"",0,[],void 0,0,d)||a;try{e=0===xc.length?JSON.stringify(f,b,c):JSON.stringify(f,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var g=wc.pop();4===g.length?Object.defineProperty(g[0],g[1],g[3]):g[0][g[1]]=g[2]}}return e}function C(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void y(vc,a,b,e);try{if("function"==typeof a.toJSON)return}catch(a){return}if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)C(a[h],h,h,d,a,f,g);else{var i={},j=Object.keys(a).sort(A);for(h=0;h<j.length;h++){var k=j[h];C(a[k],k,h,d,a,f,g),i[k]=a[k]}if(void 0===e)return i;wc.push([e,b,a]),e[b]=i}d.pop()}}function D(a){return a=void 0!==a?a:function(a,b){return b},function(b,c){if(xc.length>0)for(var d=0;d<xc.length;d++){var e=xc[d];if(e[1]===b&&e[0]===c){c=e[2],xc.splice(d,1);break}}return a.call(this,b,c)}}function E(a){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function F(a){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function G(a){if(a)return function(a){for(var b in G.prototype)Object.prototype.hasOwnProperty.call(G.prototype,b)&&(a[b]=G.prototype[b]);return a}(a)}function H(a,b){var c;if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(c=function(a,b){if(a){if("string"==typeof a)return I(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?I(a,b):void 0}}(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:e}}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 f,g=!0,h=!1;return{s:function(){c=a[Symbol.iterator]()},n:function(){var a=c.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function I(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function J(a){if(a)return function(a){for(var b in J.prototype)Object.prototype.hasOwnProperty.call(J.prototype,b)&&(a[b]=J.prototype[b]);return a}(a)}function K(a){return function(a){if(Array.isArray(a))return L(a)}(a)||function(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}(a)||function(a,b){if(a){if("string"==typeof a)return L(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?L(a,b):void 0}}(a)||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 L(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function M(){this._defaults=[]}function N(a){var b=(new Date).getTime(),c=(new Date).toISOString(),d=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;d.log("<<<<<"),d.log("[".concat(c,"]"),"\n",a.url,"\n",a.qs),d.log("-----"),a.on("response",function(c){var e=(new Date).getTime()-b,f=(new Date).toISOString();d.log(">>>>>>"),d.log("[".concat(f," / ").concat(e,"]"),"\n",a.url,"\n",a.qs,"\n",c.text),d.log("-----")})}function O(a,b,c){var d=this;this._config.logVerbosity&&(a=a.use(N)),this._config.proxy&&this._modules.proxy&&(a=this._modules.proxy.call(this,a)),this._config.keepAlive&&this._modules.keepAlive&&(a=this._modules.keepAlive(a));var e=a;if(b.abortSignal)var f=b.abortSignal.subscribe(function(){e.abort(),f()});return!0===b.forceBuffered?e="undefined"==typeof Blob?e.buffer().responseType("arraybuffer"):e.responseType("arraybuffer"):!1===b.forceBuffered&&(e=e.buffer(!1)),(e=e.timeout(b.timeout)).on("abort",function(){return c({category:ua.PNUnknownCategory,error:!0,operation:b.operation,errorData:new Error("Aborted")},null)}),e.end(function(a,b){var e,f={};if(f.error=null!==a,f.operation=g.operation,b&&b.status&&(f.statusCode=b.status),a){if(a.response&&a.response.text&&!d._config.logVerbosity)try{f.errorData=JSON.parse(a.response.text)}catch(g){f.errorData=a}else f.errorData=a;return f.category=d._detectErrorCategory(a),c(f,null)}if(g.ignoreBody)e={headers:b.headers,redirects:b.redirects,response:b};else try{e=JSON.parse(b.text)}catch(a){return f.errorData=b,f.error=!0,c(f,null)}return e.error&&1===e.error&&e.status&&e.message&&e.service?(f.errorData=e,f.statusCode=e.status,f.error=!0,f.category=d._detectErrorCategory(f),c(f,null)):(e.error&&e.error.message&&(f.errorData=e.error),c(f,e))}),e}function P(a,b,e){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return c=kd.post(a),b.forEach(function(a){var b=a.key,d=a.value;c=c.field(b,d)}),c.attach("file",e,{contentType:"application/octet-stream"}),[4,c];case 1:return[2,d.sent()]}})})}function Q(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function R(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function S(a,b,c,d){var e=kd.post(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function T(a,b,c,d){var e=kd.patch(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function U(a,b,c){var d=kd["delete"](this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function V(a,b){var c=new Uint8Array(a.byteLength+b.byteLength);return c.set(new Uint8Array(a),0),c.set(new Uint8Array(b),a.byteLength),c.buffer}function W(a){return!(!navigator||!navigator.sendBeacon)&&void navigator.sendBeacon(a)}function X(a){for(var b=pa.enc.Base64.parse(a).words,c=new ArrayBuffer(4*b.length),d=new Uint8Array(c),e=0,f=0,g=0;g<b.length;g+=1){var h=b[g];d[f=4*g]=(4278190080&h)>>24,d[f+1]=(16711680&h)>>16,d[f+2]=(65280&h)>>8,d[f+3]=255&h}for(var i=f+3;i>=f;i-=1)0===d[i]&&e<3&&(e+=1);return e>0?d.buffer.slice(0,d.byteLength-e):d.buffer}function Y(a){var b=function(a){return a&&"object"==typeof a&&a.constructor===Object};if(!b(a))return a;var c={};return Object.keys(a).forEach(function(d){var e=function(a){return"string"==typeof a||a instanceof String}(d),f=d,g=a[d];Array.isArray(d)||e&&d.indexOf(",")>=0?f=(e?d.split(","):d).reduce(function(a,b){return a+=String.fromCharCode(b)},""):(function(a){return"number"==typeof a&&isFinite(a)}(d)||e&&!isNaN(d))&&(f=String.fromCharCode(e?parseInt(d,10):10)),c[f]=b(g)?Y(g):g}),c}var Z=function(a,b){return(Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])})(a,b)},$=function(){return $=Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c])Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},$.apply(this,arguments)},_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof b?b:"undefined"!=typeof self?self:{},aa={exports:{}};!function(a){!function(b,c){var d=Math.pow(2,-24),e=Math.pow(2,32),f=Math.pow(2,53),g={encode:function(a){function b(a){for(var b=k.byteLength,c=m+a;b<c;)b*=2;if(b!==k.byteLength){var d=l;k=new ArrayBuffer(b),l=new DataView(k);for(var e=m+3>>2,f=0;f<e;++f)l.setUint32(4*f,d.getUint32(4*f))}return j=a,l}function d(){m+=j}function g(a){d(b(1).setUint8(m,a))}function h(a){for(var c=b(a.length),e=0;e<a.length;++e)c.setUint8(m+e,a[e]);d()}function i(a,c){c<24?g(a<<5|c):c<256?(g(a<<5|24),g(c)):c<65536?(g(a<<5|25),function(a){d(b(2).setUint16(m,a))}(c)):c<4294967296?(g(a<<5|26),function(a){d(b(4).setUint32(m,a))}(c)):(g(a<<5|27),function(a){var c=a%e,f=(a-c)/e,g=b(8);g.setUint32(m,f),g.setUint32(m+4,c),d()}(c))}var j,k=new ArrayBuffer(256),l=new DataView(k),m=0;if(function q(a){var e;if(!1===a)return g(244);if(!0===a)return g(245);if(null===a)return g(246);if(a===c)return g(247);switch(typeof a){case"number":if(Math.floor(a)===a){if(0<=a&&a<=f)return i(0,a);if(-f<=a&&a<0)return i(1,-(a+1))}return g(251),function(a){d(b(8).setFloat64(m,a))}(a);case"string":var j=[];for(e=0;e<a.length;++e){var k=a.charCodeAt(e);k<128?j.push(k):k<2048?(j.push(192|k>>6),j.push(128|63&k)):k<55296?(j.push(224|k>>12),j.push(128|k>>6&63),j.push(128|63&k)):(k=(1023&k)<<10,k|=1023&a.charCodeAt(++e),k+=65536,j.push(240|k>>18),j.push(128|k>>12&63),j.push(128|k>>6&63),j.push(128|63&k))}return i(3,j.length),h(j);default:var l;if(Array.isArray(a))for(i(4,l=a.length),e=0;e<l;++e)q(a[e]);else if(a instanceof Uint8Array)i(2,a.length),h(a);else{var n=Object.keys(a);for(i(5,l=n.length),e=0;e<l;++e){var o=n[e];q(o),q(a[o])}}}}(a),"slice"in k)return k.slice(0,m);for(var n=new ArrayBuffer(m),o=new DataView(n),p=0;p<m;++p)o.setUint8(p,l.getUint8(p));return n},decode:function(a,b,f){function g(a,b){return q+=b,a}function h(b){return g(new Uint8Array(a,q,b),b)}function i(){return g(p.getUint8(q),1)}function j(){return g(p.getUint16(q),2)}function k(){return g(p.getUint32(q),4)}function l(){return 255===p.getUint8(q)&&(q+=1,!0)}function m(a){if(a<24)return a;if(24===a)return i();if(25===a)return j();if(26===a)return k();if(27===a)return k()*e+k();if(31===a)return-1;throw"Invalid length encoding"}function n(a){var b=i();if(255===b)return-1;var c=m(31&b);if(c<0||b>>5!==a)throw"Invalid indefinite length element";return c}function o(a,b){for(var c=0;c<b;++c){var d=i();128&d&&(d<224?(d=(31&d)<<6|63&i(),b-=1):d<240?(d=(15&d)<<12|(63&i())<<6|63&i(),b-=2):(d=(15&d)<<18|(63&i())<<12|(63&i())<<6|63&i(),b-=3)),d<65536?a.push(d):(d-=65536,a.push(55296|d>>10),a.push(56320|1023&d))}}var p=new DataView(a),q=0;"function"!=typeof b&&(b=function(a){return a}),"function"!=typeof f&&(f=function(){return c});var r=function s(){var a,e,k=i(),r=k>>5,t=31&k;if(7===r)switch(t){case 25:return function(){var a=new ArrayBuffer(4),b=new DataView(a),c=j(),e=32768&c,f=31744&c,g=1023&c;if(31744===f)f=261120;else if(0!==f)f+=114688;else if(0!==g)return g*d;return b.setUint32(0,e<<16|f<<13|g<<13),b.getFloat32(0)}();case 26:return g(p.getFloat32(q),4);case 27:return g(p.getFloat64(q),8)}if((e=m(t))<0&&(r<2||6<r))throw"Invalid length";switch(r){case 0:return e;case 1:return-1-e;case 2:if(e<0){for(var u=[],v=0;(e=n(r))>=0;)v+=e,u.push(h(e));var w=new Uint8Array(v),x=0;for(a=0;a<u.length;++a)w.set(u[a],x),x+=u[a].length;return w}return h(e);case 3:var y=[];if(e<0)for(;(e=n(r))>=0;)o(y,e);else o(y,e);return String.fromCharCode.apply(null,y);case 4:var z;if(e<0)for(z=[];!l();)z.push(s());else for(z=new Array(e),a=0;a<e;++a)z[a]=s();return z;case 5:var A={};for(a=0;a<e||e<0&&!l();++a)A[s()]=s();return A;case 6:return b(s(),e);case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return c;default:return f(e)}}}();if(q!==a.byteLength)throw"Remaining bytes";return r}};a.exports?a.exports=g:b.CBOR||(b.CBOR=g)}(_)}(aa);var ba=aa.exports,ca={exports:{}};!function(a,b){!function(a){function b(){var a,b,c="";for(a=0;a<32;a++)b=16*Math.random()|0,8!==a&&12!==a&&16!==a&&20!==a||(c+="-"),c+=(12===a?4:16===a?3&b|8:b).toString(16);return c}function c(a,b){var c=e[b||"all"];return c&&c.test(a)||!1}var d="0.1.0",e={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};b.isUUID=c,b.VERSION=d,a.uuid=b,a.isUUID=c}(b),null!==a&&(a.exports=b.uuid)}(ca,ca.exports);var da,ea,fa,ga,ha,ia=ca.exports,ja=function(){return ia.uuid?ia.uuid():ia()},ka=function(){function a(a){var b,c,d,e=a.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(ja()),this.secretKey=e.secretKey||e.secret_key,this.subscribeKey=e.subscribeKey||e.subscribe_key,this.publishKey=e.publishKey||e.publish_key,this.sdkName=e.sdkName,this.sdkFamily=e.sdkFamily,this.partnerId=e.partnerId,this.setAuthKey(e.authKey),this.setCipherKey(e.cipherKey),this.setFilterExpression(e.filterExpression),"string"!=typeof e.origin&&!Array.isArray(e.origin)&&void 0!==e.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");this.origin=e.origin||Array.from({length:20},function(a,b){return"ps".concat(b+1,".pndsn.com")}),this.secure=e.ssl||!1,this.restore=e.restore||!1,this.proxy=e.proxy,this.keepAlive=e.keepAlive,this.keepAliveSettings=e.keepAliveSettings,this.autoNetworkDetection=e.autoNetworkDetection||!1,this.dedupeOnSubscribe=e.dedupeOnSubscribe||!1,this.maximumCacheSize=e.maximumCacheSize||100,this.customEncrypt=e.customEncrypt,this.customDecrypt=e.customDecrypt,this.fileUploadPublishRetryLimit=null!==(b=e.fileUploadPublishRetryLimit)&&void 0!==b?b:5,this.useRandomIVs=null===(c=e.useRandomIVs)||void 0===c||c,this.enableSubscribeBeta=null!==(d=e.enableSubscribeBeta)&&void 0!==d&&d,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=e.logVerbosity||!1,this.suppressLeaveEvents=e.suppressLeaveEvents||!1,this.announceFailedHeartbeats=e.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=e.announceSuccessfulHeartbeats||!1,this.useInstanceId=e.useInstanceId||!1,this.useRequestId=e.useRequestId||!1,this.requestMessageCountThreshold=e.requestMessageCountThreshold,this.setTransactionTimeout(e.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(e.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(e.useSendBeacon||!0),e.presenceTimeout?this.setPresenceTimeout(e.presenceTimeout):this._presenceTimeout=300,null!=e.heartbeatInterval&&this.setHeartbeatInterval(e.heartbeatInterval),this.setUUID(e.uuid)}return a.prototype.getAuthKey=function(){return this.authKey},a.prototype.setAuthKey=function(a){return this.authKey=a,this},a.prototype.setCipherKey=function(a){return this.cipherKey=a,this},a.prototype.getUUID=function(){return this.UUID},a.prototype.setUUID=function(a){if(!a||"string"!=typeof a||0===a.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=a,this},a.prototype.getFilterExpression=function(){return this.filterExpression},a.prototype.setFilterExpression=function(a){return this.filterExpression=a,this},a.prototype.getPresenceTimeout=function(){return this._presenceTimeout},a.prototype.setPresenceTimeout=function(a){return a>=20?this._presenceTimeout=a:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},a.prototype.setProxy=function(a){this.proxy=a},a.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},a.prototype.setHeartbeatInterval=function(a){return this._heartbeatInterval=a,this},a.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},a.prototype.setSubscribeTimeout=function(a){return this._subscribeRequestTimeout=a,this},a.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},a.prototype.setTransactionTimeout=function(a){return this._transactionalRequestTimeout=a,this},a.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},a.prototype.setSendBeaconConfig=function(a){return this._useSendBeacon=a,this},a.prototype.getVersion=function(){return"7.0.1"},a.prototype._addPnsdkSuffix=function(a,b){this._PNSDKSuffix[a]=b},a.prototype._getPnsdkSuffix=function(a){var b=this;return Object.keys(this._PNSDKSuffix).reduce(function(c,d){return c+a+b._PNSDKSuffix[d]},"")},a}(),la=la||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,b){a=this.words=a||[],this.sigBytes=null!=b?b:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e<a;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-e%4*8&255)<<24-(d+e)%4*8;else if(65535<c.length)for(e=0;e<a;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d<b;d+=4)c.push(4294967296*a.random()|0);return new g.init(c,b)}}),h=c.enc={},i=h.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++){var e=b[d>>>2]>>>24-d%4*8&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-d%4*8&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f);if(b=(h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0))*f,e=a.min(4*b,e),b){for(var i=0;i<b;i+=f)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return new g.init(i,e)},clone:function(){var a=f.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=l.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}});var m=c.algo={};return c}(Math);!function(a){for(var b=la,c=(e=b.lib).WordArray,d=e.Hasher,e=b.algo,f=[],g=[],h=function(a){return 4294967296*(a-(0|a))|0},i=2,j=0;64>j;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[];e=e.SHA256=d.extend({_doReset:function(){this._hash=new c.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[14+(e+64>>>9<<4)]=a.floor(d/4294967296),c[15+(e+64>>>9<<4)]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}}),b.SHA256=d._createHelper(e),b.HmacSHA256=d._createHmacHelper(e)}(Math),ea=(da=la).enc.Utf8,da.algo.HMAC=da.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=ea.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),f=this._iKey=b.clone(),g=e.words,h=f.words,i=0;i<c;i++)g[i]^=1549556828,h[i]^=909522486;e.sigBytes=f.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher;return a=b.finalize(a),b.reset(),b.finalize(this._oKey.clone().concat(a))}}),ga=(fa=la).lib.WordArray,fa.enc.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp(),a=[];for(var e=0;e<c;e+=3)for(var f=(b[e>>>2]>>>24-e%4*8&255)<<16|(b[e+1>>>2]>>>24-(e+1)%4*8&255)<<8|b[e+2>>>2]>>>24-(e+2)%4*8&255,g=0;4>g&&e+.75*g<c;g++)a.push(d.charAt(f>>>6*(3-g)&63));if(b=d.charAt(64))for(;a.length%4;)a.push(b);return a.join("")},parse:function(a){var b=a.length,c=this._map;(d=c.charAt(64))&&-1!=(d=a.indexOf(d))&&(b=d);for(var d=[],e=0,f=0;f<b;f++)if(f%4){var g=c.indexOf(a.charAt(f-1))<<f%4*2,h=c.indexOf(a.charAt(f))>>>6-f%4*2;d[e>>>2]|=(g|h)<<24-e%4*8,e++}return ga.create(d,e)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(a){function b(a,b,c,d,e,f,g){return((a=a+(b&c|~b&d)+e+g)<<f|a>>>32-f)+b}function c(a,b,c,d,e,f,g){return((a=a+(b&d|c&~d)+e+g)<<f|a>>>32-f)+b}function d(a,b,c,d,e,f,g){return((a=a+(b^c^d)+e+g)<<f|a>>>32-f)+b}function e(a,b,c,d,e,f,g){return((a=a+(c^(b|~d))+e+g)<<f|a>>>32-f)+b}for(var f=la,g=(i=f.lib).WordArray,h=i.Hasher,i=f.algo,j=[],k=0;64>k;k++)j[k]=4294967296*a.abs(a.sin(k+1))|0;i=i.MD5=h.extend({_doReset:function(){this._hash=new g.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=a[i=f+g];a[i]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}g=this._hash.words;var i=a[f+0],k=(h=a[f+1],a[f+2]),l=a[f+3],m=a[f+4],n=a[f+5],o=a[f+6],p=a[f+7],q=a[f+8],r=a[f+9],s=a[f+10],t=a[f+11],u=a[f+12],v=a[f+13],w=a[f+14],x=a[f+15],y=b(y=g[0],B=g[1],A=g[2],z=g[3],i,7,j[0]),z=b(z,y,B,A,h,12,j[1]),A=b(A,z,y,B,k,17,j[2]),B=b(B,A,z,y,l,22,j[3]);y=b(y,B,A,z,m,7,j[4]),z=b(z,y,B,A,n,12,j[5]),A=b(A,z,y,B,o,17,j[6]),B=b(B,A,z,y,p,22,j[7]),y=b(y,B,A,z,q,7,j[8]),z=b(z,y,B,A,r,12,j[9]),A=b(A,z,y,B,s,17,j[10]),B=b(B,A,z,y,t,22,j[11]),y=b(y,B,A,z,u,7,j[12]),z=b(z,y,B,A,v,12,j[13]),A=b(A,z,y,B,w,17,j[14]),y=c(y,B=b(B,A,z,y,x,22,j[15]),A,z,h,5,j[16]),z=c(z,y,B,A,o,9,j[17]),A=c(A,z,y,B,t,14,j[18]),B=c(B,A,z,y,i,20,j[19]),y=c(y,B,A,z,n,5,j[20]),z=c(z,y,B,A,s,9,j[21]),A=c(A,z,y,B,x,14,j[22]),B=c(B,A,z,y,m,20,j[23]),y=c(y,B,A,z,r,5,j[24]),z=c(z,y,B,A,w,9,j[25]),A=c(A,z,y,B,l,14,j[26]),B=c(B,A,z,y,q,20,j[27]),y=c(y,B,A,z,v,5,j[28]),z=c(z,y,B,A,k,9,j[29]),A=c(A,z,y,B,p,14,j[30]),y=d(y,B=c(B,A,z,y,u,20,j[31]),A,z,n,4,j[32]),z=d(z,y,B,A,q,11,j[33]),A=d(A,z,y,B,t,16,j[34]),B=d(B,A,z,y,w,23,j[35]),y=d(y,B,A,z,h,4,j[36]),z=d(z,y,B,A,m,11,j[37]),A=d(A,z,y,B,p,16,j[38]),B=d(B,A,z,y,s,23,j[39]),y=d(y,B,A,z,v,4,j[40]),z=d(z,y,B,A,i,11,j[41]),A=d(A,z,y,B,l,16,j[42]),B=d(B,A,z,y,o,23,j[43]),y=d(y,B,A,z,r,4,j[44]),z=d(z,y,B,A,u,11,j[45]),A=d(A,z,y,B,x,16,j[46]),y=e(y,B=d(B,A,z,y,k,23,j[47]),A,z,i,6,j[48]),z=e(z,y,B,A,p,10,j[49]),A=e(A,z,y,B,w,15,j[50]),B=e(B,A,z,y,n,21,j[51]),y=e(y,B,A,z,u,6,j[52]),z=e(z,y,B,A,l,10,j[53]),A=e(A,z,y,B,s,15,j[54]),B=e(B,A,z,y,h,21,j[55]),y=e(y,B,A,z,q,6,j[56]),z=e(z,y,B,A,x,10,j[57]),A=e(A,z,y,B,o,15,j[58]),B=e(B,A,z,y,v,21,j[59]),y=e(y,B,A,z,m,6,j[60]),z=e(z,y,B,A,t,10,j[61]),A=e(A,z,y,B,k,15,j[62]),B=e(B,A,z,y,r,21,j[63]),g[0]=g[0]+y|0,g[1]=g[1]+B|0,g[2]=g[2]+A|0,g[3]=g[3]+z|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296);for(c[15+(e+64>>>9<<4)]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[14+(e+64>>>9<<4)]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),b.sigBytes=4*(c.length+1),this._process(),c=(b=this._hash).words,d=0;4>d;d++)e=c[d],c[d]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8);return b},clone:function(){var a=h.clone.call(this);return a._hash=this._hash.clone(),a}}),f.MD5=h._createHelper(i),f.HmacMD5=h._createHmacHelper(i)}(Math),function(){var a,b=la,c=(a=b.lib).Base,d=a.WordArray,e=(a=b.algo).EvpKDF=c.extend({cfg:c.extend({keySize:4,hasher:a.MD5,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){for(var c=(h=this.cfg).hasher.create(),e=d.create(),f=e.words,g=h.keySize,h=h.iterations;f.length<g;){i&&c.update(i);var i=c.update(a).finalize(b);c.reset();for(var j=1;j<h;j++)i=c.finalize(i),c.reset();e.concat(i)}return e.sigBytes=4*g,e}});b.EvpKDF=function(a,b,c){return e.create(c).compute(a,b)}}(),la.lib.Cipher||function(a){var b=(n=la).lib,c=b.Base,d=b.WordArray,e=b.BufferedBlockAlgorithm,f=n.enc.Base64,g=n.algo.EvpKDF,h=b.Cipher=e.extend({cfg:c.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){e.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){return a&&this._append(a),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?o:m).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?o:m).decrypt(a,b,c,d)}}}});b.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var i=n.mode={},j=function(a,b,c){var d=this._iv;d?this._iv=void 0:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=d[e]},k=(b.BlockCipherMode=c.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}})).extend();k.Encryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;j.call(this,a,b,d),c.encryptBlock(a,b),this._prevBlock=a.slice(b,b+d)}}),k.Decryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b),j.call(this,a,b,d),this._prevBlock=e}}),i=i.CBC=k,k=(n.pad={}).Pkcs7={pad:function(a,b){for(var c,e=(c=(c=4*b)-a.sigBytes%c)<<24|c<<16|c<<8|c,f=[],g=0;g<c;g+=4)f.push(e);
10
+ c=d.create(f,c),a.concat(c)},unpad:function(a){a.sigBytes-=255&a.words[a.sigBytes-1>>>2]}},b.BlockCipher=h.extend({cfg:h.cfg.extend({mode:i,padding:k}),reset:function(){h.reset.call(this);var a=(b=this.cfg).iv,b=b.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=b.createEncryptor;else c=b.createDecryptor,this._minBufferSize=1;this._mode=c.call(b,this,a&&a.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var l=b.CipherParams=c.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(i=(n.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;return((a=a.salt)?d.create([1398893684,1701076831]).concat(a).concat(b):b).toString(f)},parse:function(a){var b=(a=f.parse(a)).words;if(1398893684==b[0]&&1701076831==b[1]){var c=d.create(b.slice(2,4));b.splice(0,4),a.sigBytes-=16}return l.create({ciphertext:a,salt:c})}},b.SerializableCipher=c.extend({cfg:c.extend({format:i}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);return b=e.finalize(b),e=e.cfg,l.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}})),n=(n.kdf={}).OpenSSL={execute:function(a,b,c,e){return e||(e=d.random(8)),a=g.create({keySize:b+c}).compute(a,e),c=d.create(a.words.slice(b),4*c),a.sigBytes=4*b,l.create({key:a,iv:c,salt:e})}},o=b.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:n}),encrypt:function(a,b,c,d){return c=(d=this.cfg.extend(d)).kdf.execute(c,a.keySize,a.ivSize),d.iv=c.iv,(a=m.encrypt.call(this,a,b,c.key,d)).mixIn(c),a},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt),d.iv=c.iv,m.decrypt.call(this,a,b,c.key,d)}})}(),function(){for(var a=la,b=a.lib.BlockCipher,c=a.algo,d=[],e=[],f=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=0;256>o;o++)n[o]=128>o?o<<1:o<<1^283;var p=0,q=0;for(o=0;256>o;o++){var r=(r=q^q<<1^q<<2^q<<3^q<<4)>>>8^255&r^99;d[p]=r,e[r]=p;var s=n[p],t=n[s],u=n[t],v=257*n[r]^16843008*r;f[p]=v<<24|v>>>8,g[p]=v<<16|v>>>16,h[p]=v<<8|v>>>24,i[p]=v,v=16843009*u^65537*t^257*s^16843008*p,j[r]=v<<24|v>>>8,k[r]=v<<16|v>>>16,l[r]=v<<8|v>>>24,m[r]=v,p?(p=s^n[n[n[u^s]]],q^=n[n[q]]):p=q=1}var w=[0,1,2,4,8,16,32,64,128,27,54];c=c.AES=b.extend({_doReset:function(){for(var a=(c=this._key).words,b=c.sigBytes/4,c=4*((this._nRounds=b+6)+1),e=this._keySchedule=[],f=0;f<c;f++)if(f<b)e[f]=a[f];else{var g=e[f-1];f%b?6<b&&4==f%b&&(g=d[g>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g]):(g=d[(g=g<<8|g>>>24)>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g],g^=w[f/b|0]<<24),e[f]=e[f-b]^g}for(a=this._invKeySchedule=[],b=0;b<c;b++)f=c-b,g=b%4?e[f]:e[f-4],a[b]=4>b||4>=f?g:j[d[g>>>24]]^k[d[g>>>16&255]]^l[d[g>>>8&255]]^m[d[255&g]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,f,g,h,i,d)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,j,k,l,m,e),c=a[b+1],a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;o<i;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++];m=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++],j=p,k=q,l=r}p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],m=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++],a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=m},keySize:8}),a.AES=b._createHelper(c)}(),la.mode.ECB=((ha=la.lib.BlockCipherMode.extend()).Encryptor=ha.extend({processBlock:function(a,b){this._cipher.encryptBlock(a,b)}}),ha.Decryptor=ha.extend({processBlock:function(a,b){this._cipher.decryptBlock(a,b)}}),ha);var ma,na,oa,pa=la,qa=function(){function a(a){var b=a.config;this._config=b,this._iv="0123456789012345",this._allowedKeyEncodings=["hex","utf8","base64","binary"],this._allowedKeyLengths=[128,256],this._allowedModes=["ecb","cbc"],this._defaultOptions={encryptKey:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}return a.prototype.HMACSHA256=function(a){return pa.HmacSHA256(a,this._config.secretKey).toString(pa.enc.Base64)},a.prototype.SHA256=function(a){return pa.SHA256(a).toString(pa.enc.Hex)},a.prototype._parseOptions=function(a){var b=a||{};return b.hasOwnProperty("encryptKey")||(b.encryptKey=this._defaultOptions.encryptKey),b.hasOwnProperty("keyEncoding")||(b.keyEncoding=this._defaultOptions.keyEncoding),b.hasOwnProperty("keyLength")||(b.keyLength=this._defaultOptions.keyLength),b.hasOwnProperty("mode")||(b.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(b.keyEncoding.toLowerCase())&&(b.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(b.keyLength,10))&&(b.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(b.mode.toLowerCase())&&(b.mode=this._defaultOptions.mode),b},a.prototype._decodeKey=function(a,b){return"base64"===b.keyEncoding?pa.enc.Base64.parse(a):"hex"===b.keyEncoding?pa.enc.Hex.parse(a):a},a.prototype._getPaddedKey=function(a,b){return a=this._decodeKey(a,b),b.encryptKey?pa.enc.Utf8.parse(this.SHA256(a).slice(0,32)):a},a.prototype._getMode=function(a){return"ecb"===a.mode?pa.mode.ECB:pa.mode.CBC},a.prototype._getIV=function(a){return"cbc"===a.mode?pa.enc.Utf8.parse(this._iv):null},a.prototype._getRandomIV=function(){return pa.lib.WordArray.random(16)},a.prototype.encrypt=function(a,b,c){return this._config.customEncrypt?this._config.customEncrypt(a):this.pnEncrypt(a,b,c)},a.prototype.decrypt=function(a,b,c){return this._config.customDecrypt?this._config.customDecrypt(a):this.pnDecrypt(a,b,c)},a.prototype.pnEncrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),e=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var f=this._getRandomIV(),g=pa.AES.encrypt(a,e,{iv:f,mode:d}).ciphertext;return f.clone().concat(g.clone()).toString(pa.enc.Base64)}var h=this._getIV(c);return pa.AES.encrypt(a,e,{iv:h,mode:d}).ciphertext.toString(pa.enc.Base64)||a},a.prototype.pnDecrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),f=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var g=i((k=e.from(a,"base64")).slice(0,16)),h=i(k.slice(16));try{var j=pa.AES.decrypt({ciphertext:h},f,{iv:g,mode:d}).toString(pa.enc.Utf8);return JSON.parse(j)}catch(a){return null}}else{g=this._getIV(c);try{var k=pa.enc.Base64.parse(a);return j=pa.AES.decrypt({ciphertext:k},f,{iv:g,mode:d}).toString(pa.enc.Utf8),JSON.parse(j)}catch(a){return null}}},a}(),ra=function(){function a(a){var b=a.timeEndpoint;this._timeEndpoint=b}return a.prototype.onReconnection=function(a){this._reconnectionCallback=a},a.prototype.startPolling=function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)},a.prototype.stopPolling=function(){clearInterval(this._timeTimer)},a.prototype._performTimeLoop=function(){var a=this;this._timeEndpoint(function(b){b.error||(clearInterval(a._timeTimer),a._reconnectionCallback())})},a}(),sa=function(){function a(a){var b=a.config;this.hashHistory=[],this._config=b}return a.prototype.getKey=function(a){var b=function(a){var b=0;if(0===a.length)return b;for(var c=0;c<a.length;c+=1)b=(b<<5)-b+a.charCodeAt(c),b&=b;return b}(JSON.stringify(a.payload)).toString(),c=a.publishMetaData.publishTimetoken;return"".concat(c,"-").concat(b)},a.prototype.isDuplicate=function(a){return this.hashHistory.includes(this.getKey(a))},a.prototype.addEntry=function(a){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(a))},a.prototype.clearHistory=function(){this.hashHistory=[]},a}(),ta={signPamFromParams:function(a){return k(a).map(function(b){return"".concat(b,"=").concat(j(a[b]))}).join("&")},endsWith:function(a,b){return-1!==a.indexOf(b,this.length-b.length)},createPromise:function(){var a,b;return{promise:new Promise(function(c,d){a=c,b=d}),reject:b,fulfill:a}},encodeString:j},ua={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},va=function(){function a(a){var b=a.subscribeEndpoint,c=a.leaveEndpoint,d=a.heartbeatEndpoint,e=a.setStateEndpoint,f=a.timeEndpoint,g=a.getFileUrl,h=a.config,i=a.crypto,j=a.listenerManager;this._listenerManager=j,this._config=h,this._leaveEndpoint=c,this._heartbeatEndpoint=d,this._setStateEndpoint=e,this._subscribeEndpoint=b,this._getFileUrl=g,this._crypto=i,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new ra({timeEndpoint:f}),this._dedupingManager=new sa({config:h})}return a.prototype.adaptStateChange=function(a,b){var c=this,d=a.state,e=a.channels,f=void 0===e?[]:e,g=a.channelGroups,h=void 0===g?[]:g;return f.forEach(function(a){a in c._channels&&(c._channels[a].state=d)}),h.forEach(function(a){a in c._channelGroups&&(c._channelGroups[a].state=d)}),this._setStateEndpoint({state:d,channels:f,channelGroups:h},b)},a.prototype.adaptPresenceChange=function(a){var b=this,c=a.connected,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f;c?(e.forEach(function(a){b._heartbeatChannels[a]={state:{}}}),g.forEach(function(a){b._heartbeatChannelGroups[a]={state:{}}})):(e.forEach(function(a){a in b._heartbeatChannels&&delete b._heartbeatChannels[a]}),g.forEach(function(a){a in b._heartbeatChannelGroups&&delete b._heartbeatChannelGroups[a]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:e,channelGroups:g},function(a){b._listenerManager.announceStatus(a)})),this.reconnect()},a.prototype.adaptSubscribeChange=function(a){var b=this,c=a.timetoken,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=a.withPresence,i=void 0!==h&&h,j=a.withHeartbeats,k=void 0!==j&&j;this._config.subscribeKey&&""!==this._config.subscribeKey?(c&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=c),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),e.forEach(function(a){b._channels[a]={state:{}},i&&(b._presenceChannels[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannels[a]={}),b._pendingChannelSubscriptions.push(a)}),g.forEach(function(a){b._channelGroups[a]={state:{}},i&&(b._presenceChannelGroups[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannelGroups[a]={}),b._pendingChannelGroupSubscriptions.push(a)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},a.prototype.adaptUnsubscribeChange=function(a,b){var c=this,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=[],i=[];e.forEach(function(a){a in c._channels&&(delete c._channels[a],h.push(a),a in c._heartbeatChannels&&delete c._heartbeatChannels[a]),a in c._presenceChannels&&(delete c._presenceChannels[a],h.push(a))}),g.forEach(function(a){a in c._channelGroups&&(delete c._channelGroups[a],i.push(a),a in c._heartbeatChannelGroups&&delete c._heartbeatChannelGroups[a]),a in c._presenceChannelGroups&&(delete c._presenceChannelGroups[a],i.push(a))}),0===h.length&&0===i.length||(!1!==this._config.suppressLeaveEvents||b||this._leaveEndpoint({channels:h,channelGroups:i},function(a){a.affectedChannels=h,a.affectedChannelGroups=i,a.currentTimetoken=c._currentTimetoken,a.lastTimetoken=c._lastTimetoken,c._listenerManager.announceStatus(a)}),0===Object.keys(this._channels).length&&0===Object.keys(this._presenceChannels).length&&0===Object.keys(this._channelGroups).length&&0===Object.keys(this._presenceChannelGroups).length&&(this._lastTimetoken=0,this._currentTimetoken=0,this._storedTimetoken=null,this._region=null,this._reconnectionManager.stopPolling()),this.reconnect())},a.prototype.unsubscribeAll=function(a){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},a)},a.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},a.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},a.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},a.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},a.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},a.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},a.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},a.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},a.prototype._performHeartbeatLoop=function(){var a=this,b=this.getHeartbeatChannels(),c=this.getHeartbeatChannelGroups(),d={};0===b.length&&0===c.length||(this.getSubscribedChannels().forEach(function(b){var c=a._channels[b].state;Object.keys(c).length&&(d[b]=c)}),this.getSubscribedChannelGroups().forEach(function(b){var c=a._channelGroups[b].state;Object.keys(c).length&&(d[b]=c)}),this._heartbeatEndpoint({channels:b,channelGroups:c,state:d},function(b){b.error&&a._config.announceFailedHeartbeats&&a._listenerManager.announceStatus(b),b.error&&a._config.autoNetworkDetection&&a._isOnline&&(a._isOnline=!1,a.disconnect(),a._listenerManager.announceNetworkDown(),a.reconnect()),!b.error&&a._config.announceSuccessfulHeartbeats&&a._listenerManager.announceStatus(b)}.bind(this)))},a.prototype._startSubscribeLoop=function(){var a=this;this._stopSubscribeLoop();var b={},c=[],d=[];if(Object.keys(this._channels).forEach(function(d){var e=a._channels[d].state;Object.keys(e).length&&(b[d]=e),c.push(d)}),Object.keys(this._presenceChannels).forEach(function(a){c.push("".concat(a,"-pnpres"))}),Object.keys(this._channelGroups).forEach(function(c){var e=a._channelGroups[c].state;Object.keys(e).length&&(b[c]=e),d.push(c)}),Object.keys(this._presenceChannelGroups).forEach(function(a){d.push("".concat(a,"-pnpres"))}),0!==c.length||0!==d.length){var e={channels:c,channelGroups:d,state:b,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(e,this._processSubscribeResponse.bind(this))}},a.prototype._processSubscribeResponse=function(a,b){var c=this;if(a.error){if(a.errorData&&"Aborted"===a.errorData.message)return;a.category===ua.PNTimeoutCategory?this._startSubscribeLoop():a.category===ua.PNNetworkIssuesCategory?(this.disconnect(),a.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){c._config.autoNetworkDetection&&!c._isOnline&&(c._isOnline=!0,c._listenerManager.announceNetworkUp()),c.reconnect(),c._subscriptionStatusAnnounced=!0;var b={category:ua.PNReconnectedCategory,operation:a.operation,lastTimetoken:c._lastTimetoken,currentTimetoken:c._currentTimetoken};c._listenerManager.announceStatus(b)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(a)):a.category===ua.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(a)):this._listenerManager.announceStatus(a)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=b.metadata.timetoken),!this._subscriptionStatusAnnounced){var d={};d.category=ua.PNConnectedCategory,d.operation=a.operation,d.affectedChannels=this._pendingChannelSubscriptions,d.subscribedChannels=this.getSubscribedChannels(),d.affectedChannelGroups=this._pendingChannelGroupSubscriptions,d.lastTimetoken=this._lastTimetoken,d.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(d),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var e=b.messages||[],f=this._config,g=f.requestMessageCountThreshold,h=f.dedupeOnSubscribe;if(g&&e.length>=g){var i={};i.category=ua.PNRequestMessageCountExceededCategory,i.operation=a.operation,this._listenerManager.announceStatus(i)}e.forEach(function(a){var b=a.channel,d=a.subscriptionMatch,e=a.publishMetaData;if(b===d&&(d=null),h){if(c._dedupingManager.isDuplicate(a))return;c._dedupingManager.addEntry(a)}if(ta.endsWith(a.channel,"-pnpres"))(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,b&&(i.channel=b.substring(0,b.lastIndexOf("-pnpres"))),d&&(i.subscription=d.substring(0,d.lastIndexOf("-pnpres"))),i.action=a.payload.action,i.state=a.payload.data,i.timetoken=e.publishTimetoken,i.occupancy=a.payload.occupancy,i.uuid=a.payload.uuid,i.timestamp=a.payload.timestamp,a.payload.join&&(i.join=a.payload.join),a.payload.leave&&(i.leave=a.payload.leave),a.payload.timeout&&(i.timeout=a.payload.timeout),c._listenerManager.announcePresence(i);else if(1===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=a.payload,c._listenerManager.announceSignal(i);else if(2===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message={event:a.payload.event,type:a.payload.type,data:a.payload.data},c._listenerManager.announceObjects(i),"user"===a.payload.type?c._listenerManager.announceUser(i):"space"===a.payload.type?c._listenerManager.announceSpace(i):"membership"===a.payload.type&&c._listenerManager.announceMembership(i);else if(3===a.messageType)(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,i.data={messageTimetoken:a.payload.data.messageTimetoken,actionTimetoken:a.payload.data.actionTimetoken,type:a.payload.data.type,uuid:a.issuingClientId,value:a.payload.data.value},i.event=a.payload.event,c._listenerManager.announceMessageAction(i);else if(4===a.messageType){(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId;var f=a.payload;if(c._config.cipherKey){var g=c._crypto.decrypt(a.payload);"object"==typeof g&&null!==g&&(f=g)}a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=f.message,i.file={id:f.file.id,name:f.file.name,url:c._getFileUrl({id:f.file.id,name:f.file.name,channel:b})},c._listenerManager.announceFile(i)}else{var i;(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,i.channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),c._config.cipherKey?i.message=c._crypto.decrypt(a.payload):i.message=a.payload,c._listenerManager.announceMessage(i)}}),this._region=b.metadata.region,this._startSubscribeLoop()}},a.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},a}(),wa={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},xa=function(){function a(a){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=a.maximumSamplesCount||this._maximumSamplesCount}return a.prototype.operationsLatencyForRequest=function(){var a=this,b={};return Object.keys(this._latencies).forEach(function(c){var d=a._latencies[c],e=a._averageLatency(d);e>0&&(b["l_".concat(c)]=e)}),b},a.prototype.startLatencyMeasure=function(a,b){a!==wa.PNSubscribeOperation&&b&&(this._trackedLatencies[b]=Date.now())},a.prototype.stopLatencyMeasure=function(a,b){if(a!==wa.PNSubscribeOperation&&b){var c=this._endpointName(a),d=this._latencies[c],e=this._trackedLatencies[b];d||(this._latencies[c]=[],d=this._latencies[c]),d.push(Date.now()-e),d.length>this._maximumSamplesCount&&d.splice(0,d.length-this._maximumSamplesCount),delete this._trackedLatencies[b]}},a.prototype._averageLatency=function(a){return Math.floor(a.reduce(function(a,b){return a+b},0)/a.length)},a.prototype._endpointName=function(a){var b=null;switch(a){case wa.PNPublishOperation:b="pub";break;case wa.PNSignalOperation:b="sig";break;case wa.PNHistoryOperation:case wa.PNFetchMessagesOperation:case wa.PNDeleteMessagesOperation:case wa.PNMessageCounts:b="hist";break;case wa.PNUnsubscribeOperation:case wa.PNWhereNowOperation:case wa.PNHereNowOperation:case wa.PNHeartbeatOperation:case wa.PNSetStateOperation:case wa.PNGetStateOperation:b="pres";break;case wa.PNAddChannelsToGroupOperation:case wa.PNRemoveChannelsFromGroupOperation:case wa.PNChannelGroupsOperation:case wa.PNRemoveGroupOperation:case wa.PNChannelsForGroupOperation:b="cg";break;case wa.PNPushNotificationEnabledChannelsOperation:case wa.PNRemoveAllPushNotificationsOperation:b="push";break;case wa.PNCreateUserOperation:case wa.PNUpdateUserOperation:case wa.PNDeleteUserOperation:case wa.PNGetUserOperation:case wa.PNGetUsersOperation:case wa.PNCreateSpaceOperation:case wa.PNUpdateSpaceOperation:case wa.PNDeleteSpaceOperation:case wa.PNGetSpaceOperation:case wa.PNGetSpacesOperation:case wa.PNGetMembersOperation:case wa.PNUpdateMembersOperation:case wa.PNGetMembershipsOperation:case wa.PNUpdateMembershipsOperation:b="obj";break;case wa.PNAddMessageActionOperation:case wa.PNRemoveMessageActionOperation:case wa.PNGetMessageActionsOperation:b="msga";break;case wa.PNAccessManagerGrant:case wa.PNAccessManagerAudit:b="pam";break;case wa.PNAccessManagerGrantToken:case wa.PNAccessManagerRevokeToken:b="pamv3";break;default:b="time"}return b},a}(),ya=function(){function a(a,b,c){this._payload=a,this._setDefaultPayloadStructure(),this.title=b,this.body=c}return Object.defineProperty(a.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{set:function(a){this._title=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{set:function(a){this._subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{set:function(a){this._body=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{set:function(a){this._badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{set:function(a){this._sound=a},enumerable:!1,configurable:!0}),a.prototype._setDefaultPayloadStructure=function(){},a.prototype.toObject=function(){return{}},a}(),za=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"configurations",{set:function(a){a&&a.length&&(this._configurations=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.aps.alert.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){a&&a.length&&(this._payload.aps.alert.subtitle=a,this._subtitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this._body},set:function(a){a&&a.length&&(this._payload.aps.alert.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this._badge},set:function(a){null!=a&&(this._payload.aps.badge=a,this._badge=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.aps.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},c.prototype.toObject=function(){var a=this,b=$({},this._payload),c=b.aps,d=c.alert;if(this._isSilent&&(c["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var e=[];this._configurations.forEach(function(b){e.push(a._objectFromAPNS2Configuration(b))}),e.length&&(b.pn_push=e)}return d&&Object.keys(d).length||delete c.alert,this._isSilent&&(delete c.alert,delete c.badge,delete c.sound,d={}),this._isSilent||Object.keys(d).length?b:null},c.prototype._objectFromAPNS2Configuration=function(a){var b=this;if(!a.targets||!a.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var c=[];a.targets.forEach(function(a){c.push(b._objectFromAPNSTarget(a))});var d=a.collapseId,e=a.expirationDate,f={auth_method:"token",targets:c,version:"v2"};return d&&d.length&&(f.collapse_id=d),e&&(f.expiration=e.toISOString()),f},c.prototype._objectFromAPNSTarget=function(a){if(!a.topic||!a.topic.length)throw new TypeError("Target 'topic' undefined.");var b=a.topic,c=a.environment,d=void 0===c?"development":c,e=a.excludedDevices,f=void 0===e?[]:e,g={topic:b,environment:d};return f.length&&(g.excluded_devices=f),g},c}(ya),Aa=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"backContent",{get:function(){return this._backContent},set:function(a){a&&a.length&&(this._payload.back_content=a,this._backContent=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"backTitle",{get:function(){return this._backTitle},set:function(a){a&&a.length&&(this._payload.back_title=a,this._backTitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"count",{get:function(){return this._count},set:function(a){null!=a&&(this._payload.count=a,this._count=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"type",{get:function(){return this._type},set:function(a){a&&a.length&&(this._payload.type=a,this._type=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this.backTitle},set:function(a){this.backTitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this.backContent},set:function(a){this.backContent=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this.count},set:function(a){this.count=a},enumerable:!1,configurable:!0}),c.prototype.toObject=function(){return Object.keys(this._payload).length?$({},this._payload):null},c}(ya),Ba=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.notification.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this._body;
11
+ },set:function(a){a&&a.length&&(this._payload.notification.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.notification.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"icon",{get:function(){return this._icon},set:function(a){a&&a.length&&(this._payload.notification.icon=a,this._icon=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"tag",{get:function(){return this._tag},set:function(a){a&&a.length&&(this._payload.notification.tag=a,this._tag=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},c.prototype.toObject=function(){var a=$({},this._payload.data),b=null,c={};if(Object.keys(this._payload).length>2){var d=this._payload;d.notification,d.data;var e=function(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(null!=a&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(d=Object.getOwnPropertySymbols(a);e<d.length;e++)b.indexOf(d[e])<0&&Object.prototype.propertyIsEnumerable.call(a,d[e])&&(c[d[e]]=a[d[e]])}return c}(d,["notification","data"]);a=$($({},a),e)}return this._isSilent?a.notification=this._payload.notification:b=this._payload.notification,Object.keys(a).length&&(c.data=a),b&&Object.keys(b).length&&(c.notification=b),Object.keys(c).length?c:null},c}(ya),Ca=function(){function a(a,b){this._payload={apns:{},mpns:{},fcm:{}},this._title=a,this._body=b,this.apns=new za(this._payload.apns,a,b),this.mpns=new Aa(this._payload.mpns,a,b),this.fcm=new Ba(this._payload.fcm,a,b)}return Object.defineProperty(a.prototype,"debugging",{set:function(a){this._debugging=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){this._subtitle=a,this.apns.subtitle=a,this.mpns.subtitle=a,this.fcm.subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{get:function(){return this._badge},set:function(a){this._badge=a,this.apns.badge=a,this.mpns.badge=a,this.fcm.badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{get:function(){return this._sound},set:function(a){this._sound=a,this.apns.sound=a,this.mpns.sound=a,this.fcm.sound=a},enumerable:!1,configurable:!0}),a.prototype.buildPayload=function(a){var b={};if(a.includes("apns")||a.includes("apns2")){this.apns._apnsPushType=a.includes("apns")?"apns":"apns2";var c=this.apns.toObject();c&&Object.keys(c).length&&(b.pn_apns=c)}if(a.includes("mpns")){var d=this.mpns.toObject();d&&Object.keys(d).length&&(b.pn_mpns=d)}if(a.includes("fcm")){var e=this.fcm.toObject();e&&Object.keys(e).length&&(b.pn_gcm=e)}return Object.keys(b).length&&this._debugging&&(b.pn_debug=!0),b},a}(),Da=function(){function a(){this._listeners=[]}return a.prototype.addListener=function(a){this._listeners.push(a)},a.prototype.removeListener=function(a){var b=[];this._listeners.forEach(function(c){c!==a&&b.push(c)}),this._listeners=b},a.prototype.removeAllListeners=function(){this._listeners=[]},a.prototype.announcePresence=function(a){this._listeners.forEach(function(b){b.presence&&b.presence(a)})},a.prototype.announceStatus=function(a){this._listeners.forEach(function(b){b.status&&b.status(a)})},a.prototype.announceMessage=function(a){this._listeners.forEach(function(b){b.message&&b.message(a)})},a.prototype.announceSignal=function(a){this._listeners.forEach(function(b){b.signal&&b.signal(a)})},a.prototype.announceMessageAction=function(a){this._listeners.forEach(function(b){b.messageAction&&b.messageAction(a)})},a.prototype.announceFile=function(a){this._listeners.forEach(function(b){b.file&&b.file(a)})},a.prototype.announceObjects=function(a){this._listeners.forEach(function(b){b.objects&&b.objects(a)})},a.prototype.announceUser=function(a){this._listeners.forEach(function(b){b.user&&b.user(a)})},a.prototype.announceSpace=function(a){this._listeners.forEach(function(b){b.space&&b.space(a)})},a.prototype.announceMembership=function(a){this._listeners.forEach(function(b){b.membership&&b.membership(a)})},a.prototype.announceNetworkUp=function(){var a={};a.category=ua.PNNetworkUpCategory,this.announceStatus(a)},a.prototype.announceNetworkDown=function(){var a={};a.category=ua.PNNetworkDownCategory,this.announceStatus(a)},a}(),Ea=function(){function a(a,b){this._config=a,this._cbor=b}return a.prototype.setToken=function(a){a&&a.length>0?this._token=a:this._token=void 0},a.prototype.getToken=function(){return this._token},a.prototype.extractPermissions=function(a){var b={read:!1,write:!1,manage:!1,"delete":!1,get:!1,update:!1,join:!1};return 128==(128&a)&&(b.join=!0),64==(64&a)&&(b.update=!0),32==(32&a)&&(b.get=!0),8==(8&a)&&(b["delete"]=!0),4==(4&a)&&(b.manage=!0),2==(2&a)&&(b.write=!0),1==(1&a)&&(b.read=!0),b},a.prototype.parseToken=function(a){var b=this,c=this._cbor.decodeToken(a);if(void 0!==c){var d=c.res.uuid?Object.keys(c.res.uuid):[],e=Object.keys(c.res.chan),f=Object.keys(c.res.grp),g=c.pat.uuid?Object.keys(c.pat.uuid):[],h=Object.keys(c.pat.chan),i=Object.keys(c.pat.grp),j={version:c.v,timestamp:c.t,ttl:c.ttl,authorized_uuid:c.uuid},k=d.length>0,l=e.length>0,m=f.length>0;(k||l||m)&&(j.resources={},k&&(j.resources.uuids={},d.forEach(function(a){j.resources.uuids[a]=b.extractPermissions(c.res.uuid[a])})),l&&(j.resources.channels={},e.forEach(function(a){j.resources.channels[a]=b.extractPermissions(c.res.chan[a])})),m&&(j.resources.groups={},f.forEach(function(a){j.resources.groups[a]=b.extractPermissions(c.res.grp[a])})));var n=g.length>0,o=h.length>0,p=i.length>0;return(n||o||p)&&(j.patterns={},n&&(j.patterns.uuids={},g.forEach(function(a){j.patterns.uuids[a]=b.extractPermissions(c.pat.uuid[a])})),o&&(j.patterns.channels={},h.forEach(function(a){j.patterns.channels[a]=b.extractPermissions(c.pat.chan[a])})),p&&(j.patterns.groups={},i.forEach(function(a){j.patterns.groups[a]=b.extractPermissions(c.pat.grp[a])}))),Object.keys(c.meta).length>0&&(j.meta=c.meta),j.signature=c.sig,j}},a}(),Fa=function(b){function c(a,c){var d=this.constructor,e=b.call(this,a)||this;return e.name=e.constructor.name,e.status=c,e.message=a,Object.setPrototypeOf(e,d.prototype),e}return a(c,b),c}(Error),Ga=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAddChannelsToGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{add:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),Ha=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveChannelsFromGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{remove:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),Ia=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Ja=Object.freeze({__proto__:null,getOperation:function(){return wa.PNChannelGroupsOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v1/channel-registration/sub-key/".concat(b.subscribeKey,"/channel-group")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{groups:b.payload.groups}}}),Ka=Object.freeze({__proto__:null,getOperation:function(){return wa.PNChannelsForGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{channels:b.payload.channels}}}),La=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,add:e.join(",")};return"apns2"===c&&delete(i=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Ma=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,remove:e.join(",")};return"apns2"===c&&delete(i=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Na=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(a,b){return{channels:b}}}),Oa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveAllPushNotificationsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c,"/remove"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c,"/remove")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(){return{}}}),Pa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNUnsubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/leave")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(){return{}}}),Qa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNWhereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d;return"/v2/presence/sub-key/".concat(c.subscribeKey,"/uuid/").concat(ta.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return b.payload?{channels:b.payload.channels}:{channels:[]}}}),Ra=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHeartbeatOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.state,f=void 0===e?{}:e,g=a.config,h={};return d.length>0&&(h["channel-group"]=d.join(",")),h.state=JSON.stringify(f),h.heartbeat=g.getPresenceTimeout(),h},handleResponse:function(){return{}}}),Sa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNGetStateOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d,f=b.channels,g=void 0===f?[]:f,h=g.length>0?g.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(h),"/uuid/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h={};return 1===e.length&&0===g.length?h[e[0]]=b.payload:h=b.payload,{channels:h}}}),Ta=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSetStateOperation},validateParams:function(a,b){var c=a.config,d=b.state,e=b.channels,f=void 0===e?[]:e,g=b.channelGroups,h=void 0===g?[]:g;return d?c.subscribeKey?0===f.length&&0===h.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(f),"/uuid/").concat(ta.encodeString(c.UUID),"/data")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.state,d=b.channelGroups,e=void 0===d?[]:d,f={};return f.state=JSON.stringify(c),e.length>0&&(f["channel-group"]=e.join(",")),f},handleResponse:function(a,b){return{state:b.payload}}}),Ua=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=b.channelGroups,g=void 0===f?[]:f,h="/v2/presence/sub-key/".concat(c.subscribeKey);if(e.length>0||g.length>0){var i=e.length>0?e.join(","):",";h+="/channel/".concat(ta.encodeString(i))}return h},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.includeUUIDs,f=void 0===e||e,g=b.includeState,h=void 0!==g&&g,i=b.queryParameters,j=void 0===i?{}:i,k={};return f||(k.disable_uuids=1),h&&(k.state=1),d.length>0&&(k["channel-group"]=d.join(",")),k=$($({},k),j)},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h=c.includeUUIDs,i=void 0===h||h,j=c.includeState,k=void 0!==j&&j;return e.length>1||g.length>0||0===g.length&&0===e.length?function(){var a={};return a.totalChannels=b.payload.total_channels,a.totalOccupancy=b.payload.total_occupancy,a.channels={},Object.keys(b.payload.channels).forEach(function(c){var d=b.payload.channels[c],e=[];return a.channels[c]={occupants:e,name:c,occupancy:d.occupancy},i&&d.uuids.forEach(function(a){k?e.push({state:a.state,uuid:a.uuid}):e.push({state:null,uuid:a})}),a}),a}():function(){var a={},c=[];return a.totalChannels=1,a.totalOccupancy=b.occupancy,a.channels={},a.channels[e[0]]={occupants:c,name:e[0],occupancy:b.occupancy},i&&b.uuids&&b.uuids.forEach(function(a){k?c.push({state:a.state,uuid:a.uuid}):c.push({state:null,uuid:a})}),a}()},handleError:function(a,b,c){402!==c.statusCode||this.getURL(a,b).includes("channel")||(c.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}}),Va=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAddMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.action,e=b.channel;return b.messageTimetoken?c.subscribeKey?e?d?d.value?d.type?d.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(a,b){var c=a.config,d=b.channel,e=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d),"/message/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(a,b){return b.action},handleResponse:function(a,b){return{data:b.data}}}),Wa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNRemoveMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken;return b.messageTimetoken?e?c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken,f=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d),"/message/").concat(f,"/action/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{data:b.data}}}),Xa=Object.freeze({__proto__:null,getOperation:function(){return wa.PNGetMessageActionsOperation},validateParams:function(a,b){var c=a.config,d=b.channel;return c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channel;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(ta.encodeString(d))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.limit,d=b.start,e=b.end,f={};return c&&(f.limit=c),d&&(f.start=d),e&&(f.end=e),f},handleResponse:function(a,b){var c={data:b.data,start:null,end:null};return c.data.length&&(c.end=c.data[c.data.length-1].actionTimetoken,c.start=c.data[0].actionTimetoken),c}}),Ya={getOperation:function(){return wa.PNListFilesOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"channel can't be empty"},getURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.limit&&(c.limit=b.limit),b.next&&(c.next=b.next),c},handleResponse:function(a,b){return{status:b.status,data:b.data,next:b.next,count:b.count}}},Za={getOperation:function(){return wa.PNGenerateUploadUrlOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/generate-upload-url")},postPayload:function(a,b){return{name:b.name}},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data,file_upload_request:b.file_upload_request}}},$a={getOperation:function(){return wa.PNPublishFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.fileId)?(null==b?void 0:b.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(a,b){var c=a.config,d=c.publishKey,e=c.subscribeKey,f=function(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e||""}(a,{message:b.message,file:{name:b.fileName,id:b.fileId}});return"/v1/files/publish-file/".concat(d,"/").concat(e,"/0/").concat(ta.encodeString(b.channel),"/0/").concat(ta.encodeString(f))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.ttl&&(c.ttl=b.ttl),void 0!==b.storeInHistory&&(c.store=b.storeInHistory?"1":"0"),b.meta&&"object"==typeof b.meta&&(c.meta=JSON.stringify(b.meta)),c},handleResponse:function(a,b){return{timetoken:b[2]}}},_a=function(a){var b=function(a){var b=this,e=a.generateUploadUrl,f=a.publishFile,g=a.modules,h=g.PubNubFile,i=g.config,j=g.cryptography,k=g.networking;return function(a){var g=a.channel,m=a.file,n=a.message,o=a.cipherKey,p=a.meta,q=a.ttl,r=a.storeInHistory;return c(b,void 0,void 0,function(){var a,b,c,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q;return d(this,function(d){switch(d.label){case 0:if(!g)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!m)throw new Fa("Validation failed, check status for details",l("file can't be empty"));return a=h.create(m),[4,e({channel:g,name:a.name})];case 1:return b=d.sent(),c=b.file_upload_request,s=c.url,t=c.form_fields,u=b.data,v=u.id,w=u.name,h.supportsEncryptFile&&(null!=o?o:i.cipherKey)?[4,j.encryptFile(null!=o?o:i.cipherKey,a,h)]:[3,3];case 2:a=d.sent(),d.label=3;case 3:x=t,a.mimeType&&(x=t.map(function(b){return"Content-Type"===b.key?{key:b.key,value:a.mimeType}:b})),d.label=4;case 4:return d.trys.push([4,18,,20]),h.supportsFileUri&&m.uri?(A=(z=k).POSTFILE,B=[s,x],[4,a.toFileUri()]):[3,7];case 5:return[4,A.apply(z,B.concat([d.sent()]))];case 6:return y=d.sent(),[3,17];case 7:return h.supportsFile?(D=(C=k).POSTFILE,E=[s,x],[4,a.toFile()]):[3,10];case 8:return[4,D.apply(C,E.concat([d.sent()]))];case 9:return y=d.sent(),[3,17];case 10:return h.supportsBuffer?(G=(F=k).POSTFILE,H=[s,x],[4,a.toBuffer()]):[3,13];case 11:return[4,G.apply(F,H.concat([d.sent()]))];case 12:return y=d.sent(),[3,17];case 13:return h.supportsBlob?(J=(I=k).POSTFILE,K=[s,x],[4,a.toBlob()]):[3,16];case 14:return[4,J.apply(I,K.concat([d.sent()]))];case 15:return y=d.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,20];case 18:return L=d.sent(),[4,(R=L.response,new Promise(function(a){var b="";R.on("data",function(a){b+=a.toString("utf8")}),R.on("end",function(){a(b)})}))];case 19:throw M=d.sent(),N=/<Message>(.*)<\/Message>/gi.exec(M),new Fa(N?"Upload to bucket failed: ".concat(N[1]):"Upload to bucket failed.",L);case 20:if(204!==y.status)throw new Fa("Upload to bucket was unsuccessful",y);O=i.fileUploadPublishRetryLimit,P=!1,Q={timetoken:"0"},d.label=21;case 21:return d.trys.push([21,23,,24]),[4,f({channel:g,message:n,fileId:v,fileName:w,meta:p,storeInHistory:r,ttl:q})];case 22:return Q=d.sent(),P=!0,[3,24];case 23:return d.sent(),O-=1,[3,24];case 24:if(!P&&O>0)return[3,21];d.label=25;case 25:if(P)return[2,{timetoken:Q.timetoken,id:v,name:w}];throw new Fa("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:g,id:v,name:w})}var R})})}}(a);return function(a,c){var d=b(a);return"function"==typeof c?(d.then(function(a){return c(null,a)})["catch"](function(a){return c(a,null)}),d):d}},ab=function(a,b){var c=b.channel,d=b.id,e=b.name,f=a.config,g=a.networking;if(!c)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!d)throw new Fa("Validation failed, check status for details",l("file id can't be empty"));if(!e)throw new Fa("Validation failed, check status for details",l("file name can't be empty"));var h="/v1/files/".concat(f.subscribeKey,"/channels/").concat(ta.encodeString(c),"/files/").concat(d,"/").concat(e),i={};i.uuid=f.getUUID(),i.pnsdk=n(f),f.getAuthKey()&&(i.auth=f.getAuthKey()),f.secretKey&&p(a,h,i,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var j=Object.keys(i).map(function(a){return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(i[a]))}).join("&");return""!==j?"".concat(g.getStandardOrigin()).concat(h,"?").concat(j):"".concat(g.getStandardOrigin()).concat(h)},bb={getOperation:function(){return wa.PNDownloadFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?(null==b?void 0:b.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b,e){var f=a.PubNubFile,g=a.config,h=a.cryptography;return c(void 0,void 0,void 0,function(){var a,c,i,j;return d(this,function(d){switch(d.label){case 0:return a=b.response.body,f.supportsEncryptFile&&(null!==(c=e.cipherKey)&&void 0!==c?c:g.cipherKey)?[4,h.decrypt(null!==(i=e.cipherKey)&&void 0!==i?i:g.cipherKey,a)]:[3,2];case 1:a=d.sent(),d.label=2;case 2:return[2,f.create({data:a,name:null!==(j=b.response.name)&&void 0!==j?j:e.name,mimeType:b.response.type})]}})})}},cb={getOperation:function(){return wa.PNListFilesOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.id)?(null==b?void 0:b.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status}}},db={getOperation:function(){return wa.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(h=b.page)||void 0===h?void 0:h.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,next:b.next,prev:b.prev}}},eb={getOperation:function(){return wa.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},fb={getOperation:function(){return wa.PNSetUUIDMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()))},patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout();
12
+ },isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},gb={getOperation:function(){return wa.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},hb={getOperation:function(){return wa.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(h=b.page)||void 0===h?void 0:h.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},ib={getOperation:function(){return wa.PNGetChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},jb={getOperation:function(){return wa.PNSetChannelMetadataOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},kb={getOperation:function(){return wa.PNRemoveChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},lb={getOperation:function(){return wa.PNGetMembersOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"UUID cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o,p={};return(null==b?void 0:b.include)&&(p.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&p.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&p.include.push("uuid.custom"),(null===(f=null===(e=b.include)||void 0===e?void 0:e.UUIDFields)||void 0===f||f)&&p.include.push("uuid"),p.include=p.include.join(",")),(null===(h=null==b?void 0:b.include)||void 0===h?void 0:h.totalCount)&&(p.count=null===(i=b.include)||void 0===i?void 0:i.totalCount),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.next)&&(p.start=null===(k=b.page)||void 0===k?void 0:k.next),(null===(l=null==b?void 0:b.page)||void 0===l?void 0:l.prev)&&(p.end=null===(m=b.page)||void 0===m?void 0:m.prev),(null==b?void 0:b.filter)&&(p.filter=b.filter),p.limit=null!==(n=null==b?void 0:b.limit)&&void 0!==n?n:100,(null==b?void 0:b.sort)&&(p.sort=Object.entries(null!==(o=b.sort)&&void 0!==o?o:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),p},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},mb={getOperation:function(){return wa.PNSetMembersOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.uuids)&&0!==(null==b?void 0:b.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(ta.encodeString(b.channel),"/uuids")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.uuids.map(function(a){return"string"==typeof a?{uuid:{id:a}}:{uuid:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&m.include.push("uuid.custom"),(null===(e=b.include)||void 0===e?void 0:e.UUIDFields)&&m.include.push("uuid"),m.include=m.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(h=null==b?void 0:b.page)||void 0===h?void 0:h.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),(null==b?void 0:b.limit)&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},nb={getOperation:function(){return wa.PNGetMembershipsOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o={};return(null==b?void 0:b.include)&&(o.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&o.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&o.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&o.include.push("channel"),o.include=o.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(o.count=null===(h=b.include)||void 0===h?void 0:h.totalCount),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.next)&&(o.start=null===(j=b.page)||void 0===j?void 0:j.next),(null===(k=null==b?void 0:b.page)||void 0===k?void 0:k.prev)&&(o.end=null===(l=b.page)||void 0===l?void 0:l.prev),(null==b?void 0:b.filter)&&(o.filter=b.filter),o.limit=null!==(m=null==b?void 0:b.limit)&&void 0!==m?m:100,(null==b?void 0:b.sort)&&(o.sort=Object.entries(null!==(n=b.sort)&&void 0!==n?n:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),o},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},ob={getOperation:function(){return wa.PNSetMembershipsOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)||0===(null==b?void 0:b.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.channels.map(function(a){return"string"==typeof a?{channel:{id:a}}:{channel:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.include=[],(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&m.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&m.include.push("channel"),m.include=m.include.join(",")),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(h=null==b?void 0:b.page)||void 0===h?void 0:h.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),(null==b?void 0:b.limit)&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=g(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},pb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerAudit},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v2/auth/audit/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channel,d=b.channelGroup,e=b.authKeys,f=void 0===e?[]:e,g={};return c&&(g.channel=c),d&&(g["channel-group"]=d),f.length>0&&(g.auth=f.join(",")),g},handleResponse:function(a,b){return b.payload}}),qb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerGrant},validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?null==b.uuids||b.authKeys?null==b.uuids||null==b.channels&&null==b.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v2/auth/grant/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.channelGroups,f=void 0===e?[]:e,g=b.uuids,h=void 0===g?[]:g,i=b.ttl,j=b.read,k=void 0!==j&&j,l=b.write,m=void 0!==l&&l,n=b.manage,o=void 0!==n&&n,p=b.get,q=void 0!==p&&p,r=b.join,s=void 0!==r&&r,t=b.update,u=void 0!==t&&t,v=b.authKeys,w=void 0===v?[]:v,x=b["delete"],y={};return y.r=k?"1":"0",y.w=m?"1":"0",y.m=o?"1":"0",y.d=x?"1":"0",y.g=q?"1":"0",y.j=s?"1":"0",y.u=u?"1":"0",d.length>0&&(y.channel=d.join(",")),f.length>0&&(y["channel-group"]=f.join(",")),w.length>0&&(y.auth=w.join(",")),h.length>0&&(y["target-uuid"]=h.join(",")),(i||0===i)&&(y.ttl=i),y},handleResponse:function(){return{}}}),rb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerGrantToken},extractPermissions:r,validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?b.resources||b.patterns?(!b.resources||b.resources.uuids&&0!==Object.keys(b.resources.uuids).length||b.resources.channels&&0!==Object.keys(b.resources.channels).length||b.resources.groups&&0!==Object.keys(b.resources.groups).length)&&(!b.patterns||b.patterns.uuids&&0!==Object.keys(b.patterns.uuids).length||b.patterns.channels&&0!==Object.keys(b.patterns.channels).length||b.patterns.groups&&0!==Object.keys(b.patterns.groups).length)?void 0:"Missing values for either Resources or Patterns.":"Missing either Resources or Patterns.":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},postURL:function(a){var b=a.config;return"/v3/pam/".concat(b.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(a,b){return function(a,b){var c=b.ttl,d=b.resources,e=b.patterns,f=b.meta,g=b.authorized_uuid,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(d){var i=d.uuids,j=d.channels,k=d.groups;i&&Object.keys(i).forEach(function(a){h.permissions.resources.uuids[a]=r(i[a])}),j&&Object.keys(j).forEach(function(a){h.permissions.resources.channels[a]=r(j[a])}),k&&Object.keys(k).forEach(function(a){h.permissions.resources.groups[a]=r(k[a])})}if(e){var l=e.uuids,m=e.channels,n=e.groups;l&&Object.keys(l).forEach(function(a){h.permissions.patterns.uuids[a]=r(l[a])}),m&&Object.keys(m).forEach(function(a){h.permissions.patterns.channels[a]=r(m[a])}),n&&Object.keys(n).forEach(function(a){h.permissions.patterns.groups[a]=r(n[a])})}return(c||0===c)&&(h.ttl=c),f&&(h.permissions.meta=f),g&&(h.permissions.uuid="".concat(g)),h}(0,b)},handleResponse:function(a,b){return b.data.token}}),sb={getOperation:function(){return wa.PNAccessManagerRevokeToken},validateParams:function(a,b){return a.config.secretKey?b?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(a,b){var c=a.config;return"/v3/pam/".concat(c.subscribeKey,"/grant/").concat(ta.encodeString(b))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a){return{uuid:a.config.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},tb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNPublishOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(a,b){var c=b.sendByPost;return void 0!==c&&c},getURL:function(a,b){var c=a.config,d=b.channel,e=s(a,b.message);return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0/").concat(ta.encodeString(e))},postURL:function(a,b){var c=a.config,d=b.channel;return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(a,b){return s(a,b.message)},prepareParams:function(a,b){var c=b.meta,d=b.replicate,e=void 0===d||d,f=b.storeInHistory,g=b.ttl,h={};return null!=f&&(h.store=f?"1":"0"),g&&(h.ttl=g),!1===e&&(h.norep="true"),c&&"object"==typeof c&&(h.meta=JSON.stringify(c)),h},handleResponse:function(a,b){return{timetoken:b[2]}}}),ub=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSignalOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(a,b){var c,d=a.config,e=b.channel,f=b.message,g=(c=f,JSON.stringify(c));return"/signal/".concat(d.publishKey,"/").concat(d.subscribeKey,"/0/").concat(ta.encodeString(e),"/0/").concat(ta.encodeString(g))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{timetoken:b[2]}}}),vb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNHistoryOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channel,d=a.config;return"/v2/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e=b.reverse,f=b.count,g=void 0===f?100:f,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l={include_token:"true"};return l.count=g,c&&(l.start=c),d&&(l.end=d),i&&(l.string_message_token="true"),null!=e&&(l.reverse=e.toString()),k&&(l.include_meta="true"),l},handleResponse:function(a,b){var c={messages:[],startTimeToken:b[1],endTimeToken:b[2]};return Array.isArray(b[0])&&b[0].forEach(function(b){var d={timetoken:b.timetoken,entry:t(a,b.message)};b.meta&&(d.meta=b.meta),c.messages.push(d)}),c}}),wb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNDeleteMessagesOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(a,b){var c=b.channel,d=a.config;return"/v3/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(ta.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e={};return c&&(e.start=c),d&&(e.end=d),e},handleResponse:function(a,b){return b.payload}}),xb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNMessageCounts},validateParams:function(a,b){var c=b.channels,d=b.timetoken,e=b.channelTimetokens,f=a.config;return c?d&&e?"timetoken and channelTimetokens are incompatible together":d&&e&&e.length>1&&c.length!==e.length?"Length of channelTimetokens and channels do not match":f.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channels,d=a.config,e=c.join(",");return"/v3/history/sub-key/".concat(d.subscribeKey,"/message-counts/").concat(ta.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.timetoken,d=b.channelTimetokens,e={};if(d&&1===d.length){var f=g(d,1)[0];e.timetoken=f}else d?e.channelsTimetoken=d.join(","):c&&(e.timetoken=c);return e},handleResponse:function(a,b){return{channels:b.channels}}}),yb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNFetchMessagesOperation},validateParams:function(a,b){var c=b.channels,d=b.includeMessageActions,e=void 0!==d&&d,f=a.config;if(!c||0===c.length)return"Missing channels";if(!f.subscribeKey)return"Missing Subscribe Key";if(e&&c.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.includeMessageActions,f=void 0!==e&&e,g=a.config,h=f?"history-with-actions":"history",i=d.length>0?d.join(","):",";return"/v3/".concat(h,"/sub-key/").concat(g.subscribeKey,"/channel/").concat(ta.encodeString(i))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels,d=b.start,e=b.end,f=b.includeMessageActions,g=b.count,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l=b.includeUuid,m=b.includeUUID,n=void 0===m||m,o=b.includeMessageType,p=void 0===o||o,q={};return q.max=g||(c.length>1||!0===f?25:100),d&&(q.start=d),e&&(q.end=e),i&&(q.string_message_token="true"),k&&(q.include_meta="true"),n&&!1!==l&&(q.include_uuid="true"),p&&(q.include_message_type="true"),q},handleResponse:function(a,b){var c={channels:{}};return Object.keys(b.channels||{}).forEach(function(d){c.channels[d]=[],(b.channels[d]||[]).forEach(function(b){var e={};e.channel=d,e.timetoken=b.timetoken,e.message=function(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}(a,b.message),e.messageType=b.message_type,e.uuid=b.uuid,b.actions&&(e.actions=b.actions,e.data=b.actions),b.meta&&(e.meta=b.meta),c.channels[d].push(e)})}),b.more&&(c.more=b.more),c}}),zb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(a,b){return{timetoken:b[0]}},validateParams:function(){}}),Ab=Object.freeze({__proto__:null,getOperation:function(){return wa.PNSubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(f),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=a.config,d=b.state,e=b.channelGroups,f=void 0===e?[]:e,g=b.timetoken,h=b.filterExpression,i=b.region,j={heartbeat:c.getPresenceTimeout()};return f.length>0&&(j["channel-group"]=f.join(",")),h&&h.length>0&&(j["filter-expr"]=h),Object.keys(d).length&&(j.state=JSON.stringify(d)),g&&(j.tt=g),i&&(j.tr=i),j},handleResponse:function(a,b){var c=[];b.m.forEach(function(a){var b={publishTimetoken:a.p.t,region:a.p.r},d={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,userMetadata:a.u,publishMetaData:b};c.push(d)});var d={timetoken:b.t.t,region:b.t.r};return{messages:c,metadata:d}}}),Bb={getOperation:function(){return wa.PNHandshakeOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)&&!(null==b?void 0:b.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=0,c},handleResponse:function(a,b){return{region:b.t.r,timetoken:b.t.t}}},Cb={getOperation:function(){return wa.PNReceiveMessagesOperation},validateParams:function(a,b){return(null==b?void 0:b.channels)||(null==b?void 0:b.channelGroups)?(null==b?void 0:b.timetoken)?(null==b?void 0:b.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(a,b){return b.abortSignal},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=b.timetoken,c.tr=b.region,c},handleResponse:function(a,b){var c=[];return b.m.forEach(function(a){var b={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,publishMetaData:{timetoken:a.p.t,region:a.p.r}};c.push(b)}),{messages:c,metadata:{region:b.t.r,timetoken:b.t.t}}}},Db=function(){function a(a){void 0===a&&(a=!1),this.sync=a,this.listeners=new Set}return a.prototype.subscribe=function(a){var b=this;return this.listeners.add(a),function(){b.listeners["delete"](a)}},a.prototype.notify=function(a){var b=this,c=function(){b.listeners.forEach(function(b){b(a)})};this.sync?c():setTimeout(c,0)},a}(),Eb=function(){function a(a){this.label=a,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return a.prototype.transition=function(a,b){var c;if(this.transitionMap.has(b.type))return null===(c=this.transitionMap.get(b.type))||void 0===c?void 0:c(a,b)},a.prototype.on=function(a,b){return this.transitionMap.set(a,b),this},a.prototype["with"]=function(a,b){return[this,a,null!=b?b:[]]},a.prototype.onEnter=function(a){return this.enterEffects.push(a),this},a.prototype.onExit=function(a){return this.exitEffects.push(a),this},a}(),Fb=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),c.prototype.describe=function(a){return new Eb(a)},c.prototype.start=function(a,b){this.currentState=a,this.currentContext=b,this.notify({type:"engineStarted",state:a,context:b})},c.prototype.transition=function(a){var b,c,d,e,h,i;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:a});var j=this.currentState.transition(this.currentContext,a);if(j){var k=g(j,3),l=k[0],m=k[1],n=k[2];try{for(var o=f(this.currentState.exitEffects),p=o.next();!p.done;p=o.next()){var q=p.value;this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}}catch(a){b={error:a}}finally{try{p&&!p.done&&(c=o["return"])&&c.call(o)}finally{if(b)throw b.error}}var r=this.currentState;this.currentState=l;var s=this.currentContext;this.currentContext=m,this.notify({type:"transitionDone",fromState:r,fromContext:s,toState:l,toContext:m,event:a});try{for(var t=f(n),u=t.next();!u.done;u=t.next())q=u.value,this.notify({type:"invocationDispatched",invocation:q})}catch(a){d={error:a}}finally{try{u&&!u.done&&(e=t["return"])&&e.call(t)}finally{if(d)throw d.error}}try{for(var v=f(this.currentState.enterEffects),w=v.next();!w.done;w=v.next())q=w.value,this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}catch(a){h={error:a}}finally{try{w&&!w.done&&(i=v["return"])&&i.call(v)}finally{if(h)throw h.error}}}},c}(Db),Gb=function(){function a(a){this.dependencies=a,this.instances=new Map,this.handlers=new Map}return a.prototype.on=function(a,b){this.handlers.set(a,b)},a.prototype.dispatch=function(a){if("CANCEL"!==a.type){var b=this.handlers.get(a.type);if(!b)throw new Error("Unhandled invocation '".concat(a.type,"'"));var c=b(a.payload,this.dependencies);a.managed&&this.instances.set(a.type,c),c.start()}else if(this.instances.has(a.payload)){var d=this.instances.get(a.payload);null==d||d.cancel(),this.instances["delete"](a.payload)}},a}(),Hb=function(b){function c(){var a=this.constructor,c=b.call(this,"The operation was aborted.")||this;return c.name="AbortError",Object.setPrototypeOf(c,a.prototype),c}return a(c,b),c}(Error),Ib=function(b){function c(){var a=null!==b&&b.apply(this,arguments)||this;return a._aborted=!1,a}return a(c,b),Object.defineProperty(c.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),c.prototype.throwIfAborted=function(){if(this._aborted)throw new Hb},c.prototype.abort=function(){this._aborted=!0,this.notify(new Hb)},c}(Db),Jb=function(b){function c(a,c,d){var e=b.call(this,a,c)||this;return e.asyncFunction=d,e.abortSignal=new Ib,e}return a(c,b),c.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies)},c.prototype.cancel=function(){this.abortSignal.abort()},c}(function(a,b){this.payload=a,this.dependencies=b}),Kb=function(a){return function(b,c){return new Jb(b,c,a)}},Lb=v("HANDSHAKE",function(a,b){return{channels:a,groups:b}}),Mb=v("RECEIVE_EVENTS",function(a,b,c){return{channels:a,groups:b,cursor:c}}),Nb=(na=function(a){return a},oa=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return{type:ma,payload:na.apply(void 0,h([],g(a),!1)),managed:!1}},oa.type=ma="EMIT_EVENTS",oa),Ob=v("RECONNECT",function(a){return a}),Pb=v("HANDSHAKE_RECONNECT",function(a){return a}),Qb=u("SUBSCRIPTION_CHANGE",function(a,b){return{channels:a,groups:b}}),Rb=u("DISCONNECT",function(){return{}}),Sb=u("RECONNECT",function(){return{}});u("RESTORE",function(a,b,c,d){return{channels:a,groups:b,timetoken:c,region:d}});var Tb=u("HANDSHAKING_SUCCESS",function(a){return a}),Ub=u("HANDSHAKING_FAILURE",function(a){return a}),Vb=u("HANDSHAKING_RECONNECTING_SUCCESS",function(a){return{cursor:a}}),Wb=u("HANDSHAKING_RECONNECTING_FAILURE",function(a){return a}),Xb=u("HANDSHAKING_RECONNECTING_GIVEUP",function(){return{}}),Yb=u("HANDSHAKING_RECONNECTING_RETRY",function(){return{}}),Zb=u("RECEIVING_SUCCESS",function(a,b){return{cursor:a,events:b}}),$b=u("RECEIVING_FAILURE",function(a){return a}),_b=u("RECONNECTING_SUCCESS",function(a,b){return{cursor:a,events:b}}),ac=u("RECONNECTING_FAILURE",function(a){return a}),bc=u("RECONNECTING_GIVEUP",function(){return{}}),cc=u("RECONNECTING_RETRY",function(){return{}}),dc=function(b){function e(a,e){var f=b.call(this,e)||this;return f.on(Lb.type,Kb(function(b,e,g){var h=g.handshake;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 2:return c=d.sent(),a.transition(Tb(c)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Ub(f))]:[3,4];case 4:return[2]}})})})),f.on(Mb.type,Kb(function(b,e,g){var h=g.receiveEvents;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 2:return c=d.sent(),a.transition(Zb(c.metadata,c.messages)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition($b(f))]:[3,4];case 4:return[2]}})})})),f.on(Nb.type,Kb(function(a,b,e){return e.receiveEvents,c(f,void 0,void 0,function(){return d(this,function(b){return a.length>0&&console.log(a),[2]})})})),f.on(Ob.type,Kb(function(b,e,g){var h=g.receiveEvents,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(bc())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 3:return c=d.sent(),[2,a.transition(_b(c.metadata,c.messages))];case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(ac(f))]:[3,5];
13
+ case 5:return[2]}})})})),f.on(Pb.type,Kb(function(b,e,g){var h=g.handshake,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(Xb())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 3:return c=d.sent(),[2,a.transition(Vb(c.metadata))];case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Wb(f))]:[3,5];case 5:return[2]}})})})),f}return a(e,b),e}(Gb),ec=new Eb("STOPPED");ec.on(Qb.type,function(a,b){return ec["with"]({channels:b.payload.channels,groups:b.payload.groups})}),ec.on(Sb.type,function(a){return lc["with"]($({},a))});var fc=new Eb("HANDSHAKE_FAILURE");fc.on(Yb.type,function(a){return kc["with"]($($({},a),{attempts:0}))}),fc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var gc=new Eb("STOPPED");gc.on(Qb.type,function(a,b){return gc["with"]({channels:b.payload.channels,groups:b.payload.groups,cursor:a.cursor})}),gc.on(Sb.type,function(a){return jc["with"]($({},a))});var hc=new Eb("RECEIVE_FAILURE");hc.on(cc.type,function(a){return ic["with"]($($({},a),{attempts:0}))}),hc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var ic=new Eb("RECEIVE_RECONNECTING");ic.onEnter(function(a){return Ob(a)}),ic.onExit(function(){return Ob.cancel}),ic.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),ic.on(ac.type,function(a,b){return ic["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),ic.on(bc.type,function(a){return hc["with"]({groups:a.groups,channels:a.channels,cursor:a.cursor,reason:a.reason})}),ic.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var jc=new Eb("RECEIVING");jc.onEnter(function(a){return Mb(a.channels,a.groups,a.cursor)}),jc.onExit(function(){return Mb.cancel}),jc.on(Zb.type,function(a,b){return jc["with"]($($({},a),{cursor:b.payload.cursor}),[Nb(b.payload.events)])}),jc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):jc["with"]($($({},a),{channels:b.payload.channels,groups:b.payload.groups}))}),jc.on($b.type,function(a,b){return ic["with"]($($({},a),{attempts:0,reason:b.payload}))}),jc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var kc=new Eb("HANDSHAKE_RECONNECTING");kc.onEnter(function(a){return Pb(a)}),kc.onExit(function(){return Ob.cancel}),kc.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),kc.on(ac.type,function(a,b){return kc["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),kc.on(bc.type,function(a){return fc["with"]({groups:a.groups,channels:a.channels,reason:a.reason})}),kc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var lc=new Eb("HANDSHAKING");lc.onEnter(function(a){return Lb(a.channels,a.groups)}),lc.onExit(function(){return Lb.cancel}),lc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):lc["with"]({channels:b.payload.channels,groups:b.payload.groups})}),lc.on(Tb.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload})}),lc.on(Ub.type,function(a,b){return kc["with"]($($({},a),{attempts:0,reason:b.payload}))}),lc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var mc=new Eb("UNSUBSCRIBED");mc.on(Qb.type,function(a,b){return lc["with"]({channels:b.payload.channels,groups:b.payload.groups})});var nc=function(){function a(a){var b=this;this.engine=new Fb,this.channels=[],this.groups=[],this.dispatcher=new dc(this.engine,a),this.engine.subscribe(function(a){"invocationDispatched"===a.type&&b.dispatcher.dispatch(a.invocation)}),this.engine.start(mc,void 0)}return Object.defineProperty(a.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),a.prototype.subscribe=function(a){var b=a.channels,c=a.groups;this.channels=h(h([],g(this.channels),!1),g(null!=b?b:[]),!1),this.groups=h(h([],g(this.groups),!1),g(null!=c?c:[]),!1),this.engine.transition(Qb(this.channels,this.groups))},a.prototype.unsubscribe=function(a){var b=a.channels,c=a.groups;this.channels=this.channels.filter(function(a){var c;return null===(c=!(null==b?void 0:b.includes(a)))||void 0===c||c}),this.groups=this.groups.filter(function(a){var b;return null===(b=!(null==c?void 0:c.includes(a)))||void 0===b||b}),this.engine.transition(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.reconnect=function(){this.engine.transition(Sb())},a.prototype.disconnect=function(){this.engine.transition(Rb())},a}(),oc=function(){function a(a){var b=this,c=a.networking,d=a.cbor,e=new ka({setup:a});this._config=e;var f=new qa({config:e}),i=a.cryptography;c.init(e);var j=new Ea(e,d);this._tokenManager=j;var k=new xa({maximumSamplesCount:6e4});this._telemetryManager=k;var l={config:e,networking:c,crypto:f,cryptography:i,tokenManager:j,telemetryManager:k,PubNubFile:a.PubNubFile};this.File=a.PubNubFile,this.encryptFile=function(a,c){return i.encryptFile(a,c,b.File)},this.decryptFile=function(a,c){return i.decryptFile(a,c,b.File)};var m=q.bind(this,l,zb),n=q.bind(this,l,Pa),o=q.bind(this,l,Ra),p=q.bind(this,l,Ta),r=q.bind(this,l,Ab),s=new Da;if(this._listenerManager=s,this.iAmHere=q.bind(this,l,Ra),this.iAmAway=q.bind(this,l,Pa),this.setPresenceState=q.bind(this,l,Ta),this.handshake=q.bind(this,l,Bb),this.receiveMessages=q.bind(this,l,Cb),!0===e.enableSubscribeBeta){var t=new nc({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=t.subscribe.bind(t),this.unsubscribe=t.unsubscribe.bind(t),this.eventEngine=t}else{var u=new va({timeEndpoint:m,leaveEndpoint:n,heartbeatEndpoint:o,setStateEndpoint:p,subscribeEndpoint:r,crypto:l.crypto,config:l.config,listenerManager:s,getFileUrl:function(a){return ab(l,a)}});this.subscribe=u.adaptSubscribeChange.bind(u),this.unsubscribe=u.adaptUnsubscribeChange.bind(u),this.disconnect=u.disconnect.bind(u),this.reconnect=u.reconnect.bind(u),this.unsubscribeAll=u.unsubscribeAll.bind(u),this.getSubscribedChannels=u.getSubscribedChannels.bind(u),this.getSubscribedChannelGroups=u.getSubscribedChannelGroups.bind(u),this.setState=u.adaptStateChange.bind(u),this.presence=u.adaptPresenceChange.bind(u),this.destroy=function(a){u.unsubscribeAll(a),u.disconnect()}}this.addListener=s.addListener.bind(s),this.removeListener=s.removeListener.bind(s),this.removeAllListeners=s.removeAllListeners.bind(s),this.parseToken=j.parseToken.bind(j),this.setToken=j.setToken.bind(j),this.getToken=j.getToken.bind(j),this.channelGroups={listGroups:q.bind(this,l,Ja),listChannels:q.bind(this,l,Ka),addChannels:q.bind(this,l,Ga),removeChannels:q.bind(this,l,Ha),deleteGroup:q.bind(this,l,Ia)},this.push={addChannels:q.bind(this,l,La),removeChannels:q.bind(this,l,Ma),deleteDevice:q.bind(this,l,Oa),listChannels:q.bind(this,l,Na)},this.hereNow=q.bind(this,l,Ua),this.whereNow=q.bind(this,l,Qa),this.getState=q.bind(this,l,Sa),this.grant=q.bind(this,l,qb),this.grantToken=q.bind(this,l,rb),this.audit=q.bind(this,l,pb),this.revokeToken=q.bind(this,l,sb),this.publish=q.bind(this,l,tb),this.fire=function(a,c){return a.replicate=!1,a.storeInHistory=!1,b.publish(a,c)},this.signal=q.bind(this,l,ub),this.history=q.bind(this,l,vb),this.deleteMessages=q.bind(this,l,wb),this.messageCounts=q.bind(this,l,xb),this.fetchMessages=q.bind(this,l,yb),this.addMessageAction=q.bind(this,l,Va),this.removeMessageAction=q.bind(this,l,Wa),this.getMessageActions=q.bind(this,l,Xa),this.listFiles=q.bind(this,l,Ya);var v=q.bind(this,l,Za);this.publishFile=q.bind(this,l,$a),this.sendFile=_a({generateUploadUrl:v,publishFile:this.publishFile,modules:l}),this.getFileUrl=function(a){return ab(l,a)},this.downloadFile=q.bind(this,l,bb),this.deleteFile=q.bind(this,l,cb),this.objects={getAllUUIDMetadata:q.bind(this,l,db),getUUIDMetadata:q.bind(this,l,eb),setUUIDMetadata:q.bind(this,l,fb),removeUUIDMetadata:q.bind(this,l,gb),getAllChannelMetadata:q.bind(this,l,hb),getChannelMetadata:q.bind(this,l,ib),setChannelMetadata:q.bind(this,l,jb),removeChannelMetadata:q.bind(this,l,kb),getChannelMembers:q.bind(this,l,lb),setChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"set"},a)],g(c),!1))},removeChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"delete"},a)],g(c),!1))},getMemberships:q.bind(this,l,nb),setMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"set"},a)],g(c),!1))},removeMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"delete"},a)],g(c),!1))}},this.createUser=function(a){return b.objects.setUUIDMetadata({uuid:a.userId,data:a.data,include:a.include})},this.updateUser=this.createUser,this.removeUser=function(a){return b.objects.removeUUIDMetadata({uuid:null==a?void 0:a.userId})},this.fetchUser=function(a){return b.objects.getUUIDMetadata({uuid:null==a?void 0:a.userId,include:null==a?void 0:a.include})},this.fetchUsers=this.objects.getAllUUIDMetadata,this.createSpace=function(a){return b.objects.setChannelMetadata({channel:a.spaceId,data:a.data,include:a.include})},this.updateSpace=this.createSpace,this.removeSpace=function(a){return b.objects.removeChannelMetadata({channel:a.spaceId})},this.fetchSpace=function(a){return b.objects.getChannelMetadata({channel:a.spaceId,include:a.include})},this.fetchSpaces=this.objects.getAllChannelMetadata,this.time=m,this.stop=this.destroy,this.encrypt=f.encrypt.bind(f),this.decrypt=f.decrypt.bind(f),this.getAuthKey=l.config.getAuthKey.bind(l.config),this.setAuthKey=l.config.setAuthKey.bind(l.config),this.setCipherKey=l.config.setCipherKey.bind(l.config),this.getUUID=l.config.getUUID.bind(l.config),this.setUUID=l.config.setUUID.bind(l.config),this.getFilterExpression=l.config.getFilterExpression.bind(l.config),this.setFilterExpression=l.config.setFilterExpression.bind(l.config),this.setHeartbeatInterval=l.config.setHeartbeatInterval.bind(l.config),c.hasModule("proxy")&&(this.setProxy=function(a){l.config.setProxy(a),b.reconnect()})}return a.prototype.getVersion=function(){return this._config.getVersion()},a.prototype._addPnsdkSuffix=function(a,b){this._config._addPnsdkSuffix(a,b)},a.prototype.networkDownDetected=function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)},a.prototype.networkUpDetected=function(){this._listenerManager.announceNetworkUp(),this.reconnect()},a.notificationPayload=function(a,b){return new Ca(a,b)},a.generateUUID=function(){return ja()},a.OPERATIONS=wa,a.CATEGORIES=ua,a}(),pc=function(){function a(a){var b=this;this._modules={},Object.keys(a).forEach(function(c){b._modules[c]=a[c].bind(b)})}return a.prototype.init=function(a){this._config=a,Array.isArray(this._config.origin)?this._currentSubDomain=Math.floor(Math.random()*this._config.origin.length):this._currentSubDomain=0,this._coreParams={},this.shiftStandardOrigin()},a.prototype.nextOrigin=function(){var a=this._config.secure?"https://":"http://";if("string"==typeof this._config.origin)return"".concat(a).concat(this._config.origin);this._currentSubDomain+=1,this._currentSubDomain>=this._config.origin.length&&(this._currentSubDomain=0);var b=this._config.origin[this._currentSubDomain];return"".concat(a).concat(b)},a.prototype.hasModule=function(a){return a in this._modules},a.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},a.prototype.getStandardOrigin=function(){return this._standardOrigin},a.prototype.POSTFILE=function(a,b,c){return this._modules.postfile(a,b,c)},a.prototype.GETFILE=function(a,b,c){return this._modules.getfile(a,b,c)},a.prototype.POST=function(a,b,c,d){return this._modules.post(a,b,c,d)},a.prototype.PATCH=function(a,b,c,d){return this._modules.patch(a,b,c,d)},a.prototype.GET=function(a,b,c){return this._modules.get(a,b,c)},a.prototype.DELETE=function(a,b,c){return this._modules.del(a,b,c)},a.prototype._detectErrorCategory=function(a){if("ENOTFOUND"===a.code)return ua.PNNetworkIssuesCategory;if("ECONNREFUSED"===a.code)return ua.PNNetworkIssuesCategory;if("ECONNRESET"===a.code)return ua.PNNetworkIssuesCategory;if("EAI_AGAIN"===a.code)return ua.PNNetworkIssuesCategory;if(0===a.status||a.hasOwnProperty("status")&&void 0===a.status)return ua.PNNetworkIssuesCategory;if(a.timeout)return ua.PNTimeoutCategory;if("ETIMEDOUT"===a.code)return ua.PNNetworkIssuesCategory;if(a.response){if(a.response.badRequest)return ua.PNBadRequestCategory;if(a.response.forbidden)return ua.PNAccessDeniedCategory}return ua.PNUnknownCategory},a}(),qc=function(){function a(a,b){this._base64ToBinary=b,this._decode=a}return a.prototype.decodeToken=function(a){var b="";a.length%4==3?b="=":a.length%4==2&&(b="==");var c=a.replace(/-/gi,"+").replace(/_/gi,"/")+b,d=this._decode(this._base64ToBinary(c));if("object"==typeof d)return d},a}(),rc={exports:{}},sc={exports:{}};!function(a){function b(a){if(a)return function(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}(a)}a.exports=b,b.prototype.on=b.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=b.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c,d=this._callbacks["$"+a];if(!d)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var e=0;e<d.length;e++)if((c=d[e])===b||c.fn===b){d.splice(e,1);break}return 0===d.length&&delete this._callbacks["$"+a],this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){d=0;for(var e=(c=c.slice(0)).length;d<e;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length}}(sc);var tc=x;x["default"]=x,x.stable=B,x.stableStringify=B;var uc="[...]",vc="[Circular]",wc=[],xc=[],yc=String.prototype.replace,zc=/%20/g,Ac="RFC3986",Bc={"default":Ac,formatters:{RFC1738:function(a){return yc.call(a,zc,"+")},RFC3986:function(a){return String(a)}},RFC1738:"RFC1738",RFC3986:Ac},Cc=Bc,Dc=Object.prototype.hasOwnProperty,Ec=Array.isArray,Fc=function(){for(var a=[],b=0;b<256;++b)a.push("%"+((b<16?"0":"")+b.toString(16)).toUpperCase());return a}(),Gc=function(a,b){for(var c=b&&b.plainObjects?Object.create(null):{},d=0;d<a.length;++d)void 0!==a[d]&&(c[d]=a[d]);return c},Hc={arrayToObject:Gc,assign:function(a,b){return Object.keys(b).reduce(function(a,c){return a[c]=b[c],a},a)},combine:function(a,b){return[].concat(a,b)},compact:function(a){for(var b=[{obj:{o:a},prop:"o"}],c=[],d=0;d<b.length;++d)for(var e=b[d],f=e.obj[e.prop],g=Object.keys(f),h=0;h<g.length;++h){var i=g[h],j=f[i];"object"==typeof j&&null!==j&&-1===c.indexOf(j)&&(b.push({obj:f,prop:i}),c.push(j))}return function(a){for(;a.length>1;){var b=a.pop(),c=b.obj[b.prop];if(Ec(c)){for(var d=[],e=0;e<c.length;++e)void 0!==c[e]&&d.push(c[e]);b.obj[b.prop]=d}}}(b),a},decode:function(a,b,c){var d=a.replace(/\+/g," ");if("iso-8859-1"===c)return d.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(d)}catch(a){return d}},encode:function(a,b,c,d,e){if(0===a.length)return a;var f=a;if("symbol"==typeof a?f=Symbol.prototype.toString.call(a):"string"!=typeof a&&(f=String(a)),"iso-8859-1"===c)return escape(f).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});for(var g="",h=0;h<f.length;++h){var i=f.charCodeAt(h);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||e===Cc.RFC1738&&(40===i||41===i)?g+=f.charAt(h):i<128?g+=Fc[i]:i<2048?g+=Fc[192|i>>6]+Fc[128|63&i]:i<55296||i>=57344?g+=Fc[224|i>>12]+Fc[128|i>>6&63]+Fc[128|63&i]:(h+=1,i=65536+((1023&i)<<10|1023&f.charCodeAt(h)),g+=Fc[240|i>>18]+Fc[128|i>>12&63]+Fc[128|i>>6&63]+Fc[128|63&i])}return g},isBuffer:function(a){return!(!a||"object"!=typeof a||!(a.constructor&&a.constructor.isBuffer&&a.constructor.isBuffer(a)))},isRegExp:function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},maybeMap:function(a,b){if(Ec(a)){for(var c=[],d=0;d<a.length;d+=1)c.push(b(a[d]));return c}return b(a)},merge:function od(a,b,c){if(!b)return a;if("object"!=typeof b){if(Ec(a))a.push(b);else{if(!a||"object"!=typeof a)return[a,b];(c&&(c.plainObjects||c.allowPrototypes)||!Dc.call(Object.prototype,b))&&(a[b]=!0)}return a}if(!a||"object"!=typeof a)return[a].concat(b);var d=a;return Ec(a)&&!Ec(b)&&(d=Gc(a,c)),Ec(a)&&Ec(b)?(b.forEach(function(b,d){if(Dc.call(a,d)){var e=a[d];e&&"object"==typeof e&&b&&"object"==typeof b?a[d]=od(e,b,c):a.push(b)}else a[d]=b}),a):Object.keys(b).reduce(function(a,d){var e=b[d];return Dc.call(a,d)?a[d]=od(a[d],e,c):a[d]=e,a},d)}},Ic=Hc,Jc=Bc,Kc=Object.prototype.hasOwnProperty,Lc={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},Mc=Array.isArray,Nc=String.prototype.split,Oc=Array.prototype.push,Pc=function(a,b){Oc.apply(a,Mc(b)?b:[b])},Qc=Date.prototype.toISOString,Rc=Jc["default"],Sc={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Ic.encode,encodeValuesOnly:!1,format:Rc,formatter:Jc.formatters[Rc],indices:!1,serializeDate:function(a){return Qc.call(a)},skipNulls:!1,strictNullHandling:!1},Tc=function pd(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o,p=a;if("function"==typeof g?p=g(b,p):p instanceof Date?p=j(p):"comma"===c&&Mc(p)&&(p=Ic.maybeMap(p,function(a){return a instanceof Date?j(a):a})),null===p){if(d)return f&&!m?f(b,Sc.encoder,n,"key",k):b;p=""}if("string"==typeof(o=p)||"number"==typeof o||"boolean"==typeof o||"symbol"==typeof o||"bigint"==typeof o||Ic.isBuffer(p)){if(f){var q=m?b:f(b,Sc.encoder,n,"key",k);if("comma"===c&&m){for(var r=Nc.call(String(p),","),s="",t=0;t<r.length;++t)s+=(0===t?"":",")+l(f(r[t],Sc.encoder,n,"value",k));return[l(q)+"="+s]}return[l(q)+"="+l(f(p,Sc.encoder,n,"value",k))]}return[l(b)+"="+l(String(p))]}var u,v=[];if(void 0===p)return v;if("comma"===c&&Mc(p))u=[{value:p.length>0?p.join(",")||null:void 0}];else if(Mc(g))u=g;else{var w=Object.keys(p);u=h?w.sort(h):w}for(var x=0;x<u.length;++x){var y=u[x],z="object"==typeof y&&void 0!==y.value?y.value:p[y];if(!e||null!==z){var A=Mc(p)?"function"==typeof c?c(b,y):b:b+(i?"."+y:"["+y+"]");Pc(v,pd(z,A,c,d,e,f,g,h,i,j,k,l,m,n))}}return v},Uc=Hc,Vc=Object.prototype.hasOwnProperty,Wc=Array.isArray,Xc={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Uc.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Yc=function(a){return a.replace(/&#(\d+);/g,function(a,b){return String.fromCharCode(parseInt(b,10))})},Zc=function(a,b){return a&&"string"==typeof a&&b.comma&&a.indexOf(",")>-1?a.split(","):a},$c=function(a,b,c,d){if(a){var e=c.allowDots?a.replace(/\.([^.[]+)/g,"[$1]"):a,f=/(\[[^[\]]*])/g,g=c.depth>0&&/(\[[^[\]]*])/.exec(e),h=g?e.slice(0,g.index):e,i=[];if(h){if(!c.plainObjects&&Vc.call(Object.prototype,h)&&!c.allowPrototypes)return;i.push(h)}for(var j=0;c.depth>0&&null!==(g=f.exec(e))&&j<c.depth;){if(j+=1,!c.plainObjects&&Vc.call(Object.prototype,g[1].slice(1,-1))&&!c.allowPrototypes)return;i.push(g[1])}return g&&i.push("["+e.slice(g.index)+"]"),function(a,b,c,d){for(var e=d?b:Zc(b,c),f=a.length-1;f>=0;--f){var g,h=a[f];if("[]"===h&&c.parseArrays)g=[].concat(e);else{g=c.plainObjects?Object.create(null):{};var i="["===h.charAt(0)&&"]"===h.charAt(h.length-1)?h.slice(1,-1):h,j=parseInt(i,10);c.parseArrays||""!==i?!isNaN(j)&&h!==i&&String(j)===i&&j>=0&&c.parseArrays&&j<=c.arrayLimit?(g=[])[j]=e:"__proto__"!==i&&(g[i]=e):g={0:e}}e=g}return e}(i,b,c,d)}},_c={formats:Bc,parse:function(a,b){var c=function(a){if(!a)return Xc;if(null!==a.decoder&&void 0!==a.decoder&&"function"!=typeof a.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=void 0===a.charset?Xc.charset:a.charset;return{allowDots:void 0===a.allowDots?Xc.allowDots:!!a.allowDots,allowPrototypes:"boolean"==typeof a.allowPrototypes?a.allowPrototypes:Xc.allowPrototypes,arrayLimit:"number"==typeof a.arrayLimit?a.arrayLimit:Xc.arrayLimit,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Xc.charsetSentinel,comma:"boolean"==typeof a.comma?a.comma:Xc.comma,decoder:"function"==typeof a.decoder?a.decoder:Xc.decoder,delimiter:"string"==typeof a.delimiter||Uc.isRegExp(a.delimiter)?a.delimiter:Xc.delimiter,depth:"number"==typeof a.depth||!1===a.depth?+a.depth:Xc.depth,ignoreQueryPrefix:!0===a.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof a.interpretNumericEntities?a.interpretNumericEntities:Xc.interpretNumericEntities,parameterLimit:"number"==typeof a.parameterLimit?a.parameterLimit:Xc.parameterLimit,parseArrays:!1!==a.parseArrays,plainObjects:"boolean"==typeof a.plainObjects?a.plainObjects:Xc.plainObjects,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Xc.strictNullHandling}}(b);if(""===a||null==a)return c.plainObjects?Object.create(null):{};for(var d="string"==typeof a?function(a,b){var c,d={},e=b.ignoreQueryPrefix?a.replace(/^\?/,""):a,f=b.parameterLimit===1/0?void 0:b.parameterLimit,g=e.split(b.delimiter,f),h=-1,i=b.charset;if(b.charsetSentinel)for(c=0;c<g.length;++c)0===g[c].indexOf("utf8=")&&("utf8=%E2%9C%93"===g[c]?i="utf-8":"utf8=%26%2310003%3B"===g[c]&&(i="iso-8859-1"),h=c,c=g.length);for(c=0;c<g.length;++c)if(c!==h){var j,k,l=g[c],m=l.indexOf("]="),n=-1===m?l.indexOf("="):m+1;-1===n?(j=b.decoder(l,Xc.decoder,i,"key"),k=b.strictNullHandling?null:""):(j=b.decoder(l.slice(0,n),Xc.decoder,i,"key"),k=Uc.maybeMap(Zc(l.slice(n+1),b),function(a){return b.decoder(a,Xc.decoder,i,"value")})),k&&b.interpretNumericEntities&&"iso-8859-1"===i&&(k=Yc(k)),l.indexOf("[]=")>-1&&(k=Wc(k)?[k]:k),Vc.call(d,j)?d[j]=Uc.combine(d[j],k):d[j]=k}return d}(a,c):a,e=c.plainObjects?Object.create(null):{},f=Object.keys(d),g=0;g<f.length;++g){var h=f[g],i=$c(h,d[h],c,"string"==typeof a);e=Uc.merge(e,i,c)}return Uc.compact(e)},stringify:function(a,b){var c,d=a,e=function(a){if(!a)return Sc;if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");var b=a.charset||Sc.charset;if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var c=Jc["default"];if(void 0!==a.format){if(!Kc.call(Jc.formatters,a.format))throw new TypeError("Unknown format option provided.");c=a.format}var d=Jc.formatters[c],e=Sc.filter;return("function"==typeof a.filter||Mc(a.filter))&&(e=a.filter),{addQueryPrefix:"boolean"==typeof a.addQueryPrefix?a.addQueryPrefix:Sc.addQueryPrefix,allowDots:void 0===a.allowDots?Sc.allowDots:!!a.allowDots,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Sc.charsetSentinel,delimiter:void 0===a.delimiter?Sc.delimiter:a.delimiter,encode:"boolean"==typeof a.encode?a.encode:Sc.encode,encoder:"function"==typeof a.encoder?a.encoder:Sc.encoder,encodeValuesOnly:"boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:Sc.encodeValuesOnly,filter:e,format:c,formatter:d,serializeDate:"function"==typeof a.serializeDate?a.serializeDate:Sc.serializeDate,skipNulls:"boolean"==typeof a.skipNulls?a.skipNulls:Sc.skipNulls,sort:"function"==typeof a.sort?a.sort:null,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Sc.strictNullHandling}}(b);"function"==typeof e.filter?d=(0,e.filter)("",d):Mc(e.filter)&&(c=e.filter);var f,g=[];if("object"!=typeof d||null===d)return"";f=b&&b.arrayFormat in Lc?b.arrayFormat:b&&"indices"in b?b.indices?"indices":"repeat":"indices";var h=Lc[f];c||(c=Object.keys(d)),e.sort&&c.sort(e.sort);for(var i=0;i<c.length;++i){var j=c[i];e.skipNulls&&null===d[j]||Pc(g,Tc(d[j],j,h,e.strictNullHandling,e.skipNulls,e.encode?e.encoder:null,e.filter,e.sort,e.allowDots,e.serializeDate,e.format,e.formatter,e.encodeValuesOnly,e.charset))}var k=g.join(e.delimiter),l=!0===e.addQueryPrefix?"?":"";return e.charsetSentinel&&(l+="iso-8859-1"===e.charset?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),k.length>0?l+k:""}},ad=function(a){return null!==a&&"object"===E(a)},bd=ad,cd=G;G.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},G.prototype.parse=function(a){return this._parser=a,this},G.prototype.responseType=function(a){return this._responseType=a,this},G.prototype.serialize=function(a){return this._serializer=a,this},G.prototype.timeout=function(a){if(!a||"object"!==F(a))return this._timeout=a,this._responseTimeout=0,this._uploadTimeout=0,this;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))switch(b){case"deadline":this._timeout=a.deadline;break;case"response":this._responseTimeout=a.response;break;case"upload":this._uploadTimeout=a.upload;break;default:console.warn("Unknown timeout option",b)}return this},G.prototype.retry=function(a,b){return 0!==arguments.length&&!0!==a||(a=1),a<=0&&(a=0),this._maxRetries=a,this._retries=0,this._retryCallback=b,this};var dd=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),ed=new Set([408,413,429,500,502,503,504,521,522,524]);G.prototype._shouldRetry=function(a,b){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var c=this._retryCallback(a,b);if(!0===c)return!0;if(!1===c)return!1}catch(a){console.error(a)}if(b&&b.status&&ed.has(b.status))return!0;if(a){if(a.code&&dd.has(a.code))return!0;if(a.timeout&&"ECONNABORTED"===a.code)return!0;if(a.crossDomain)return!0}return!1},G.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},G.prototype.then=function(a,b){var c=this;if(!this._fullfilledPromise){var d=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(a,b){d.on("abort",function(){if(!(c._maxRetries&&c._maxRetries>c._retries))if(c.timedout&&c.timedoutError)b(c.timedoutError);else{var a=new Error("Aborted");a.code="ABORTED",a.status=c.status,a.method=c.method,a.url=c.url,b(a)}}),d.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},G.prototype["catch"]=function(a){return this.then(void 0,a)},G.prototype.use=function(a){return a(this),this},G.prototype.ok=function(a){if("function"!=typeof a)throw new Error("Callback required");return this._okCallback=a,this},G.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},G.prototype.get=function(a){return this._header[a.toLowerCase()]},G.prototype.getHeader=G.prototype.get,G.prototype.set=function(a,b){if(bd(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},G.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},G.prototype.field=function(a,b){if(null==a)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(bd(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.field(c,a[c]);return this}if(Array.isArray(b)){for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&this.field(a,b[d]);return this}if(null==b)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof b&&(b=String(b)),this._getFormData().append(a,b),this},G.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},G.prototype._auth=function(a,b,c,d){switch(c.type){case"basic":this.set("Authorization","Basic ".concat(d("".concat(a,":").concat(b))));break;case"auto":this.username=a,this.password=b;break;case"bearer":this.set("Authorization","Bearer ".concat(a))}return this},G.prototype.withCredentials=function(a){return void 0===a&&(a=!0),this._withCredentials=a,this},G.prototype.redirects=function(a){return this._maxRedirects=a,this},G.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw new TypeError("Invalid argument");return this._maxResponseSize=a,this},G.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},G.prototype.send=function(a){var b=bd(a),c=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(b&&!this._data)Array.isArray(a)?this._data=[]:this._isHost(a)||(this._data={});else if(a&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(b&&bd(this._data))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(this._data[d]=a[d]);else"string"==typeof a?(c||this.type("form"),(c=this._header["content-type"])&&(c=c.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===c?this._data?"".concat(this._data,"&").concat(a):a:(this._data||"")+a):this._data=a;return!b||this._isHost(a)||c||this.type("json"),this},G.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},G.prototype._finalizeQueryString=function(){var a=this._query.join("&");if(a&&(this.url+=(this.url.includes("?")?"&":"?")+a),this._query.length=0,this._sort){var b=this.url.indexOf("?");if(b>=0){var c=this.url.slice(b+1).split("&");"function"==typeof this._sort?c.sort(this._sort):c.sort(),this.url=this.url.slice(0,b)+"?"+c.join("&")}}},G.prototype._appendQueryString=function(){console.warn("Unsupported")},G.prototype._timeoutError=function(a,b,c){if(!this._aborted){var d=new Error("".concat(a+b,"ms exceeded"));d.timeout=b,d.code="ECONNABORTED",d.errno=c,this.timedout=!0,this.timedoutError=d,this.abort(),this.callback(d)}},G.prototype._setTimeouts=function(){var a=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){a._timeoutError("Timeout of ",a._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){a._timeoutError("Response timeout of ",a._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var fd={};fd.type=function(a){return a.split(/ *; */).shift()},fd.params=function(a){var b,c={},d=H(a.split(/ *; */));try{
14
+ for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *= */),f=e.shift(),g=e.shift();f&&g&&(c[f]=g)}}catch(a){d.e(a)}finally{d.f()}return c},fd.parseLinks=function(a){var b,c={},d=H(a.split(/ *, */));try{for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *; */),f=e[0].slice(1,-1);c[e[1].split(/ *= */)[1].slice(1,-1)]=f}}catch(a){d.e(a)}finally{d.f()}return c},fd.cleanHeader=function(a,b){return delete a["content-type"],delete a["content-length"],delete a["transfer-encoding"],delete a.host,b&&(delete a.authorization,delete a.cookie),a};var gd=fd,hd=J;J.prototype.get=function(a){return this.header[a.toLowerCase()]},J.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=gd.type(b);var c=gd.params(b);for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(this[d]=c[d]);this.links={};try{a.link&&(this.links=gd.parseLinks(a.link))}catch(a){}},J.prototype._setStatusProperties=function(a){var b=a/100|0;this.statusCode=a,this.status=this.statusCode,this.statusType=b,this.info=1===b,this.ok=2===b,this.redirect=3===b,this.clientError=4===b,this.serverError=5===b,this.error=(4===b||5===b)&&this.toError(),this.created=201===a,this.accepted=202===a,this.noContent=204===a,this.badRequest=400===a,this.unauthorized=401===a,this.notAcceptable=406===a,this.forbidden=403===a,this.notFound=404===a,this.unprocessableEntity=422===a},["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"].forEach(function(a){M.prototype[a]=function(){for(var b=arguments.length,c=new Array(b),d=0;d<b;d++)c[d]=arguments[d];return this._defaults.push({fn:a,args:c}),this}}),M.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,K(b.args))})};var id=M;!function(a,b){function c(a){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function d(){}function e(a){if(!q(a))return a;var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(void 0!==c)if(null!==c)if(Array.isArray(c))c.forEach(function(c){f(a,b,c)});else if(q(c))for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&f(a,"".concat(b,"[").concat(d,"]"),c[d]);else a.push(encodeURI(b)+"="+encodeURIComponent(c));else a.push(encodeURI(b))}function g(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)-1===(c=(b=e[f]).indexOf("="))?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){return/[/+]json($|[^-\w])/i.test(a)}function i(a){this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var b=this.xhr.status;1223===b&&(b=204),this._setStatusProperties(b),this.headers=function(a){for(var b,c,d,e,f=a.split(/\r?\n/),g={},h=0,i=f.length;h<i;++h)-1!==(b=(c=f[h]).indexOf(":"))&&(d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e);return g}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&a._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function j(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a,b=null,d=null;try{d=new i(c)}catch(a){return(b=new Error("Parser is unable to parse the response")).parse=!0,b.original=a,c.xhr?(b.rawResponse=void 0===c.xhr.responseType?c.xhr.responseText:c.xhr.response,b.status=c.xhr.status?c.xhr.status:null,b.statusCode=b.status):(b.rawResponse=null,b.status=null),c.callback(b)}c.emit("response",d);try{c._isResponseOK(d)||(a=new Error(d.statusText||d.text||"Unsuccessful HTTP response"))}catch(b){a=b}a?(a.original=b,a.response=d,a.status=d.status,c.callback(a,d)):c.callback(null,d)})}function k(a,b,c){var d=t("DELETE",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}var l;"undefined"!=typeof window?l=window:"undefined"==typeof self?(console.warn("Using browser-only version of superagent in non-browser environment"),l=void 0):l=self;var m=sc.exports,n=tc,o=_c,p=cd,q=ad,r=hd,s=id;a.exports=function(a,c){return"function"==typeof c?new b.Request("GET",a).end(c):1===arguments.length?new b.Request("GET",a):new b.Request(a,c)};var t=b=a.exports;b.Request=j,t.getXHR=function(){if(l.XMLHttpRequest&&(!l.location||"file:"!==l.location.protocol||!l.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}throw new Error("Browser-only version of superagent could not find XHR")};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};t.serializeObject=e,t.parseString=g,t.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},t.serialize={"application/x-www-form-urlencoded":o.stringify,"application/json":n},t.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},r(i.prototype),i.prototype._parseBody=function(a){var b=t.parse[this.type];return this.req._parser?this.req._parser(this,a):(!b&&h(this.type)&&(b=t.parse["application/json"]),b&&a&&(a.length>0||a instanceof Object)?b(a):null)},i.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot ".concat(b," ").concat(c," (").concat(this.status,")"),e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},t.Response=i,m(j.prototype),p(j.prototype),j.prototype.type=function(a){return this.set("Content-Type",t.types[a]||a),this},j.prototype.accept=function(a){return this.set("Accept",t.types[a]||a),this},j.prototype.auth=function(a,b,d){1===arguments.length&&(b=""),"object"===c(b)&&null!==b&&(d=b,b=""),d||(d={type:"function"==typeof btoa?"basic":"auto"});var e=function(a){if("function"==typeof btoa)return btoa(a);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(a,b,d,e)},j.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},j.prototype.attach=function(a,b,c){if(b){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(a,b,c||b.name)}return this},j.prototype._getFormData=function(){return this._formData||(this._formData=new l.FormData),this._formData},j.prototype.callback=function(a,b){if(this._shouldRetry(a,b))return this._retry();var c=this._callback;this.clearTimeout(),a&&(this._maxRetries&&(a.retries=this._retries-1),this.emit("error",a)),c(a,b)},j.prototype.crossDomainError=function(){var a=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},j.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},j.prototype.ca=j.prototype.agent,j.prototype.buffer=j.prototype.ca,j.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},j.prototype.pipe=j.prototype.write,j.prototype._isHost=function(a){return a&&"object"===c(a)&&!Array.isArray(a)&&"[object Object]"!==Object.prototype.toString.call(a)},j.prototype.end=function(a){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=a||d,this._finalizeQueryString(),this._end()},j.prototype._setUploadTimeout=function(){var a=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){a._timeoutError("Upload timeout of ",a._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},j.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var a=this;this.xhr=t.getXHR();var b=this.xhr,c=this._formData||this._data;this._setTimeouts(),b.onreadystatechange=function(){var a=b.readyState;if(a>=2&&d._responseTimeoutTimer&&clearTimeout(d._responseTimeoutTimer),4===a){var c;try{c=b.status}catch(d){c=0}if(!c){if(d.timedout||d._aborted)return;return d.crossDomainError()}d.emit("end")}};var d=function(b,c){c.total>0&&(c.percent=c.loaded/c.total*100,100===c.percent&&clearTimeout(a._uploadTimeoutTimer)),c.direction=b,a.emit("progress",c)};if(this.hasListeners("progress"))try{b.addEventListener("progress",d.bind(null,"download")),b.upload&&b.upload.addEventListener("progress",d.bind(null,"upload"))}catch(a){}b.upload&&this._setUploadTimeout();try{this.username&&this.password?b.open(this.method,this.url,!0,this.username,this.password):b.open(this.method,this.url,!0)}catch(a){return this.callback(a)}if(this._withCredentials&&(b.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof c&&!this._isHost(c)){var e=this._header["content-type"],f=this._serializer||t.serialize[e?e.split(";")[0]:""];!f&&h(e)&&(f=t.serialize["application/json"]),f&&(c=f(c))}for(var g in this.header)null!==this.header[g]&&Object.prototype.hasOwnProperty.call(this.header,g)&&b.setRequestHeader(g,this.header[g]);this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(void 0===c?null:c)},t.agent=function(){return new s},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(a){s.prototype[a.toLowerCase()]=function(b,c){var d=new t.Request(a,b);return this._setDefaults(d),c&&d.end(c),d}}),s.prototype.del=s.prototype["delete"],t.get=function(a,b,c){var d=t("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.head=function(a,b,c){var d=t("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.options=function(a,b,c){var d=t("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.del=k,t["delete"]=k,t.patch=function(a,b,c){var d=t("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.post=function(a,b,c){var d=t("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.put=function(a,b,c){var d=t("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}}(rc,rc.exports);var jd,kd=rc.exports,ld=function(){function a(){}return Object.defineProperty(a.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),a.prototype.encrypt=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.encryptString(c,b)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}})})},a.prototype.decrypt=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.decryptString(c,b)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}})})},a.prototype.encryptFile=function(a,b,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.encryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,mimeType:"application/octet-stream",data:g})]}})})},a.prototype.decryptFile=function(a,b,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.decryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,data:g})]}})})},a.prototype.getKey=function(a){return c(this,void 0,void 0,function(){var b,c,f;return d(this,function(d){switch(d.label){case 0:return b=e.from(a),[4,crypto.subtle.digest("SHA-256",b.buffer)];case 1:return c=d.sent(),f=e.from(e.from(c).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",f,"AES-CBC",!0,["encrypt","decrypt"])]}})})},a.prototype.encryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c,e,f;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),e=V,f=[c.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,b)];case 1:return[2,e.apply(void 0,f.concat([d.sent()]))]}})})},a.prototype.decryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c;return d(this,function(d){return c=b.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:c},a,b.slice(16))]})})},a.prototype.encryptString=function(a,b){return c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),f=e.from(b).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,f)];case 1:return g=d.sent(),h=V(c.buffer,g),[2,e.from(h).toString("utf8")]}})})},a.prototype.decryptString=function(a,b){return c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=e.from(b),f=c.slice(0,16),g=c.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:f},a,g)];case 1:return h=d.sent(),[2,e.from(h).toString("utf8")]}})})},a.IV_LENGTH=16,a}(),md=(jd=function(){function a(a){if(a instanceof File)this.data=a,this.name=this.data.name,this.mimeType=this.data.type;else if(a.data){var b=a.data;this.data=new File([b],a.name,{type:a.mimeType}),this.name=a.name,a.mimeType&&(this.mimeType=a.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return a.create=function(a){return new this(a)},a.prototype.toBuffer=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toStream=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toFileUri=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in react native environments.")})})},a.prototype.toBlob=function(){return c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a.prototype.toArrayBuffer=function(){return c(this,void 0,void 0,function(){var a=this;return d(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if(d.result instanceof ArrayBuffer)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsArrayBuffer(a.data)})]})})},a.prototype.toString=function(){return c(this,void 0,void 0,function(){var a=this;return d(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if("string"==typeof d.result)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsBinaryString(a.data)})]})})},a.prototype.toFile=function(){return c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a}(),jd.supportsFile="undefined"!=typeof File,jd.supportsBlob="undefined"!=typeof Blob,jd.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,jd.supportsBuffer=!1,jd.supportsStream=!1,jd.supportsString=!0,jd.supportsEncryptFile=!0,jd.supportsFileUri=!1,jd),nd=function(b){function c(a){var c=this,d=a.listenToBrowserNetworkEvents,e=void 0===d||d;return a.sdkFamily="Web",a.networking=new pc({del:U,get:R,post:S,patch:T,sendBeacon:W,getfile:Q,postfile:P}),a.cbor=new qc(function(a){return Y(ba.decode(a))},X),a.PubNubFile=md,a.cryptography=new ld,c=b.call(this,a)||this,e&&(window.addEventListener("offline",function(){c.networkDownDetected()}),window.addEventListener("online",function(){c.networkUpDetected()})),c}return a(c,b),c}(oc);return nd})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b("buffer").Buffer)},{buffer:38}],46:[function(b,c,d){(function(b){!function(b){"use strict";if("function"==typeof bootstrap)bootstrap("promise",b);else if("object"==typeof d&&"object"==typeof c)c.exports=b();else if("function"==typeof a&&a.amd)a(b);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=b}else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var e="undefined"!=typeof window?window:self,f=e.Q;e.Q=b(),e.Q.noConflict=function(){return e.Q=f,this}}}(function(){"use strict";function a(a){return function(){return X.apply(a,arguments)}}function c(a){return a===Object(a)}function d(a){return"[object StopIteration]"===da(a)||a instanceof T}function e(a,b){if(Q&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&a.stack.indexOf(ea)===-1){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var e=c.join("\n"+ea+"\n");a.stack=f(e)}}function f(a){for(var b=a.split("\n"),c=[],d=0;d<b.length;++d){var e=b[d];i(e)||g(e)||!e||c.push(e)}return c.join("\n")}function g(a){return a.indexOf("(module.js:")!==-1||a.indexOf("(node.js:")!==-1}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===S&&d>=U&&d<=ja}function j(){if(Q)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return S=d[0],d[1]}}function k(a,b,c){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(b+" is deprecated, use "+c+" instead.",new Error("").stack),a.apply(a,arguments)}}function l(a){return a instanceof p?a:t(a)?C(a):B(a)}function m(){function a(a){b=a,f.source=a,Z(c,function(b,c){l.nextTick(function(){a.promiseDispatch.apply(a,c)})},void 0),c=void 0,d=void 0}var b,c=[],d=[],e=aa(m.prototype),f=aa(p.prototype);if(f.promiseDispatch=function(a,e,f){var g=Y(arguments);c?(c.push(g),"when"===e&&f[1]&&d.push(f[1])):l.nextTick(function(){b.promiseDispatch.apply(b,g)})},f.valueOf=function(){if(c)return f;var a=r(b);return s(a)&&(b=a),a},f.inspect=function(){return b?b.inspect():{state:"pending"}},l.longStackSupport&&Q)try{throw new Error}catch(g){f.stack=g.stack.substring(g.stack.indexOf("\n")+1)}return e.promise=f,e.resolve=function(c){b||a(l(c))},e.fulfill=function(c){b||a(B(c))},e.reject=function(c){b||a(A(c))},e.notify=function(a){b||Z(d,function(b,c){l.nextTick(function(){c(a)})},void 0)},e}function n(a){if("function"!=typeof a)throw new TypeError("resolver must be a function.");var b=m();try{a(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}return b.promise}function o(a){return n(function(b,c){for(var d=0,e=a.length;d<e;d++)l(a[d]).then(b,c)})}function p(a,b,c){void 0===b&&(b=function(a){return A(new Error("Promise does not support operation: "+a))}),void 0===c&&(c=function(){return{state:"unknown"}});var d=aa(p.prototype);if(d.promiseDispatch=function(c,e,f){var g;try{g=a[e]?a[e].apply(d,f):b.call(d,e,f)}catch(h){g=A(h)}c&&c(g)},d.inspect=c,c){var e=c();"rejected"===e.state&&(d.exception=e.reason),d.valueOf=function(){var a=c();return"pending"===a.state||"rejected"===a.state?d:a.value}}return d}function q(a,b,c,d){return l(a).then(b,c,d)}function r(a){if(s(a)){var b=a.inspect();if("fulfilled"===b.state)return b.value}return a}function s(a){return a instanceof p}function t(a){return c(a)&&"function"==typeof a.then}function u(a){return s(a)&&"pending"===a.inspect().state}function v(a){return!s(a)||"fulfilled"===a.inspect().state}function w(a){return s(a)&&"rejected"===a.inspect().state}function x(){fa.length=0,ga.length=0,ia||(ia=!0)}function y(a,c){ia&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){$(ga,a)!==-1&&(b.emit("unhandledRejection",c,a),ha.push(a))}),ga.push(a),c&&"undefined"!=typeof c.stack?fa.push(c.stack):fa.push("(no stack) "+c))}function z(a){if(ia){var c=$(ga,a);c!==-1&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){var d=$(ha,a);d!==-1&&(b.emit("rejectionHandled",fa[c],a),ha.splice(d,1))}),ga.splice(c,1),fa.splice(c,1))}}function A(a){var b=p({when:function(b){return b&&z(this),b?b(a):this}},function(){return this},function(){return{state:"rejected",reason:a}});return y(b,a),b}function B(a){return p({when:function(){return a},get:function(b){return a[b]},set:function(b,c){a[b]=c},"delete":function(b){delete a[b]},post:function(b,c){return null===b||void 0===b?a.apply(void 0,c):a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},keys:function(){return ca(a)}},void 0,function(){return{state:"fulfilled",value:a}})}function C(a){var b=m();return l.nextTick(function(){try{a.then(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}}),b.promise}function D(a){return p({isDef:function(){}},function(b,c){return J(a,b,c)},function(){return l(a).inspect()})}function E(a,b,c){return l(a).spread(b,c)}function F(a){return function(){function b(a,b){var g;if("undefined"==typeof StopIteration){try{g=c[a](b)}catch(h){return A(h)}return g.done?l(g.value):q(g.value,e,f)}try{g=c[a](b)}catch(h){return d(h)?l(h.value):A(h)}return q(g,e,f)}var c=a.apply(this,arguments),e=b.bind(b,"next"),f=b.bind(b,"throw");return e()}}function G(a){l.done(l.async(a)())}function H(a){throw new T(a)}function I(a){return function(){return E([this,K(arguments)],function(b,c){return a.apply(b,c)})}}function J(a,b,c){return l(a).dispatch(b,c)}function K(a){return q(a,function(a){var b=0,c=m();return Z(a,function(d,e,f){var g;s(e)&&"fulfilled"===(g=e.inspect()).state?a[f]=g.value:(++b,q(e,function(d){a[f]=d,0===--b&&c.resolve(a)},c.reject,function(a){c.notify({index:f,value:a})}))},void 0),0===b&&c.resolve(a),c.promise})}function L(a){if(0===a.length)return l.resolve();var b=l.defer(),c=0;return Z(a,function(d,e,f){function g(a){b.resolve(a)}function h(){c--,0===c&&b.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function i(a){b.notify({index:f,value:a})}var j=a[f];c++,q(j,g,h,i)},void 0),b.promise}function M(a){return q(a,function(a){return a=_(a,l),q(K(_(a,function(a){return q(a,V,V)})),function(){return a})})}function N(a){return l(a).allSettled()}function O(a,b){return l(a).then(void 0,void 0,b)}function P(a,b){return l(a).nodeify(b)}var Q=!1;try{throw new Error}catch(R){Q=!!R.stack}var S,T,U=j(),V=function(){},W=function(){function a(){for(var a,b;d.next;)d=d.next,a=d.task,d.task=void 0,b=d.domain,b&&(d.domain=void 0,b.enter()),c(a,b);for(;i.length;)a=i.pop(),c(a);f=!1}function c(b,c){try{b()}catch(d){if(h)throw c&&c.exit(),setTimeout(a,0),c&&c.enter(),d;setTimeout(function(){throw d},0)}c&&c.exit()}var d={task:void 0,next:null},e=d,f=!1,g=void 0,h=!1,i=[];if(W=function(a){e=e.next={task:a,domain:h&&b.domain,next:null},f||(f=!0,g())},"object"==typeof b&&"[object process]"===b.toString()&&b.nextTick)h=!0,g=function(){b.nextTick(a)};else if("function"==typeof setImmediate)g="undefined"!=typeof window?setImmediate.bind(window,a):function(){setImmediate(a)};else if("undefined"!=typeof MessageChannel){var j=new MessageChannel;j.port1.onmessage=function(){g=k,j.port1.onmessage=a,a()};var k=function(){j.port2.postMessage(0)};g=function(){setTimeout(a,0),k()}}else g=function(){setTimeout(a,0)};return W.runAfter=function(a){i.push(a),f||(f=!0,g())},W}(),X=Function.call,Y=a(Array.prototype.slice),Z=a(Array.prototype.reduce||function(a,b){var c=0,d=this.length;if(1===arguments.length)for(;;){if(c in this){b=this[c++];break}if(++c>=d)throw new TypeError}for(;c<d;c++)c in this&&(b=a(b,this[c],c));return b}),$=a(Array.prototype.indexOf||function(a){for(var b=0;b<this.length;b++)if(this[b]===a)return b;return-1}),_=a(Array.prototype.map||function(a,b){var c=this,d=[];return Z(c,function(e,f,g){d.push(a.call(b,f,g,c))},void 0),d}),aa=Object.create||function(a){function b(){}return b.prototype=a,new b},ba=a(Object.prototype.hasOwnProperty),ca=Object.keys||function(a){var b=[];for(var c in a)ba(a,c)&&b.push(c);return b},da=a(Object.prototype.toString);T="undefined"!=typeof ReturnValue?ReturnValue:function(a){this.value=a};var ea="From previous event:";l.resolve=l,l.nextTick=W,l.longStackSupport=!1,"object"==typeof b&&b&&b.env&&b.env.Q_DEBUG&&(l.longStackSupport=!0),l.defer=m,m.prototype.makeNodeResolver=function(){var a=this;return function(b,c){b?a.reject(b):arguments.length>2?a.resolve(Y(arguments,1)):a.resolve(c)}},l.Promise=n,l.promise=n,n.race=o,n.all=K,n.reject=A,n.resolve=l,l.passByCopy=function(a){return a},p.prototype.passByCopy=function(){return this},l.join=function(a,b){return l(a).join(b)},p.prototype.join=function(a){return l([this,a]).spread(function(a,b){if(a===b)return a;throw new Error("Can't join: not the same: "+a+" "+b)})},l.race=o,p.prototype.race=function(){return this.then(l.race)},l.makePromise=p,p.prototype.toString=function(){return"[object Promise]"},p.prototype.then=function(a,b,c){function d(b){try{return"function"==typeof a?a(b):b}catch(c){return A(c)}}function f(a){if("function"==typeof b){e(a,h);try{return b(a)}catch(c){return A(c)}}return A(a)}function g(a){return"function"==typeof c?c(a):a}var h=this,i=m(),j=!1;return l.nextTick(function(){h.promiseDispatch(function(a){j||(j=!0,i.resolve(d(a)))},"when",[function(a){j||(j=!0,i.resolve(f(a)))}])}),h.promiseDispatch(void 0,"when",[void 0,function(a){var b,c=!1;try{b=g(a)}catch(d){if(c=!0,!l.onerror)throw d;l.onerror(d)}c||i.notify(b)}]),i.promise},l.tap=function(a,b){return l(a).tap(b)},p.prototype.tap=function(a){return a=l(a),this.then(function(b){return a.fcall(b).thenResolve(b)})},l.when=q,p.prototype.thenResolve=function(a){return this.then(function(){return a})},l.thenResolve=function(a,b){return l(a).thenResolve(b)},p.prototype.thenReject=function(a){return this.then(function(){throw a})},l.thenReject=function(a,b){return l(a).thenReject(b)},l.nearer=r,l.isPromise=s,l.isPromiseAlike=t,l.isPending=u,p.prototype.isPending=function(){return"pending"===this.inspect().state},l.isFulfilled=v,p.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},l.isRejected=w,p.prototype.isRejected=function(){return"rejected"===this.inspect().state};var fa=[],ga=[],ha=[],ia=!0;l.resetUnhandledRejections=x,l.getUnhandledReasons=function(){return fa.slice()},l.stopUnhandledRejectionTracking=function(){x(),ia=!1},x(),l.reject=A,l.fulfill=B,l.master=D,l.spread=E,p.prototype.spread=function(a,b){return this.all().then(function(b){return a.apply(void 0,b)},b)},l.async=F,l.spawn=G,l["return"]=H,l.promised=I,l.dispatch=J,p.prototype.dispatch=function(a,b){var c=this,d=m();return l.nextTick(function(){c.promiseDispatch(d.resolve,a,b)}),d.promise},l.get=function(a,b){return l(a).dispatch("get",[b])},p.prototype.get=function(a){return this.dispatch("get",[a])},l.set=function(a,b,c){return l(a).dispatch("set",[b,c])},p.prototype.set=function(a,b){return this.dispatch("set",[a,b])},l.del=l["delete"]=function(a,b){return l(a).dispatch("delete",[b])},p.prototype.del=p.prototype["delete"]=function(a){return this.dispatch("delete",[a])},l.mapply=l.post=function(a,b,c){return l(a).dispatch("post",[b,c])},p.prototype.mapply=p.prototype.post=function(a,b){return this.dispatch("post",[a,b])},l.send=l.mcall=l.invoke=function(a,b){return l(a).dispatch("post",[b,Y(arguments,2)])},p.prototype.send=p.prototype.mcall=p.prototype.invoke=function(a){return this.dispatch("post",[a,Y(arguments,1)])},l.fapply=function(a,b){return l(a).dispatch("apply",[void 0,b])},p.prototype.fapply=function(a){return this.dispatch("apply",[void 0,a])},l["try"]=l.fcall=function(a){return l(a).dispatch("apply",[void 0,Y(arguments,1)])},p.prototype.fcall=function(){return this.dispatch("apply",[void 0,Y(arguments)])},l.fbind=function(a){var b=l(a),c=Y(arguments,1);return function(){return b.dispatch("apply",[this,c.concat(Y(arguments))])}},p.prototype.fbind=function(){var a=this,b=Y(arguments);return function(){return a.dispatch("apply",[this,b.concat(Y(arguments))])}},l.keys=function(a){return l(a).dispatch("keys",[])},p.prototype.keys=function(){return this.dispatch("keys",[])},l.all=K,p.prototype.all=function(){return K(this)},l.any=L,p.prototype.any=function(){return L(this)},l.allResolved=k(M,"allResolved","allSettled"),p.prototype.allResolved=function(){return M(this)},l.allSettled=N,p.prototype.allSettled=function(){return this.then(function(a){return K(_(a,function(a){function b(){return a.inspect()}return a=l(a),a.then(b,b)}))})},l.fail=l["catch"]=function(a,b){return l(a).then(void 0,b)},p.prototype.fail=p.prototype["catch"]=function(a){return this.then(void 0,a)},l.progress=O,p.prototype.progress=function(a){return this.then(void 0,void 0,a)},l.fin=l["finally"]=function(a,b){return l(a)["finally"](b)},p.prototype.fin=p.prototype["finally"]=function(a){return a=l(a),this.then(function(b){return a.fcall().then(function(){return b})},function(b){return a.fcall().then(function(){throw b})})},l.done=function(a,b,c,d){return l(a).done(b,c,d)},p.prototype.done=function(a,c,d){var f=function(a){l.nextTick(function(){if(e(a,g),!l.onerror)throw a;l.onerror(a)})},g=a||c||d?this.then(a,c,d):this;"object"==typeof b&&b&&b.domain&&(f=b.domain.bind(f)),g.then(void 0,f)},l.timeout=function(a,b,c){return l(a).timeout(b,c)},p.prototype.timeout=function(a,b){var c=m(),d=setTimeout(function(){b&&"string"!=typeof b||(b=new Error(b||"Timed out after "+a+" ms"),b.code="ETIMEDOUT"),c.reject(b)},a);return this.then(function(a){clearTimeout(d),c.resolve(a)},function(a){clearTimeout(d),c.reject(a)},c.notify),c.promise},l.delay=function(a,b){return void 0===b&&(b=a,a=void 0),l(a).delay(b)},p.prototype.delay=function(a){return this.then(function(b){var c=m();return setTimeout(function(){c.resolve(b)},a),c.promise})},l.nfapply=function(a,b){return l(a).nfapply(b)},p.prototype.nfapply=function(a){var b=m(),c=Y(a);return c.push(b.makeNodeResolver()),this.fapply(c).fail(b.reject),b.promise},l.nfcall=function(a){var b=Y(arguments,1);return l(a).nfapply(b)},p.prototype.nfcall=function(){var a=Y(arguments),b=m();return a.push(b.makeNodeResolver()),this.fapply(a).fail(b.reject),b.promise},l.nfbind=l.denodeify=function(a){var b=Y(arguments,1);return function(){var c=b.concat(Y(arguments)),d=m();return c.push(d.makeNodeResolver()),l(a).fapply(c).fail(d.reject),d.promise}},p.prototype.nfbind=p.prototype.denodeify=function(){var a=Y(arguments);return a.unshift(this),l.denodeify.apply(void 0,a)},l.nbind=function(a,b){var c=Y(arguments,2);return function(){function d(){return a.apply(b,arguments)}var e=c.concat(Y(arguments)),f=m();return e.push(f.makeNodeResolver()),l(d).fapply(e).fail(f.reject),f.promise}},p.prototype.nbind=function(){var a=Y(arguments,0);return a.unshift(this),l.nbind.apply(void 0,a)},l.nmapply=l.npost=function(a,b,c){return l(a).npost(b,c)},p.prototype.nmapply=p.prototype.npost=function(a,b){var c=Y(b||[]),d=m();return c.push(d.makeNodeResolver()),
15
+ this.dispatch("post",[a,c]).fail(d.reject),d.promise},l.nsend=l.nmcall=l.ninvoke=function(a,b){var c=Y(arguments,2),d=m();return c.push(d.makeNodeResolver()),l(a).dispatch("post",[b,c]).fail(d.reject),d.promise},p.prototype.nsend=p.prototype.nmcall=p.prototype.ninvoke=function(a){var b=Y(arguments,1),c=m();return b.push(c.makeNodeResolver()),this.dispatch("post",[a,b]).fail(c.reject),c.promise},l.nodeify=P,p.prototype.nodeify=function(a){return a?void this.then(function(b){l.nextTick(function(){a(null,b)})},function(b){l.nextTick(function(){a(b)})}):this},l.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ja=j();return l})}).call(this,b("_process"))},{_process:44}],47:[function(a,b,c){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];d<e;)f=b.call(null,f,a[d],++d,a);return f}},{}],48:[function(a,b,c){function d(a){var b;if(2===arguments.length&&"object"==typeof arguments[1])b=arguments[1];else{b=new Array(arguments.length-1);for(var c=1;c<arguments.length;++c)b[c-1]=arguments[c]}return b&&b.hasOwnProperty||(b={}),a.replace(e,function(c,d,e){var f;return"{"===a[e-1]&&"}"===a[e+c.length]?d:(f=b.hasOwnProperty(d)?b[d]:null,null===f||void 0===f?"":f)})}var e=/\{([0-9a-zA-Z_]+)\}/g;b.exports=d},{}],49:[function(a,b,c){function d(){}function e(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function f(a){return a===Object(a)}function g(a){if(!f(a))return a;var b=[];for(var c in a)null!=a[c]&&h(b,c,a[c]);return b.join("&")}function h(a,b,c){return Array.isArray(c)?c.forEach(function(c){h(a,b,c)}):void a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}function i(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function j(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;h<i;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e;return g}function k(a){return/[\/+]json\b/.test(a)}function l(a){return a.split(/ *; */).shift()}function m(a){return t(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function n(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=j(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function o(a,b){var c=this;s.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a=null,b=null;try{b=new n(c)}catch(d){return a=new Error("Parser is unable to parse the response"),a.parse=!0,a.original=d,a.rawResponse=c.xhr&&c.xhr.responseText?c.xhr.responseText:null,c.callback(a)}if(c.emit("response",b),a)return c.callback(a,b);if(b.status>=200&&b.status<300)return c.callback(a,b);var e=new Error(b.statusText||"Unsuccessful HTTP response");e.original=a,e.response=b,e.status=b.status,c.callback(e,b)})}function p(a,b){return"function"==typeof b?new o("GET",a).end(b):1==arguments.length?new o("GET",a):new o(a,b)}function q(a,b){var c=p("DELETE",a);return b&&c.end(b),c}var r,s=a("emitter"),t=a("reduce");r="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,p.getXHR=function(){if(!(!r.XMLHttpRequest||r.location&&"file:"==r.location.protocol&&r.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};p.serializeObject=g,p.parseString=i,p.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},p.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},p.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},n.prototype.get=function(a){return this.header[a.toLowerCase()]},n.prototype.setHeaderProperties=function(a){var b=this.header["content-type"]||"";this.type=l(b);var c=m(b);for(var d in c)this[d]=c[d]},n.prototype.parseBody=function(a){var b=p.parse[this.type];return b&&a&&(a.length||a instanceof Object)?b(a):null},n.prototype.setStatusProperties=function(a){1223===a&&(a=204);var b=a/100|0;this.status=this.statusCode=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=(4==b||5==b)&&this.toError(),this.accepted=202==a,this.noContent=204==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},n.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},p.Response=n,s(o.prototype),o.prototype.use=function(a){return a(this),this},o.prototype.timeout=function(a){return this._timeout=a,this},o.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},o.prototype.abort=function(){if(!this.aborted)return this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this},o.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},o.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},o.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},o.prototype.type=function(a){return this.set("Content-Type",p.types[a]||a),this},o.prototype.parse=function(a){return this._parser=a,this},o.prototype.accept=function(a){return this.set("Accept",p.types[a]||a),this},o.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},o.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},o.prototype.field=function(a,b){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b),this},o.prototype.attach=function(a,b,c){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b,c||b.name),this},o.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==c?this._data=this._data?this._data+"&"+a:a:this._data=(this._data||"")+a):this._data=a;return!b||e(a)?this:(c||this.type("json"),this)},o.prototype.callback=function(a,b){var c=this._callback;this.clearTimeout(),c(a,b)},o.prototype.crossDomainError=function(){var a=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},o.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},o.prototype.withCredentials=function(){return this._withCredentials=!0,this},o.prototype.end=function(a){var b=this,c=this.xhr=p.getXHR(),f=this._query.join("&"),g=this._timeout,h=this._formData||this._data;this._callback=a||d,c.onreadystatechange=function(){if(4==c.readyState){var a;try{a=c.status}catch(d){a=0}if(0==a){if(b.timedout)return b.timeoutError();if(b.aborted)return;return b.crossDomainError()}b.emit("end")}};var i=function(a){a.total>0&&(a.percent=a.loaded/a.total*100),a.direction="download",b.emit("progress",a)};this.hasListeners("progress")&&(c.onprogress=i);try{c.upload&&this.hasListeners("progress")&&(c.upload.onprogress=i)}catch(j){}if(g&&!this._timer&&(this._timer=setTimeout(function(){b.timedout=!0,b.abort()},g)),f&&(f=p.serializeObject(f),this.url+=~this.url.indexOf("?")?"&"+f:"?"+f),c.open(this.method,this.url,!0),this._withCredentials&&(c.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof h&&!e(h)){var l=this.getHeader("Content-Type"),m=this._parser||p.serialize[l?l.split(";")[0]:""];!m&&k(l)&&(m=p.serialize["application/json"]),m&&(h=m(h))}for(var n in this.header)null!=this.header[n]&&c.setRequestHeader(n,this.header[n]);return this.emit("request",this),c.send("undefined"!=typeof h?h:null),this},o.prototype.then=function(a,b){return this.end(function(c,d){c?b(c):a(d)})},p.Request=o,p.get=function(a,b,c){var d=p("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},p.head=function(a,b,c){var d=p("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.del=q,p["delete"]=q,p.patch=function(a,b,c){var d=p("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.post=function(a,b,c){var d=p("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.put=function(a,b,c){var d=p("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=p},{emitter:40,reduce:47}],50:[function(b,c,d){(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};c.cleanAttributes!==!1&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return!!a&&(!(!e.isFunction(a.querySelectorAll)||!e.isFunction(a.querySelector))&&(!(!e.isObject(document)||a!==document)||("object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName)))},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1===0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return!!e.isDefined(a)&&(e.isArray(a)?a.indexOf(b)!==-1:b in a)},forEachKeyInKeypath:function(a,b,c){if(e.isString(b)){var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)}},getDeepObjectValue:function(a,b){if(e.isObject(a))return e.forEachKeyInKeypath(a,b,function(a,b){if(e.isObject(a))return a[b]})},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);return e.isString(d)?("^"===d[0]?d=d.slice(1):b.fullMessages!==!1&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),void c.push(e.extend({},a,{error:d}))):void c.push(a)}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=!!c||{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){if(b=e.extend({},this.options,b),e.isEmpty(a))return b.message||this.message||"can't be blank"},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&k<h&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return a<b},lessThanOrEqualTo:function(a,b){return a<=b}};if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var h="not"+e.capitalize(c),i=b[h]||this[h]||"must be %{type} %{count}";f.push(e.format(i,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):NaN,g=b.latest?this.parse(b.latest,b):NaN;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(f)&&a<f&&(c=this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;if(!e.isEmpty(a))return e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))";f?h="(?:localhost|"+h+")":g+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",g+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+h+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";var i=new RegExp(g,"i");return i.exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof d?d:null,"undefined"!=typeof c?c:null,"undefined"!=typeof a?a:null)},{}]},{},[1])(1)});