/
var
/
www
/
html
/
sugar14
/
include
/
javascript
/
amazon-connect
/
Upload File
HOME
(()=>{var e={228:(e,t,n)=>{var r;!function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){t.exports={version:"2.0",metadata:{apiVersion:"2014-06-30",endpointPrefix:"cognito-identity",jsonVersion:"1.1",protocol:"json",serviceFullName:"Amazon Cognito Identity",serviceId:"Cognito Identity",signatureVersion:"v4",targetPrefix:"AWSCognitoIdentityService",uid:"cognito-identity-2014-06-30"},operations:{CreateIdentityPool:{input:{type:"structure",required:["IdentityPoolName","AllowUnauthenticatedIdentities"],members:{IdentityPoolName:{},AllowUnauthenticatedIdentities:{type:"boolean"},AllowClassicFlow:{type:"boolean"},SupportedLoginProviders:{shape:"S5"},DeveloperProviderName:{},OpenIdConnectProviderARNs:{shape:"S9"},CognitoIdentityProviders:{shape:"Sb"},SamlProviderARNs:{shape:"Sg"},IdentityPoolTags:{shape:"Sh"}}},output:{shape:"Sk"}},DeleteIdentities:{input:{type:"structure",required:["IdentityIdsToDelete"],members:{IdentityIdsToDelete:{type:"list",member:{}}}},output:{type:"structure",members:{UnprocessedIdentityIds:{type:"list",member:{type:"structure",members:{IdentityId:{},ErrorCode:{}}}}}}},DeleteIdentityPool:{input:{type:"structure",required:["IdentityPoolId"],members:{IdentityPoolId:{}}}},DescribeIdentity:{input:{type:"structure",required:["IdentityId"],members:{IdentityId:{}}},output:{shape:"Sv"}},DescribeIdentityPool:{input:{type:"structure",required:["IdentityPoolId"],members:{IdentityPoolId:{}}},output:{shape:"Sk"}},GetCredentialsForIdentity:{input:{type:"structure",required:["IdentityId"],members:{IdentityId:{},Logins:{shape:"S10"},CustomRoleArn:{}}},output:{type:"structure",members:{IdentityId:{},Credentials:{type:"structure",members:{AccessKeyId:{},SecretKey:{},SessionToken:{},Expiration:{type:"timestamp"}}}}}},GetId:{input:{type:"structure",required:["IdentityPoolId"],members:{AccountId:{},IdentityPoolId:{},Logins:{shape:"S10"}}},output:{type:"structure",members:{IdentityId:{}}}},GetIdentityPoolRoles:{input:{type:"structure",required:["IdentityPoolId"],members:{IdentityPoolId:{}}},output:{type:"structure",members:{IdentityPoolId:{},Roles:{shape:"S1c"},RoleMappings:{shape:"S1e"}}}},GetOpenIdToken:{input:{type:"structure",required:["IdentityId"],members:{IdentityId:{},Logins:{shape:"S10"}}},output:{type:"structure",members:{IdentityId:{},Token:{}}}},GetOpenIdTokenForDeveloperIdentity:{input:{type:"structure",required:["IdentityPoolId","Logins"],members:{IdentityPoolId:{},IdentityId:{},Logins:{shape:"S10"},TokenDuration:{type:"long"}}},output:{type:"structure",members:{IdentityId:{},Token:{}}}},ListIdentities:{input:{type:"structure",required:["IdentityPoolId","MaxResults"],members:{IdentityPoolId:{},MaxResults:{type:"integer"},NextToken:{},HideDisabled:{type:"boolean"}}},output:{type:"structure",members:{IdentityPoolId:{},Identities:{type:"list",member:{shape:"Sv"}},NextToken:{}}}},ListIdentityPools:{input:{type:"structure",required:["MaxResults"],members:{MaxResults:{type:"integer"},NextToken:{}}},output:{type:"structure",members:{IdentityPools:{type:"list",member:{type:"structure",members:{IdentityPoolId:{},IdentityPoolName:{}}}},NextToken:{}}}},ListTagsForResource:{input:{type:"structure",required:["ResourceArn"],members:{ResourceArn:{}}},output:{type:"structure",members:{Tags:{shape:"Sh"}}}},LookupDeveloperIdentity:{input:{type:"structure",required:["IdentityPoolId"],members:{IdentityPoolId:{},IdentityId:{},DeveloperUserIdentifier:{},MaxResults:{type:"integer"},NextToken:{}}},output:{type:"structure",members:{IdentityId:{},DeveloperUserIdentifierList:{type:"list",member:{}},NextToken:{}}}},MergeDeveloperIdentities:{input:{type:"structure",required:["SourceUserIdentifier","DestinationUserIdentifier","DeveloperProviderName","IdentityPoolId"],members:{SourceUserIdentifier:{},DestinationUserIdentifier:{},DeveloperProviderName:{},IdentityPoolId:{}}},output:{type:"structure",members:{IdentityId:{}}}},SetIdentityPoolRoles:{input:{type:"structure",required:["IdentityPoolId","Roles"],members:{IdentityPoolId:{},Roles:{shape:"S1c"},RoleMappings:{shape:"S1e"}}}},TagResource:{input:{type:"structure",required:["ResourceArn","Tags"],members:{ResourceArn:{},Tags:{shape:"Sh"}}},output:{type:"structure",members:{}}},UnlinkDeveloperIdentity:{input:{type:"structure",required:["IdentityId","IdentityPoolId","DeveloperProviderName","DeveloperUserIdentifier"],members:{IdentityId:{},IdentityPoolId:{},DeveloperProviderName:{},DeveloperUserIdentifier:{}}}},UnlinkIdentity:{input:{type:"structure",required:["IdentityId","Logins","LoginsToRemove"],members:{IdentityId:{},Logins:{shape:"S10"},LoginsToRemove:{shape:"Sw"}}}},UntagResource:{input:{type:"structure",required:["ResourceArn","TagKeys"],members:{ResourceArn:{},TagKeys:{type:"list",member:{}}}},output:{type:"structure",members:{}}},UpdateIdentityPool:{input:{shape:"Sk"},output:{shape:"Sk"}}},shapes:{S5:{type:"map",key:{},value:{}},S9:{type:"list",member:{}},Sb:{type:"list",member:{type:"structure",members:{ProviderName:{},ClientId:{},ServerSideTokenCheck:{type:"boolean"}}}},Sg:{type:"list",member:{}},Sh:{type:"map",key:{},value:{}},Sk:{type:"structure",required:["IdentityPoolId","IdentityPoolName","AllowUnauthenticatedIdentities"],members:{IdentityPoolId:{},IdentityPoolName:{},AllowUnauthenticatedIdentities:{type:"boolean"},AllowClassicFlow:{type:"boolean"},SupportedLoginProviders:{shape:"S5"},DeveloperProviderName:{},OpenIdConnectProviderARNs:{shape:"S9"},CognitoIdentityProviders:{shape:"Sb"},SamlProviderARNs:{shape:"Sg"},IdentityPoolTags:{shape:"Sh"}}},Sv:{type:"structure",members:{IdentityId:{},Logins:{shape:"Sw"},CreationDate:{type:"timestamp"},LastModifiedDate:{type:"timestamp"}}},Sw:{type:"list",member:{}},S10:{type:"map",key:{},value:{}},S1c:{type:"map",key:{},value:{}},S1e:{type:"map",key:{},value:{type:"structure",required:["Type"],members:{Type:{},AmbiguousRoleResolution:{},RulesConfiguration:{type:"structure",required:["Rules"],members:{Rules:{type:"list",member:{type:"structure",required:["Claim","MatchType","Value","RoleARN"],members:{Claim:{},MatchType:{},Value:{},RoleARN:{}}}}}}}}}}}},{}],2:[function(e,t,n){t.exports={pagination:{}}},{}],3:[function(e,t,n){t.exports={version:"2.0",metadata:{apiVersion:"2018-09-07",endpointPrefix:"participant.connect",jsonVersion:"1.1",protocol:"rest-json",serviceAbbreviation:"Amazon Connect Participant",serviceFullName:"Amazon Connect Participant Service",serviceId:"ConnectParticipant",signatureVersion:"v4",signingName:"execute-api",uid:"connectparticipant-2018-09-07"},operations:{CompleteAttachmentUpload:{http:{requestUri:"/participant/complete-attachment-upload"},input:{type:"structure",required:["AttachmentIds","ClientToken","ConnectionToken"],members:{AttachmentIds:{type:"list",member:{}},ClientToken:{idempotencyToken:!0},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{}}},CreateParticipantConnection:{http:{requestUri:"/participant/connection"},input:{type:"structure",required:["ParticipantToken"],members:{Type:{type:"list",member:{}},ParticipantToken:{location:"header",locationName:"X-Amz-Bearer"},ConnectParticipant:{type:"boolean"}}},output:{type:"structure",members:{Websocket:{type:"structure",members:{Url:{},ConnectionExpiry:{}}},ConnectionCredentials:{type:"structure",members:{ConnectionToken:{},Expiry:{}}}}}},DisconnectParticipant:{http:{requestUri:"/participant/disconnect"},input:{type:"structure",required:["ConnectionToken"],members:{ClientToken:{idempotencyToken:!0},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{}}},GetAttachment:{http:{requestUri:"/participant/attachment"},input:{type:"structure",required:["AttachmentId","ConnectionToken"],members:{AttachmentId:{},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{Url:{},UrlExpiry:{}}}},GetTranscript:{http:{requestUri:"/participant/transcript"},input:{type:"structure",required:["ConnectionToken"],members:{ContactId:{},MaxResults:{type:"integer"},NextToken:{},ScanDirection:{},SortOrder:{},StartPosition:{type:"structure",members:{Id:{},AbsoluteTime:{},MostRecent:{type:"integer"}}},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{InitialContactId:{},Transcript:{type:"list",member:{type:"structure",members:{AbsoluteTime:{},Content:{},ContentType:{},Id:{},Type:{},ParticipantId:{},DisplayName:{},ParticipantRole:{},Attachments:{type:"list",member:{type:"structure",members:{ContentType:{},AttachmentId:{},AttachmentName:{},Status:{}}}},MessageMetadata:{type:"structure",members:{MessageId:{},Receipts:{type:"list",member:{type:"structure",members:{DeliveredTimestamp:{},ReadTimestamp:{},RecipientParticipantId:{}}}}}}}}},NextToken:{}}}},SendEvent:{http:{requestUri:"/participant/event"},input:{type:"structure",required:["ContentType","ConnectionToken"],members:{ContentType:{},Content:{},ClientToken:{idempotencyToken:!0},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{Id:{},AbsoluteTime:{}}}},SendMessage:{http:{requestUri:"/participant/message"},input:{type:"structure",required:["ContentType","Content","ConnectionToken"],members:{ContentType:{},Content:{},ClientToken:{idempotencyToken:!0},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{Id:{},AbsoluteTime:{}}}},StartAttachmentUpload:{http:{requestUri:"/participant/start-attachment-upload"},input:{type:"structure",required:["ContentType","AttachmentSizeInBytes","AttachmentName","ClientToken","ConnectionToken"],members:{ContentType:{},AttachmentSizeInBytes:{type:"long"},AttachmentName:{},ClientToken:{idempotencyToken:!0},ConnectionToken:{location:"header",locationName:"X-Amz-Bearer"}}},output:{type:"structure",members:{AttachmentId:{},UploadMetadata:{type:"structure",members:{Url:{},UrlExpiry:{},HeadersToInclude:{type:"map",key:{},value:{}}}}}}}},shapes:{}}},{}],4:[function(e,t,n){t.exports={pagination:{GetTranscript:{input_token:"NextToken",output_token:"NextToken",limit_key:"MaxResults"}}}},{}],5:[function(e,t,n){t.exports={acm:{name:"ACM",cors:!0},apigateway:{name:"APIGateway",cors:!0},applicationautoscaling:{prefix:"application-autoscaling",name:"ApplicationAutoScaling",cors:!0},appstream:{name:"AppStream"},autoscaling:{name:"AutoScaling",cors:!0},batch:{name:"Batch"},budgets:{name:"Budgets"},clouddirectory:{name:"CloudDirectory",versions:["2016-05-10*"]},cloudformation:{name:"CloudFormation",cors:!0},cloudfront:{name:"CloudFront",versions:["2013-05-12*","2013-11-11*","2014-05-31*","2014-10-21*","2014-11-06*","2015-04-17*","2015-07-27*","2015-09-17*","2016-01-13*","2016-01-28*","2016-08-01*","2016-08-20*","2016-09-07*","2016-09-29*","2016-11-25*","2017-03-25*","2017-10-30*","2018-06-18*","2018-11-05*","2019-03-26*"],cors:!0},cloudhsm:{name:"CloudHSM",cors:!0},cloudsearch:{name:"CloudSearch"},cloudsearchdomain:{name:"CloudSearchDomain"},cloudtrail:{name:"CloudTrail",cors:!0},cloudwatch:{prefix:"monitoring",name:"CloudWatch",cors:!0},cloudwatchevents:{prefix:"events",name:"CloudWatchEvents",versions:["2014-02-03*"],cors:!0},cloudwatchlogs:{prefix:"logs",name:"CloudWatchLogs",cors:!0},codebuild:{name:"CodeBuild",cors:!0},codecommit:{name:"CodeCommit",cors:!0},codedeploy:{name:"CodeDeploy",cors:!0},codepipeline:{name:"CodePipeline",cors:!0},cognitoidentity:{prefix:"cognito-identity",name:"CognitoIdentity",cors:!0},cognitoidentityserviceprovider:{prefix:"cognito-idp",name:"CognitoIdentityServiceProvider",cors:!0},cognitosync:{prefix:"cognito-sync",name:"CognitoSync",cors:!0},configservice:{prefix:"config",name:"ConfigService",cors:!0},cur:{name:"CUR",cors:!0},datapipeline:{name:"DataPipeline"},devicefarm:{name:"DeviceFarm",cors:!0},directconnect:{name:"DirectConnect",cors:!0},directoryservice:{prefix:"ds",name:"DirectoryService"},discovery:{name:"Discovery"},dms:{name:"DMS"},dynamodb:{name:"DynamoDB",cors:!0},dynamodbstreams:{prefix:"streams.dynamodb",name:"DynamoDBStreams",cors:!0},ec2:{name:"EC2",versions:["2013-06-15*","2013-10-15*","2014-02-01*","2014-05-01*","2014-06-15*","2014-09-01*","2014-10-01*","2015-03-01*","2015-04-15*","2015-10-01*","2016-04-01*","2016-09-15*"],cors:!0},ecr:{name:"ECR",cors:!0},ecs:{name:"ECS",cors:!0},efs:{prefix:"elasticfilesystem",name:"EFS",cors:!0},elasticache:{name:"ElastiCache",versions:["2012-11-15*","2014-03-24*","2014-07-15*","2014-09-30*"],cors:!0},elasticbeanstalk:{name:"ElasticBeanstalk",cors:!0},elb:{prefix:"elasticloadbalancing",name:"ELB",cors:!0},elbv2:{prefix:"elasticloadbalancingv2",name:"ELBv2",cors:!0},emr:{prefix:"elasticmapreduce",name:"EMR",cors:!0},es:{name:"ES"},elastictranscoder:{name:"ElasticTranscoder",cors:!0},firehose:{name:"Firehose",cors:!0},gamelift:{name:"GameLift",cors:!0},glacier:{name:"Glacier"},health:{name:"Health"},iam:{name:"IAM",cors:!0},importexport:{name:"ImportExport"},inspector:{name:"Inspector",versions:["2015-08-18*"],cors:!0},iot:{name:"Iot",cors:!0},iotdata:{prefix:"iot-data",name:"IotData",cors:!0},kinesis:{name:"Kinesis",cors:!0},kinesisanalytics:{name:"KinesisAnalytics"},kms:{name:"KMS",cors:!0},lambda:{name:"Lambda",cors:!0},lexruntime:{prefix:"runtime.lex",name:"LexRuntime",cors:!0},lightsail:{name:"Lightsail"},machinelearning:{name:"MachineLearning",cors:!0},marketplacecommerceanalytics:{name:"MarketplaceCommerceAnalytics",cors:!0},marketplacemetering:{prefix:"meteringmarketplace",name:"MarketplaceMetering"},mturk:{prefix:"mturk-requester",name:"MTurk",cors:!0},mobileanalytics:{name:"MobileAnalytics",cors:!0},opsworks:{name:"OpsWorks",cors:!0},opsworkscm:{name:"OpsWorksCM"},organizations:{name:"Organizations"},pinpoint:{name:"Pinpoint"},polly:{name:"Polly",cors:!0},rds:{name:"RDS",versions:["2014-09-01*"],cors:!0},redshift:{name:"Redshift",cors:!0},rekognition:{name:"Rekognition",cors:!0},resourcegroupstaggingapi:{name:"ResourceGroupsTaggingAPI"},route53:{name:"Route53",cors:!0},route53domains:{name:"Route53Domains",cors:!0},s3:{name:"S3",dualstackAvailable:!0,cors:!0},s3control:{name:"S3Control",dualstackAvailable:!0,xmlNoDefaultLists:!0},servicecatalog:{name:"ServiceCatalog",cors:!0},ses:{prefix:"email",name:"SES",cors:!0},shield:{name:"Shield"},simpledb:{prefix:"sdb",name:"SimpleDB"},sms:{name:"SMS"},snowball:{name:"Snowball"},sns:{name:"SNS",cors:!0},sqs:{name:"SQS",cors:!0},ssm:{name:"SSM",cors:!0},storagegateway:{name:"StorageGateway",cors:!0},stepfunctions:{prefix:"states",name:"StepFunctions"},sts:{name:"STS",cors:!0},support:{name:"Support"},swf:{name:"SWF"},xray:{name:"XRay",cors:!0},waf:{name:"WAF",cors:!0},wafregional:{prefix:"waf-regional",name:"WAFRegional"},workdocs:{name:"WorkDocs",cors:!0},workspaces:{name:"WorkSpaces"},codestar:{name:"CodeStar"},lexmodelbuildingservice:{prefix:"lex-models",name:"LexModelBuildingService",cors:!0},marketplaceentitlementservice:{prefix:"entitlement.marketplace",name:"MarketplaceEntitlementService"},athena:{name:"Athena"},greengrass:{name:"Greengrass"},dax:{name:"DAX"},migrationhub:{prefix:"AWSMigrationHub",name:"MigrationHub"},cloudhsmv2:{name:"CloudHSMV2"},glue:{name:"Glue"},mobile:{name:"Mobile"},pricing:{name:"Pricing",cors:!0},costexplorer:{prefix:"ce",name:"CostExplorer",cors:!0},mediaconvert:{name:"MediaConvert"},medialive:{name:"MediaLive"},mediapackage:{name:"MediaPackage"},mediastore:{name:"MediaStore"},mediastoredata:{prefix:"mediastore-data",name:"MediaStoreData",cors:!0},appsync:{name:"AppSync"},guardduty:{name:"GuardDuty"},mq:{name:"MQ"},comprehend:{name:"Comprehend",cors:!0},iotjobsdataplane:{prefix:"iot-jobs-data",name:"IoTJobsDataPlane"},kinesisvideoarchivedmedia:{prefix:"kinesis-video-archived-media",name:"KinesisVideoArchivedMedia",cors:!0},kinesisvideomedia:{prefix:"kinesis-video-media",name:"KinesisVideoMedia",cors:!0},kinesisvideo:{name:"KinesisVideo",cors:!0},sagemakerruntime:{prefix:"runtime.sagemaker",name:"SageMakerRuntime"},sagemaker:{name:"SageMaker"},translate:{name:"Translate",cors:!0},resourcegroups:{prefix:"resource-groups",name:"ResourceGroups",cors:!0},alexaforbusiness:{name:"AlexaForBusiness"},cloud9:{name:"Cloud9"},serverlessapplicationrepository:{prefix:"serverlessrepo",name:"ServerlessApplicationRepository"},servicediscovery:{name:"ServiceDiscovery"},workmail:{name:"WorkMail"},autoscalingplans:{prefix:"autoscaling-plans",name:"AutoScalingPlans"},transcribeservice:{prefix:"transcribe",name:"TranscribeService"},connect:{name:"Connect",cors:!0},acmpca:{prefix:"acm-pca",name:"ACMPCA"},fms:{name:"FMS"},secretsmanager:{name:"SecretsManager",cors:!0},iotanalytics:{name:"IoTAnalytics",cors:!0},iot1clickdevicesservice:{prefix:"iot1click-devices",name:"IoT1ClickDevicesService"},iot1clickprojects:{prefix:"iot1click-projects",name:"IoT1ClickProjects"},pi:{name:"PI"},neptune:{name:"Neptune"},mediatailor:{name:"MediaTailor"},eks:{name:"EKS"},macie:{name:"Macie"},dlm:{name:"DLM"},signer:{name:"Signer"},chime:{name:"Chime"},pinpointemail:{prefix:"pinpoint-email",name:"PinpointEmail"},ram:{name:"RAM"},route53resolver:{name:"Route53Resolver"},pinpointsmsvoice:{prefix:"sms-voice",name:"PinpointSMSVoice"},quicksight:{name:"QuickSight"},rdsdataservice:{prefix:"rds-data",name:"RDSDataService"},amplify:{name:"Amplify"},datasync:{name:"DataSync"},robomaker:{name:"RoboMaker"},transfer:{name:"Transfer"},globalaccelerator:{name:"GlobalAccelerator"},comprehendmedical:{name:"ComprehendMedical",cors:!0},kinesisanalyticsv2:{name:"KinesisAnalyticsV2"},mediaconnect:{name:"MediaConnect"},fsx:{name:"FSx"},securityhub:{name:"SecurityHub"},appmesh:{name:"AppMesh",versions:["2018-10-01*"]},licensemanager:{prefix:"license-manager",name:"LicenseManager"},kafka:{name:"Kafka"},apigatewaymanagementapi:{name:"ApiGatewayManagementApi"},apigatewayv2:{name:"ApiGatewayV2"},docdb:{name:"DocDB"},backup:{name:"Backup"},worklink:{name:"WorkLink"},textract:{name:"Textract"},managedblockchain:{name:"ManagedBlockchain"},mediapackagevod:{prefix:"mediapackage-vod",name:"MediaPackageVod"},groundstation:{name:"GroundStation"},iotthingsgraph:{name:"IoTThingsGraph"},iotevents:{name:"IoTEvents"},ioteventsdata:{prefix:"iotevents-data",name:"IoTEventsData"},personalize:{name:"Personalize",cors:!0},personalizeevents:{prefix:"personalize-events",name:"PersonalizeEvents",cors:!0},personalizeruntime:{prefix:"personalize-runtime",name:"PersonalizeRuntime",cors:!0},applicationinsights:{prefix:"application-insights",name:"ApplicationInsights"},servicequotas:{prefix:"service-quotas",name:"ServiceQuotas"},ec2instanceconnect:{prefix:"ec2-instance-connect",name:"EC2InstanceConnect"},eventbridge:{name:"EventBridge"},lakeformation:{name:"LakeFormation"},forecastservice:{prefix:"forecast",name:"ForecastService",cors:!0},forecastqueryservice:{prefix:"forecastquery",name:"ForecastQueryService",cors:!0},qldb:{name:"QLDB"},qldbsession:{prefix:"qldb-session",name:"QLDBSession"},workmailmessageflow:{name:"WorkMailMessageFlow"},codestarnotifications:{prefix:"codestar-notifications",name:"CodeStarNotifications"},savingsplans:{name:"SavingsPlans"},sso:{name:"SSO"},ssooidc:{prefix:"sso-oidc",name:"SSOOIDC"},marketplacecatalog:{prefix:"marketplace-catalog",name:"MarketplaceCatalog"},dataexchange:{name:"DataExchange"},sesv2:{name:"SESV2"},migrationhubconfig:{prefix:"migrationhub-config",name:"MigrationHubConfig"},connectparticipant:{name:"ConnectParticipant"},appconfig:{name:"AppConfig"},iotsecuretunneling:{name:"IoTSecureTunneling"},wafv2:{name:"WAFV2"},elasticinference:{prefix:"elastic-inference",name:"ElasticInference"},imagebuilder:{name:"Imagebuilder"},schemas:{name:"Schemas"},accessanalyzer:{name:"AccessAnalyzer"},codegurureviewer:{prefix:"codeguru-reviewer",name:"CodeGuruReviewer"},codeguruprofiler:{name:"CodeGuruProfiler"},computeoptimizer:{prefix:"compute-optimizer",name:"ComputeOptimizer"},frauddetector:{name:"FraudDetector"},kendra:{name:"Kendra"},networkmanager:{name:"NetworkManager"},outposts:{name:"Outposts"},augmentedairuntime:{prefix:"sagemaker-a2i-runtime",name:"AugmentedAIRuntime"},ebs:{name:"EBS"},kinesisvideosignalingchannels:{prefix:"kinesis-video-signaling",name:"KinesisVideoSignalingChannels",cors:!0},detective:{name:"Detective"},codestarconnections:{prefix:"codestar-connections",name:"CodeStarconnections"},synthetics:{name:"Synthetics"},iotsitewise:{name:"IoTSiteWise"},macie2:{name:"Macie2"},codeartifact:{name:"CodeArtifact"},honeycode:{name:"Honeycode"},ivs:{name:"IVS"},braket:{name:"Braket"},identitystore:{name:"IdentityStore"},appflow:{name:"Appflow"},redshiftdata:{prefix:"redshift-data",name:"RedshiftData"},ssoadmin:{prefix:"sso-admin",name:"SSOAdmin"},timestreamquery:{prefix:"timestream-query",name:"TimestreamQuery"},timestreamwrite:{prefix:"timestream-write",name:"TimestreamWrite"},s3outposts:{name:"S3Outposts"}}},{}],6:[function(e,t,n){t.exports={version:"2.0",metadata:{apiVersion:"2011-06-15",endpointPrefix:"sts",globalEndpoint:"sts.amazonaws.com",protocol:"query",serviceAbbreviation:"AWS STS",serviceFullName:"AWS Security Token Service",serviceId:"STS",signatureVersion:"v4",uid:"sts-2011-06-15",xmlNamespace:"https://sts.amazonaws.com/doc/2011-06-15/"},operations:{AssumeRole:{input:{type:"structure",required:["RoleArn","RoleSessionName"],members:{RoleArn:{},RoleSessionName:{},PolicyArns:{shape:"S4"},Policy:{},DurationSeconds:{type:"integer"},Tags:{shape:"S8"},TransitiveTagKeys:{type:"list",member:{}},ExternalId:{},SerialNumber:{},TokenCode:{}}},output:{resultWrapper:"AssumeRoleResult",type:"structure",members:{Credentials:{shape:"Sh"},AssumedRoleUser:{shape:"Sm"},PackedPolicySize:{type:"integer"}}}},AssumeRoleWithSAML:{input:{type:"structure",required:["RoleArn","PrincipalArn","SAMLAssertion"],members:{RoleArn:{},PrincipalArn:{},SAMLAssertion:{},PolicyArns:{shape:"S4"},Policy:{},DurationSeconds:{type:"integer"}}},output:{resultWrapper:"AssumeRoleWithSAMLResult",type:"structure",members:{Credentials:{shape:"Sh"},AssumedRoleUser:{shape:"Sm"},PackedPolicySize:{type:"integer"},Subject:{},SubjectType:{},Issuer:{},Audience:{},NameQualifier:{}}}},AssumeRoleWithWebIdentity:{input:{type:"structure",required:["RoleArn","RoleSessionName","WebIdentityToken"],members:{RoleArn:{},RoleSessionName:{},WebIdentityToken:{},ProviderId:{},PolicyArns:{shape:"S4"},Policy:{},DurationSeconds:{type:"integer"}}},output:{resultWrapper:"AssumeRoleWithWebIdentityResult",type:"structure",members:{Credentials:{shape:"Sh"},SubjectFromWebIdentityToken:{},AssumedRoleUser:{shape:"Sm"},PackedPolicySize:{type:"integer"},Provider:{},Audience:{}}}},DecodeAuthorizationMessage:{input:{type:"structure",required:["EncodedMessage"],members:{EncodedMessage:{}}},output:{resultWrapper:"DecodeAuthorizationMessageResult",type:"structure",members:{DecodedMessage:{}}}},GetAccessKeyInfo:{input:{type:"structure",required:["AccessKeyId"],members:{AccessKeyId:{}}},output:{resultWrapper:"GetAccessKeyInfoResult",type:"structure",members:{Account:{}}}},GetCallerIdentity:{input:{type:"structure",members:{}},output:{resultWrapper:"GetCallerIdentityResult",type:"structure",members:{UserId:{},Account:{},Arn:{}}}},GetFederationToken:{input:{type:"structure",required:["Name"],members:{Name:{},Policy:{},PolicyArns:{shape:"S4"},DurationSeconds:{type:"integer"},Tags:{shape:"S8"}}},output:{resultWrapper:"GetFederationTokenResult",type:"structure",members:{Credentials:{shape:"Sh"},FederatedUser:{type:"structure",required:["FederatedUserId","Arn"],members:{FederatedUserId:{},Arn:{}}},PackedPolicySize:{type:"integer"}}}},GetSessionToken:{input:{type:"structure",members:{DurationSeconds:{type:"integer"},SerialNumber:{},TokenCode:{}}},output:{resultWrapper:"GetSessionTokenResult",type:"structure",members:{Credentials:{shape:"Sh"}}}}},shapes:{S4:{type:"list",member:{type:"structure",members:{arn:{}}}},S8:{type:"list",member:{type:"structure",required:["Key","Value"],members:{Key:{},Value:{}}}},Sh:{type:"structure",required:["AccessKeyId","SecretAccessKey","SessionToken","Expiration"],members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}},Sm:{type:"structure",required:["AssumedRoleId","Arn"],members:{AssumedRoleId:{},Arn:{}}}}}},{}],7:[function(e,t,n){arguments[4][2][0].apply(n,arguments)},{dup:2}],8:[function(e,t,n){e("../lib/node_loader");var r=e("../lib/core"),i=r.Service,o=r.apiLoader;o.services.cognitoidentity={},r.CognitoIdentity=i.defineService("cognitoidentity",["2014-06-30"]),e("../lib/services/cognitoidentity"),Object.defineProperty(o.services.cognitoidentity,"2014-06-30",{get:function(){var t=e("../apis/cognito-identity-2014-06-30.min.json");return t.paginators=e("../apis/cognito-identity-2014-06-30.paginators.json").pagination,t},enumerable:!0,configurable:!0}),t.exports=r.CognitoIdentity},{"../apis/cognito-identity-2014-06-30.min.json":1,"../apis/cognito-identity-2014-06-30.paginators.json":2,"../lib/core":20,"../lib/node_loader":17,"../lib/services/cognitoidentity":62}],9:[function(e,t,n){e("../lib/node_loader");var r=e("../lib/core"),i=r.Service,o=r.apiLoader;o.services.sts={},r.STS=i.defineService("sts",["2011-06-15"]),e("../lib/services/sts"),Object.defineProperty(o.services.sts,"2011-06-15",{get:function(){var t=e("../apis/sts-2011-06-15.min.json");return t.paginators=e("../apis/sts-2011-06-15.paginators.json").pagination,t},enumerable:!0,configurable:!0}),t.exports=r.STS},{"../apis/sts-2011-06-15.min.json":6,"../apis/sts-2011-06-15.paginators.json":7,"../lib/core":20,"../lib/node_loader":17,"../lib/services/sts":63}],10:[function(e,t,n){function r(e,t){if(!r.services.hasOwnProperty(e))throw new Error("InvalidService: Failed to load api for "+e);return r.services[e][t]}r.services={},t.exports=r},{}],11:[function(e,t,n){var r=e("./browserHmac"),i=e("./browserMd5"),o=e("./browserSha1"),s=e("./browserSha256");t.exports={createHash:function(e){if("md5"===(e=e.toLowerCase()))return new i;if("sha256"===e)return new s;if("sha1"===e)return new o;throw new Error("Hash algorithm "+e+" is not supported in the browser SDK")},createHmac:function(e,t){if("md5"===(e=e.toLowerCase()))return new r(i,t);if("sha256"===e)return new r(s,t);if("sha1"===e)return new r(o,t);throw new Error("HMAC algorithm "+e+" is not supported in the browser SDK")},createSign:function(){throw new Error("createSign is not implemented in the browser")}}},{"./browserHmac":13,"./browserMd5":14,"./browserSha1":15,"./browserSha256":16}],12:[function(e,t,n){var r=e("buffer/").Buffer;"undefined"!=typeof ArrayBuffer&&void 0===ArrayBuffer.isView&&(ArrayBuffer.isView=function(e){return i.indexOf(Object.prototype.toString.call(e))>-1});var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object DataView]"];t.exports={isEmptyData:function(e){return"string"==typeof e?0===e.length:0===e.byteLength},convertToBuffer:function(e){return"string"==typeof e&&(e=new r(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":82}],13:[function(e,t,n){function r(e,t){this.hash=new e,this.outer=new e;var n=i(e,t),r=new Uint8Array(e.BLOCK_SIZE);r.set(n);for(var o=0;o<e.BLOCK_SIZE;o++)n[o]^=54,r[o]^=92;for(this.hash.update(n),this.outer.update(r),o=0;o<n.byteLength;o++)n[o]=0}function i(e,t){var n=o.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var r=new e;r.update(n),n=r.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}var o=e("./browserHashUtils");t.exports=r,r.prototype.update=function(e){if(o.isEmptyData(e)||this.error)return this;try{this.hash.update(o.convertToBuffer(e))}catch(e){this.error=e}return this},r.prototype.digest=function(e){return this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest(e)}},{"./browserHashUtils":12}],14:[function(e,t,n){function r(){this.state=[1732584193,4023233417,2562383102,271733878],this.buffer=new DataView(new ArrayBuffer(p)),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}function i(e,t,n,r,i,o){return((t=(t+e&4294967295)+(r+o&4294967295)&4294967295)<<i|t>>>32-i)+n&4294967295}function o(e,t,n,r,o,s,a){return i(t&n|~t&r,e,t,o,s,a)}function s(e,t,n,r,o,s,a){return i(t&r|n&~r,e,t,o,s,a)}function a(e,t,n,r,o,s,a){return i(t^n^r,e,t,o,s,a)}function c(e,t,n,r,o,s,a){return i(n^(t|~r),e,t,o,s,a)}var u=e("./browserHashUtils"),l=e("buffer/").Buffer,p=64;t.exports=r,r.BLOCK_SIZE=p,r.prototype.update=function(e){if(u.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=u.convertToBuffer(e),n=0,r=t.byteLength;for(this.bytesHashed+=r;r>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),r--,this.bufferLength===p&&(this.hashBuffer(),this.bufferLength=0);return this},r.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,r=t.bufferLength,i=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),r%p>=p-8){for(var o=this.bufferLength;o<p;o++)n.setUint8(o,0);this.hashBuffer(),this.bufferLength=0}for(o=this.bufferLength;o<p-8;o++)n.setUint8(o,0);n.setUint32(p-8,i>>>0,!0),n.setUint32(p-4,Math.floor(i/4294967296),!0),this.hashBuffer(),this.finished=!0}var s=new DataView(new ArrayBuffer(16));for(o=0;o<4;o++)s.setUint32(4*o,this.state[o],!0);var a=new l(s.buffer,s.byteOffset,s.byteLength);return e?a.toString(e):a},r.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],r=t[1],i=t[2],u=t[3];n=o(n,r,i,u,e.getUint32(0,!0),7,3614090360),u=o(u,n,r,i,e.getUint32(4,!0),12,3905402710),i=o(i,u,n,r,e.getUint32(8,!0),17,606105819),r=o(r,i,u,n,e.getUint32(12,!0),22,3250441966),n=o(n,r,i,u,e.getUint32(16,!0),7,4118548399),u=o(u,n,r,i,e.getUint32(20,!0),12,1200080426),i=o(i,u,n,r,e.getUint32(24,!0),17,2821735955),r=o(r,i,u,n,e.getUint32(28,!0),22,4249261313),n=o(n,r,i,u,e.getUint32(32,!0),7,1770035416),u=o(u,n,r,i,e.getUint32(36,!0),12,2336552879),i=o(i,u,n,r,e.getUint32(40,!0),17,4294925233),r=o(r,i,u,n,e.getUint32(44,!0),22,2304563134),n=o(n,r,i,u,e.getUint32(48,!0),7,1804603682),u=o(u,n,r,i,e.getUint32(52,!0),12,4254626195),i=o(i,u,n,r,e.getUint32(56,!0),17,2792965006),n=s(n,r=o(r,i,u,n,e.getUint32(60,!0),22,1236535329),i,u,e.getUint32(4,!0),5,4129170786),u=s(u,n,r,i,e.getUint32(24,!0),9,3225465664),i=s(i,u,n,r,e.getUint32(44,!0),14,643717713),r=s(r,i,u,n,e.getUint32(0,!0),20,3921069994),n=s(n,r,i,u,e.getUint32(20,!0),5,3593408605),u=s(u,n,r,i,e.getUint32(40,!0),9,38016083),i=s(i,u,n,r,e.getUint32(60,!0),14,3634488961),r=s(r,i,u,n,e.getUint32(16,!0),20,3889429448),n=s(n,r,i,u,e.getUint32(36,!0),5,568446438),u=s(u,n,r,i,e.getUint32(56,!0),9,3275163606),i=s(i,u,n,r,e.getUint32(12,!0),14,4107603335),r=s(r,i,u,n,e.getUint32(32,!0),20,1163531501),n=s(n,r,i,u,e.getUint32(52,!0),5,2850285829),u=s(u,n,r,i,e.getUint32(8,!0),9,4243563512),i=s(i,u,n,r,e.getUint32(28,!0),14,1735328473),n=a(n,r=s(r,i,u,n,e.getUint32(48,!0),20,2368359562),i,u,e.getUint32(20,!0),4,4294588738),u=a(u,n,r,i,e.getUint32(32,!0),11,2272392833),i=a(i,u,n,r,e.getUint32(44,!0),16,1839030562),r=a(r,i,u,n,e.getUint32(56,!0),23,4259657740),n=a(n,r,i,u,e.getUint32(4,!0),4,2763975236),u=a(u,n,r,i,e.getUint32(16,!0),11,1272893353),i=a(i,u,n,r,e.getUint32(28,!0),16,4139469664),r=a(r,i,u,n,e.getUint32(40,!0),23,3200236656),n=a(n,r,i,u,e.getUint32(52,!0),4,681279174),u=a(u,n,r,i,e.getUint32(0,!0),11,3936430074),i=a(i,u,n,r,e.getUint32(12,!0),16,3572445317),r=a(r,i,u,n,e.getUint32(24,!0),23,76029189),n=a(n,r,i,u,e.getUint32(36,!0),4,3654602809),u=a(u,n,r,i,e.getUint32(48,!0),11,3873151461),i=a(i,u,n,r,e.getUint32(60,!0),16,530742520),n=c(n,r=a(r,i,u,n,e.getUint32(8,!0),23,3299628645),i,u,e.getUint32(0,!0),6,4096336452),u=c(u,n,r,i,e.getUint32(28,!0),10,1126891415),i=c(i,u,n,r,e.getUint32(56,!0),15,2878612391),r=c(r,i,u,n,e.getUint32(20,!0),21,4237533241),n=c(n,r,i,u,e.getUint32(48,!0),6,1700485571),u=c(u,n,r,i,e.getUint32(12,!0),10,2399980690),i=c(i,u,n,r,e.getUint32(40,!0),15,4293915773),r=c(r,i,u,n,e.getUint32(4,!0),21,2240044497),n=c(n,r,i,u,e.getUint32(32,!0),6,1873313359),u=c(u,n,r,i,e.getUint32(60,!0),10,4264355552),i=c(i,u,n,r,e.getUint32(24,!0),15,2734768916),r=c(r,i,u,n,e.getUint32(52,!0),21,1309151649),n=c(n,r,i,u,e.getUint32(16,!0),6,4149444226),u=c(u,n,r,i,e.getUint32(44,!0),10,3174756917),i=c(i,u,n,r,e.getUint32(8,!0),15,718787259),r=c(r,i,u,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=r+t[1]&4294967295,t[2]=i+t[2]&4294967295,t[3]=u+t[3]&4294967295}},{"./browserHashUtils":12,"buffer/":82}],15:[function(e,t,n){function r(){this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=new Uint32Array(80),this.offset=0,this.shift=24,this.totalLength=0}var i=e("buffer/").Buffer,o=e("./browserHashUtils");new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53),t.exports=r,r.BLOCK_SIZE=64,r.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n<t;n++)this.write(e[n]);return this},r.prototype.write=function(e){this.block[this.offset]|=(255&e)<<this.shift,this.shift?this.shift-=8:(this.offset++,this.shift=24),16===this.offset&&this.processBlock()},r.prototype.digest=function(e){this.write(128),(this.offset>14||14===this.offset&&this.shift<24)&&this.processBlock(),this.offset=14,this.shift=24,this.write(0),this.write(0),this.write(this.totalLength>0xffffffffff?this.totalLength/1099511627776:0),this.write(this.totalLength>4294967295?this.totalLength/4294967296:0);for(var t=24;t>=0;t-=8)this.write(this.totalLength>>t);var n=new i(20),r=new DataView(n.buffer);return r.setUint32(0,this.h0,!1),r.setUint32(4,this.h1,!1),r.setUint32(8,this.h2,!1),r.setUint32(12,this.h3,!1),r.setUint32(16,this.h4,!1),e?n.toString(e):n},r.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}var n,r,i=this.h0,o=this.h1,s=this.h2,a=this.h3,c=this.h4;for(e=0;e<80;e++){e<20?(n=a^o&(s^a),r=1518500249):e<40?(n=o^s^a,r=1859775393):e<60?(n=o&s|a&(o|s),r=2400959708):(n=o^s^a,r=3395469782);var u=(i<<5|i>>>27)+n+c+r+(0|this.block[e]);c=a,a=s,s=o<<30|o>>>2,o=i,i=u}for(this.h0=this.h0+i|0,this.h1=this.h1+o|0,this.h2=this.h2+s|0,this.h3=this.h3+a|0,this.h4=this.h4+c|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":12,"buffer/":82}],16:[function(e,t,n){function r(){this.state=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}var i=e("buffer/").Buffer,o=e("./browserHashUtils"),s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=Math.pow(2,53)-1;t.exports=r,r.BLOCK_SIZE=64,r.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>a)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,64===this.bufferLength&&(this.hashBuffer(),this.bufferLength=0);return this},r.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(n.setUint8(this.bufferLength++,128),r%64>=56){for(var o=this.bufferLength;o<64;o++)n.setUint8(o,0);this.hashBuffer(),this.bufferLength=0}for(o=this.bufferLength;o<56;o++)n.setUint8(o,0);n.setUint32(56,Math.floor(t/4294967296),!0),n.setUint32(60,t),this.hashBuffer(),this.finished=!0}var s=new i(32);for(o=0;o<8;o++)s[4*o]=this.state[o]>>>24&255,s[4*o+1]=this.state[o]>>>16&255,s[4*o+2]=this.state[o]>>>8&255,s[4*o+3]=this.state[o]>>>0&255;return e?s.toString(e):s},r.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],l=t[7],p=0;p<64;p++){if(p<16)this.temp[p]=(255&e[4*p])<<24|(255&e[4*p+1])<<16|(255&e[4*p+2])<<8|255&e[4*p+3];else{var d=this.temp[p-2],h=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,f=((d=this.temp[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;this.temp[p]=(h+this.temp[p-7]|0)+(f+this.temp[p-16]|0)}var m=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&c^~a&u)|0)+(l+(s[p]+this.temp[p]|0)|0)|0,g=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&r^n&i^r&i)|0;l=u,u=c,c=a,a=o+m|0,o=i,i=r,r=n,n=m+g|0}t[0]+=n,t[1]+=r,t[2]+=i,t[3]+=o,t[4]+=a,t[5]+=c,t[6]+=u,t[7]+=l}},{"./browserHashUtils":12,"buffer/":82}],17:[function(e,t,n){(function(n){(function(){var n=e("./util");n.crypto.lib=e("./browserCryptoLib"),n.Buffer=e("buffer/").Buffer,n.url=e("url/"),n.querystring=e("querystring/"),n.realClock=e("./realclock/browserClock"),n.environment="js",n.createEventStream=e("./event-stream/buffered-create-event-stream").createEventStream,n.isBrowser=function(){return!0},n.isNode=function(){return!1};var r=e("./core");if(t.exports=r,e("./credentials"),e("./credentials/credential_provider_chain"),e("./credentials/temporary_credentials"),e("./credentials/chainable_temporary_credentials"),e("./credentials/web_identity_credentials"),e("./credentials/cognito_identity_credentials"),e("./credentials/saml_credentials"),r.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),void 0===i)var i={browser:!0}}).call(this)}).call(this,e("_process"))},{"./browserCryptoLib":11,"./core":20,"./credentials":21,"./credentials/chainable_temporary_credentials":22,"./credentials/cognito_identity_credentials":23,"./credentials/credential_provider_chain":24,"./credentials/saml_credentials":25,"./credentials/temporary_credentials":26,"./credentials/web_identity_credentials":27,"./event-stream/buffered-create-event-stream":29,"./http/xhr":37,"./realclock/browserClock":54,"./util":73,"./xml/browser_parser":74,_process:87,"buffer/":82,"querystring/":94,"url/":96}],18:[function(e,t,n){var r,i=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),i.Config=i.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),i.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){function t(t){e(t,t?null:r.credentials)}function n(e,t){return new i.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}var r=this;r.credentials?"function"==typeof r.credentials.get?r.credentials.get((function(e){e&&(e=n("Could not load credentials from "+r.credentials.constructor.name,e)),t(e)})):function(){var e=null;r.credentials.accessKeyId&&r.credentials.secretAccessKey||(e=n("Missing credentials")),t(e)}():r.credentialProvider?r.credentialProvider.resolve((function(e,i){e&&(e=n("Could not load credentials from any providers",e)),r.credentials=i,t(e)})):t(n("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),i.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||i.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(i.util.readFileSync(e)),n=new i.FileSystemCredentials(e),r=new i.CredentialProviderChain;return r.providers.unshift(n),r.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){i.util.each.call(this,this.keys,(function(e){delete this[e]})),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"==typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=i.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,s3UsEast1RegionalEndpoint:"legacy",s3UseArnRegion:void 0,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:void 0,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:"legacy"},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=i.util.copy(e)).credentials=new i.Credentials(e)),e},setPromisesDependency:function(e){r=e,null===e&&"function"==typeof Promise&&(r=Promise);var t=[i.Request,i.Credentials,i.CredentialProviderChain];i.S3&&(t.push(i.S3),i.S3.ManagedUpload&&t.push(i.S3.ManagedUpload)),i.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),i.config=new i.Config},{"./core":20,"./credentials":21,"./credentials/credential_provider_chain":24}],19:[function(e,t,n){(function(n){(function(){function r(e,t){if("string"==typeof e){if(["legacy","regional"].indexOf(e.toLowerCase())>=0)return e.toLowerCase();throw i.util.error(new Error,t)}}var i=e("./core");t.exports=function(e,t){var o;if((e=e||{})[t.clientConfig]&&(o=r(e[t.clientConfig],{code:"InvalidConfiguration",message:'invalid "'+t.clientConfig+'" configuration. Expect "legacy" or "regional". Got "'+e[t.clientConfig]+'".'})))return o;if(!i.util.isNode())return o;if(Object.prototype.hasOwnProperty.call(n.env,t.env)&&(o=r(n.env[t.env],{code:"InvalidEnvironmentalVariable",message:"invalid "+t.env+' environmental variable. Expect "legacy" or "regional". Got "'+n.env[t.env]+'".'})))return o;var s={};try{s=i.util.getProfilesFromSharedConfig(i.util.iniLoader)[n.env.AWS_PROFILE||i.util.defaultProfile]}catch(e){}return s&&Object.prototype.hasOwnProperty.call(s,t.sharedConfig)&&(o=r(s[t.sharedConfig],{code:"InvalidConfiguration",message:"invalid "+t.sharedConfig+' profile config. Expect "legacy" or "regional". Got "'+s[t.sharedConfig]+'".'})),o}}).call(this)}).call(this,e("_process"))},{"./core":20,_process:87}],20:[function(e,t,n){var r={util:e("./util")};({}).toString(),t.exports=r,r.util.update(r,{VERSION:"2.772.0",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},apiLoader:e("./api_loader"),EndpointCache:e("../vendor/endpoint-cache").EndpointCache}),e("./sequential_executor"),e("./service"),e("./config"),e("./http"),e("./event_listeners"),e("./request"),e("./response"),e("./resource_waiter"),e("./signers/request_signer"),e("./param_validator"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",(function(){return new r.EndpointCache(r.config.endpointCacheSize)}),!0)},{"../vendor/endpoint-cache":105,"./api_loader":10,"./config":18,"./event_listeners":35,"./http":36,"./json/builder":38,"./json/parser":39,"./model/api":40,"./model/operation":42,"./model/paginator":43,"./model/resource_waiter":44,"./model/shape":45,"./param_validator":46,"./protocol/json":48,"./protocol/query":49,"./protocol/rest":50,"./protocol/rest_json":51,"./protocol/rest_xml":52,"./request":57,"./resource_waiter":58,"./response":59,"./sequential_executor":60,"./service":61,"./signers/request_signer":65,"./util":73,"./xml/builder":75}],21:[function(e,t,n){var r=e("./core");r.Credentials=r.util.inherit({constructor:function(){if(r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof arguments[0]){var e=arguments[0].credentials||arguments[0];this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken}else this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2]},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||this.expired||!this.accessKeyId||!this.secretAccessKey},get:function(e){var t=this;this.needsRefresh()?this.refresh((function(n){n||(t.expired=!1),e&&e(n)})):e&&e()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,t){var n=this;1===n.refreshCallbacks.push(e)&&n.load((function(e){r.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):r.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":20}],22:[function(e,t,n){var r=e("../core"),i=e("../../clients/sts");r.ChainableTemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=r.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new r.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=r.util.merge({params:t,credentials:e.masterCredentials||r.config.credentials},e.stsConfig||{});this.service=new i(n)},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(r,i){var o={};r?e(r):(i&&(o.TokenCode=i),t.service[n](o,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,i){if(n){var o=n;return n instanceof Error&&(o=n.message),void e(r.util.error(new Error("Error fetching MFA token: "+o),{code:t.errorCode}))}e(null,i)})):e(null)}})},{"../../clients/sts":9,"../core":20}],23:[function(e,t,n){var r=e("../core"),i=e("../../clients/cognitoidentity"),o=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.data=null,t._identityId=null,t.getId((function(n){n?(t.clearIdOnNotAuthorized(n),e(n)):t.params.RoleArn?t.getCredentialsFromSTS(e):t.getCredentialsForIdentity(e)}))},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(e){var t=this;if("string"==typeof t.params.IdentityId)return e(null,t.params.IdentityId);t.cognito.getId((function(n,r){!n&&r.IdentityId?(t.params.IdentityId=r.IdentityId,e(null,r.IdentityId)):e(n)}))},loadCredentials:function(e,t){e&&t&&(t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration)},getCredentialsForIdentity:function(e){var t=this;t.cognito.getCredentialsForIdentity((function(n,r){n?t.clearIdOnNotAuthorized(n):(t.cacheId(r),t.data=r,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,r){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(r),t.params.WebIdentityToken=r.Token,t.webIdentityCredentials.refresh((function(n){n||(t.data=t.webIdentityCredentials.data,t.sts.credentialsFrom(t.data,t)),e(n)})))}))},loadCachedId:function(){var e=this;if(r.util.isBrowser()&&!e.params.IdentityId){var t=e.getStorage("id");if(t&&e.params.Logins){var n=Object.keys(e.params.Logins);0!==(e.getStorage("providers")||"").split(",").filter((function(e){return-1!==n.indexOf(e)})).length&&(e.params.IdentityId=t)}else t&&(e.params.IdentityId=t)}},createClients:function(){var e=this._clientConfig;if(this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,e),!this.cognito){var t=r.util.merge({},e);t.params=this.params,this.cognito=new i(t)}this.sts=this.sts||new o(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.util.isBrowser()&&(this.setStorage("id",e.IdentityId),this.params.Logins&&this.setStorage("providers",Object.keys(this.params.Logins).join(",")))},getStorage:function(e){return this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(e){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"==typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(e){return{}}}()})},{"../../clients/cognitoidentity":8,"../../clients/sts":9,"../core":20}],24:[function(e,t,n){var r=e("../core");r.CredentialProviderChain=r.util.inherit(r.Credentials,{constructor:function(e){this.providers=e||r.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var t=this;if(0===t.providers.length)return e(new Error("No providers")),t;if(1===t.resolveCallbacks.push(e)){var n=0,i=t.providers.slice(0);!function e(o,s){if(!o&&s||n===i.length)return r.util.arrayEach(t.resolveCallbacks,(function(e){e(o,s)})),void(t.resolveCallbacks.length=0);var a=i[n++];(s="function"==typeof a?a.call():a).get?s.get((function(t){e(t,t?null:s)})):e(null,s)}()}return t}}),r.CredentialProviderChain.defaultProviders=[],r.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=r.util.promisifyMethod("resolve",e)},r.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},r.util.addPromises(r.CredentialProviderChain)},{"../core":20}],25:[function(e,t,n){var r=e("../core"),i=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))},createClients:function(){this.service=this.service||new i({params:this.params})}})},{"../../clients/sts":9,"../core":20}],26:[function(e,t,n){var r=e("../core"),i=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.masterCredentials.get((function(){t.service.config.credentials=t.masterCredentials,(t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken).call(t.service,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new i({params:this.params})}})},{"../../clients/sts":9,"../core":20}],27:[function(e,t,n){var r=e("../core"),i=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,r){t.data=null,n||(t.data=r,t.service.credentialsFrom(r,t)),e(n)}))},createClients:function(){if(!this.service){var e=r.util.merge({},this._clientConfig);e.params=this.params,this.service=new i(e)}}})},{"../../clients/sts":9,"../core":20}],28:[function(e,t,n){(function(n){(function(){function r(e){var t=e.service,n=t.api||{},r={};return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function i(e,t,n){n&&null!=t&&"structure"===n.type&&n.required&&n.required.length>0&&h.arrayEach(n.required,(function(r){var o=n.members[r];if(!0===o.endpointDiscoveryId){var s=o.isLocationName?o.name:r;e[s]=String(t[r])}else i(e,t[r],o)}))}function o(e,t){var n={};return i(n,e.params,t),n}function s(e){var t=e.service,n=t.api,i=n.operations?n.operations[e.operation]:void 0,s=o(e,i?i.input:void 0),a=r(e);Object.keys(s).length>0&&(a=h.update(a,s),i&&(a.operation=i.name));var u=d.endpointCache.get(a);if(!u||1!==u.length||""!==u[0].Address)if(u&&u.length>0)e.httpRequest.updateEndpoint(u[0].Address);else{var l=t.makeRequest(n.endpointOperation,{Operation:i.name,Identifiers:s});c(l),l.removeListener("validate",d.EventListeners.Core.VALIDATE_PARAMETERS),l.removeListener("retry",d.EventListeners.Core.RETRY_CHECK),d.endpointCache.put(a,[{Address:"",CachePeriodInMinutes:1}]),l.send((function(e,t){t&&t.Endpoints?d.endpointCache.put(a,t.Endpoints):e&&d.endpointCache.put(a,[{Address:"",CachePeriodInMinutes:1}])}))}}function a(e,t){var n=e.service,i=n.api,s=i.operations?i.operations[e.operation]:void 0,a=s?s.input:void 0,u=o(e,a),l=r(e);Object.keys(u).length>0&&(l=h.update(l,u),s&&(l.operation=s.name));var p=d.EndpointCache.getKeyString(l),f=d.endpointCache.get(p);if(f&&1===f.length&&""===f[0].Address)return m[p]||(m[p]=[]),void m[p].push({request:e,callback:t});if(f&&f.length>0)e.httpRequest.updateEndpoint(f[0].Address),t();else{var g=n.makeRequest(i.endpointOperation,{Operation:s.name,Identifiers:u});g.removeListener("validate",d.EventListeners.Core.VALIDATE_PARAMETERS),c(g),d.endpointCache.put(p,[{Address:"",CachePeriodInMinutes:60}]),g.send((function(n,r){if(n){if(e.response.error=h.error(n,{retryable:!1}),d.endpointCache.remove(l),m[p]){var i=m[p];h.arrayEach(i,(function(e){e.request.response.error=h.error(n,{retryable:!1}),e.callback()})),delete m[p]}}else r&&(d.endpointCache.put(p,r.Endpoints),e.httpRequest.updateEndpoint(r.Endpoints[0].Address),m[p])&&(i=m[p],h.arrayEach(i,(function(e){e.request.httpRequest.updateEndpoint(r.Endpoints[0].Address),e.callback()})),delete m[p]);t()}))}}function c(e){var t=e.service.api.apiVersion;t&&!e.httpRequest.headers["x-amz-api-version"]&&(e.httpRequest.headers["x-amz-api-version"]=t)}function u(e){var t=e.error,n=e.httpResponse;if(t&&("InvalidEndpointException"===t.code||421===n.statusCode)){var i=e.request,s=i.service.api.operations||{},a=o(i,s[i.operation]?s[i.operation].input:void 0),c=r(i);Object.keys(a).length>0&&(c=h.update(c,a),s[i.operation]&&(c.operation=s[i.operation].name)),d.endpointCache.remove(c)}}function l(e){return["false","0"].indexOf(e)>=0}function p(e){var t=e.service||{};if(void 0!==t.config.endpointDiscoveryEnabled)return t.config.endpointDiscoveryEnabled;if(!h.isBrowser()){for(var r=0;r<f.length;r++){var i=f[r];if(Object.prototype.hasOwnProperty.call(n.env,i)){if(""===n.env[i]||void 0===n.env[i])throw h.error(new Error,{code:"ConfigurationException",message:"environmental variable "+i+" cannot be set to nothing"});return!l(n.env[i])}}var o={};try{o=d.util.iniLoader?d.util.iniLoader.loadFrom({isConfig:!0,filename:n.env[d.util.sharedConfigFileEnv]}):{}}catch(e){}var s=o[n.env.AWS_PROFILE||d.util.defaultProfile]||{};if(Object.prototype.hasOwnProperty.call(s,"endpoint_discovery_enabled")){if(void 0===s.endpoint_discovery_enabled)throw h.error(new Error,{code:"ConfigurationException",message:"config file entry 'endpoint_discovery_enabled' cannot be set to nothing"});return!l(s.endpoint_discovery_enabled)}}}var d=e("./core"),h=e("./util"),f=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"],m={};t.exports={discoverEndpoint:function(e,t){var n=e.service||{};if(function(e){if(e._originalConfig&&e._originalConfig.endpoint&&!0===e._originalConfig.endpointDiscoveryEnabled)throw h.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=d.config[e.serviceIdentifier]||{};return Boolean(d.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(n)||e.isPresigned())return t();var r=(n.api.operations||{})[e.operation],i=r?r.endpointDiscoveryRequired:"NULL",o=p(e),c=n.api.hasRequiredEndpointDiscovery;switch((o||c)&&e.httpRequest.appendToUserAgent("endpoint-discovery"),i){case"OPTIONAL":(o||c)&&(s(e),e.addNamedListener("INVALIDATE_CACHED_ENDPOINTS","extractError",u)),t();break;case"REQUIRED":if(!1===o){e.response.error=h.error(new Error,{code:"ConfigurationException",message:"Endpoint Discovery is disabled but "+n.api.className+"."+e.operation+"() requires it. Please check your configurations."}),t();break}e.addNamedListener("INVALIDATE_CACHED_ENDPOINTS","extractError",u),a(e,t);break;default:t()}},requiredDiscoverEndpoint:a,optionalDiscoverEndpoint:s,marshallCustomIdentifiers:o,getCacheKey:r,invalidateCachedEndpoint:u}}).call(this)}).call(this,e("_process"))},{"./core":20,"./util":73,_process:87}],29:[function(e,t,n){var r=e("../event-stream/event-message-chunker").eventMessageChunker,i=e("./parse-event").parseEvent;t.exports={createEventStream:function(e,t,n){for(var o=r(e),s=[],a=0;a<o.length;a++)s.push(i(t,o[a],n));return s}}},{"../event-stream/event-message-chunker":30,"./parse-event":32}],30:[function(e,t,n){t.exports={eventMessageChunker:function(e){for(var t=[],n=0;n<e.length;){var r=e.readInt32BE(n),i=e.slice(n,r+n);n+=r,t.push(i)}return t}}},{}],31:[function(e,t,n){function r(e){if(8!==e.length)throw new Error("Int64 buffers must be exactly 8 bytes");o.Buffer.isBuffer(e)||(e=s(e)),this.bytes=e}function i(e){for(var t=0;t<8;t++)e[t]^=255;for(t=7;t>-1&&0==++e[t];t--);}var o=e("../core").util,s=o.buffer.toBuffer;r.fromNumber=function(e){if(e>0x8000000000000000||e<-0x8000000000000000)throw new Error(e+" is too large (or, if negative, too small) to represent as an Int64");for(var t=new Uint8Array(8),n=7,o=Math.abs(Math.round(e));n>-1&&o>0;n--,o/=256)t[n]=o;return e<0&&i(t),new r(t)},r.prototype.valueOf=function(){var e=this.bytes.slice(0),t=128&e[0];return t&&i(e),parseInt(e.toString("hex"),16)*(t?-1:1)},r.prototype.toString=function(){return String(this.valueOf())},t.exports={Int64:r}},{"../core":20}],32:[function(e,t,n){var r=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var i=r(t),o=i.headers[":message-type"];if(o){if("error"===o.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],r=new Error(n.value||n);return r.code=r.name=t.value||t,r}(i);if("event"!==o.value)return}var s=i.headers[":event-type"],a=n.members[s.value];if(a){var c={},u=a.eventPayloadMemberName;if(u){var l=a.members[u];"binary"===l.type?c[u]=i.body:c[u]=e.parse(i.body.toString(),l)}for(var p=a.eventHeaderMemberNames,d=0;d<p.length;d++){var h=p[d];i.headers[h]&&(c[h]=a.members[h].toType(i.headers[h].value))}var f={};return f[s.value]=c,f}}}},{"./parse-message":33}],33:[function(e,t,n){function r(e){for(var t={},n=0;n<e.length;){var r=e.readUInt8(n++),o=e.slice(n,n+r).toString();switch(n+=r,e.readUInt8(n++)){case 0:t[o]={type:s,value:!0};break;case 1:t[o]={type:s,value:!1};break;case 2:t[o]={type:a,value:e.readInt8(n++)};break;case 3:t[o]={type:c,value:e.readInt16BE(n)},n+=2;break;case 4:t[o]={type:u,value:e.readInt32BE(n)},n+=4;break;case 5:t[o]={type:l,value:new i(e.slice(n,n+8))},n+=8;break;case 6:var m=e.readUInt16BE(n);n+=2,t[o]={type:p,value:e.slice(n,n+m)},n+=m;break;case 7:var g=e.readUInt16BE(n);n+=2,t[o]={type:d,value:e.slice(n,n+g).toString()},n+=g;break;case 8:t[o]={type:h,value:new Date(new i(e.slice(n,n+8)).valueOf())},n+=8;break;case 9:var v=e.slice(n,n+16).toString("hex");n+=16,t[o]={type:f,value:v.substr(0,8)+"-"+v.substr(8,4)+"-"+v.substr(12,4)+"-"+v.substr(16,4)+"-"+v.substr(20)};break;default:throw new Error("Unrecognized header type tag")}}return t}var i=e("./int64").Int64,o=e("./split-message").splitMessage,s="boolean",a="byte",c="short",u="integer",l="long",p="binary",d="string",h="timestamp",f="uuid";t.exports={parseMessage:function(e){var t=o(e);return{headers:r(t.headers),body:t.body}}}},{"./int64":31,"./split-message":34}],34:[function(e,t,n){var r=e("../core").util,i=r.buffer.toBuffer;t.exports={splitMessage:function(e){if(r.Buffer.isBuffer(e)||(e=i(e)),e.length<16)throw new Error("Provided message too short to accommodate event stream message overhead");if(e.length!==e.readUInt32BE(0))throw new Error("Reported message length does not match received message length");var t=e.readUInt32BE(8);if(t!==r.crypto.crc32(e.slice(0,8)))throw new Error("The prelude checksum specified in the message ("+t+") does not match the calculated CRC32 checksum.");var n=e.readUInt32BE(e.length-4);if(n!==r.crypto.crc32(e.slice(0,e.length-4)))throw new Error("The message checksum did not match the expected value of "+n);var o=12+e.readUInt32BE(4);return{headers:e.slice(12,o),body:e.slice(o,e.length-4)}}}},{"../core":20}],35:[function(e,t,n){var r=e("./core"),i=e("./sequential_executor"),o=e("./discover_endpoint").discoverEndpoint;r.EventListeners={Core:{}},r.EventListeners={Core:(new i).addNamedListeners((function(e,t){t("VALIDATE_CREDENTIALS","validate",(function(e,t){if(!e.service.api.signatureVersion&&!e.service.config.signatureVersion)return t();e.service.config.getCredentials((function(n){n&&(e.response.error=r.util.error(n,{code:"CredentialsError",message:"Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1"})),t()}))})),e("VALIDATE_REGION","validate",(function(e){if(!e.service.isGlobalEndpoint){var t=new RegExp(/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/);e.service.config.region?t.test(e.service.config.region)||(e.response.error=r.util.error(new Error,{code:"ConfigError",message:"Invalid region in config"})):e.response.error=r.util.error(new Error,{code:"ConfigError",message:"Missing region in config"})}})),e("BUILD_IDEMPOTENCY_TOKENS","validate",(function(e){if(e.service.api.operations){var t=e.service.api.operations[e.operation];if(t){var n=t.idempotentMembers;if(n.length){for(var i=r.util.copy(e.params),o=0,s=n.length;o<s;o++)i[n[o]]||(i[n[o]]=r.util.uuid.v4());e.params=i}}}})),e("VALIDATE_PARAMETERS","validate",(function(e){if(e.service.api.operations){var t=e.service.api.operations[e.operation].input,n=e.service.config.paramValidation;new r.ParamValidator(n).validate(t,e.params)}})),t("COMPUTE_SHA256","afterBuild",(function(e,t){if(e.haltHandlersOnError(),e.service.api.operations){var n=e.service.api.operations[e.operation],i=n?n.authtype:"";if(!e.service.api.signatureVersion&&!i&&!e.service.config.signatureVersion)return t();if(e.service.getSignerClass(e)===r.Signers.V4){var o=e.httpRequest.body||"";if(i.indexOf("unsigned-body")>=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();r.util.computeSha256(o,(function(n,r){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=r,t())}))}else t()}})),e("SET_CONTENT_LENGTH","afterBuild",(function(e){var t=function(e){if(!e.service.api.operations)return"";var t=e.service.api.operations[e.operation];return t?t.authtype:""}(e),n=r.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var i=r.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=i}catch(r){if(n&&n.isStreaming){if(n.requiresLength)throw r;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw r}throw r}})),e("SET_HTTP_HOST","afterBuild",(function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host})),e("RESTART","restart",(function(){var e=this.response.error;e&&e.retryable&&(this.httpRequest=new r.HttpRequest(this.service.endpoint,this.service.region),this.response.retryCount<this.service.config.maxRetries?this.response.retryCount++:this.response.error=null)})),t("DISCOVER_ENDPOINT","sign",o,!0),t("SIGN","sign",(function(e,t){var n=e.service,r=(e.service.api.operations||{})[e.operation],i=r?r.authtype:"";if(!n.api.signatureVersion&&!i&&!n.config.signatureVersion)return t();n.config.getCredentials((function(i,o){if(i)return e.response.error=i,t();try{var s=n.getSkewCorrectedDate(),a=new(n.getSignerClass(e))(e.httpRequest,n.getSigningName(),{signatureCache:n.config.signatureCache,operation:r,signatureVersion:n.api.signatureVersion});a.setServiceClientId(n._clientId),delete e.httpRequest.headers.Authorization,delete e.httpRequest.headers.Date,delete e.httpRequest.headers["X-Amz-Date"],a.addAuthorization(o,s),e.signedAt=s}catch(t){e.response.error=t}t()}))})),e("VALIDATE_RESPONSE","validateResponse",(function(e){this.service.successfulResponse(e,this)?(e.data={},e.error=null):(e.data=null,e.error=r.util.error(new Error,{code:"UnknownError",message:"An unknown error occurred."}))})),t("SEND","send",(function(e,t){function n(n){e.httpResponse.stream=n;var i=e.request.httpRequest.stream,o=e.request.service,s=o.api,a=e.request.operation,c=s.operations[a]||{};n.on("headers",(function(i,s,a){if(e.request.emit("httpHeaders",[i,s,e,a]),!e.httpResponse.streaming)if(2===r.HttpClient.streamsApiVersion){if(c.hasEventOutput&&o.successfulResponse(e))return e.request.emit("httpDone"),void t();n.on("readable",(function(){var t=n.read();null!==t&&e.request.emit("httpData",[t,e])}))}else n.on("data",(function(t){e.request.emit("httpData",[t,e])}))})),n.on("end",(function(){if(!i||!i.didCallback){if(2===r.HttpClient.streamsApiVersion&&c.hasEventOutput&&o.successfulResponse(e))return;e.request.emit("httpDone"),t()}}))}function i(n){if("RequestAbortedError"!==n.code){var i="TimeoutError"===n.code?n.code:"NetworkingError";n=r.util.error(n,{code:i,region:e.request.httpRequest.region,hostname:e.request.httpRequest.endpoint.hostname,retryable:!0})}e.error=n,e.request.emit("httpError",[e.error,e],(function(){t()}))}function o(){var t=r.HttpClient.getInstance(),o=e.request.service.config.httpOptions||{};try{!function(t){t.on("sendProgress",(function(t){e.request.emit("httpUploadProgress",[t,e])})),t.on("receiveProgress",(function(t){e.request.emit("httpDownloadProgress",[t,e])}))}(t.handleRequest(e.request.httpRequest,o,n,i))}catch(e){i(e)}}e.httpResponse._abortCallback=t,e.error=null,e.data=null,(e.request.service.getSkewCorrectedDate()-this.signedAt)/1e3>=600?this.emit("sign",[this],(function(e){e?t(e):o()})):o()})),e("HTTP_HEADERS","httpHeaders",(function(e,t,n,i){n.httpResponse.statusCode=e,n.httpResponse.statusMessage=i,n.httpResponse.headers=t,n.httpResponse.body=r.util.buffer.toBuffer(""),n.httpResponse.buffers=[],n.httpResponse.numBytes=0;var o=t.date||t.Date,s=n.request.service;if(o){var a=Date.parse(o);s.config.correctClockSkew&&s.isClockSkewed(a)&&s.applyClockOffset(a)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(r.util.isNode()){t.httpResponse.numBytes+=e.length;var n=t.httpResponse.headers["content-length"],i={loaded:t.httpResponse.numBytes,total:n};t.request.emit("httpDownloadProgress",[i,t])}t.httpResponse.buffers.push(r.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=r.util.buffer.concat(e.httpResponse.buffers);e.httpResponse.body=t}delete e.httpResponse.numBytes,delete e.httpResponse.buffers})),e("FINALIZE_ERROR","retry",(function(e){e.httpResponse.statusCode&&(e.error.statusCode=e.httpResponse.statusCode,void 0===e.error.retryable&&(e.error.retryable=this.service.retryableError(e.error,this)))})),e("INVALIDATE_CREDENTIALS","retry",(function(e){if(e.error)switch(e.error.code){case"RequestExpired":case"ExpiredTokenException":case"ExpiredToken":e.error.retryable=!0,e.request.service.config.credentials.expired=!0}})),e("EXPIRED_SIGNATURE","retry",(function(e){var t=e.error;t&&"string"==typeof t.code&&"string"==typeof t.message&&t.code.match(/Signature/)&&t.message.match(/expired/)&&(e.error.retryable=!0)})),e("CLOCK_SKEWED","retry",(function(e){e.error&&this.service.clockSkewError(e.error)&&this.service.config.correctClockSkew&&(e.error.retryable=!0)})),e("REDIRECT","retry",(function(e){e.error&&e.error.statusCode>=300&&e.error.statusCode<400&&e.httpResponse.headers.location&&(this.httpRequest.endpoint=new r.Endpoint(e.httpResponse.headers.location),this.httpRequest.headers.Host=this.httpRequest.endpoint.host,e.error.redirect=!0,e.error.retryable=!0)})),e("RETRY_CHECK","retry",(function(e){e.error&&(e.error.redirect&&e.redirectCount<e.maxRedirects?e.error.retryDelay=0:e.retryCount<e.maxRetries&&(e.error.retryDelay=this.service.retryDelays(e.retryCount,e.error)||0))})),t("RESET_RETRY_STATE","afterRetry",(function(e,t){var n,r=!1;e.error&&(n=e.error.retryDelay||0,e.error.retryable&&e.retryCount<e.maxRetries?(e.retryCount++,r=!0):e.error.redirect&&e.redirectCount<e.maxRedirects&&(e.redirectCount++,r=!0)),r&&n>=0?(e.error=null,setTimeout(t,n)):t()}))})),CorePost:(new i).addNamedListeners((function(e){e("EXTRACT_REQUEST_ID","extractData",r.util.extractRequestId),e("EXTRACT_REQUEST_ID","extractError",r.util.extractRequestId),e("ENOTFOUND_ERROR","httpError",(function(e){if("NetworkingError"===e.code&&function(e){return"ENOTFOUND"===e.errno||"number"==typeof e.errno&&"function"==typeof r.util.getSystemErrorName&&["EAI_NONAME","EAI_NODATA"].indexOf(r.util.getSystemErrorName(e.errno)>=0)}(e)){var t="Inaccessible host: `"+e.hostname+"'. This service may not be available in the `"+e.region+"' region.";this.response.error=r.util.error(new Error(t),{code:"UnknownEndpoint",region:e.region,hostname:e.hostname,retryable:!0,originalError:e})}}))})),Logger:(new i).addNamedListeners((function(t){t("LOG_REQUEST","complete",(function(t){function n(e,t){if(!t)return t;if(e.isSensitive)return"***SensitiveInformation***";switch(e.type){case"structure":var i={};return r.util.each(t,(function(t,r){Object.prototype.hasOwnProperty.call(e.members,t)?i[t]=n(e.members[t],r):i[t]=r})),i;case"list":var o=[];return r.util.arrayEach(t,(function(t,r){o.push(n(e.member,t))})),o;case"map":var s={};return r.util.each(t,(function(t,r){s[t]=n(e.value,r)})),s;default:return t}}var i=t.request,o=i.service.config.logger;if(o){var s=function(){var s=(t.request.service.getSkewCorrectedDate().getTime()-i.startTime.getTime())/1e3,a=!!o.isTTY,c=t.httpResponse.statusCode,u=i.params;i.service.api.operations&&i.service.api.operations[i.operation]&&i.service.api.operations[i.operation].input&&(u=n(i.service.api.operations[i.operation].input,i.params));var l=e("util").inspect(u,!0,null),p="";return a&&(p+="[33m"),p+="[AWS "+i.service.serviceIdentifier+" "+c,p+=" "+s.toString()+"s "+t.retryCount+" retries]",a&&(p+="[0;1m"),p+=" "+r.util.string.lowerFirst(i.operation),p+="("+l+")",a&&(p+="[0m"),p}();"function"==typeof o.log?o.log(s):"function"==typeof o.write&&o.write(s+"\n")}}))})),Json:(new i).addNamedListeners((function(t){var n=e("./protocol/json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Rest:(new i).addNamedListeners((function(t){var n=e("./protocol/rest");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestJson:(new i).addNamedListeners((function(t){var n=e("./protocol/rest_json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestXml:(new i).addNamedListeners((function(t){var n=e("./protocol/rest_xml");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Query:(new i).addNamedListeners((function(t){var n=e("./protocol/query");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)}))}},{"./core":20,"./discover_endpoint":28,"./protocol/json":48,"./protocol/query":49,"./protocol/rest":50,"./protocol/rest_json":51,"./protocol/rest_xml":52,"./sequential_executor":60,util:99}],36:[function(e,t,n){var r=e("./core"),i=r.util.inherit;r.Endpoint=i({constructor:function(e,t){if(r.util.hideProperties(this,["slashes","auth","hash","search","query"]),null==e)throw new Error("Invalid endpoint: "+e);if("string"!=typeof e)return r.util.copy(e);e.match(/^http/)||(e=((t&&void 0!==t.sslEnabled?t.sslEnabled:r.config.sslEnabled)?"https":"http")+"://"+e),r.util.update(this,r.util.urlParse(e)),this.port?this.port=parseInt(this.port,10):this.port="https:"===this.protocol?443:80}}),r.HttpRequest=i({constructor:function(e,t){e=new r.Endpoint(e),this.method="POST",this.path=e.path||"/",this.headers={},this.body="",this.endpoint=e,this.region=t,this._userAgent="",this.setUserAgent()},setUserAgent:function(){this._userAgent=this.headers[this.getUserAgentHeaderName()]=r.util.userAgent()},getUserAgentHeaderName:function(){return(r.util.isBrowser()?"X-Amz-":"")+"User-Agent"},appendToUserAgent:function(e){"string"==typeof e&&e&&(this._userAgent+=" "+e),this.headers[this.getUserAgentHeaderName()]=this._userAgent},getUserAgent:function(){return this._userAgent},pathname:function(){return this.path.split("?",1)[0]},search:function(){var e=this.path.split("?",2)[1];return e?(e=r.util.queryStringParse(e),r.util.queryParamsToString(e)):""},updateEndpoint:function(e){var t=new r.Endpoint(e);this.endpoint=t,this.path=t.path||"/",this.headers.Host&&(this.headers.Host=t.host)}}),r.HttpResponse=i({constructor:function(){this.statusCode=void 0,this.headers={},this.body=void 0,this.streaming=!1,this.stream=null},createUnbufferedStream:function(){return this.streaming=!0,this.stream}}),r.HttpClient=i({}),r.HttpClient.getInstance=function(){return void 0===this.singleton&&(this.singleton=new this),this.singleton}},{"./core":20}],37:[function(e,t,n){var r=e("../core"),i=e("events").EventEmitter;e("../http"),r.XHRClient=r.util.inherit({handleRequest:function(e,t,n,o){var s=this,a=e.endpoint,c=new i,u=a.protocol+"//"+a.hostname;80!==a.port&&443!==a.port&&(u+=":"+a.port),u+=e.path;var l=new XMLHttpRequest,p=!1;e.stream=l,l.addEventListener("readystatechange",(function(){try{if(0===l.status)return}catch(e){return}this.readyState>=this.HEADERS_RECEIVED&&!p&&(c.statusCode=l.status,c.headers=s.parseHeaders(l.getAllResponseHeaders()),c.emit("headers",c.statusCode,c.headers,l.statusText),p=!0),this.readyState===this.DONE&&s.finishRequest(l,c)}),!1),l.upload.addEventListener("progress",(function(e){c.emit("sendProgress",e)})),l.addEventListener("progress",(function(e){c.emit("receiveProgress",e)}),!1),l.addEventListener("timeout",(function(){o(r.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),l.addEventListener("error",(function(){o(r.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),l.addEventListener("abort",(function(){o(r.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(c),l.open(e.method,u,!1!==t.xhrAsync),r.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&l.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(l.timeout=t.timeout),t.xhrWithCredentials&&(l.withCredentials=!0);try{l.responseType="arraybuffer"}catch(e){}try{e.body?l.send(e.body):l.send()}catch(t){if(!e.body||"object"!=typeof e.body.buffer)throw t;l.send(e.body.buffer)}return c},parseHeaders:function(e){var t={};return r.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],r=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=r)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var i=e.response;n=new r.util.Buffer(i.byteLength);for(var o=new Uint8Array(i),s=0;s<n.length;++s)n[s]=o[s]}try{n||"string"!=typeof e.responseText||(n=new r.util.Buffer(e.responseText))}catch(e){}n&&t.emit("data",n),t.emit("end")}}),r.HttpClient.prototype=r.XHRClient.prototype,r.HttpClient.streamsApiVersion=1},{"../core":20,"../http":36,events:83}],38:[function(e,t,n){function r(){}function i(e,t){if(t&&null!=e)switch(t.type){case"structure":return function(e,t){var n={};return o.each(e,(function(e,r){var o=t.members[e];if(o){if("body"!==o.location)return;var s=o.isLocationName?o.name:e,a=i(r,o);void 0!==a&&(n[s]=a)}})),n}(e,t);case"map":return function(e,t){var n={};return o.each(e,(function(e,r){var o=i(r,t.value);void 0!==o&&(n[e]=o)})),n}(e,t);case"list":return function(e,t){var n=[];return o.arrayEach(e,(function(e){var r=i(e,t.member);void 0!==r&&n.push(r)})),n}(e,t);default:return function(e,t){return t.toWireFormat(e)}(e,t)}}var o=e("../util");r.prototype.build=function(e,t){return JSON.stringify(i(e,t))},t.exports=r},{"../util":73}],39:[function(e,t,n){function r(){}function i(e,t){if(t&&void 0!==e)switch(t.type){case"structure":return function(e,t){if(null!=e){var n={},r=t.members;return o.each(r,(function(t,r){var o=r.isLocationName?r.name:t;if(Object.prototype.hasOwnProperty.call(e,o)){var s=i(e[o],r);void 0!==s&&(n[t]=s)}})),n}}(e,t);case"map":return function(e,t){if(null!=e){var n={};return o.each(e,(function(e,r){var o=i(r,t.value);n[e]=void 0===o?null:o})),n}}(e,t);case"list":return function(e,t){if(null!=e){var n=[];return o.arrayEach(e,(function(e){var r=i(e,t.member);void 0===r?n.push(null):n.push(r)})),n}}(e,t);default:return function(e,t){return t.toType(e)}(e,t)}}var o=e("../util");r.prototype.parse=function(e,t){return i(JSON.parse(e),t)},t.exports=r},{"../util":73}],40:[function(e,t,n){var r=e("./collection"),i=e("./operation"),o=e("./shape"),s=e("./paginator"),a=e("./resource_waiter"),c=e("../../apis/metadata.json"),u=e("../util"),l=u.property,p=u.memoizedProperty;t.exports=function(e,t){var n=this;e=e||{},(t=t||{}).api=this,e.metadata=e.metadata||{};var d=t.serviceIdentifier;delete t.serviceIdentifier,l(this,"isApi",!0,!1),l(this,"apiVersion",e.metadata.apiVersion),l(this,"endpointPrefix",e.metadata.endpointPrefix),l(this,"signingName",e.metadata.signingName),l(this,"globalEndpoint",e.metadata.globalEndpoint),l(this,"signatureVersion",e.metadata.signatureVersion),l(this,"jsonVersion",e.metadata.jsonVersion),l(this,"targetPrefix",e.metadata.targetPrefix),l(this,"protocol",e.metadata.protocol),l(this,"timestampFormat",e.metadata.timestampFormat),l(this,"xmlNamespaceUri",e.metadata.xmlNamespace),l(this,"abbreviation",e.metadata.serviceAbbreviation),l(this,"fullName",e.metadata.serviceFullName),l(this,"serviceId",e.metadata.serviceId),d&&c[d]&&l(this,"xmlNoDefaultLists",c[d].xmlNoDefaultLists,!1),p(this,"className",(function(){var t=e.metadata.serviceAbbreviation||e.metadata.serviceFullName;return t?("ElasticLoadBalancing"===(t=t.replace(/^Amazon|AWS\s*|\(.*|\s+|\W+/g,""))&&(t="ELB"),t):null})),l(this,"operations",new r(e.operations,t,(function(e,n){return new i(e,n,t)}),u.string.lowerFirst,(function(e,t){!0===t.endpointoperation&&l(n,"endpointOperation",u.string.lowerFirst(e)),t.endpointdiscovery&&!n.hasRequiredEndpointDiscovery&&l(n,"hasRequiredEndpointDiscovery",!0===t.endpointdiscovery.required)}))),l(this,"shapes",new r(e.shapes,t,(function(e,n){return o.create(n,t)}))),l(this,"paginators",new r(e.paginators,t,(function(e,n){return new s(e,n,t)}))),l(this,"waiters",new r(e.waiters,t,(function(e,n){return new a(e,n,t)}),u.string.lowerFirst)),t.documentation&&(l(this,"documentation",e.documentation),l(this,"documentationUrl",e.documentationUrl))}},{"../../apis/metadata.json":5,"../util":73,"./collection":41,"./operation":42,"./paginator":43,"./resource_waiter":44,"./shape":45}],41:[function(e,t,n){function r(e,t,n,r){i(this,r(e),(function(){return n(e,t)}))}var i=e("../util").memoizedProperty;t.exports=function(e,t,n,i,o){for(var s in i=i||String,e)Object.prototype.hasOwnProperty.call(e,s)&&(r.call(this,s,e[s],n,i),o&&o(s,e[s]))}},{"../util":73}],42:[function(e,t,n){var r=e("./shape"),i=e("../util"),o=i.property,s=i.memoizedProperty;t.exports=function(e,t,n){var i=this;n=n||{},o(this,"name",t.name||e),o(this,"api",n.api,!1),t.http=t.http||{},o(this,"endpoint",t.endpoint),o(this,"httpMethod",t.http.method||"POST"),o(this,"httpPath",t.http.requestUri||"/"),o(this,"authtype",t.authtype||""),o(this,"endpointDiscoveryRequired",t.endpointdiscovery?t.endpointdiscovery.required?"REQUIRED":"OPTIONAL":"NULL"),s(this,"input",(function(){return t.input?r.create(t.input,n):new r.create({type:"structure"},n)})),s(this,"output",(function(){return t.output?r.create(t.output,n):new r.create({type:"structure"},n)})),s(this,"errors",(function(){var e=[];if(!t.errors)return null;for(var i=0;i<t.errors.length;i++)e.push(r.create(t.errors[i],n));return e})),s(this,"paginator",(function(){return n.api.paginators[e]})),n.documentation&&(o(this,"documentation",t.documentation),o(this,"documentationUrl",t.documentationUrl)),s(this,"idempotentMembers",(function(){var e=[],t=i.input,n=t.members;if(!t.members)return e;for(var r in n)n.hasOwnProperty(r)&&!0===n[r].isIdempotent&&e.push(r);return e})),s(this,"hasEventOutput",(function(){return function(e){var t=e.members,n=e.payload;if(!e.members)return!1;if(n)return t[n].isEventStream;for(var r in t)if(!t.hasOwnProperty(r)&&!0===t[r].isEventStream)return!0;return!1}(i.output)}))}},{"../util":73,"./shape":45}],43:[function(e,t,n){var r=e("../util").property;t.exports=function(e,t){r(this,"inputToken",t.input_token),r(this,"limitKey",t.limit_key),r(this,"moreResults",t.more_results),r(this,"outputToken",t.output_token),r(this,"resultKey",t.result_key)}},{"../util":73}],44:[function(e,t,n){var r=e("../util"),i=r.property;t.exports=function(e,t,n){n=n||{},i(this,"name",e),i(this,"api",n.api,!1),t.operation&&i(this,"operation",r.string.lowerFirst(t.operation));var o=this;["type","description","delay","maxAttempts","acceptors"].forEach((function(e){var n=t[e];n&&i(o,e,n)}))}},{"../util":73}],45:[function(e,t,n){function r(e,t,n){null!=n&&m.property.apply(this,arguments)}function i(e,t){e.constructor.prototype[t]||m.memoizedProperty.apply(this,arguments)}function o(e,t,n){t=t||{},r(this,"shape",e.shape),r(this,"api",t.api,!1),r(this,"type",e.type),r(this,"enum",e.enum),r(this,"min",e.min),r(this,"max",e.max),r(this,"pattern",e.pattern),r(this,"location",e.location||this.location||"body"),r(this,"name",this.name||e.xmlName||e.queryName||e.locationName||n),r(this,"isStreaming",e.streaming||this.isStreaming||!1),r(this,"requiresLength",e.requiresLength,!1),r(this,"isComposite",e.isComposite||!1),r(this,"isShape",!0,!1),r(this,"isQueryName",Boolean(e.queryName),!1),r(this,"isLocationName",Boolean(e.locationName),!1),r(this,"isIdempotent",!0===e.idempotencyToken),r(this,"isJsonValue",!0===e.jsonvalue),r(this,"isSensitive",!0===e.sensitive||e.prototype&&!0===e.prototype.sensitive),r(this,"isEventStream",Boolean(e.eventstream),!1),r(this,"isEvent",Boolean(e.event),!1),r(this,"isEventPayload",Boolean(e.eventpayload),!1),r(this,"isEventHeader",Boolean(e.eventheader),!1),r(this,"isTimestampFormatSet",Boolean(e.timestampFormat)||e.prototype&&!0===e.prototype.isTimestampFormatSet,!1),r(this,"endpointDiscoveryId",Boolean(e.endpointdiscoveryid),!1),r(this,"hostLabel",Boolean(e.hostLabel),!1),t.documentation&&(r(this,"documentation",e.documentation),r(this,"documentationUrl",e.documentationUrl)),e.xmlAttribute&&r(this,"isXmlAttribute",e.xmlAttribute||!1),r(this,"defaultValue",null),this.toWireFormat=function(e){return null==e?"":e},this.toType=function(e){return e}}function s(e){o.apply(this,arguments),r(this,"isComposite",!0),e.flattened&&r(this,"flattened",e.flattened||!1)}function a(e,t){var n=this,a=null,c=!this.isShape;s.apply(this,arguments),c&&(r(this,"defaultValue",(function(){return{}})),r(this,"members",{}),r(this,"memberNames",[]),r(this,"required",[]),r(this,"isRequired",(function(){return!1}))),e.members&&(r(this,"members",new f(e.members,t,(function(e,n){return o.create(n,t,e)}))),i(this,"memberNames",(function(){return e.xmlOrder||Object.keys(e.members)})),e.event&&(i(this,"eventPayloadMemberName",(function(){for(var e=n.members,t=n.memberNames,r=0,i=t.length;r<i;r++)if(e[t[r]].isEventPayload)return t[r]})),i(this,"eventHeaderMemberNames",(function(){for(var e=n.members,t=n.memberNames,r=[],i=0,o=t.length;i<o;i++)e[t[i]].isEventHeader&&r.push(t[i]);return r})))),e.required&&(r(this,"required",e.required),r(this,"isRequired",(function(t){if(!a){a={};for(var n=0;n<e.required.length;n++)a[e.required[n]]=!0}return a[t]}),!1,!0)),r(this,"resultWrapper",e.resultWrapper||null),e.payload&&r(this,"payload",e.payload),"string"==typeof e.xmlNamespace?r(this,"xmlNamespaceUri",e.xmlNamespace):"object"==typeof e.xmlNamespace&&(r(this,"xmlNamespacePrefix",e.xmlNamespace.prefix),r(this,"xmlNamespaceUri",e.xmlNamespace.uri))}function c(e,t){var n=this,a=!this.isShape;if(s.apply(this,arguments),a&&r(this,"defaultValue",(function(){return[]})),e.member&&i(this,"member",(function(){return o.create(e.member,t)})),this.flattened){var c=this.name;i(this,"name",(function(){return n.member.name||c}))}}function u(e,t){var n=!this.isShape;s.apply(this,arguments),n&&(r(this,"defaultValue",(function(){return{}})),r(this,"key",o.create({type:"string"},t)),r(this,"value",o.create({type:"string"},t))),e.key&&i(this,"key",(function(){return o.create(e.key,t)})),e.value&&i(this,"value",(function(){return o.create(e.value,t)}))}function l(){o.apply(this,arguments);var e=["rest-xml","query","ec2"];this.toType=function(t){return t=this.api&&e.indexOf(this.api.protocol)>-1?t||"":t,this.isJsonValue?JSON.parse(t):t&&"function"==typeof t.toString?t.toString():t},this.toWireFormat=function(e){return this.isJsonValue?JSON.stringify(e):e}}function p(){o.apply(this,arguments),this.toType=function(e){var t=m.base64.decode(e);if(this.isSensitive&&m.isNode()&&"function"==typeof m.Buffer.alloc){var n=m.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=m.base64.encode}function d(){p.apply(this,arguments)}function h(){o.apply(this,arguments),this.toType=function(e){return"boolean"==typeof e?e:null==e?null:"true"===e}}var f=e("./collection"),m=e("../util");o.normalizedTypes={character:"string",double:"float",long:"integer",short:"integer",biginteger:"integer",bigdecimal:"float",blob:"binary"},o.types={structure:a,list:c,map:u,boolean:h,timestamp:function(e){var t=this;if(o.apply(this,arguments),e.timestampFormat)r(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)r(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)r(this,"timestampFormat","rfc822");else if("querystring"===this.location)r(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":r(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":r(this,"timestampFormat","iso8601")}this.toType=function(e){return null==e?null:"function"==typeof e.toUTCString?e:"string"==typeof e||"number"==typeof e?m.date.parseTimestamp(e):null},this.toWireFormat=function(e){return m.date.format(e,t.timestampFormat)}},float:function(){o.apply(this,arguments),this.toType=function(e){return null==e?null:parseFloat(e)},this.toWireFormat=this.toType},integer:function(){o.apply(this,arguments),this.toType=function(e){return null==e?null:parseInt(e,10)},this.toWireFormat=this.toType},string:l,base64:d,binary:p},o.resolve=function(e,t){if(e.shape){var n=t.api.shapes[e.shape];if(!n)throw new Error("Cannot find shape reference: "+e.shape);return n}return null},o.create=function(e,t,n){if(e.isShape)return e;var r=o.resolve(e,t);if(r){var i=Object.keys(e);t.documentation||(i=i.filter((function(e){return!e.match(/documentation/)})));var s=function(){r.constructor.call(this,e,t,n)};return s.prototype=r,new s}e.type||(e.members?e.type="structure":e.member?e.type="list":e.key?e.type="map":e.type="string");var a=e.type;if(o.normalizedTypes[e.type]&&(e.type=o.normalizedTypes[e.type]),o.types[e.type])return new o.types[e.type](e,t,n);throw new Error("Unrecognized shape type: "+a)},o.shapes={StructureShape:a,ListShape:c,MapShape:u,StringShape:l,BooleanShape:h,Base64Shape:d},t.exports=o},{"../util":73,"./collection":41}],46:[function(e,t,n){var r=e("./core");r.ParamValidator=r.util.inherit({constructor:function(e){!0!==e&&void 0!==e||(e={min:!0}),this.validation=e},validate:function(e,t,n){if(this.errors=[],this.validateMember(e,t||{},n||"params"),this.errors.length>1){var i=this.errors.join("\n* ");throw i="There were "+this.errors.length+" validation errors:\n* "+i,r.util.error(new Error(i),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(r.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){this.validateType(t,n,["object"],"structure");for(var r,i=0;e.required&&i<e.required.length;i++){null!=t[r=e.required[i]]||this.fail("MissingRequiredParameter","Missing required key '"+r+"' in "+n)}for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var o=t[r],s=e.members[r];if(void 0!==s){var a=[n,r].join(".");this.validateMember(s,o,a)}else this.fail("UnexpectedParameter","Unexpected key '"+r+"' found in "+n)}return!0},validateMember:function(e,t,n){switch(e.type){case"structure":return this.validateStructure(e,t,n);case"list":return this.validateList(e,t,n);case"map":return this.validateMap(e,t,n);default:return this.validateScalar(e,t,n)}},validateList:function(e,t,n){if(this.validateType(t,n,[Array])){this.validateRange(e,t.length,n,"list member count");for(var r=0;r<t.length;r++)this.validateMember(e.member,t[r],n+"["+r+"]")}},validateMap:function(e,t,n){if(this.validateType(t,n,["object"],"map")){var r=0;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.validateMember(e.key,i,n+"[key='"+i+"']"),this.validateMember(e.value,t[i],n+"['"+i+"']"),r++);this.validateRange(e,r,n,"map member count")}},validateScalar:function(e,t,n){switch(e.type){case null:case void 0:case"string":return this.validateString(e,t,n);case"base64":case"binary":return this.validatePayload(t,n);case"integer":case"float":return this.validateNumber(e,t,n);case"boolean":return this.validateType(t,n,["boolean"]);case"timestamp":return this.validateType(t,n,[Date,/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/,"number"],"Date object, ISO-8601 string, or a UNIX timestamp");default:return this.fail("UnkownType","Unhandled type "+e.type+" for "+n)}},validateString:function(e,t,n){var r=["string"];e.isJsonValue&&(r=r.concat(["number","object","boolean"])),null!==t&&this.validateType(t,n,r)&&(this.validateEnum(e,t,n),this.validateRange(e,t.length,n,"string length"),this.validatePattern(e,t,n),this.validateUri(e,t,n))},validateUri:function(e,t,n){"uri"===e.location&&0===t.length&&this.fail("UriParameterError",'Expected uri parameter to have length >= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t<e.min&&this.fail("MinRangeError","Expected "+r+" >= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,i){if(null==e)return!1;for(var o=!1,s=0;s<n.length;s++){if("string"==typeof n[s]){if(typeof e===n[s])return!0}else if(n[s]instanceof RegExp){if((e||"").toString().match(n[s]))return!0}else{if(e instanceof n[s])return!0;if(r.util.isType(e,n[s]))return!0;i||o||(n=n.slice()),n[s]=r.util.typeName(n[s])}o=!0}var a=i;a||(a=n.join(", ").replace(/,([^,]+)$/,", or$1"));var c=a.match(/^[aeiou]/i)?"n":"";return this.fail("InvalidParameterType","Expected "+t+" to be a"+c+" "+a),!1},validateNumber:function(e,t,n){if(null!=t){if("string"==typeof t){var r=parseFloat(t);r.toString()===t&&(t=r)}this.validateType(t,n,["number"])&&this.validateRange(e,t,n,"numeric value")}},validatePayload:function(e,t){if(null!=e&&"string"!=typeof e&&(!e||"number"!=typeof e.byteLength)){if(r.util.isNode()){var n=r.util.stream.Stream;if(r.util.Buffer.isBuffer(e)||e instanceof n)return}else if(void 0!==typeof Blob&&e instanceof Blob)return;var i=["Buffer","Stream","File","Blob","ArrayBuffer","DataView"];if(e)for(var o=0;o<i.length;o++){if(r.util.isType(e,i[o]))return;if(r.util.typeName(e.constructor)===i[o])return}this.fail("InvalidParameterType","Expected "+t+" to be a string, Buffer, Stream, Blob, or typed array object")}}})},{"./core":20}],47:[function(e,t,n){var r=e("../util"),i=e("../core");t.exports={populateHostPrefix:function(e){if(!e.service.config.hostPrefixEnabled)return e;var t=e.service.api.operations[e.operation];if(function(e){var t=e.service.api,n=t.operations[e.operation],i=t.endpointOperation&&t.endpointOperation===r.string.lowerFirst(n.name);return"NULL"!==n.endpointDiscoveryRequired||!0===i}(e))return e;if(t.endpoint&&t.endpoint.hostPrefix){var n=function(e,t,n){return r.each(n.members,(function(n,i){if(!0===i.hostLabel){if("string"!=typeof t[n]||""===t[n])throw r.error(new Error,{message:"Parameter "+n+" should be a non-empty string.",code:"InvalidParameter"});var o=new RegExp("\\{"+n+"\\}","g");e=e.replace(o,t[n])}})),e}(t.endpoint.hostPrefix,e.params,t.input);(function(e,t){e.host&&(e.host=t+e.host),e.hostname&&(e.hostname=t+e.hostname)})(e.httpRequest.endpoint,n),function(e){var t=e.split("."),n=/^[a-zA-Z0-9]{1}$|^[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]$/;r.arrayEach(t,(function(e){if(!e.length||e.length<1||e.length>63)throw r.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!n.test(e))throw i.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}(e.httpRequest.endpoint.hostname)}return e}}},{"../core":20,"../util":73}],48:[function(e,t,n){var r=e("../util"),i=e("../json/builder"),o=e("../json/parser"),s=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,r=n.targetPrefix+"."+n.operations[e.operation].name,o=n.jsonVersion||"1.0",a=n.operations[e.operation].input,c=new i;1===o&&(o="1.0"),t.body=c.build(e.params||{},a),t.headers["Content-Type"]="application/x-amz-json-"+o,t.headers["X-Amz-Target"]=r,s(e)},extractError:function(e){var t={},n=e.httpResponse;if(t.code=n.headers["x-amzn-errortype"]||"UnknownError","string"==typeof t.code&&(t.code=t.code.split(":")[0]),n.body.length>0)try{var i=JSON.parse(n.body.toString()),o=i.__type||i.code||i.Code;o&&(t.code=o.split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=i.message||i.Message||null}catch(i){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=r.error(new Error,t)},extractData:function(e){var t=e.httpResponse.body.toString()||"{}";if(!1===e.request.service.config.convertResponseTypes)e.data=JSON.parse(t);else{var n=e.request.service.api.operations[e.request.operation].output||{},r=new o;e.data=r.parse(t,n)}}}},{"../json/builder":38,"../json/parser":39,"../util":73,"./helpers":47}],49:[function(e,t,n){var r=e("../core"),i=e("../util"),o=e("../query/query_param_serializer"),s=e("../model/shape"),a=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.service.api.operations[e.operation],n=e.httpRequest;n.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8",n.params={Version:e.service.api.apiVersion,Action:t.name},(new o).serialize(e.params,t.input,(function(e,t){n.params[e]=t})),n.body=i.queryParamsToString(n.params),a(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("<UnknownOperationException"))t={Code:"UnknownOperation",Message:"Unknown operation "+e.request.operation};else try{t=(new r.XML.Parser).parse(n)}catch(n){t={Code:e.httpResponse.statusCode,Message:e.httpResponse.statusMessage}}t.requestId&&!e.requestId&&(e.requestId=t.requestId),t.Errors&&(t=t.Errors),t.Error&&(t=t.Error),t.Code?e.error=i.error(new Error,{code:t.Code,message:t.Message}):e.error=i.error(new Error,{code:e.httpResponse.statusCode,message:null})},extractData:function(e){var t=e.request,n=t.service.api.operations[t.operation].output||{},o=n;if(o.resultWrapper){var a=s.create({type:"structure"});a.members[o.resultWrapper]=n,a.memberNames=[o.resultWrapper],i.property(n,"name",n.resultWrapper),n=a}var c=new r.XML.Parser;if(n&&n.members&&!n.members._XAMZRequestId){var u=s.create({type:"string"},{api:{protocol:"query"}},"requestId");n.members._XAMZRequestId=u}var l=c.parse(e.httpResponse.body.toString(),n);e.requestId=l._XAMZRequestId||l.requestId,l._XAMZRequestId&&delete l._XAMZRequestId,o.resultWrapper&&l[o.resultWrapper]&&(i.update(l,l[o.resultWrapper]),delete l[o.resultWrapper]),e.data=l}}},{"../core":20,"../model/shape":45,"../query/query_param_serializer":53,"../util":73,"./helpers":47}],50:[function(e,t,n){function r(e,t,n,r){var o=[e,t].join("/");o=o.replace(/\/+/g,"/");var s={},a=!1;if(i.each(n.members,(function(e,t){var n=r[e];if(null!=n)if("uri"===t.location){var c=new RegExp("\\{"+t.name+"(\\+)?\\}");o=o.replace(c,(function(e,t){return(t?i.uriEscapePath:i.uriEscape)(String(n))}))}else"querystring"===t.location&&(a=!0,"list"===t.type?s[t.name]=n.map((function(e){return i.uriEscape(t.member.toWireFormat(e).toString())})):"map"===t.type?i.each(n,(function(e,t){Array.isArray(t)?s[e]=t.map((function(e){return i.uriEscape(String(e))})):s[e]=i.uriEscape(String(t))})):s[t.name]=i.uriEscape(t.toWireFormat(n).toString()))})),a){o+=o.indexOf("?")>=0?"&":"?";var c=[];i.arrayEach(Object.keys(s).sort(),(function(e){Array.isArray(s[e])||(s[e]=[s[e]]);for(var t=0;t<s[e].length;t++)c.push(i.uriEscape(String(e))+"="+s[e][t])})),o+=c.join("&")}return o}var i=e("../util"),o=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){(function(e){e.httpRequest.method=e.service.api.operations[e.operation].httpMethod})(e),function(e){var t=e.service.api.operations[e.operation],n=t.input,i=r(e.httpRequest.endpoint.path,t.httpPath,n,e.params);e.httpRequest.path=i}(e),function(e){var t=e.service.api.operations[e.operation];i.each(t.input.members,(function(t,n){var r=e.params[t];null!=r&&("headers"===n.location&&"map"===n.type?i.each(r,(function(t,r){e.httpRequest.headers[n.name+t]=r})):"header"===n.location&&(r=n.toWireFormat(r).toString(),n.isJsonValue&&(r=i.base64.encode(r)),e.httpRequest.headers[n.name]=r))}))}(e),o(e)},extractError:function(){},extractData:function(e){var t=e.request,n={},r=e.httpResponse,o=t.service.api.operations[t.operation].output,s={};i.each(r.headers,(function(e,t){s[e.toLowerCase()]=t})),i.each(o.members,(function(e,t){var o=(t.name||e).toLowerCase();if("headers"===t.location&&"map"===t.type){n[e]={};var a=t.isLocationName?t.name:"",c=new RegExp("^"+a+"(.+)","i");i.each(r.headers,(function(t,r){var i=t.match(c);null!==i&&(n[e][i[1]]=r)}))}else if("header"===t.location){if(void 0!==s[o]){var u=t.isJsonValue?i.base64.decode(s[o]):s[o];n[e]=t.toType(u)}}else"statusCode"===t.location&&(n[e]=parseInt(r.statusCode,10))})),e.data=n},generateURI:r}},{"../util":73,"./helpers":47}],51:[function(e,t,n){function r(e,t){if(e.service.api.operations[e.operation].input,!e.httpRequest.headers["Content-Type"]){var n=t?"binary/octet-stream":"application/json";e.httpRequest.headers["Content-Type"]=n}}var i=e("../util"),o=e("./rest"),s=e("./json"),a=e("../json/builder"),c=e("../json/parser");t.exports={buildRequest:function(e){o.buildRequest(e),["HEAD","DELETE"].indexOf(e.httpRequest.method)<0&&function(e){var t=new a,n=e.service.api.operations[e.operation].input;if(n.payload){var i,o=n.members[n.payload];if(void 0===(i=e.params[n.payload]))return;"structure"===o.type?(e.httpRequest.body=t.build(i,o),r(e)):(e.httpRequest.body=i,("binary"===o.type||o.isStreaming)&&r(e,!0))}else{var s=t.build(e.params,n);"{}"===s&&"GET"===e.httpRequest.method||(e.httpRequest.body=s),r(e)}}(e)},extractError:function(e){s.extractError(e)},extractData:function(e){o.extractData(e);var t=e.request,n=t.service.api.operations[t.operation],r=t.service.api.operations[t.operation].output||{};if(n.hasEventOutput,r.payload){var a=r.members[r.payload],u=e.httpResponse.body;if(a.isEventStream)l=new c,e.data[payload]=i.createEventStream(2===AWS.HttpClient.streamsApiVersion?e.httpResponse.stream:u,l,a);else if("structure"===a.type||"list"===a.type){var l=new c;e.data[r.payload]=l.parse(u,a)}else"binary"===a.type||a.isStreaming?e.data[r.payload]=u:e.data[r.payload]=a.toType(u)}else{var p=e.data;s.extractData(e),e.data=i.merge(p,e.data)}}}},{"../json/builder":38,"../json/parser":39,"../util":73,"./json":48,"./rest":50}],52:[function(e,t,n){var r=e("../core"),i=e("../util"),o=e("./rest");t.exports={buildRequest:function(e){o.buildRequest(e),["GET","HEAD"].indexOf(e.httpRequest.method)<0&&function(e){var t=e.service.api.operations[e.operation].input,n=new r.XML.Builder,o=e.params,s=t.payload;if(s){var a=t.members[s];if(void 0===(o=o[s]))return;if("structure"===a.type){var c=a.name;e.httpRequest.body=n.toXML(o,a,c,!0)}else e.httpRequest.body=o}else e.httpRequest.body=n.toXML(o,t,t.name||t.shape||i.string.upperFirst(e.operation)+"Request")}(e)},extractError:function(e){var t;o.extractError(e);try{t=(new r.XML.Parser).parse(e.httpResponse.body.toString())}catch(n){t={Code:e.httpResponse.statusCode,Message:e.httpResponse.statusMessage}}t.Errors&&(t=t.Errors),t.Error&&(t=t.Error),t.Code?e.error=i.error(new Error,{code:t.Code,message:t.Message}):e.error=i.error(new Error,{code:e.httpResponse.statusCode,message:null})},extractData:function(e){o.extractData(e);var t,n=e.request,s=e.httpResponse.body,a=n.service.api.operations[n.operation],c=a.output,u=(a.hasEventOutput,c.payload);if(u){var l=c.members[u];l.isEventStream?(t=new r.XML.Parser,e.data[u]=i.createEventStream(2===r.HttpClient.streamsApiVersion?e.httpResponse.stream:e.httpResponse.body,t,l)):"structure"===l.type?(t=new r.XML.Parser,e.data[u]=t.parse(s.toString(),l)):"binary"===l.type||l.isStreaming?e.data[u]=s:e.data[u]=l.toType(s)}else if(s.length>0){var p=(t=new r.XML.Parser).parse(s.toString(),c);i.update(e.data,p)}}}},{"../core":20,"../util":73,"./rest":50}],53:[function(e,t,n){function r(){}function i(e){return e.isQueryName||"ec2"!==e.api.protocol?e.name:e.name[0].toUpperCase()+e.name.substr(1)}function o(e,t,n,r){a.each(n.members,(function(n,o){var a=t[n];if(null!=a){var c=i(o);s(c=e?e+"."+c:c,a,o,r)}}))}function s(e,t,n,r){null!=t&&("structure"===n.type?o(e,t,n,r):"list"===n.type?function(e,t,n,r){var o=n.member||{};0!==t.length?a.arrayEach(t,(function(t,a){var c="."+(a+1);if("ec2"===n.api.protocol)c+="";else if(n.flattened){if(o.name){var u=e.split(".");u.pop(),u.push(i(o)),e=u.join(".")}}else c="."+(o.name?o.name:"member")+c;s(e+c,t,o,r)})):r.call(this,e,null)}(e,t,n,r):"map"===n.type?function(e,t,n,r){var i=1;a.each(t,(function(t,o){var a=(n.flattened?".":".entry.")+i+++".",c=a+(n.key.name||"key"),u=a+(n.value.name||"value");s(e+c,t,n.key,r),s(e+u,o,n.value,r)}))}(e,t,n,r):r(e,n.toWireFormat(t).toString()))}var a=e("../util");r.prototype.serialize=function(e,t,n){o("",e,t,n)},t.exports=r},{"../util":73}],54:[function(e,t,n){t.exports={now:function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}}},{}],55:[function(e,t,n){function r(e,t){i.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}var i=e("./util"),o=e("./region_config_data.json");t.exports={configureEndpoint:function(e){for(var t=function(e){var t=e.config.region,n=function(e){if(!e)return null;var t=e.split("-");return t.length<3?null:t.slice(0,t.length-2).join("-")+"-*"}(t),r=e.api.endpointPrefix;return[[t,r],[n,r],[t,"*"],[n,"*"],["*",r],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=0;n<t.length;n++){var s=t[n];if(s&&Object.prototype.hasOwnProperty.call(o.rules,s)){var a=o.rules[s];return"string"==typeof a&&(a=o.patterns[a]),e.config.useDualstack&&i.isDualstackAvailable(e)&&((a=i.copy(a)).endpoint=a.endpoint.replace(/{service}\.({region}\.)?/,"{service}.dualstack.{region}.")),e.isGlobalEndpoint=!!a.globalEndpoint,a.signingRegion&&(e.signingRegion=a.signingRegion),a.signatureVersion||(a.signatureVersion="v4"),void r(e,a)}}},getEndpointSuffix:function(e){for(var t={"^(us|eu|ap|sa|ca|me)\\-\\w+\\-\\d+$":"amazonaws.com","^cn\\-\\w+\\-\\d+$":"amazonaws.com.cn","^us\\-gov\\-\\w+\\-\\d+$":"amazonaws.com","^us\\-iso\\-\\w+\\-\\d+$":"c2s.ic.gov","^us\\-isob\\-\\w+\\-\\d+$":"sc2s.sgov.gov"},n=Object.keys(t),r=0;r<n.length;r++){var i=RegExp(n[r]),o=t[n[r]];if(i.test(e))return o}return"amazonaws.com"}}},{"./region_config_data.json":56,"./util":73}],56:[function(e,t,n){t.exports={rules:{"*/*":{endpoint:"{service}.{region}.amazonaws.com"},"cn-*/*":{endpoint:"{service}.{region}.amazonaws.com.cn"},"us-iso-*/*":{endpoint:"{service}.{region}.c2s.ic.gov"},"us-isob-*/*":{endpoint:"{service}.{region}.sc2s.sgov.gov"},"*/budgets":"globalSSL","*/cloudfront":"globalSSL","*/sts":"globalSSL","*/importexport":{endpoint:"{service}.amazonaws.com",signatureVersion:"v2",globalEndpoint:!0},"*/route53":"globalSSL","cn-*/route53":{endpoint:"{service}.amazonaws.com.cn",globalEndpoint:!0,signingRegion:"cn-northwest-1"},"us-gov-*/route53":"globalGovCloud","*/waf":"globalSSL","*/iam":"globalSSL","cn-*/iam":{endpoint:"{service}.cn-north-1.amazonaws.com.cn",globalEndpoint:!0,signingRegion:"cn-north-1"},"us-gov-*/iam":"globalGovCloud","us-gov-*/sts":{endpoint:"{service}.{region}.amazonaws.com"},"us-gov-west-1/s3":"s3signature","us-west-1/s3":"s3signature","us-west-2/s3":"s3signature","eu-west-1/s3":"s3signature","ap-southeast-1/s3":"s3signature","ap-southeast-2/s3":"s3signature","ap-northeast-1/s3":"s3signature","sa-east-1/s3":"s3signature","us-east-1/s3":{endpoint:"{service}.amazonaws.com",signatureVersion:"s3"},"us-east-1/sdb":{endpoint:"{service}.amazonaws.com",signatureVersion:"v2"},"*/sdb":{endpoint:"{service}.{region}.amazonaws.com",signatureVersion:"v2"}},patterns:{globalSSL:{endpoint:"https://{service}.amazonaws.com",globalEndpoint:!0,signingRegion:"us-east-1"},globalGovCloud:{endpoint:"{service}.us-gov.amazonaws.com",globalEndpoint:!0,signingRegion:"us-gov-west-1"},s3signature:{endpoint:"{service}.{region}.amazonaws.com",signatureVersion:"s3"}}}},{}],57:[function(e,t,n){(function(t){(function(){var n=e("./core"),r=e("./state_machine"),i=n.util.inherit,o=n.util.domain,s=e("jmespath"),a={success:1,error:1,complete:1},c=new r;c.setupStates=function(){var e=function(e,t){var n=this;n._haltHandlersOnError=!1,n.emit(n._asm.currentState,(function(e){if(e)if(function(e){return Object.prototype.hasOwnProperty.call(a,e._asm.currentState)}(n)){if(!(o&&n.domain instanceof o.Domain))throw e;e.domainEmitter=n,e.domain=n.domain,e.domainThrown=!1,n.domain.emit("error",e)}else n.response.error=e,t(e);else t(n.response.error)}))};this.addState("validate","build","error",e),this.addState("build","afterBuild","restart",e),this.addState("afterBuild","sign","restart",e),this.addState("sign","send","retry",e),this.addState("retry","afterRetry","afterRetry",e),this.addState("afterRetry","sign","error",e),this.addState("send","validateResponse","retry",e),this.addState("validateResponse","extractData","extractError",e),this.addState("extractError","extractData","retry",e),this.addState("extractData","success","retry",e),this.addState("restart","build","error",e),this.addState("success","complete","complete",e),this.addState("error","complete","complete",e),this.addState("complete",null,null,e)},c.setupStates(),n.Request=i({constructor:function(e,t,i){var s=e.endpoint,a=e.config.region,u=e.config.customUserAgent;e.isGlobalEndpoint&&(a=e.signingRegion?e.signingRegion:"us-east-1"),this.domain=o&&o.active,this.service=e,this.operation=t,this.params=i||{},this.httpRequest=new n.HttpRequest(s,a),this.httpRequest.appendToUserAgent(u),this.startTime=e.getSkewCorrectedDate(),this.response=new n.Response(this),this._asm=new r(c.states,"validate"),this._haltHandlersOnError=!1,n.SequentialExecutor.call(this),this.emit=this.emitEvent},send:function(e){return e&&(this.httpRequest.appendToUserAgent("callback"),this.on("complete",(function(t){e.call(t,t.error,t.data)}))),this.runTo(),this.response},build:function(e){return this.runTo("send",e)},runTo:function(e,t){return this._asm.runTo(e,t,this),this},abort:function(){return this.removeAllListeners("validateResponse"),this.removeAllListeners("extractError"),this.on("validateResponse",(function(e){e.error=n.util.error(new Error("Request aborted by user"),{code:"RequestAbortedError",retryable:!1})})),this.httpRequest.stream&&!this.httpRequest.stream.didCallback&&(this.httpRequest.stream.abort(),this.httpRequest._abortCallback?this.httpRequest._abortCallback():this.removeAllListeners("send")),this},eachPage:function(e){e=n.util.fn.makeAsync(e,3),this.on("complete",(function t(r){e.call(r,r.error,r.data,(function(i){!1!==i&&(r.hasNextPage()?r.nextPage().on("complete",t).send():e.call(r,null,null,n.util.fn.noop))}))})).send()},eachItem:function(e){var t=this;this.eachPage((function(r,i){if(r)return e(r,null);if(null===i)return e(null,null);var o=t.service.paginationConfig(t.operation).resultKey;Array.isArray(o)&&(o=o[0]);var a=s.search(i,o),c=!0;return n.util.arrayEach(a,(function(t){if(!1===(c=e(null,t)))return n.util.abort})),c}))},isPageable:function(){return!!this.service.paginationConfig(this.operation)},createReadStream:function(){var e=n.util.stream,r=this,i=null;return 2===n.HttpClient.streamsApiVersion?(i=new e.PassThrough,t.nextTick((function(){r.send()}))):((i=new e.Stream).readable=!0,i.sent=!1,i.on("newListener",(function(e){i.sent||"data"!==e||(i.sent=!0,t.nextTick((function(){r.send()})))}))),this.on("error",(function(e){i.emit("error",e)})),this.on("httpHeaders",(function(t,o,s){if(t<300){r.removeListener("httpData",n.EventListeners.Core.HTTP_DATA),r.removeListener("httpError",n.EventListeners.Core.HTTP_ERROR),r.on("httpError",(function(e){s.error=e,s.error.retryable=!1}));var a,c=!1;if("HEAD"!==r.httpRequest.method&&(a=parseInt(o["content-length"],10)),void 0!==a&&!isNaN(a)&&a>=0){c=!0;var u=0}var l=function(){c&&u!==a?i.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+a+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?i.end():i.emit("end")},p=s.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(c){var d=new e.PassThrough;d._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},d.on("end",l),i.on("error",(function(e){c=!1,p.unpipe(d),d.emit("end"),d.end()})),p.pipe(d).pipe(i,{end:!1})}else p.pipe(i);else c&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){i.emit("data",e)})),p.on("end",l);p.on("error",(function(e){c=!1,i.emit("error",e)}))}})),i},emitEvent:function(e,t,r){"function"==typeof t&&(r=t,t=null),r||(r=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),r.call(this,e)}))},eventParameters:function(e){switch(e){case"restart":case"validate":case"sign":case"build":case"afterValidate":case"afterBuild":return[this];case"error":return[this.response.error,this.response];default:return[this.response]}},presign:function(e,t){return t||"function"!=typeof e||(t=e,e=null),(new n.Signers.Presign).sign(this.toGet(),e,t)},isPresigned:function(){return Object.prototype.hasOwnProperty.call(this.httpRequest.headers,"presigned-expires")},toUnauthenticated:function(){return this._unAuthenticated=!0,this.removeListener("validate",n.EventListeners.Core.VALIDATE_CREDENTIALS),this.removeListener("sign",n.EventListeners.Core.SIGN),this},toGet:function(){return"query"!==this.service.api.protocol&&"ec2"!==this.service.api.protocol||(this.removeListener("build",this.buildAsGet),this.addListener("build",this.buildAsGet)),this},buildAsGet:function(e){e.httpRequest.method="GET",e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body,e.httpRequest.body="",delete e.httpRequest.headers["Content-Length"],delete e.httpRequest.headers["Content-Type"]},haltHandlersOnError:function(){this._haltHandlersOnError=!0}}),n.Request.addPromisesToClass=function(e){this.prototype.promise=function(){var t=this;return this.httpRequest.appendToUserAgent("promise"),new e((function(e,n){t.on("complete",(function(t){t.error?n(t.error):e(Object.defineProperty(t.data||{},"$response",{value:t}))})),t.runTo()}))}},n.Request.deletePromisesFromClass=function(){delete this.prototype.promise},n.util.addPromises(n.Request),n.util.mixin(n.Request,n.SequentialExecutor)}).call(this)}).call(this,e("_process"))},{"./core":20,"./state_machine":72,_process:87,jmespath:86}],58:[function(e,t,n){function r(e){var t=e.request._waiter,n=t.config.acceptors,r=!1,i="retry";n.forEach((function(n){if(!r){var o=t.matchers[n.matcher];o&&o(e,n.expected,n.argument)&&(r=!0,i=n.state)}})),!r&&e.error&&(i="failure"),"success"===i?t.setSuccess(e):t.setError(e,"retry"===i)}var i=e("./core"),o=i.util.inherit,s=e("jmespath");i.ResourceWaiter=o({constructor:function(e,t){this.service=e,this.state=t,this.loadWaiterConfig(this.state)},service:null,state:null,config:null,matchers:{path:function(e,t,n){try{var r=s.search(e.data,n)}catch(e){return!1}return s.strictDeepEqual(r,t)},pathAll:function(e,t,n){try{var r=s.search(e.data,n)}catch(e){return!1}Array.isArray(r)||(r=[r]);var i=r.length;if(!i)return!1;for(var o=0;o<i;o++)if(!s.strictDeepEqual(r[o],t))return!1;return!0},pathAny:function(e,t,n){try{var r=s.search(e.data,n)}catch(e){return!1}Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++)if(s.strictDeepEqual(r[o],t))return!0;return!1},status:function(e,t){var n=e.httpResponse.statusCode;return"number"==typeof n&&n===t},error:function(e,t){return"string"==typeof t&&e.error?t===e.error.code:t===!!e.error}},listeners:(new i.SequentialExecutor).addNamedListeners((function(e){e("RETRY_CHECK","retry",(function(e){var t=e.request._waiter;e.error&&"ResourceNotReady"===e.error.code&&(e.error.retryDelay=1e3*(t.config.delay||0))})),e("CHECK_OUTPUT","extractData",r),e("CHECK_ERROR","extractError",r)})),wait:function(e,t){"function"==typeof e&&(t=e,e=void 0),e&&e.$waiter&&("number"==typeof(e=i.util.copy(e)).$waiter.delay&&(this.config.delay=e.$waiter.delay),"number"==typeof e.$waiter.maxAttempts&&(this.config.maxAttempts=e.$waiter.maxAttempts),delete e.$waiter);var n=this.service.makeRequest(this.config.operation,e);return n._waiter=this,n.response.maxRetries=this.config.maxAttempts,n.addListeners(this.listeners),t&&n.send(t),n},setSuccess:function(e){e.error=null,e.data=e.data||{},e.request.removeAllListeners("extractData")},setError:function(e,t){e.data=null,e.error=i.util.error(e.error||new Error,{code:"ResourceNotReady",message:"Resource is not in the state "+this.state,retryable:t})},loadWaiterConfig:function(e){if(!this.service.api.waiters[e])throw new i.util.error(new Error,{code:"StateNotFoundError",message:"State "+e+" not found."});this.config=i.util.copy(this.service.api.waiters[e])}})},{"./core":20,jmespath:86}],59:[function(e,t,n){var r=e("./core"),i=r.util.inherit,o=e("jmespath");r.Response=i({constructor:function(e){this.request=e,this.data=null,this.error=null,this.retryCount=0,this.redirectCount=0,this.httpResponse=new r.HttpResponse,e&&(this.maxRetries=e.service.numRetries(),this.maxRedirects=e.service.config.maxRedirects)},nextPage:function(e){var t,n=this.request.service,i=this.request.operation;try{t=n.paginationConfig(i,!0)}catch(e){this.error=e}if(!this.hasNextPage()){if(e)e(this.error,null);else if(this.error)throw this.error;return null}var o=r.util.copy(this.request.params);if(this.nextPageTokens){var s=t.inputToken;"string"==typeof s&&(s=[s]);for(var a=0;a<s.length;a++)o[s[a]]=this.nextPageTokens[a];return n.makeRequest(this.request.operation,o,e)}return e?e(null,null):null},hasNextPage:function(){return this.cacheNextPageTokens(),!!this.nextPageTokens||void 0===this.nextPageTokens&&void 0},cacheNextPageTokens:function(){if(Object.prototype.hasOwnProperty.call(this,"nextPageTokens"))return this.nextPageTokens;this.nextPageTokens=void 0;var e=this.request.service.paginationConfig(this.request.operation);if(!e)return this.nextPageTokens;if(this.nextPageTokens=null,e.moreResults&&!o.search(this.data,e.moreResults))return this.nextPageTokens;var t=e.outputToken;return"string"==typeof t&&(t=[t]),r.util.arrayEach.call(this,t,(function(e){var t=o.search(this.data,e);t&&(this.nextPageTokens=this.nextPageTokens||[],this.nextPageTokens.push(t))})),this.nextPageTokens}})},{"./core":20,jmespath:86}],60:[function(e,t,n){var r=e("./core");r.SequentialExecutor=r.util.inherit({constructor:function(){this._events={}},listeners:function(e){return this._events[e]?this._events[e].slice(0):[]},on:function(e,t,n){return this._events[e]?n?this._events[e].unshift(t):this._events[e].push(t):this._events[e]=[t],this},onAsync:function(e,t,n){return t._isAsync=!0,this.on(e,t,n)},removeListener:function(e,t){var n=this._events[e];if(n){for(var r=n.length,i=-1,o=0;o<r;++o)n[o]===t&&(i=o);i>-1&&n.splice(i,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var r=this.listeners(e),i=r.length;return this.callListeners(r,t,n),i>0},callListeners:function(e,t,n,i){function o(i){if(i&&(a=r.util.error(a||new Error,i),s._haltHandlersOnError))return n.call(s,a);s.callListeners(e,t,n,a)}for(var s=this,a=i||null;e.length>0;){var c=e.shift();if(c._isAsync)return void c.apply(s,t.concat([o]));try{c.apply(s,t)}catch(e){a=r.util.error(a||new Error,e)}if(a&&s._haltHandlersOnError)return void n.call(s,a)}n.call(s,a)},addListeners:function(e){var t=this;return e._events&&(e=e._events),r.util.each(e,(function(e,n){"function"==typeof n&&(n=[n]),r.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,r){return this[e]=n,this.addListener(t,n,r),this},addNamedAsyncListener:function(e,t,n,r){return n._isAsync=!0,this.addNamedListener(e,t,n,r)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),r.SequentialExecutor.prototype.addListener=r.SequentialExecutor.prototype.on,t.exports=r.SequentialExecutor},{"./core":20}],61:[function(e,t,n){(function(n){(function(){var r=e("./core"),i=e("./model/api"),o=e("./region_config"),s=r.util.inherit,a=0;r.Service=s({constructor:function(e){if(!this.loadServiceClass)throw r.util.error(new Error,"Service must be constructed with `new' operator");var t=this.loadServiceClass(e||{});if(t){var n=r.util.copy(e),i=new t(e);return Object.defineProperty(i,"_originalConfig",{get:function(){return n},enumerable:!1,configurable:!0}),i._clientId=++a,i}this.initialize(e)},initialize:function(e){var t=r.config[this.serviceIdentifier];if(this.config=new r.Config(r.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||o.configureEndpoint(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),r.SequentialExecutor.call(this),r.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||r.Service._clientSideMonitoring)&&this.publisher){var i=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){i.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){i.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(r.util.isEmpty(this.api)){if(t.apiConfig)return r.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new r.Config(r.config)).update(e,!0);var n=t.apiVersions[this.constructor.serviceIdentifier];return n=n||t.apiVersion,this.getLatestServiceClass(n)}return null}return null},getLatestServiceClass:function(e){return e=this.getLatestServiceVersion(e),null===this.constructor.services[e]&&r.Service.defineServiceApi(this.constructor,e),this.constructor.services[e]},getLatestServiceVersion:function(e){if(!this.constructor.services||0===this.constructor.services.length)throw new Error("No services defined on "+this.constructor.serviceIdentifier);if(e?r.util.isType(e,Date)&&(e=r.util.date.iso8601(e).split("T")[0]):e="latest",Object.hasOwnProperty(this.constructor.services,e))return e;for(var t=Object.keys(this.constructor.services).sort(),n=null,i=t.length-1;i>=0;i--)if("*"!==t[i][t[i].length-1]&&(n=t[i]),t[i].substr(0,10)<=e)return n;throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,customizeRequests:function(e){if(e){if("function"!=typeof e)throw new Error("Invalid callback type '"+typeof e+"' provided in customizeRequests");this.customRequestHandler=e}else this.customRequestHandler=null},makeRequest:function(e,t,n){if("function"==typeof t&&(n=t,t=null),t=t||{},this.config.params){var i=this.api.operations[e];i&&(t=r.util.copy(t),r.util.each(this.config.params,(function(e,n){i.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var o=new r.Request(this,e,t);return this.addAllRequestListeners(o),this.attachMonitoringEmitter(o),n&&o.send(n),o},makeUnauthenticatedRequest:function(e,t,n){"function"==typeof t&&(n=t,t={});var r=this.makeRequest(e,t).toUnauthenticated();return n?r.send(n):r},waitFor:function(e,t,n){return new r.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[r.events,r.EventListeners.Core,this.serviceInterface(),r.EventListeners.CorePost],n=0;n<t.length;n++)t[n]&&e.addListeners(t[n]);this.config.paramValidation||e.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),this.config.logger&&e.addListeners(r.EventListeners.Logger),this.setupRequestListeners(e),"function"==typeof this.constructor.prototype.customRequestHandler&&this.constructor.prototype.customRequestHandler(e),Object.prototype.hasOwnProperty.call(this,"customRequestHandler")&&"function"==typeof this.customRequestHandler&&this.customRequestHandler(e)},apiCallEvent:function(e){var t=e.service.api.operations[e.operation],n={Type:"ApiCall",Api:t?t.name:e.operation,Version:1,Service:e.service.api.serviceId||e.service.api.endpointPrefix,Region:e.httpRequest.region,MaxRetriesExceeded:0,UserAgent:e.httpRequest.getUserAgent()},r=e.response;if(r.httpResponse.statusCode&&(n.FinalHttpStatusCode=r.httpResponse.statusCode),r.error){var i=r.error;r.httpResponse.statusCode>299?(i.code&&(n.FinalAwsException=i.code),i.message&&(n.FinalAwsExceptionMessage=i.message)):((i.code||i.name)&&(n.FinalSdkException=i.code||i.name),i.message&&(n.FinalSdkExceptionMessage=i.message))}return n},apiAttemptEvent:function(e){var t=e.service.api.operations[e.operation],n={Type:"ApiCallAttempt",Api:t?t.name:e.operation,Version:1,Service:e.service.api.serviceId||e.service.api.endpointPrefix,Fqdn:e.httpRequest.endpoint.hostname,UserAgent:e.httpRequest.getUserAgent()},r=e.response;return r.httpResponse.statusCode&&(n.HttpStatusCode=r.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),r.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),r.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=r.httpResponse.headers["x-amzn-requestid"]),r.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=r.httpResponse.headers["x-amz-request-id"]),r.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=r.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,r=n.error;return n.httpResponse.statusCode>299?(r.code&&(t.AwsException=r.code),r.message&&(t.AwsExceptionMessage=r.message)):((r.code||r.name)&&(t.SdkException=r.code||r.name),r.message&&(t.SdkExceptionMessage=r.message)),t},attachMonitoringEmitter:function(e){var t,n,i,o,s,a,c=0,u=this;e.on("validate",(function(){o=r.util.realClock.now(),a=Date.now()}),!0),e.on("sign",(function(){n=r.util.realClock.now(),t=Date.now(),s=e.httpRequest.region,c++}),!0),e.on("validateResponse",(function(){i=Math.round(r.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=i>=0?i:0,n.Region=s,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var o=u.attemptFailEvent(e);o.Timestamp=t,i=i||Math.round(r.util.realClock.now()-n),o.AttemptLatency=i>=0?i:0,o.Region=s,u.emit("apiCallAttempt",[o])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=c,!(t.AttemptCount<=0)){t.Timestamp=a;var n=Math.round(r.util.realClock.now()-o);t.Latency=n>=0?n:0;var i=e.response;i.error&&i.error.retryable&&"number"==typeof i.retryCount&&"number"==typeof i.maxRetries&&i.retryCount>=i.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSigningName:function(){return this.api.signingName||this.api.endpointPrefix},getSignerClass:function(e){var t,n=null,i="";return e&&(i=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===i||"v4-unsigned-body"===i?"v4":this.api.signatureVersion,r.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return r.EventListeners.Query;case"json":return r.EventListeners.Json;case"rest-json":return r.EventListeners.RestJson;case"rest-xml":return r.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e,t){return r.util.calculateRetryDelay(e,this.config.retryDelayOptions,t)},retryableError:function(e){return!!this.timeoutError(e)||!!this.networkingError(e)||!!this.expiredCredentialsError(e)||!!this.throttledError(e)||e.statusCode>=500},networkingError:function(e){return"NetworkingError"===e.code},timeoutError:function(e){return"TimeoutError"===e.code},expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},clockSkewError:function(e){switch(e.code){case"RequestTimeTooSkewed":case"RequestExpired":case"InvalidSignatureException":case"SignatureDoesNotMatch":case"AuthFailure":case"RequestInTheFuture":return!0;default:return!1}},getSkewCorrectedDate:function(){return new Date(Date.now()+this.config.systemClockOffset)},applyClockOffset:function(e){e&&(this.config.systemClockOffset=e-Date.now())},isClockSkewed:function(e){if(e)return Math.abs(this.getSkewCorrectedDate().getTime()-e)>=3e5},throttledError:function(e){if(429===e.statusCode)return!0;switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":case"ThrottlingException":case"RequestLimitExceeded":case"RequestThrottled":case"RequestThrottledException":case"TooManyRequestsException":case"TransactionInProgressException":case"EC2ThrottledException":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;return e.replace(/\{service\}/g,this.api.endpointPrefix).replace(/\{region\}/g,this.config.region).replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new r.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var i=new Error;throw r.util.error(i,"No pagination configuration for "+e)}return null}return n}}),r.util.update(r.Service,{defineMethods:function(e){r.util.each(e.prototype.api.operations,(function(t){e.prototype[t]||("none"===e.prototype.api.operations[t].authtype?e.prototype[t]=function(e,n){return this.makeUnauthenticatedRequest(t,e,n)}:e.prototype[t]=function(e,n){return this.makeRequest(t,e,n)})}))},defineService:function(e,t,n){r.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var i=s(r.Service,n||{});if("string"==typeof e){r.Service.addVersions(i,t);var o=i.serviceIdentifier||e;i.serviceIdentifier=o}else i.prototype.api=e,r.Service.defineMethods(i);if(r.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&r.util.clientSideMonitoring){var a=r.util.clientSideMonitoring.Publisher,c=(0,r.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new a(c),c.enabled&&(r.Service._clientSideMonitoring=!0)}return r.SequentialExecutor.call(i.prototype),r.Service.addDefaultMonitoringListeners(i.prototype),i},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n<t.length;n++)void 0===e.services[t[n]]&&(e.services[t[n]]=null);e.apiVersions=Object.keys(e.services).sort()},defineServiceApi:function(e,t,n){function o(t){t.isApi?a.prototype.api=t:a.prototype.api=new i(t,{serviceIdentifier:e.serviceIdentifier})}var a=s(e,{serviceIdentifier:e.serviceIdentifier});if("string"==typeof t){if(n)o(n);else try{o(r.apiLoader(e.serviceIdentifier,t))}catch(n){throw r.util.error(n,{message:"Could not find API configuration "+e.serviceIdentifier+"-"+t})}Object.prototype.hasOwnProperty.call(e.services,t)||(e.apiVersions=e.apiVersions.concat(t).sort()),e.services[t]=a}else o(t);return r.Service.defineMethods(a),a},hasService:function(e){return Object.prototype.hasOwnProperty.call(r.Service._serviceMap,e)},addDefaultMonitoringListeners:function(e){e.addNamedListener("MONITOR_EVENTS_BUBBLE","apiCallAttempt",(function(t){var n=Object.getPrototypeOf(e);n._events&&n.emit("apiCallAttempt",[t])})),e.addNamedListener("CALL_EVENTS_BUBBLE","apiCall",(function(t){var n=Object.getPrototypeOf(e);n._events&&n.emit("apiCall",[t])}))},_serviceMap:{}}),r.util.mixin(r.Service,r.SequentialExecutor),t.exports=r.Service}).call(this)}).call(this,e("_process"))},{"./core":20,"./model/api":40,"./region_config":55,_process:87}],62:[function(e,t,n){var r=e("../core");r.util.update(r.CognitoIdentity.prototype,{getOpenIdToken:function(e,t){return this.makeUnauthenticatedRequest("getOpenIdToken",e,t)},getId:function(e,t){return this.makeUnauthenticatedRequest("getId",e,t)},getCredentialsForIdentity:function(e,t){return this.makeUnauthenticatedRequest("getCredentialsForIdentity",e,t)}})},{"../core":20}],63:[function(e,t,n){var r=e("../core"),i=e("../config_regional_endpoint");r.util.update(r.STS.prototype,{credentialsFrom:function(e,t){return e?(t||(t=new r.TemporaryCredentials),t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretAccessKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration,t):null},assumeRoleWithWebIdentity:function(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithWebIdentity",e,t)},assumeRoleWithSAML:function(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithSAML",e,t)},setupRequestListeners:function(e){e.addListener("validate",this.optInRegionalEndpoint,!0)},optInRegionalEndpoint:function(e){var t=e.service,n=t.config;if(n.stsRegionalEndpoints=i(t._originalConfig,{env:"AWS_STS_REGIONAL_ENDPOINTS",sharedConfig:"sts_regional_endpoints",clientConfig:"stsRegionalEndpoints"}),"regional"===n.stsRegionalEndpoints&&t.isGlobalEndpoint){if(!n.region)throw r.util.error(new Error,{code:"ConfigError",message:"Missing region in config"});var o=n.endpoint.indexOf(".amazonaws.com"),s=n.endpoint.substring(0,o)+"."+n.region+n.endpoint.substring(o);e.httpRequest.updateEndpoint(s),e.httpRequest.region=n.region}}})},{"../config_regional_endpoint":19,"../core":20}],64:[function(e,t,n){function r(e){var t=e.httpRequest.headers[a],n=e.service.getSignerClass(e);if(delete e.httpRequest.headers["User-Agent"],delete e.httpRequest.headers["X-Amz-User-Agent"],n===o.Signers.V4){if(t>604800)throw o.util.error(new Error,{code:"InvalidExpiryTime",message:"Presigning does not support expiry time greater than a week with SigV4 signing.",retryable:!1});e.httpRequest.headers[a]=t}else{if(n!==o.Signers.S3)throw o.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var r=e.service?e.service.getSkewCorrectedDate():o.util.date.getDate();e.httpRequest.headers[a]=parseInt(o.util.date.unixTimestamp(r)+t,10).toString()}}function i(e){var t=e.httpRequest.endpoint,n=o.util.urlParse(e.httpRequest.path),r={};n.search&&(r=o.util.queryStringParse(n.search.substr(1)));var i=e.httpRequest.headers.Authorization.split(" ");if("AWS"===i[0])i=i[1].split(":"),r.Signature=i.pop(),r.AWSAccessKeyId=i.join(":"),o.util.each(e.httpRequest.headers,(function(e,t){e===a&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete r[e],e=e.toLowerCase()),r[e]=t})),delete e.httpRequest.headers[a],delete r.Authorization,delete r.Host;else if("AWS4-HMAC-SHA256"===i[0]){i.shift();var s=i.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];r["X-Amz-Signature"]=s,delete r.Expires}t.pathname=n.pathname,t.search=o.util.queryParamsToString(r)}var o=e("../core"),s=o.util.inherit,a="presigned-expires";o.Signers.Presign=s({sign:function(e,t,n){if(e.httpRequest.headers[a]=t||3600,e.on("build",r),e.on("sign",i),e.removeListener("afterBuild",o.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",o.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return o.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,o.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=o.Signers.Presign},{"../core":20}],65:[function(e,t,n){var r=e("../core"),i=r.util.inherit;r.Signers.RequestSigner=i({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),r.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return r.Signers.V2;case"v3":return r.Signers.V3;case"s3v4":case"v4":return r.Signers.V4;case"s3":return r.Signers.S3;case"v3https":return r.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":20,"./presign":64,"./s3":66,"./v2":67,"./v3":68,"./v3https":69,"./v4":70}],66:[function(e,t,n){var r=e("../core"),i=r.util.inherit;r.Signers.S3=i(r.Signers.RequestSigner,{subResources:{acl:1,accelerate:1,analytics:1,cors:1,lifecycle:1,delete:1,inventory:1,location:1,logging:1,metrics:1,notification:1,partNumber:1,policy:1,requestPayment:1,replication:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function(e,t){this.request.headers["presigned-expires"]||(this.request.headers["X-Amz-Date"]=r.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),i="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=i},stringToSign:function(){var e=this.request,t=[];t.push(e.method),t.push(e.headers["Content-MD5"]||""),t.push(e.headers["Content-Type"]||""),t.push(e.headers["presigned-expires"]||"");var n=this.canonicalizedAmzHeaders();return n&&t.push(n),t.push(this.canonicalizedResource()),t.join("\n")},canonicalizedAmzHeaders:function(){var e=[];r.util.each(this.request.headers,(function(t){t.match(/^x-amz-/i)&&e.push(t)})),e.sort((function(e,t){return e.toLowerCase()<t.toLowerCase()?-1:1}));var t=[];return r.util.arrayEach.call(this,e,(function(e){t.push(e.toLowerCase()+":"+String(this.request.headers[e]))})),t.join("\n")},canonicalizedResource:function(){var e=this.request,t=e.path.split("?"),n=t[0],i=t[1],o="";if(e.virtualHostedBucket&&(o+="/"+e.virtualHostedBucket),o+=n,i){var s=[];r.util.arrayEach.call(this,i.split("&"),(function(e){var t=e.split("=")[0],n=e.split("=")[1];if(this.subResources[t]||this.responseHeaders[t]){var r={name:t};void 0!==n&&(this.subResources[t]?r.value=n:r.value=decodeURIComponent(n)),s.push(r)}})),s.sort((function(e,t){return e.name<t.name?-1:1})),s.length&&(i=[],r.util.arrayEach(s,(function(e){void 0===e.value?i.push(e.name):i.push(e.name+"="+e.value)})),o+="?"+i.join("&"))}return o},sign:function(e,t){return r.util.crypto.hmac(e,t,"base64","sha1")}}),t.exports=r.Signers.S3},{"../core":20}],67:[function(e,t,n){var r=e("../core"),i=r.util.inherit;r.Signers.V2=i(r.Signers.RequestSigner,{addAuthorization:function(e,t){t||(t=r.util.date.getDate());var n=this.request;n.params.Timestamp=r.util.date.iso8601(t),n.params.SignatureVersion="2",n.params.SignatureMethod="HmacSHA256",n.params.AWSAccessKeyId=e.accessKeyId,e.sessionToken&&(n.params.SecurityToken=e.sessionToken),delete n.params.Signature,n.params.Signature=this.signature(e),n.body=r.util.queryParamsToString(n.params),n.headers["Content-Length"]=n.body.length},signature:function(e){return r.util.crypto.hmac(e.secretAccessKey,this.stringToSign(),"base64")},stringToSign:function(){var e=[];return e.push(this.request.method),e.push(this.request.endpoint.host.toLowerCase()),e.push(this.request.pathname()),e.push(r.util.queryParamsToString(this.request.params)),e.join("\n")}}),t.exports=r.Signers.V2},{"../core":20}],68:[function(e,t,n){var r=e("../core"),i=r.util.inherit;r.Signers.V3=i(r.Signers.RequestSigner,{addAuthorization:function(e,t){var n=r.util.date.rfc822(t);this.request.headers["X-Amz-Date"]=n,e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken),this.request.headers["X-Amzn-Authorization"]=this.authorization(e,n)},authorization:function(e){return"AWS3 AWSAccessKeyId="+e.accessKeyId+",Algorithm=HmacSHA256,SignedHeaders="+this.signedHeaders()+",Signature="+this.signature(e)},signedHeaders:function(){var e=[];return r.util.arrayEach(this.headersToSign(),(function(t){e.push(t.toLowerCase())})),e.sort().join(";")},canonicalHeaders:function(){var e=this.request.headers,t=[];return r.util.arrayEach(this.headersToSign(),(function(n){t.push(n.toLowerCase().trim()+":"+String(e[n]).trim())})),t.sort().join("\n")+"\n"},headersToSign:function(){var e=[];return r.util.each(this.request.headers,(function(t){("Host"===t||"Content-Encoding"===t||t.match(/^X-Amz/i))&&e.push(t)})),e},signature:function(e){return r.util.crypto.hmac(e.secretAccessKey,this.stringToSign(),"base64")},stringToSign:function(){var e=[];return e.push(this.request.method),e.push("/"),e.push(""),e.push(this.canonicalHeaders()),e.push(this.request.body),r.util.crypto.sha256(e.join("\n"))}}),t.exports=r.Signers.V3},{"../core":20}],69:[function(e,t,n){var r=e("../core"),i=r.util.inherit;e("./v3"),r.Signers.V3Https=i(r.Signers.V3,{authorization:function(e){return"AWS3-HTTPS AWSAccessKeyId="+e.accessKeyId+",Algorithm=HmacSHA256,Signature="+this.signature(e)},stringToSign:function(){return this.request.headers["X-Amz-Date"]}}),t.exports=r.Signers.V3Https},{"../core":20,"./v3":68}],70:[function(e,t,n){var r=e("../core"),i=e("./v4_credentials"),o=r.util.inherit;r.Signers.V4=o(r.Signers.RequestSigner,{constructor:function(e,t,n){r.Signers.RequestSigner.call(this,e),this.serviceName=t,n=n||{},this.signatureCache="boolean"!=typeof n.signatureCache||n.signatureCache,this.operation=n.operation,this.signatureVersion=n.signatureVersion},algorithm:"AWS4-HMAC-SHA256",addAuthorization:function(e,t){var n=r.util.date.iso8601(t).replace(/[:\-]|\.\d{3}/g,"");this.isPresigned()?this.updateForPresigned(e,n):this.addHeaders(e,n),this.request.headers.Authorization=this.authorization(e,n)},addHeaders:function(e,t){this.request.headers["X-Amz-Date"]=t,e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken)},updateForPresigned:function(e,t){var n=this.credentialString(t),i={"X-Amz-Date":t,"X-Amz-Algorithm":this.algorithm,"X-Amz-Credential":e.accessKeyId+"/"+n,"X-Amz-Expires":this.request.headers["presigned-expires"],"X-Amz-SignedHeaders":this.signedHeaders()};e.sessionToken&&(i["X-Amz-Security-Token"]=e.sessionToken),this.request.headers["Content-Type"]&&(i["Content-Type"]=this.request.headers["Content-Type"]),this.request.headers["Content-MD5"]&&(i["Content-MD5"]=this.request.headers["Content-MD5"]),this.request.headers["Cache-Control"]&&(i["Cache-Control"]=this.request.headers["Cache-Control"]),r.util.each.call(this,this.request.headers,(function(e,t){if("presigned-expires"!==e&&this.isSignableHeader(e)){var n=e.toLowerCase();0===n.indexOf("x-amz-meta-")?i[n]=t:0===n.indexOf("x-amz-")&&(i[e]=t)}}));var o=this.request.path.indexOf("?")>=0?"&":"?";this.request.path+=o+r.util.queryParamsToString(i)},authorization:function(e,t){var n=[],r=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+r),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=i.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return r.util.crypto.hmac(n,this.stringToSign(t),"hex")},stringToSign:function(e){var t=[];return t.push("AWS4-HMAC-SHA256"),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")},canonicalString:function(){var e=[],t=this.request.pathname();return"s3"!==this.serviceName&&"s3v4"!==this.signatureVersion&&(t=r.util.uriEscapePath(t)),e.push(this.request.method),e.push(t),e.push(this.request.search()),e.push(this.canonicalHeaders()+"\n"),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")},canonicalHeaders:function(){var e=[];r.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1}));var t=[];return r.util.arrayEach.call(this,e,(function(e){var n=e[0].toLowerCase();if(this.isSignableHeader(n)){var i=e[1];if(null==i||"function"!=typeof i.toString)throw r.util.error(new Error("Header "+n+" contains invalid value"),{code:"InvalidHeader"});t.push(n+":"+this.canonicalHeaderValues(i.toString()))}})),t.join("\n")},canonicalHeaderValues:function(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")},signedHeaders:function(){var e=[];return r.util.each.call(this,this.request.headers,(function(t){t=t.toLowerCase(),this.isSignableHeader(t)&&e.push(t)})),e.sort().join(";")},credentialString:function(e){return i.createScope(e.substr(0,8),this.request.region,this.serviceName)},hexEncodedHash:function(e){return r.util.crypto.sha256(e,"hex")},hexEncodedBodyHash:function(){var e=this.request;return this.isPresigned()&&"s3"===this.serviceName&&!e.body?"UNSIGNED-PAYLOAD":e.headers["X-Amz-Content-Sha256"]?e.headers["X-Amz-Content-Sha256"]:this.hexEncodedHash(this.request.body||"")},unsignableHeaders:["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],isSignableHeader:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||this.unsignableHeaders.indexOf(e)<0},isPresigned:function(){return!!this.request.headers["presigned-expires"]}}),t.exports=r.Signers.V4},{"../core":20,"./v4_credentials":71}],71:[function(e,t,n){var r=e("../core"),i={},o=[];t.exports={createScope:function(e,t,n){return[e.substr(0,8),t,n,"aws4_request"].join("/")},getSigningKey:function(e,t,n,s,a){var c=[r.util.crypto.hmac(e.secretAccessKey,e.accessKeyId,"base64"),t,n,s].join("_");if((a=!1!==a)&&c in i)return i[c];var u=r.util.crypto.hmac("AWS4"+e.secretAccessKey,t,"buffer"),l=r.util.crypto.hmac(u,n,"buffer"),p=r.util.crypto.hmac(l,s,"buffer"),d=r.util.crypto.hmac(p,"aws4_request","buffer");return a&&(i[c]=d,o.push(c),o.length>50&&delete i[o.shift()]),d},emptyCache:function(){i={},o=[]}}},{"../core":20}],72:[function(e,t,n){function r(e,t){this.currentState=t||null,this.states=e||{}}r.prototype.runTo=function(e,t,n,r){"function"==typeof e&&(r=n,n=t,t=e,e=null);var i=this,o=i.states[i.currentState];o.fn.call(n||i,r,(function(r){if(r){if(!o.fail)return t?t.call(n,r):null;i.currentState=o.fail}else{if(!o.accept)return t?t.call(n):null;i.currentState=o.accept}if(i.currentState===e)return t?t.call(n,r):null;i.runTo(e,t,n,r)}))},r.prototype.addState=function(e,t,n,r){return"function"==typeof t?(r=t,t=null,n=null):"function"==typeof n&&(r=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:r},this},t.exports=r},{}],73:[function(e,t,n){(function(n,r){(function(){var i,o={environment:"nodejs",engine:function(){if(o.isBrowser()&&"undefined"!=typeof navigator)return navigator.userAgent;var e=n.platform+"/"+n.version;return n.env.AWS_EXECUTION_ENV&&(e+=" exec-env/"+n.env.AWS_EXECUTION_ENV),e},userAgent:function(){var t=o.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+o.engine()),n},uriEscape:function(e){var t=encodeURIComponent(e);return(t=t.replace(/[^A-Za-z0-9_.~\-%]+/g,escape)).replace(/[*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))},uriEscapePath:function(e){var t=[];return o.arrayEach(e.split("/"),(function(e){t.push(o.uriEscape(e))})),t.join("/")},urlParse:function(e){return o.url.parse(e)},urlFormat:function(e){return o.url.format(e)},queryStringParse:function(e){return o.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=o.uriEscape,r=Object.keys(e).sort();return o.arrayEach(r,(function(r){var i=e[r],s=n(r),a=s+"=";if(Array.isArray(i)){var c=[];o.arrayEach(i,(function(e){c.push(n(e))})),a=s+"="+c.sort().join("&"+s+"=")}else null!=i&&(a=s+"="+n(i));t.push(a)})),t.join("&")},readFileSync:function(t){return o.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"==typeof e)throw o.error(new Error("Cannot base64 encode number "+e));return null==e?e:o.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"==typeof e)throw o.error(new Error("Cannot base64 decode number "+e));return null==e?e:o.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"==typeof o.Buffer.from&&o.Buffer.from!==Uint8Array.from?o.Buffer.from(e,t):new o.Buffer(e,t)},alloc:function(e,t,n){if("number"!=typeof e)throw new Error("size passed to alloc must be a number.");if("function"==typeof o.Buffer.alloc)return o.Buffer.alloc(e,t,n);var r=new o.Buffer(e);return void 0!==t&&"function"==typeof r.fill&&r.fill(t,void 0,void 0,n),r},toStream:function(e){o.Buffer.isBuffer(e)||(e=o.buffer.toBuffer(e));var t=new o.stream.Readable,n=0;return t._read=function(r){if(n>=e.length)return t.push(null);var i=n+r;i>e.length&&(i=e.length),t.push(e.slice(n,i)),n=i},t},concat:function(e){var t,n,r=0,i=0;for(t=0;t<e.length;t++)r+=e[t].length;for(n=o.buffer.alloc(r),t=0;t<e.length;t++)e[t].copy(n,i),i+=e[t].length;return n}},string:{byteLength:function(t){if(null==t)return 0;if("string"==typeof t&&(t=o.buffer.toBuffer(t)),"number"==typeof t.byteLength)return t.byteLength;if("number"==typeof t.length)return t.length;if("number"==typeof t.size)return t.size;if("string"==typeof t.path)return e("fs").lstatSync(t.path).size;throw o.error(new Error("Cannot determine length of "+t),{object:t})},upperFirst:function(e){return e[0].toUpperCase()+e.substr(1)},lowerFirst:function(e){return e[0].toLowerCase()+e.substr(1)}},ini:{parse:function(e){var t,n={};return o.arrayEach(e.split(/\r?\n/),(function(e){var r=(e=e.split(/(^|\s)[;#]/)[0]).match(/^\s*\[([^\[\]]+)\]\s*$/);if(r)t=r[1];else if(t){var i=e.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/);i&&(n[t]=n[t]||{},n[t][i[1]]=i[2])}})),n}},fn:{noop:function(){},callback:function(e){if(e)throw e},makeAsync:function(e,t){return t&&t<=e.length?e:function(){var t=Array.prototype.slice.call(arguments,0);t.pop()(e.apply(null,t))}}},date:{getDate:function(){return i||(i=e("./core")),i.config.systemClockOffset?new Date((new Date).getTime()+i.config.systemClockOffset):new Date},iso8601:function(e){return void 0===e&&(e=o.date.getDate()),e.toISOString().replace(/\.\d{3}Z$/,"Z")},rfc822:function(e){return void 0===e&&(e=o.date.getDate()),e.toUTCString()},unixTimestamp:function(e){return void 0===e&&(e=o.date.getDate()),e.getTime()/1e3},from:function(e){return"number"==typeof e?new Date(1e3*e):new Date(e)},format:function(e,t){return t||(t="iso8601"),o.date[t](o.date.from(e))},parseTimestamp:function(e){if("number"==typeof e)return new Date(1e3*e);if(e.match(/^\d+$/))return new Date(1e3*e);if(e.match(/^\d{4}/))return new Date(e);if(e.match(/^\w{3},/))return new Date(e);throw o.error(new Error("unhandled timestamp format: "+e),{code:"TimestampParserError"})}},crypto:{crc32Table:[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],crc32:function(e){var t=o.crypto.crc32Table,n=-1;"string"==typeof e&&(e=o.buffer.toBuffer(e));for(var r=0;r<e.length;r++)n=n>>>8^t[255&(n^e.readUInt8(r))];return(-1^n)>>>0},hmac:function(e,t,n,r){return n||(n="binary"),"buffer"===n&&(n=void 0),r||(r="sha256"),"string"==typeof t&&(t=o.buffer.toBuffer(t)),o.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return o.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return o.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var i=o.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"==typeof t&&(t=o.buffer.toBuffer(t));var s=o.arraySliceFn(t),a=o.Buffer.isBuffer(t);if(o.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(a=!0),r&&"object"==typeof t&&"function"==typeof t.on&&!a)t.on("data",(function(e){i.update(e)})),t.on("error",(function(e){r(e)})),t.on("end",(function(){r(null,i.digest(n))}));else{if(!r||!s||a||"undefined"==typeof FileReader){o.isBrowser()&&"object"==typeof t&&!a&&(t=new o.Buffer(new Uint8Array(t)));var c=i.update(t).digest(n);return r&&r(null,c),c}var u=0,l=new FileReader;l.onerror=function(){r(new Error("Failed to read data."))},l.onload=function(){var e=new o.Buffer(new Uint8Array(l.result));i.update(e),u+=e.length,l._continueReading()},l._continueReading=function(){if(u>=t.size)r(null,i.digest(n));else{var e=u+524288;e>t.size&&(e=t.size),l.readAsArrayBuffer(s.call(t,u,e))}},l._continueReading()}},toHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push(("0"+e.charCodeAt(n).toString(16)).substr(-2,2));return t.join("")},createHash:function(e){return o.crypto.lib.createHash(e)}},abort:{},each:function(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.call(this,n,e[n])===o.abort)break},arrayEach:function(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.call(this,e[n],parseInt(n,10))===o.abort)break},update:function(e,t){return o.each(t,(function(t,n){e[t]=n})),e},merge:function(e,t){return o.update(o.copy(e),t)},copy:function(e){if(null==e)return e;var t={};for(var n in e)t[n]=e[n];return t},isEmpty:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},arraySliceFn:function(e){var t=e.slice||e.webkitSlice||e.mozSlice;return"function"==typeof t?t:null},isType:function(e,t){return"function"==typeof t&&(t=o.typeName(t)),Object.prototype.toString.call(e)==="[object "+t+"]"},typeName:function(e){if(Object.prototype.hasOwnProperty.call(e,"name"))return e.name;var t=e.toString(),n=t.match(/^\s*function (.+)\(/);return n?n[1]:t},error:function(e,t){var n=null;return"string"==typeof e.message&&""!==e.message&&("string"==typeof t||t&&t.message)&&((n=o.copy(e)).message=e.message),e.message=e.message||null,"string"==typeof t?e.message=t:"object"==typeof t&&null!==t&&(o.update(e,t),t.message&&(e.message=t.message),(t.code||t.name)&&(e.code=t.code||t.name),t.stack&&(e.stack=t.stack)),"function"==typeof Object.defineProperty&&(Object.defineProperty(e,"name",{writable:!0,enumerable:!1}),Object.defineProperty(e,"message",{enumerable:!0})),e.name=String(t&&t.name||e.name||e.code||"Error"),e.time=new Date,n&&(e.originalError=n),e},inherit:function(e,t){var n=null;if(void 0===t)t=e,e=Object,n={};else{var r=function(){};r.prototype=e.prototype,n=new r}return t.constructor===Object&&(t.constructor=function(){if(e!==Object)return e.apply(this,arguments)}),t.constructor.prototype=n,o.update(t.constructor.prototype,t),t.constructor.__super__=e,t.constructor},mixin:function(){for(var e=arguments[0],t=1;t<arguments.length;t++)for(var n in arguments[t].prototype){var r=arguments[t].prototype[n];"constructor"!==n&&(e.prototype[n]=r)}return e},hideProperties:function(e,t){"function"==typeof Object.defineProperty&&o.arrayEach(t,(function(t){Object.defineProperty(e,t,{enumerable:!1,writable:!0,configurable:!0})}))},property:function(e,t,n,r,i){var o={configurable:!0,enumerable:void 0===r||r};"function"!=typeof n||i?(o.value=n,o.writable=!0):o.get=n,Object.defineProperty(e,t,o)},memoizedProperty:function(e,t,n,r){var i=null;o.property(e,t,(function(){return null===i&&(i=n()),i}),r)},hoistPayloadMember:function(e){var t=e.request,n=t.operation,r=t.service.api.operations[n],i=r.output;if(i.payload&&!r.hasEventOutput){var s=i.members[i.payload],a=e.data[i.payload];"structure"===s.type&&o.each(a,(function(t,n){o.property(e.data,t,n,!1)}))}},computeSha256:function(t,n){if(o.isNode()){var r=o.stream.Stream,i=e("fs");if("function"==typeof r&&t instanceof r){if("string"!=typeof t.path)return n(new Error("Non-file stream objects are not supported with SigV4"));var s={};"number"==typeof t.start&&(s.start=t.start),"number"==typeof t.end&&(s.end=t.end),t=i.createReadStream(t.path,s)}}o.crypto.sha256(t,"hex",(function(e,t){e?n(e):n(null,t)}))},isClockSkewed:function(e){if(e)return o.property(i.config,"isClockSkewed",Math.abs((new Date).getTime()-e)>=3e5,!1),i.config.isClockSkewed},applyClockOffset:function(e){e&&(i.config.systemClockOffset=e-(new Date).getTime())},extractRequestId:function(e){var t=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"];!t&&e.data&&e.data.ResponseMetadata&&(t=e.data.ResponseMetadata.RequestId),t&&(e.requestId=t),e.error&&(e.error.requestId=t)},addPromises:function(e,t){var n=!1;void 0===t&&i&&i.config&&(t=i.config.getPromisesDependency()),void 0===t&&"undefined"!=typeof Promise&&(t=Promise),"function"!=typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++){var o=e[r];n?o.deletePromisesFromClass&&o.deletePromisesFromClass():o.addPromisesToClass&&o.addPromisesToClass(t)}},promisifyMethod:function(e,t){return function(){var n=this,r=Array.prototype.slice.call(arguments);return new t((function(t,i){r.push((function(e,n){e?i(e):t(n)})),n[e].apply(n,r)}))}},isDualstackAvailable:function(t){if(!t)return!1;var n=e("../apis/metadata.json");return"string"!=typeof t&&(t=t.serviceIdentifier),!("string"!=typeof t||!n.hasOwnProperty(t)||!n[t].dualstackAvailable)},calculateRetryDelay:function(e,t,n){t||(t={});var r=t.customBackoff||null;if("function"==typeof r)return r(e,n);var i="number"==typeof t.base?t.base:100;return Math.random()*(Math.pow(2,e)*i)},handleRequestWithRetries:function(e,t,n){t||(t={});var r=i.HttpClient.getInstance(),s=t.httpOptions||{},a=0,c=function(e){var r=t.maxRetries||0;if(e&&"TimeoutError"===e.code&&(e.retryable=!0),e&&e.retryable&&a<r){var i=o.calculateRetryDelay(a,t.retryDelayOptions,e);if(i>=0)return a++,void setTimeout(u,i+(e.retryAfter||0))}n(e)},u=function(){var t="";r.handleRequest(e,s,(function(e){e.on("data",(function(e){t+=e.toString()})),e.on("end",(function(){var r=e.statusCode;if(r<300)n(null,t);else{var i=1e3*parseInt(e.headers["retry-after"],10)||0,s=o.error(new Error,{statusCode:r,retryable:r>=500||429===r});i&&s.retryable&&(s.retryAfter=i),c(s)}}))}),c)};i.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,r=t.service.api.operations[n].output||{};r.payload&&e.data[r.payload]&&(e.data[r.payload]=e.data[r.payload].toString())},defer:function(e){"object"==typeof n&&"function"==typeof n.nextTick?n.nextTick(e):"function"==typeof r?r(e):setTimeout(e,0)},getRequestPayloadShape:function(e){var t=e.service.api.operations;if(t){var n=(t||{})[e.operation];if(n&&n.input&&n.input.payload)return n.input.members[n.input.payload]}},getProfilesFromSharedConfig:function(e,t){function r(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++)e[r[n]]=t[r[n]];return e}var i={},s={};n.env[o.configOptInEnv]&&(s=e.loadFrom({isConfig:!0,filename:n.env[o.sharedConfigFileEnv]}));for(var a=e.loadFrom({filename:t||n.env[o.configOptInEnv]&&n.env[o.sharedCredentialsFileEnv]}),c=0,u=Object.keys(s);c<u.length;c++)i[u[c]]=r(i[u[c]]||{},s[u[c]]);for(c=0,u=Object.keys(a);c<u.length;c++)i[u[c]]=r(i[u[c]]||{},a[u[c]]);return i},ARN:{validate:function(e){return e&&0===e.indexOf("arn:")&&e.split(":").length>=6},parse:function(e){var t=e.split(":");return{partition:t[1],service:t[2],region:t[3],accountId:t[4],resource:t.slice(5).join(":")}},build:function(e){if(void 0===e.service||void 0===e.region||void 0===e.accountId||void 0===e.resource)throw o.error(new Error("Input ARN object is invalid"));return"arn:"+(e.partition||"aws")+":"+e.service+":"+e.region+":"+e.accountId+":"+e.resource}},defaultProfile:"default",configOptInEnv:"AWS_SDK_LOAD_CONFIG",sharedCredentialsFileEnv:"AWS_SHARED_CREDENTIALS_FILE",sharedConfigFileEnv:"AWS_CONFIG_FILE",imdsDisabledEnv:"AWS_EC2_METADATA_DISABLED"};t.exports=o}).call(this)}).call(this,e("_process"),e("timers").setImmediate)},{"../apis/metadata.json":5,"./core":20,_process:87,fs:81,timers:95,uuid:100}],74:[function(e,t,n){function r(){}function i(e,t){for(var n=e.getElementsByTagName(t),r=0,i=n.length;r<i;r++)if(n[r].parentNode===e)return n[r]}function o(e,t){switch(t||(t={}),t.type){case"structure":return s(e,t);case"map":return function(e,t){for(var n={},r=t.key.name||"key",s=t.value.name||"value",a=t.flattened?t.name:"entry",c=e.firstElementChild;c;){if(c.nodeName===a){var u=i(c,r).textContent,l=i(c,s);n[u]=o(l,t.value)}c=c.nextElementSibling}return n}(e,t);case"list":return function(e,t){for(var n=[],r=t.flattened?t.name:t.member.name||"member",i=e.firstElementChild;i;)i.nodeName===r&&n.push(o(i,t.member)),i=i.nextElementSibling;return n}(e,t);case void 0:case null:return function(e){if(null==e)return"";if(!e.firstElementChild)return null===e.parentNode.parentNode?{}:0===e.childNodes.length?"":e.textContent;for(var t={type:"structure",members:{}},n=e.firstElementChild;n;){var r=n.nodeName;Object.prototype.hasOwnProperty.call(t.members,r)?t.members[r].type="list":t.members[r]={name:r},n=n.nextElementSibling}return s(e,t)}(e);default:return function(e,t){if(e.getAttribute){var n=e.getAttribute("encoding");"base64"===n&&(t=new c.create({type:n}))}var r=e.textContent;return""===r&&(r=null),"function"==typeof t.toType?t.toType(r):r}(e,t)}}function s(e,t){var n={};return null===e||a.each(t.members,(function(r,s){if(s.isXmlAttribute){if(Object.prototype.hasOwnProperty.call(e.attributes,s.name)){var a=e.attributes[s.name].value;n[r]=o({textContent:a},s)}}else{var c=s.flattened?e:i(e,s.name);c?n[r]=o(c,s):s.flattened||"list"!==s.type||t.api.xmlNoDefaultLists||(n[r]=s.defaultValue)}})),n}var a=e("../util"),c=e("../model/shape");r.prototype.parse=function(e,t){if(""===e.replace(/^\s+/,""))return{};var n,r;try{if(window.DOMParser){try{n=(new DOMParser).parseFromString(e,"text/xml")}catch(e){throw a.error(new Error("Parse error in document"),{originalError:e,code:"XMLParserError",retryable:!0})}if(null===n.documentElement)throw a.error(new Error("Cannot parse empty document."),{code:"XMLParserError",retryable:!0});var s=n.getElementsByTagName("parsererror")[0];if(s&&(s.parentNode===n||"body"===s.parentNode.nodeName||s.parentNode.parentNode===n||"body"===s.parentNode.parentNode.nodeName)){var c=s.getElementsByTagName("div")[0]||s;throw a.error(new Error(c.textContent||"Parser error in document"),{code:"XMLParserError",retryable:!0})}}else{if(!window.ActiveXObject)throw new Error("Cannot load XML parser");if((n=new window.ActiveXObject("Microsoft.XMLDOM")).async=!1,!n.loadXML(e))throw a.error(new Error("Parse error in document"),{code:"XMLParserError",retryable:!0})}}catch(e){r=e}if(n&&n.documentElement&&!r){var u=o(n.documentElement,t),l=i(n.documentElement,"ResponseMetadata");return l&&(u.ResponseMetadata=o(l,{})),u}if(r)throw a.error(r||new Error,{code:"XMLParserError",retryable:!0});return{}},t.exports=r},{"../model/shape":45,"../util":73}],75:[function(e,t,n){function r(){}function i(e,t,n){switch(n.type){case"structure":return function(e,t,n){s.arrayEach(n.memberNames,(function(r){var s=n.members[r];if("body"===s.location){var c=t[r],u=s.name;if(null!=c)if(s.isXmlAttribute)e.addAttribute(u,c);else if(s.flattened)i(e,c,s);else{var l=new a(u);e.addChildNode(l),o(l,s),i(l,c,s)}}}))}(e,t,n);case"map":return function(e,t,n){var r=n.key.name||"key",o=n.value.name||"value";s.each(t,(function(t,s){var c=new a(n.flattened?n.name:"entry");e.addChildNode(c);var u=new a(r),l=new a(o);c.addChildNode(u),c.addChildNode(l),i(u,t,n.key),i(l,s,n.value)}))}(e,t,n);case"list":return function(e,t,n){n.flattened?s.arrayEach(t,(function(t){var r=n.member.name||n.name,o=new a(r);e.addChildNode(o),i(o,t,n.member)})):s.arrayEach(t,(function(t){var r=n.member.name||"member",o=new a(r);e.addChildNode(o),i(o,t,n.member)}))}(e,t,n);default:return function(e,t,n){e.addChildNode(new c(n.toWireFormat(t)))}(e,t,n)}}function o(e,t,n){var r,i="xmlns";t.xmlNamespaceUri?(r=t.xmlNamespaceUri,t.xmlNamespacePrefix&&(i+=":"+t.xmlNamespacePrefix)):n&&t.api.xmlNamespaceUri&&(r=t.api.xmlNamespaceUri),r&&e.addAttribute(i,r)}var s=e("../util"),a=e("./xml-node").XmlNode,c=e("./xml-text").XmlText;r.prototype.toXML=function(e,t,n,r){var s=new a(n);return o(s,t,!0),i(s,e,t),s.children.length>0||r?s.toString():""},t.exports=r},{"../util":73,"./xml-node":78,"./xml-text":79}],76:[function(e,t,n){t.exports={escapeAttribute:function(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}}},{}],77:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}}},{}],78:[function(e,t,n){function r(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}var i=e("./escape-attribute").escapeAttribute;r.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},r.prototype.addChildNode=function(e){return this.children.push(e),this},r.prototype.removeAttribute=function(e){return delete this.attributes[e],this},r.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,r=0,o=Object.keys(n);r<o.length;r++){var s=o[r],a=n[s];null!=a&&(t+=" "+s+'="'+i(""+a)+'"')}return t+(e?">"+this.children.map((function(e){return e.toString()})).join("")+"</"+this.name+">":"/>")},t.exports={XmlNode:r}},{"./escape-attribute":76}],79:[function(e,t,n){function r(e){this.value=e}var i=e("./escape-element").escapeElement;r.prototype.toString=function(){return i(""+this.value)},t.exports={XmlText:r}},{"./escape-element":77}],80:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,n){for(var r,o=[],s=t;s<n;s+=3)r=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),o.push(i(r));return o.join("")}n.byteLength=function(e){var t=r(e),n=t[0],i=t[1];return 3*(n+i)/4-i},n.toByteArray=function(e){var t,n,i=r(e),o=i[0],s=i[1],u=new c(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),l=0,p=s>0?o-4:o;for(n=0;n<p;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===s&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,u[l++]=255&t),1===s&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],a=0,c=n-r;a<c;a+=16383)i.push(o(e,a,a+16383>c?c:a+16383));return 1===r?(t=e[n-1],i.push(s[t>>2]+s[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),i.join("")};for(var s=[],a=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=u.length;l<p;++l)s[l]=u[l],a[u.charCodeAt(l)]=l;a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],81:[function(e,t,n){},{}],82:[function(e,t,n){(function(t,r){(function(){"use strict";function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=o.prototype:(null===e&&(e=new o(t)),e.length=t),e}function o(e,t,n){if(!(o.TYPED_ARRAY_SUPPORT||this instanceof o))return new o(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(this,e)}return s(this,e,t,n)}function s(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),o.TYPED_ARRAY_SUPPORT?(e=t).__proto__=o.prototype:e=u(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!o.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),s=(e=i(e,r)).write(t,n);return s!==r&&(e=e.slice(0,s)),e}(e,t,n):function(e,t){if(o.isBuffer(t)){var n=0|l(t.length);return 0===(e=i(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?i(e,0):u(e,t);if("Buffer"===t.type&&W(t.data))return u(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function c(e,t){if(a(t),e=i(e,t<0?0:0|l(t)),!o.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function u(e,t){var n=t.length<0?0:0|l(t.length);e=i(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function l(e){if(e>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function p(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(e).length;default:if(r)return D(e).length;t=(""+t).toLowerCase(),r=!0}}function d(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return k(this,t,n);case"utf8":case"utf-8":return C(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return I(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function h(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function f(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var s,a=1,c=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,c/=2,u/=2,n/=2}if(i){var l=-1;for(s=n;s<c;s++)if(o(e,s)===o(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*a}else-1!==l&&(s-=s-l),l=-1}else for(n+u>c&&(n=c-u),s=n;s>=0;s--){for(var p=!0,d=0;d<u;d++)if(o(e,s+d)!==o(t,d)){p=!1;break}if(p)return s}return-1}function g(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function v(e,t,n,r){return q(D(t,e.length-n),e,n,r)}function y(e,t,n,r){return q(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function b(e,t,n,r){return y(e,t,n,r)}function w(e,t,n,r){return q(U(t),e,n,r)}function E(e,t,n,r){return q(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?j.fromByteArray(e):j.fromByteArray(e.slice(t,n))}function C(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],l=null,p=u>239?4:u>223?3:u>191?2:1;if(i+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=p}return function(e){var t=e.length;if(t<=B)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=B));return n}(r)}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function I(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function k(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=P(e[o]);return i}function _(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function x(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,n,r,i,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function O(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function N(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return i||N(e,0,n,4),F.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,i){return i||N(e,0,n,8),F.write(e,t,n,r,52,8),n+8}function P(e){return e<16?"0"+e.toString(16):e.toString(16)}function D(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function U(e){return j.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}var j=e("base64-js"),F=e("ieee754"),W=e("isarray");n.Buffer=o,n.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},n.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),n.kMaxLength=r(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,n){return s(null,e,t,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,n){return function(e,t,n,r){return a(t),t<=0?i(e,t):void 0!==n?"string"==typeof r?i(e,t).fill(n,r):i(e,t).fill(n):i(e,t)}(null,e,t,n)},o.allocUnsafe=function(e){return c(null,e)},o.allocUnsafeSlow=function(e){return c(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!W(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=o.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)h(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)h(this,t,t+3),h(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)h(this,t,t+7),h(this,t+1,t+6),h(this,t+2,t+5),h(this,t+3,t+4);return this},o.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):d.apply(this,arguments)},o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},o.prototype.compare=function(e,t,n,r,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),c=Math.min(s,a),u=this.slice(r,i),l=e.slice(t,n),p=0;p<c;++p)if(u[p]!==l[p]){s=u[p],a=l[p];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},o.prototype.indexOf=function(e,t,n){return f(this,e,t,n,!0)},o.prototype.lastIndexOf=function(e,t,n){return f(this,e,t,n,!1)},o.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return g(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return y(this,e,t,n);case"latin1":case"binary":return b(this,e,t,n);case"base64":return w(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;o.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),o.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=o.prototype;else{var i=t-e;n=new o(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},o.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||x(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},o.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||x(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},o.prototype.readUInt8=function(e,t){return t||x(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||x(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||x(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||x(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||x(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||x(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||x(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||x(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||x(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||x(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||x(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||x(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||x(e,4,this.length),F.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||x(e,4,this.length),F.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||x(e,8,this.length),F.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||x(e,8,this.length),F.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},o.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):O(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},o.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var a=o.isBuffer(e)?e:D(new o(e,r).toString()),c=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%c]}return this};var z=/[^+\/0-9A-Za-z-_]/g}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":80,buffer:82,ieee754:84,isarray:85}],83:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(s(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(o(n))for(a=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,c=0;c<r;c++)u[c].apply(this,a);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],84:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,l=-7,p=n?i-1:0,d=n?-1:1,h=e[t+p];for(p+=d,o=h&(1<<-l)-1,h>>=-l,l+=a;l>0;o=256*o+e[t+p],p+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),o-=u}return(h?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,p=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(a=0,s=l):s+p>=1?(a=(t*c-1)*Math.pow(2,i),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,i),s=0));i>=8;e[n+h]=255&a,h+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*m}},{}],85:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],86:[function(e,t,n){!function(e){"use strict";function t(e){return null!==e&&"[object Array]"===Object.prototype.toString.call(e)}function n(e){return null!==e&&"[object Object]"===Object.prototype.toString.call(e)}function r(e,i){if(e===i)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(i))return!1;if(!0===t(e)){if(e.length!==i.length)return!1;for(var o=0;o<e.length;o++)if(!1===r(e[o],i[o]))return!1;return!0}if(!0===n(e)){var s={};for(var a in e)if(hasOwnProperty.call(e,a)){if(!1===r(e[a],i[a]))return!1;s[a]=!0}for(var c in i)if(hasOwnProperty.call(i,c)&&!0!==s[c])return!1;return!0}return!1}function i(e){if(""===e||!1===e||null===e)return!0;if(t(e)&&0===e.length)return!0;if(n(e)){for(var r in e)if(e.hasOwnProperty(r))return!1;return!0}return!1}function o(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e}function s(e){return e>="0"&&e<="9"||"-"===e}function a(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"_"===e}function c(){}function u(){}function l(e){this.runtime=e}function p(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[h]}]},avg:{_func:this._functionAvg,_signature:[{types:[b]}]},ceil:{_func:this._functionCeil,_signature:[{types:[h]}]},contains:{_func:this._functionContains,_signature:[{types:[m,g]},{types:[f]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[m]},{types:[m]}]},floor:{_func:this._functionFloor,_signature:[{types:[h]}]},length:{_func:this._functionLength,_signature:[{types:[m,g,v]}]},map:{_func:this._functionMap,_signature:[{types:[y]},{types:[g]}]},max:{_func:this._functionMax,_signature:[{types:[b,w]}]},merge:{_func:this._functionMerge,_signature:[{types:[v],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[g]},{types:[y]}]},sum:{_func:this._functionSum,_signature:[{types:[b]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[m]},{types:[m]}]},min:{_func:this._functionMin,_signature:[{types:[b,w]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[g]},{types:[y]}]},type:{_func:this._functionType,_signature:[{types:[f]}]},keys:{_func:this._functionKeys,_signature:[{types:[v]}]},values:{_func:this._functionValues,_signature:[{types:[v]}]},sort:{_func:this._functionSort,_signature:[{types:[w,b]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[g]},{types:[y]}]},join:{_func:this._functionJoin,_signature:[{types:[m]},{types:[w]}]},reverse:{_func:this._functionReverse,_signature:[{types:[m,g]}]},to_array:{_func:this._functionToArray,_signature:[{types:[f]}]},to_string:{_func:this._functionToString,_signature:[{types:[f]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[f]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[f],variadic:!0}]}}}var d;d="function"==typeof String.prototype.trimLeft?function(e){return e.trimLeft()}:function(e){return e.match(/^\s*(.*)/)[1]};var h=0,f=1,m=2,g=3,v=4,y=6,b=8,w=9,E={".":"Dot","*":"Star",",":"Comma",":":"Colon","{":"Lbrace","}":"Rbrace","]":"Rbracket","(":"Lparen",")":"Rparen","@":"Current"},S={"<":!0,">":!0,"=":!0,"!":!0},C={" ":!0,"\t":!0,"\n":!0};c.prototype={tokenize:function(e){var t,n,r,i=[];for(this._current=0;this._current<e.length;)if(o(e[this._current]))t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:"UnquotedIdentifier",value:n,start:t});else if(void 0!==E[e[this._current]])i.push({type:E[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(s(e[this._current]))r=this._consumeNumber(e),i.push(r);else if("["===e[this._current])r=this._consumeLBracket(e),i.push(r);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:"QuotedIdentifier",value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:"Literal",value:n,start:t});else if("`"===e[this._current]){t=this._current;var a=this._consumeLiteral(e);i.push({type:"Literal",value:a,start:t})}else if(void 0!==S[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==C[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:"And",value:"&&",start:t})):i.push({type:"Expref",value:"&",start:t});else{if("|"!==e[this._current]){var c=new Error("Unknown character:"+e[this._current]);throw c.name="LexerError",c}t=this._current,this._current++,"|"===e[this._current]?(this._current++,i.push({type:"Or",value:"||",start:t})):i.push({type:"Pipe",value:"|",start:t})}return i},_consumeUnquotedIdentifier:function(e){var t=this._current;for(this._current++;this._current<e.length&&a(e[this._current]);)this._current++;return e.slice(t,this._current)},_consumeQuotedIdentifier:function(e){var t=this._current;this._current++;for(var n=e.length;'"'!==e[this._current]&&this._current<n;){var r=this._current;"\\"!==e[r]||"\\"!==e[r+1]&&'"'!==e[r+1]?r++:r+=2,this._current=r}return this._current++,JSON.parse(e.slice(t,this._current))},_consumeRawStringLiteral:function(e){var t=this._current;this._current++;for(var n=e.length;"'"!==e[this._current]&&this._current<n;){var r=this._current;"\\"!==e[r]||"\\"!==e[r+1]&&"'"!==e[r+1]?r++:r+=2,this._current=r}return this._current++,e.slice(t+1,this._current-1).replace("\\'","'")},_consumeNumber:function(e){var t=this._current;this._current++;for(var n=e.length;s(e[this._current])&&this._current<n;)this._current++;return{type:"Number",value:parseInt(e.slice(t,this._current)),start:t}},_consumeLBracket:function(e){var t=this._current;return this._current++,"?"===e[this._current]?(this._current++,{type:"Filter",value:"[?",start:t}):"]"===e[this._current]?(this._current++,{type:"Flatten",value:"[]",start:t}):{type:"Lbracket",value:"[",start:t}},_consumeOperator:function(e){var t=this._current,n=e[t];return this._current++,"!"===n?"="===e[this._current]?(this._current++,{type:"NE",value:"!=",start:t}):{type:"Not",value:"!",start:t}:"<"===n?"="===e[this._current]?(this._current++,{type:"LTE",value:"<=",start:t}):{type:"LT",value:"<",start:t}:">"===n?"="===e[this._current]?(this._current++,{type:"GTE",value:">=",start:t}):{type:"GT",value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:"EQ",value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,r=e.length;"`"!==e[this._current]&&this._current<r;){var i=this._current;"\\"!==e[i]||"\\"!==e[i+1]&&"`"!==e[i+1]?i++:i+=2,this._current=i}var o=d(e.slice(n,this._current));return o=o.replace("\\`","`"),t=this._looksLikeJSON(o)?JSON.parse(o):JSON.parse('"'+o+'"'),this._current++,t},_looksLikeJSON:function(e){if(""===e)return!1;if('[{"'.indexOf(e[0])>=0)return!0;if(["true","false","null"].indexOf(e)>=0)return!0;if(!("-0123456789".indexOf(e[0])>=0))return!1;try{return JSON.parse(e),!0}catch(e){return!1}}};var T={EOF:0,UnquotedIdentifier:0,QuotedIdentifier:0,Rbracket:0,Rparen:0,Comma:0,Rbrace:0,Number:0,Current:0,Expref:0,Pipe:1,Or:2,And:3,EQ:5,GT:5,LT:5,GTE:5,LTE:5,NE:5,Flatten:9,Star:20,Filter:21,Dot:40,Not:45,Lbrace:50,Lbracket:55,Lparen:60};u.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if("EOF"!==this._lookahead(0)){var n=this._lookaheadToken(0),r=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw r.name="ParserError",r}return t},_loadTokens:function(e){var t=(new c).tokenize(e);t.push({type:"EOF",value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),r=this._lookahead(0);e<T[r];)this._advance(),n=this.led(r,n),r=this._lookahead(0);return n},_lookahead:function(e){return this.tokens[this.index+e].type},_lookaheadToken:function(e){return this.tokens[this.index+e]},_advance:function(){this.index++},nud:function(e){var t,n;switch(e.type){case"Literal":return{type:"Literal",value:e.value};case"UnquotedIdentifier":return{type:"Field",name:e.value};case"QuotedIdentifier":var r={type:"Field",name:e.value};if("Lparen"===this._lookahead(0))throw new Error("Quoted identifier not allowed for function names.");return r;case"Not":return{type:"NotExpression",children:[t=this.expression(T.Not)]};case"Star":return t=null,{type:"ValueProjection",children:[{type:"Identity"},t="Rbracket"===this._lookahead(0)?{type:"Identity"}:this._parseProjectionRHS(T.Star)]};case"Filter":return this.led(e.type,{type:"Identity"});case"Lbrace":return this._parseMultiselectHash();case"Flatten":return{type:"Projection",children:[{type:"Flatten",children:[{type:"Identity"}]},t=this._parseProjectionRHS(T.Flatten)]};case"Lbracket":return"Number"===this._lookahead(0)||"Colon"===this._lookahead(0)?(t=this._parseIndexExpression(),this._projectIfSlice({type:"Identity"},t)):"Star"===this._lookahead(0)&&"Rbracket"===this._lookahead(1)?(this._advance(),this._advance(),{type:"Projection",children:[{type:"Identity"},t=this._parseProjectionRHS(T.Star)]}):this._parseMultiselectList();case"Current":return{type:"Current"};case"Expref":return{type:"ExpressionReference",children:[n=this.expression(T.Expref)]};case"Lparen":for(var i=[];"Rparen"!==this._lookahead(0);)"Current"===this._lookahead(0)?(n={type:"Current"},this._advance()):n=this.expression(0),i.push(n);return this._match("Rparen"),i[0];default:this._errorToken(e)}},led:function(e,t){var n;switch(e){case"Dot":var r=T.Dot;return"Star"!==this._lookahead(0)?{type:"Subexpression",children:[t,n=this._parseDotRHS(r)]}:(this._advance(),{type:"ValueProjection",children:[t,n=this._parseProjectionRHS(r)]});case"Pipe":return{type:"Pipe",children:[t,n=this.expression(T.Pipe)]};case"Or":return{type:"OrExpression",children:[t,n=this.expression(T.Or)]};case"And":return{type:"AndExpression",children:[t,n=this.expression(T.And)]};case"Lparen":for(var i,o=t.name,s=[];"Rparen"!==this._lookahead(0);)"Current"===this._lookahead(0)?(i={type:"Current"},this._advance()):i=this.expression(0),"Comma"===this._lookahead(0)&&this._match("Comma"),s.push(i);return this._match("Rparen"),{type:"Function",name:o,children:s};case"Filter":var a=this.expression(0);return this._match("Rbracket"),{type:"FilterProjection",children:[t,n="Flatten"===this._lookahead(0)?{type:"Identity"}:this._parseProjectionRHS(T.Filter),a]};case"Flatten":return{type:"Projection",children:[{type:"Flatten",children:[t]},this._parseProjectionRHS(T.Flatten)]};case"EQ":case"NE":case"GT":case"GTE":case"LT":case"LTE":return this._parseComparator(t,e);case"Lbracket":var c=this._lookaheadToken(0);return"Number"===c.type||"Colon"===c.type?(n=this._parseIndexExpression(),this._projectIfSlice(t,n)):(this._match("Star"),this._match("Rbracket"),{type:"Projection",children:[t,n=this._parseProjectionRHS(T.Star)]});default:this._errorToken(this._lookaheadToken(0))}},_match:function(e){if(this._lookahead(0)!==e){var t=this._lookaheadToken(0),n=new Error("Expected "+e+", got: "+t.type);throw n.name="ParserError",n}this._advance()},_errorToken:function(e){var t=new Error("Invalid token ("+e.type+'): "'+e.value+'"');throw t.name="ParserError",t},_parseIndexExpression:function(){if("Colon"===this._lookahead(0)||"Colon"===this._lookahead(1))return this._parseSliceExpression();var e={type:"Index",value:this._lookaheadToken(0).value};return this._advance(),this._match("Rbracket"),e},_projectIfSlice:function(e,t){var n={type:"IndexExpression",children:[e,t]};return"Slice"===t.type?{type:"Projection",children:[n,this._parseProjectionRHS(T.Star)]}:n},_parseSliceExpression:function(){for(var e=[null,null,null],t=0,n=this._lookahead(0);"Rbracket"!==n&&t<3;){if("Colon"===n)t++,this._advance();else{if("Number"!==n){var r=this._lookahead(0),i=new Error("Syntax error, unexpected token: "+r.value+"("+r.type+")");throw i.name="Parsererror",i}e[t]=this._lookaheadToken(0).value,this._advance()}n=this._lookahead(0)}return this._match("Rbracket"),{type:"Slice",children:e}},_parseComparator:function(e,t){return{type:"Comparator",name:t,children:[e,this.expression(T[t])]}},_parseDotRHS:function(e){var t=this._lookahead(0);return["UnquotedIdentifier","QuotedIdentifier","Star"].indexOf(t)>=0?this.expression(e):"Lbracket"===t?(this._match("Lbracket"),this._parseMultiselectList()):"Lbrace"===t?(this._match("Lbrace"),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(T[this._lookahead(0)]<10)t={type:"Identity"};else if("Lbracket"===this._lookahead(0))t=this.expression(e);else if("Filter"===this._lookahead(0))t=this.expression(e);else{if("Dot"!==this._lookahead(0)){var n=this._lookaheadToken(0),r=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw r.name="ParserError",r}this._match("Dot"),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];"Rbracket"!==this._lookahead(0);){var t=this.expression(0);if(e.push(t),"Comma"===this._lookahead(0)&&(this._match("Comma"),"Rbracket"===this._lookahead(0)))throw new Error("Unexpected token Rbracket")}return this._match("Rbracket"),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,r=[],i=["UnquotedIdentifier","QuotedIdentifier"];;){if(e=this._lookaheadToken(0),i.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match("Colon"),n={type:"KeyValuePair",name:t,value:this.expression(0)},r.push(n),"Comma"===this._lookahead(0))this._match("Comma");else if("Rbrace"===this._lookahead(0)){this._match("Rbrace");break}}return{type:"MultiSelectHash",children:r}}},l.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,o){var s,a,c,u,l,p,d,h,f;switch(e.type){case"Field":return null===o?null:n(o)?void 0===(p=o[e.name])?null:p:null;case"Subexpression":for(c=this.visit(e.children[0],o),f=1;f<e.children.length;f++)if(null===(c=this.visit(e.children[1],c)))return null;return c;case"IndexExpression":case"Pipe":return d=this.visit(e.children[0],o),this.visit(e.children[1],d);case"Index":if(!t(o))return null;var m=e.value;return m<0&&(m=o.length+m),void 0===(c=o[m])&&(c=null),c;case"Slice":if(!t(o))return null;var g=e.children.slice(0),v=this.computeSliceParams(o.length,g),y=v[0],b=v[1],w=v[2];if(c=[],w>0)for(f=y;f<b;f+=w)c.push(o[f]);else for(f=y;f>b;f+=w)c.push(o[f]);return c;case"Projection":var E=this.visit(e.children[0],o);if(!t(E))return null;for(h=[],f=0;f<E.length;f++)null!==(a=this.visit(e.children[1],E[f]))&&h.push(a);return h;case"ValueProjection":if(!n(E=this.visit(e.children[0],o)))return null;h=[];var S=function(e){for(var t=Object.keys(e),n=[],r=0;r<t.length;r++)n.push(e[t[r]]);return n}(E);for(f=0;f<S.length;f++)null!==(a=this.visit(e.children[1],S[f]))&&h.push(a);return h;case"FilterProjection":if(!t(E=this.visit(e.children[0],o)))return null;var C=[],T=[];for(f=0;f<E.length;f++)i(s=this.visit(e.children[2],E[f]))||C.push(E[f]);for(var I=0;I<C.length;I++)null!==(a=this.visit(e.children[1],C[I]))&&T.push(a);return T;case"Comparator":switch(u=this.visit(e.children[0],o),l=this.visit(e.children[1],o),e.name){case"EQ":c=r(u,l);break;case"NE":c=!r(u,l);break;case"GT":c=u>l;break;case"GTE":c=u>=l;break;case"LT":c=u<l;break;case"LTE":c=u<=l;break;default:throw new Error("Unknown comparator: "+e.name)}return c;case"Flatten":var k=this.visit(e.children[0],o);if(!t(k))return null;var _=[];for(f=0;f<k.length;f++)t(a=k[f])?_.push.apply(_,a):_.push(a);return _;case"Identity":case"Current":return o;case"MultiSelectList":if(null===o)return null;for(h=[],f=0;f<e.children.length;f++)h.push(this.visit(e.children[f],o));return h;case"MultiSelectHash":if(null===o)return null;var x;for(h={},f=0;f<e.children.length;f++)h[(x=e.children[f]).name]=this.visit(x.value,o);return h;case"OrExpression":return i(s=this.visit(e.children[0],o))&&(s=this.visit(e.children[1],o)),s;case"AndExpression":return!0===i(u=this.visit(e.children[0],o))?u:this.visit(e.children[1],o);case"NotExpression":return i(u=this.visit(e.children[0],o));case"Literal":return e.value;case"Function":var A=[];for(f=0;f<e.children.length;f++)A.push(this.visit(e.children[f],o));return this.runtime.callFunction(e.name,A);case"ExpressionReference":var R=e.children[0];return R.jmespathType="Expref",R;default:throw new Error("Unknown node type: "+e.type)}},computeSliceParams:function(e,t){var n=t[0],r=t[1],i=t[2],o=[null,null,null];if(null===i)i=1;else if(0===i){var s=new Error("Invalid slice, step cannot be 0");throw s.name="RuntimeError",s}var a=i<0;return n=null===n?a?e-1:0:this.capSliceRange(e,n,i),r=null===r?a?-1:e:this.capSliceRange(e,r,i),o[0]=n,o[1]=r,o[2]=i,o},capSliceRange:function(e,t,n){return t<0?(t+=e)<0&&(t=n<0?-1:0):t>=e&&(t=n<0?e-1:e),t}},p.prototype={callFunction:function(e,t){var n=this.functionTable[e];if(void 0===n)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,n._signature),n._func.call(this,t)},_validateArgs:function(e,t,n){var r;if(n[n.length-1].variadic){if(t.length<n.length)throw r=1===n.length?" argument":" arguments",new Error("ArgumentError: "+e+"() takes at least"+n.length+r+" but received "+t.length)}else if(t.length!==n.length)throw r=1===n.length?" argument":" arguments",new Error("ArgumentError: "+e+"() takes "+n.length+r+" but received "+t.length);for(var i,o,s,a=0;a<n.length;a++){s=!1,i=n[a].types,o=this._getTypeName(t[a]);for(var c=0;c<i.length;c++)if(this._typeMatches(o,i[c],t[a])){s=!0;break}if(!s)throw new Error("TypeError: "+e+"() expected argument "+(a+1)+" to be type "+i+" but received type "+o+" instead.")}},_typeMatches:function(e,t,n){if(t===f)return!0;if(t!==w&&t!==b&&t!==g)return e===t;if(t===g)return e===g;if(e===g){var r;t===b?r=h:t===w&&(r=m);for(var i=0;i<n.length;i++)if(!this._typeMatches(this._getTypeName(n[i]),r,n[i]))return!1;return!0}},_getTypeName:function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return m;case"[object Number]":return h;case"[object Array]":return g;case"[object Boolean]":return 5;case"[object Null]":return 7;case"[object Object]":return"Expref"===e.jmespathType?y:v}},_functionStartsWith:function(e){return 0===e[0].lastIndexOf(e[1])},_functionEndsWith:function(e){var t=e[0],n=e[1];return-1!==t.indexOf(n,t.length-n.length)},_functionReverse:function(e){if(this._getTypeName(e[0])===m){for(var t=e[0],n="",r=t.length-1;r>=0;r--)n+=t[r];return n}var i=e[0].slice(0);return i.reverse(),i},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,n=e[0],r=0;r<n.length;r++)t+=n[r];return t/n.length},_functionContains:function(e){return e[0].indexOf(e[1])>=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return n(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],n=this._interpreter,r=e[0],i=e[1],o=0;o<i.length;o++)t.push(n.visit(r,i[o]));return t},_functionMerge:function(e){for(var t={},n=0;n<e.length;n++){var r=e[n];for(var i in r)t[i]=r[i]}return t},_functionMax:function(e){if(e[0].length>0){if(this._getTypeName(e[0][0])===h)return Math.max.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;r<t.length;r++)n.localeCompare(t[r])<0&&(n=t[r]);return n}return null},_functionMin:function(e){if(e[0].length>0){if(this._getTypeName(e[0][0])===h)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;r<t.length;r++)t[r].localeCompare(n)<0&&(n=t[r]);return n}return null},_functionSum:function(e){for(var t=0,n=e[0],r=0;r<n.length;r++)t+=n[r];return t},_functionType:function(e){switch(this._getTypeName(e[0])){case h:return"number";case m:return"string";case g:return"array";case v:return"object";case 5:return"boolean";case y:return"expref";case 7:return"null"}},_functionKeys:function(e){return Object.keys(e[0])},_functionValues:function(e){for(var t=e[0],n=Object.keys(t),r=[],i=0;i<n.length;i++)r.push(t[n[i]]);return r},_functionJoin:function(e){var t=e[0];return e[1].join(t)},_functionToArray:function(e){return this._getTypeName(e[0])===g?e[0]:[e[0]]},_functionToString:function(e){return this._getTypeName(e[0])===m?e[0]:JSON.stringify(e[0])},_functionToNumber:function(e){var t,n=this._getTypeName(e[0]);return n===h?e[0]:n!==m||(t=+e[0],isNaN(t))?null:t},_functionNotNull:function(e){for(var t=0;t<e.length;t++)if(7!==this._getTypeName(e[t]))return e[t];return null},_functionSort:function(e){var t=e[0].slice(0);return t.sort(),t},_functionSortBy:function(e){var t=e[0].slice(0);if(0===t.length)return t;var n=this._interpreter,r=e[1],i=this._getTypeName(n.visit(r,t[0]));if([h,m].indexOf(i)<0)throw new Error("TypeError");for(var o=this,s=[],a=0;a<t.length;a++)s.push([a,t[a]]);s.sort((function(e,t){var s=n.visit(r,e[1]),a=n.visit(r,t[1]);if(o._getTypeName(s)!==i)throw new Error("TypeError: expected "+i+", received "+o._getTypeName(s));if(o._getTypeName(a)!==i)throw new Error("TypeError: expected "+i+", received "+o._getTypeName(a));return s>a?1:s<a?-1:e[0]-t[0]}));for(var c=0;c<s.length;c++)t[c]=s[c][1];return t},_functionMaxBy:function(e){for(var t,n,r=e[1],i=e[0],o=this.createKeyFunction(r,[h,m]),s=-1/0,a=0;a<i.length;a++)(n=o(i[a]))>s&&(s=n,t=i[a]);return t},_functionMinBy:function(e){for(var t,n,r=e[1],i=e[0],o=this.createKeyFunction(r,[h,m]),s=1/0,a=0;a<i.length;a++)(n=o(i[a]))<s&&(s=n,t=i[a]);return t},createKeyFunction:function(e,t){var n=this,r=this._interpreter;return function(i){var o=r.visit(e,i);if(t.indexOf(n._getTypeName(o))<0){var s="TypeError: expected one of "+t+", received "+n._getTypeName(o);throw new Error(s)}return o}}},e.tokenize=function(e){return(new c).tokenize(e)},e.compile=function(e){return(new u).parse(e)},e.search=function(e,t){var n=new u,r=new p,i=new l(r);r._interpreter=i;var o=n.parse(t);return i.search(o,e)},e.strictDeepEqual=r}(void 0===n?this.jmespath={}:n)},{}],87:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function s(){m&&h&&(m=!1,h.length?f=h.concat(f):g=-1,f.length&&a())}function a(){if(!m){var e=o(s);m=!0;for(var t=f.length;t;){for(h=f,f=[];++g<t;)h&&h[g].run();g=-1,t=f.length}h=null,m=!1,function(e){if(p===clearTimeout)return clearTimeout(e);if((p===i||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(e);try{return p(e)}catch(t){try{return p.call(null,e)}catch(t){return p.call(this,e)}}}(e)}}function c(e,t){this.fun=e,this.array=t}function u(){}var l,p,d=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:r}catch(e){l=r}try{p="function"==typeof clearTimeout?clearTimeout:i}catch(e){p=i}}();var h,f=[],m=!1,g=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new c(e,t)),1!==f.length||m||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=u,d.addListener=u,d.once=u,d.off=u,d.removeListener=u,d.removeAllListeners=u,d.emit=u,d.prependListener=u,d.prependOnceListener=u,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},{}],88:[function(i,o,s){(function(i){(function(){!function(a){function c(e){throw RangeError(P[e])}function u(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function l(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+u((e=e.replace(M,".")).split("."),t).join(".")}function p(e){for(var t,n,r=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function d(e){return u(e,(function(e){var t="";return e>65535&&(t+=q((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+q(e)})).join("")}function h(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:T}function f(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function m(e,t,n){var r=0;for(e=n?U(e/x):e>>1,e+=U(e/t);e>D*k>>1;r+=T)e=U(e/D);return U(r+(D+1)*e/(e+_))}function g(e){var t,n,r,i,o,s,a,u,l,p,f=[],g=e.length,v=0,y=R,b=A;for((n=e.lastIndexOf(O))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&c("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<g;){for(o=v,s=1,a=T;i>=g&&c("invalid-input"),((u=h(e.charCodeAt(i++)))>=T||u>U((C-v)/s))&&c("overflow"),v+=u*s,!(u<(l=a<=b?I:a>=b+k?k:a-b));a+=T)s>U(C/(p=T-l))&&c("overflow"),s*=p;b=m(v-o,t=f.length+1,0==o),U(v/t)>C-y&&c("overflow"),y+=U(v/t),v%=t,f.splice(v++,0,y)}return d(f)}function v(e){var t,n,r,i,o,s,a,u,l,d,h,g,v,y,b,w=[];for(g=(e=p(e)).length,t=R,n=0,o=A,s=0;s<g;++s)(h=e[s])<128&&w.push(q(h));for(r=i=w.length,i&&w.push(O);r<g;){for(a=C,s=0;s<g;++s)(h=e[s])>=t&&h<a&&(a=h);for(a-t>U((C-n)/(v=r+1))&&c("overflow"),n+=(a-t)*v,t=a,s=0;s<g;++s)if((h=e[s])<t&&++n>C&&c("overflow"),h==t){for(u=n,l=T;!(u<(d=l<=o?I:l>=o+k?k:l-o));l+=T)b=u-d,y=T-d,w.push(q(f(d+b%y,0))),u=U(b/y);w.push(q(f(u,0))),o=m(n,v,r==i),n=0,++r}++n,++t}return w.join("")}var y="object"==typeof s&&s&&!s.nodeType&&s,b="object"==typeof o&&o&&!o.nodeType&&o,w="object"==typeof i&&i;w.global!==w&&w.window!==w&&w.self!==w||(a=w);var E,S,C=2147483647,T=36,I=1,k=26,_=38,x=700,A=72,R=128,O="-",N=/^xn--/,L=/[^\x20-\x7E]/,M=/[\x2E\u3002\uFF0E\uFF61]/g,P={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-I,U=Math.floor,q=String.fromCharCode;if(E={version:"1.3.2",ucs2:{decode:p,encode:d},decode:g,encode:v,toASCII:function(e){return l(e,(function(e){return L.test(e)?"xn--"+v(e):e}))},toUnicode:function(e){return l(e,(function(e){return N.test(e)?g(e.slice(4).toLowerCase()):e}))}},n.amdO)void 0===(r=function(){return E}.call(t,n,t,e))||(e.exports=r);else if(y&&b)if(o.exports==y)b.exports=E;else for(S in E)E.hasOwnProperty(S)&&(y[S]=E[S]);else a.punycode=E}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],89:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,o){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var l=0;l<u;++l){var p,d,h,f,m=e[l].replace(a,"%20"),g=m.indexOf(n);g>=0?(p=m.substr(0,g),d=m.substr(g+1)):(p=m,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),r(s,h)?i(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],90:[function(e,t,n){"use strict";function r(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var i=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?r(s(e),(function(s){var a=encodeURIComponent(i(s))+n;return o(e[s])?r(e[s],(function(e){return a+encodeURIComponent(i(e))})).join(t):a+encodeURIComponent(i(e[s]))})).join(t):a?encodeURIComponent(i(a))+n+encodeURIComponent(i(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],91:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":89,"./encode":90}],92:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var s=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var c=e.length;a>0&&c>a&&(c=a);for(var u=0;u<c;++u){var l,p,d,h,f=e[u].replace(s,"%20"),m=f.indexOf(n);m>=0?(l=f.substr(0,m),p=f.substr(m+1)):(l=f,p=""),d=decodeURIComponent(l),h=decodeURIComponent(p),r(o,d)?Array.isArray(o[d])?o[d].push(h):o[d]=[o[d],h]:o[d]=h}return o}},{}],93:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,i){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(i){var o=encodeURIComponent(r(i))+n;return Array.isArray(e[i])?e[i].map((function(e){return o+encodeURIComponent(r(e))})).join(t):o+encodeURIComponent(r(e[i]))})).join(t):i?encodeURIComponent(r(i))+n+encodeURIComponent(r(e)):""}},{}],94:[function(e,t,n){arguments[4][91][0].apply(n,arguments)},{"./decode":92,"./encode":93,dup:91}],95:[function(e,t,n){(function(t,r){(function(){function i(e,t){this._id=e,this._clearFn=t}var o=e("process/browser.js").nextTick,s=Function.prototype.apply,a=Array.prototype.slice,c={},u=0;n.setTimeout=function(){return new i(s.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new i(s.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n.setImmediate="function"==typeof t?t:function(e){var t=u++,r=!(arguments.length<2)&&a.call(arguments,1);return c[t]=!0,o((function(){c[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof r?r:function(e){delete c[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":87,timers:95}],96:[function(e,t,n){function r(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(e,t,n){if(e&&s(e)&&e instanceof r)return e;var i=new r;return i.parse(e,t,n),i}function o(e){return"string"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return null===e}var c=e("punycode");n.parse=i,n.resolve=function(e,t){return i(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?i(e,!1,!0).resolveObject(t):t},n.format=function(e){return o(e)&&(e=i(e)),e instanceof r?e.format():r.prototype.format.call(e)},n.Url=r;var u=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,p=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),d=["'"].concat(p),h=["%","/","?",";","#"].concat(d),f=["/","?","#"],m=/^[a-z0-9A-Z_-]{0,63}$/,g=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},w=e("querystring");r.prototype.parse=function(e,t,n){if(!o(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e;r=r.trim();var i=u.exec(r);if(i){var s=(i=i[0]).toLowerCase();this.protocol=s,r=r.substr(i.length)}if(n||i||r.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===r.substr(0,2);!a||i&&y[i]||(r=r.substr(2),this.slashes=!0)}if(!y[i]&&(a||i&&!b[i])){for(var l=-1,p=0;p<f.length;p++)-1!==(C=r.indexOf(f[p]))&&(-1===l||C<l)&&(l=C);var E,S;for(-1!==(S=-1===l?r.lastIndexOf("@"):r.lastIndexOf("@",l))&&(E=r.slice(0,S),r=r.slice(S+1),this.auth=decodeURIComponent(E)),l=-1,p=0;p<h.length;p++){var C;-1!==(C=r.indexOf(h[p]))&&(-1===l||C<l)&&(l=C)}-1===l&&(l=r.length),this.host=r.slice(0,l),r=r.slice(l),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var I=this.hostname.split(/\./),k=(p=0,I.length);p<k;p++){var _=I[p];if(_&&!_.match(m)){for(var x="",A=0,R=_.length;A<R;A++)_.charCodeAt(A)>127?x+="x":x+=_[A];if(!x.match(m)){var O=I.slice(0,p),N=I.slice(p+1),L=_.match(g);L&&(O.push(L[1]),N.unshift(L[2])),N.length&&(r="/"+N.join(".")+r),this.hostname=O.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!T){var M=this.hostname.split("."),P=[];for(p=0;p<M.length;++p){var D=M[p];P.push(D.match(/[^A-Za-z0-9_-]/)?"xn--"+c.encode(D):D)}this.hostname=P.join(".")}var U=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+U,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==r[0]&&(r="/"+r))}if(!v[s])for(p=0,k=d.length;p<k;p++){var j=d[p],F=encodeURIComponent(j);F===j&&(F=escape(j)),r=r.split(j).join(F)}var W=r.indexOf("#");-1!==W&&(this.hash=r.substr(W),r=r.slice(0,W));var B=r.indexOf("?");return-1!==B?(this.search=r.substr(B),this.query=r.substr(B+1),t&&(this.query=w.parse(this.query)),r=r.slice(0,B)):t&&(this.search="",this.query={}),r&&(this.pathname=r),b[s]&&this.hostname&&!this.pathname&&(this.pathname="/"),(this.pathname||this.search)&&(U=this.pathname||"",D=this.search||"",this.path=U+D),this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&s(this.query)&&Object.keys(this.query).length&&(o=w.stringify(this.query));var a=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})),t+i+n+(a=a.replace("#","%23"))+r},r.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(o(e)){var t=new r;t.parse(e,!1,!0),e=t}var n=new r;if(Object.keys(this).forEach((function(e){n[e]=this[e]}),this),n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol)return Object.keys(e).forEach((function(t){"protocol"!==t&&(n[t]=e[t])})),b[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n;if(e.protocol&&e.protocol!==n.protocol){if(!b[e.protocol])return Object.keys(e).forEach((function(t){n[t]=e[t]})),n.href=n.format(),n;if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var i=(e.pathname||"").split("/");i.length&&!(e.host=i.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),n.pathname=i.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var s=n.pathname||"",c=n.search||"";n.path=s+c}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var u=n.pathname&&"/"===n.pathname.charAt(0),l=e.host||e.pathname&&"/"===e.pathname.charAt(0),p=l||u||n.host&&e.pathname,d=p,h=n.pathname&&n.pathname.split("/")||[],f=(i=e.pathname&&e.pathname.split("/")||[],n.protocol&&!b[n.protocol]);if(f&&(n.hostname="",n.port=null,n.host&&(""===h[0]?h[0]=n.host:h.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===i[0]?i[0]=e.host:i.unshift(e.host)),e.host=null),p=p&&(""===i[0]||""===h[0])),l)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,h=i;else if(i.length)h||(h=[]),h.pop(),h=h.concat(i),n.search=e.search,n.query=e.query;else if(!function(e){return null==e}(e.search))return f&&(n.hostname=n.host=h.shift(),(E=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=E.shift(),n.host=n.hostname=E.shift())),n.search=e.search,n.query=e.query,a(n.pathname)&&a(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!h.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var m=h.slice(-1)[0],g=(n.host||e.host)&&("."===m||".."===m)||""===m,v=0,w=h.length;w>=0;w--)"."==(m=h[w])?h.splice(w,1):".."===m?(h.splice(w,1),v++):v&&(h.splice(w,1),v--);if(!p&&!d)for(;v--;v)h.unshift("..");!p||""===h[0]||h[0]&&"/"===h[0].charAt(0)||h.unshift(""),g&&"/"!==h.join("/").substr(-1)&&h.push("");var E,S=""===h[0]||h[0]&&"/"===h[0].charAt(0);return f&&(n.hostname=n.host=S?"":h.length?h.shift():"",(E=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=E.shift(),n.host=n.hostname=E.shift())),(p=p||n.host&&h.length)&&!S&&h.unshift(""),h.length?n.pathname=h.join("/"):(n.pathname=null,n.path=null),a(n.pathname)&&a(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=l.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:88,querystring:91}],97:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],98:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],99:[function(e,t,n){(function(t,r){(function(){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(t)?r.showHidden=t:t&&n._extend(r,t),g(r.showHidden)&&(r.showHidden=!1),g(r.depth)&&(r.depth=2),g(r.colors)&&(r.colors=!1),g(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),a(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e,t,r){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return m(i)||(i=a(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),d=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),w(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return u(t);if(0===s.length){if(E(t)){var h=t.name?": "+t.name:"";return e.stylize("[Function"+h+"]","special")}if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(w(t))return u(t)}var f,g="",y=!1,S=["{","}"];return p(t)&&(y=!0,S=["[","]"]),E(t)&&(g=" [Function"+(t.name?": "+t.name:"")+"]"),v(t)&&(g=" "+RegExp.prototype.toString.call(t)),b(t)&&(g=" "+Date.prototype.toUTCString.call(t)),w(t)&&(g=" "+u(t)),0!==s.length||y&&0!=t.length?r<0?v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=y?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)T(t,String(s))?o.push(l(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(l(e,t,n,r,i,!0))})),o}(e,t,r,d,s):s.map((function(n){return l(e,t,r,d,n,y)})),e.seen.pop(),function(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(f,g,S)):S[0]+g+S[1]}function c(e,t){if(g(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return f(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):h(t)?e.stylize("null","null"):void 0}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,r,i,o){var s,c,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?c=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(c=e.stylize("[Setter]","special")),T(r,i)||(s="["+i+"]"),c||(e.seen.indexOf(u.value)<0?(c=h(n)?a(e,u.value,null):a(e,u.value,n-1)).indexOf("\n")>-1&&(c=o?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return c;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+c}function p(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function h(e){return null===e}function f(e){return"number"==typeof e}function m(e){return"string"==typeof e}function g(e){return void 0===e}function v(e){return y(e)&&"[object RegExp]"===S(e)}function y(e){return"object"==typeof e&&null!==e}function b(e){return y(e)&&"[object Date]"===S(e)}function w(e){return y(e)&&("[object Error]"===S(e)||e instanceof Error)}function E(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I=/%[sdj%]/g;n.format=function(e){if(!m(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,s=String(e).replace(I,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),a=r[n];n<o;a=r[++n])h(a)||!y(a)?s+=" "+a:s+=" "+i(a);return s},n.deprecate=function(e,i){if(g(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(!0===t.noDeprecation)return e;var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var k,_={};n.debuglog=function(e){if(g(k)&&(k=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!_[e])if(new RegExp("\\b"+e+"\\b","i").test(k)){var r=t.pid;_[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else _[e]=function(){};return _[e]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=h,n.isNullOrUndefined=function(e){return null==e},n.isNumber=f,n.isString=m,n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=g,n.isRegExp=v,n.isObject=y,n.isDate=b,n.isError=w,n.isFunction=E,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",function(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),x[e.getMonth()],t].join(" ")}(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!y(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":98,_process:87,inherits:97}],100:[function(e,t,n){var r=e("./v1"),i=e("./v4"),o=i;o.v1=r,o.v4=i,t.exports=o},{"./v1":103,"./v4":104}],101:[function(e,t,n){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,i=r;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")}},{}],102:[function(e,t,n){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var i=new Uint8Array(16);t.exports=function(){return r(i),i}}else{var o=new Array(16);t.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}},{}],103:[function(e,t,n){var r,i,o=e("./lib/rng"),s=e("./lib/bytesToUuid"),a=0,c=0;t.exports=function(e,t,n){var u=t&&n||0,l=t||[],p=(e=e||{}).node||r,d=void 0!==e.clockseq?e.clockseq:i;if(null==p||null==d){var h=o();null==p&&(p=r=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=i=16383&(h[6]<<8|h[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),m=void 0!==e.nsecs?e.nsecs:c+1,g=f-a+(m-c)/1e4;if(g<0&&void 0===e.clockseq&&(d=d+1&16383),(g<0||f>a)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=f,c=m,i=d;var v=(1e4*(268435455&(f+=122192928e5))+m)%4294967296;l[u++]=v>>>24&255,l[u++]=v>>>16&255,l[u++]=v>>>8&255,l[u++]=255&v;var y=f/4294967296*1e4&268435455;l[u++]=y>>>8&255,l[u++]=255&y,l[u++]=y>>>24&15|16,l[u++]=y>>>16&255,l[u++]=d>>>8|128,l[u++]=255&d;for(var b=0;b<6;++b)l[u+b]=p[b];return t||s(l)}},{"./lib/bytesToUuid":101,"./lib/rng":102}],104:[function(e,t,n){var r=e("./lib/rng"),i=e("./lib/bytesToUuid");t.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},{"./lib/bytesToUuid":101,"./lib/rng":102}],105:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils/LRU"),i=function(){function e(e){void 0===e&&(e=1e3),this.maxSize=e,this.cache=new r.LRUCache(e)}return Object.defineProperty(e.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),e.prototype.put=function(t,n){var r="string"!=typeof t?e.getKeyString(t):t,i=this.populateValue(n);this.cache.put(r,i)},e.prototype.get=function(t){var n="string"!=typeof t?e.getKeyString(t):t,r=Date.now(),i=this.cache.get(n);if(i)for(var o=0;o<i.length;o++)if(i[o].Expire<r)return void this.cache.remove(n);return i},e.getKeyString=function(e){for(var t=[],n=Object.keys(e).sort(),r=0;r<n.length;r++){var i=n[r];void 0!==e[i]&&t.push(e[i])}return t.join(" ")},e.prototype.populateValue=function(e){var t=Date.now();return e.map((function(e){return{Address:e.Address||"",Expire:t+60*(e.CachePeriodInMinutes||1)*1e3}}))},e.prototype.empty=function(){this.cache.empty()},e.prototype.remove=function(t){var n="string"!=typeof t?e.getKeyString(t):t;this.cache.remove(n)},e}();n.EndpointCache=i},{"./utils/LRU":106}],106:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(e,t){this.key=e,this.value=t},i=function(){function e(e){if(this.nodeMap={},this.size=0,"number"!=typeof e||e<1)throw new Error("Cache size can only be positive number");this.sizeLimit=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.size},enumerable:!0,configurable:!0}),e.prototype.prependToList=function(e){this.headerNode?(this.headerNode.prev=e,e.next=this.headerNode):this.tailNode=e,this.headerNode=e,this.size++},e.prototype.removeFromTail=function(){if(this.tailNode){var e=this.tailNode,t=e.prev;return t&&(t.next=void 0),e.prev=void 0,this.tailNode=t,this.size--,e}},e.prototype.detachFromList=function(e){this.headerNode===e&&(this.headerNode=e.next),this.tailNode===e&&(this.tailNode=e.prev),e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.next=void 0,e.prev=void 0,this.size--},e.prototype.get=function(e){if(this.nodeMap[e]){var t=this.nodeMap[e];return this.detachFromList(t),this.prependToList(t),t.value}},e.prototype.remove=function(e){if(this.nodeMap[e]){var t=this.nodeMap[e];this.detachFromList(t),delete this.nodeMap[e]}},e.prototype.put=function(e,t){if(this.nodeMap[e])this.remove(e);else if(this.size===this.sizeLimit){var n=this.removeFromTail().key;delete this.nodeMap[n]}var i=new r(e,t);this.nodeMap[e]=i,this.prependToList(i)},e.prototype.empty=function(){for(var e=Object.keys(this.nodeMap),t=0;t<e.length;t++){var n=e[t],r=this.nodeMap[n];this.detachFromList(r),delete this.nodeMap[n]}},e}();n.LRUCache=i},{}],107:[function(e,t,n){e("./browser_loader");var r=e("./core");"undefined"!=typeof window&&(window.AWS=r),void 0!==t&&(t.exports=r),"undefined"!=typeof self&&(self.AWS=r),Object.prototype.hasOwnProperty.call(r,"ConnectParticipant")||(r.apiLoader.services.connectparticipant={},r.ConnectParticipant=r.Service.defineService("connectparticipant",["2018-09-07"])),r.apiLoader.services.connectparticipant["2018-09-07"]=e("../apis/connectparticipant-2018-09-07.min"),r.apiLoader.services.connectparticipant["2018-09-07"].paginators=e("../apis/connectparticipant-2018-09-07.paginators").pagination,Object.prototype.hasOwnProperty.call(r,"STS")||(r.apiLoader.services.sts={},r.STS=r.Service.defineService("sts",["2011-06-15"]),e("./services/sts"))},{"../apis/connectparticipant-2018-09-07.min":3,"../apis/connectparticipant-2018-09-07.paginators":4,"../apis/sts-2011-06-15.min":6,"./browser_loader":17,"./core":20,"./services/sts":63}]},{},[107])},705:(e,t,n)=>{var r=n(639).Symbol;e.exports=r},239:(e,t,n)=>{var r=n(705),i=n(607),o=n(333),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):o(e)}},561:(e,t,n)=>{var r=n(990),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},957:e=>{var t="object"==typeof global&&global&&global.Object===Object&&global;e.exports=t},607:(e,t,n)=>{var r=n(705),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var i=s.call(e);return r&&(t?e[a]=n:delete e[a]),i}},333:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},639:(e,t,n)=>{var r=n(957),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},990:e=>{var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},279:(e,t,n)=>{var r=n(218),i=n(771),o=n(841),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,p,d,h,f=0,m=!1,g=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,f=t,p=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||g&&e-f>=l}function w(){var e=i();if(b(e))return E(e);d=setTimeout(w,function(e){var n=t-(e-h);return g?a(n,l-(e-f)):n}(e))}function E(e){return d=void 0,v&&c?y(e):(c=u=void 0,p)}function S(){var e=i(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===d)return function(e){return f=e,d=setTimeout(w,t),m?y(e):p}(h);if(g)return clearTimeout(d),d=setTimeout(w,t),y(h)}return void 0===d&&(d=setTimeout(w,t)),p}return t=o(t)||0,r(n)&&(m=!!n.leading,l=(g="maxWait"in n)?s(o(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),S.cancel=function(){void 0!==d&&clearTimeout(d),f=0,c=h=u=d=void 0},S.flush=function(){return void 0===d?p:E(i())},S}},218:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},448:(e,t,n)=>{var r=n(239),i=n(5);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},771:(e,t,n)=>{var r=n(639);e.exports=function(){return r.Date.now()}},493:(e,t,n)=>{var r=n(279),i=n(218);e.exports=function(e,t,n){var o=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return i(n)&&(o="leading"in n?!!n.leading:o,s="trailing"in n?!!n.trailing:s),r(e,t,{leading:o,maxWait:t,trailing:s})}},841:(e,t,n)=>{var r=n(561),i=n(218),o=n(448),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return NaN;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},975:(e,t,n)=>{var r;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function o(e){return function(e,t){var n,r,s,a,c,u,l,p,d,h=1,f=e.length,m="";for(r=0;r<f;r++)if("string"==typeof e[r])m+=e[r];else if("object"==typeof e[r]){if((a=e[r]).keys)for(n=t[h],s=0;s<a.keys.length;s++){if(null==n)throw new Error(o('[sprintf] Cannot access property "%s" of undefined value "%s"',a.keys[s],a.keys[s-1]));n=n[a.keys[s]]}else n=a.param_no?t[a.param_no]:t[h++];if(i.not_type.test(a.type)&&i.not_primitive.test(a.type)&&n instanceof Function&&(n=n()),i.numeric_arg.test(a.type)&&"number"!=typeof n&&isNaN(n))throw new TypeError(o("[sprintf] expecting number but found %T",n));switch(i.number.test(a.type)&&(p=n>=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?m+=n:(!i.number.test(a.type)||p&&!a.sign?d="":(d=p?"+":"-",n=n.toString().replace(i.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(d+n).length,c=a.width&&l>0?u.repeat(l):"",m+=a.align?d+n+c:"0"===u?d+c+n:c+d+n)}return m}(function(e){if(a[e])return a[e];for(var t,n=e,r=[],o=0;n;){if(null!==(t=i.text.exec(n)))r.push(t[0]);else if(null!==(t=i.modulo.exec(n)))r.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){o|=1;var s=[],c=t[2],u=[];if(null===(u=i.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=i.key_access.exec(c)))s.push(u[1]);else{if(null===(u=i.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return a[e]=r}(e),arguments)}function s(e,t){return o.apply(null,[e].concat(t||[]))}var a=Object.create(null);t.sprintf=o,t.vsprintf=s,"undefined"!=typeof window&&(window.sprintf=o,window.vsprintf=s,void 0===(r=function(){return{sprintf:o,vsprintf:s}}.call(t,n,t,e))||(e.exports=r))}()}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";class e extends Error{constructor(e){super(e),this.name="ValueError"}}class t extends Error{constructor(e){super(e),this.name="UnImplementedMethod"}}class r extends Error{constructor(e,t){super(e),this.name="IllegalArgument",this.argument=t}}class i extends Error{constructor(e){super(e),this.name="IllegalState"}}class o extends Error{constructor(e,t){super(e),this.name="IllegalState",this.causeException=t.causeException,this.originalJsonString=t.originalJsonString}}var s=new class{constructor(){this.stage="prod",this.region="us-west-2",this.reconnect=!0;var e=this;this.features=new Proxy([],{set:function(t,n,r){console.log("new features added, initialValue: "+t[n]+" , newValue: "+r,Array.isArray(t[n]));var i=t[n];return Array.isArray(r)&&r.forEach((t=>{Array.isArray(i)&&-1===i.indexOf(t)&&Array.isArray(e.featureChangeListeners[t])&&(e.featureChangeListeners[t].forEach((e=>e())),e._cleanFeatureChangeListener(t))})),t[n]=r,!0}}),this.featureChangeListeners=[]}update(e){var t=e||{};this.stage=t.stage||this.stage,this.region=t.region||this.region,this.endpointOverride=t.endpoint||this.endpointOverride,this.reconnect=!1!==t.reconnect&&this.reconnect,this.messageReceiptThrottleTime=t.throttleTime?t.throttleTime:5e3,this.features.values=Array.isArray(t.features)?[...t.features]:new Array}updateStageRegion(e){e&&(this.stage=e.stage||this.stage,this.region=e.region||this.region)}updateThrottleTime(e){this.messageReceiptThrottleTime=e||this.messageReceiptThrottleTime}getMessageReceiptsThrottleTime(){return this.messageReceiptThrottleTime}getStage(){return this.stage}getRegion(){return this.region}getEndpointOverride(){return this.endpointOverride}setFeatureFlag(e){if(!this.isFeatureEnabled(e)){var t=Array.isArray(this.features.values)?this.features.values:[];this.features.values=[...t,e]}}_registerFeatureChangeListener(e,t){this.featureChangeListeners[e]||(this.featureChangeListeners[e]=[]),this.featureChangeListeners[e].push(t)}_cleanFeatureChangeListener(e){delete this.featureChangeListeners[e]}isFeatureEnabled(e,t){return Array.isArray(this.features.values)&&-1!==this.features.values.indexOf(e)?"function"!=typeof t||t():("function"==typeof t&&this._registerFeatureChangeListener(e,t),!1)}},a="MESSAGE_RECEIPTS_ENABLED",c={AGENT:"AGENT",CUSTOMER:"CUSTOMER"},u="API",l="SendMessage",p="SendAttachment",d="DownloadAttachment",h="SendEvent",f="GetTranscript",m="DisconnectParticipant",g="CreateParticipantConnection",v="InitWebsocket",y={INCOMING_MESSAGE:"INCOMING_MESSAGE",INCOMING_TYPING:"INCOMING_TYPING",INCOMING_READ_RECEIPT:"INCOMING_READ_RECEIPT",INCOMING_DELIVERED_RECEIPT:"INCOMING_DELIVERED_RECEIPT",CONNECTION_ESTABLISHED:"CONNECTION_ESTABLISHED",CONNECTION_LOST:"CONNECTION_LOST",CONNECTION_BROKEN:"CONNECTION_BROKEN",CONNECTION_ACK:"CONNECTION_ACK",CHAT_ENDED:"CHAT_ENDED",MESSAGE_METADATA:"MESSAGEMETADATA",PARTICIPANT_IDLE:"PARTICIPANT_IDLE",PARTICIPANT_RETURNED:"PARTICIPANT_RETURNED",AUTODISCONNECTION:"AUTODISCONNECTION"},b={textPlain:"text/plain",textMarkdown:"text/markdown",textCsv:"text/csv",applicationDoc:"application/msword",applicationDocx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",applicationJson:"application/json",applicationPdf:"application/pdf",applicationPpt:"application/vnd.ms-powerpoint",applicationPptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",applicationXls:"application/vnd.ms-excel",applicationXlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",imageJpg:"image/jpeg",imagePng:"image/png",audioWav:"audio/wav",audioXWav:"audio/x-wav",audioVndWave:"audio/vnd.wave",connectionAcknowledged:"application/vnd.amazonaws.connect.event.connection.acknowledged",typing:"application/vnd.amazonaws.connect.event.typing",participantJoined:"application/vnd.amazonaws.connect.event.participant.joined",participantLeft:"application/vnd.amazonaws.connect.event.participant.left",participantActive:"application/vnd.amazonaws.connect.event.participant.active",participantInactive:"application/vnd.amazonaws.connect.event.participant.inactive",transferSucceeded:"application/vnd.amazonaws.connect.event.transfer.succeeded",transferFailed:"application/vnd.amazonaws.connect.event.transfer.failed",chatEnded:"application/vnd.amazonaws.connect.event.chat.ended",interactiveMessage:"application/vnd.amazonaws.connect.message.interactive",interactiveMessageResponse:"application/vnd.amazonaws.connect.message.interactive.response",readReceipt:"application/vnd.amazonaws.connect.event.message.read",deliveredReceipt:"application/vnd.amazonaws.connect.event.message.delivered",participantIdle:"application/vnd.amazonaws.connect.event.participant.idle",participantReturned:"application/vnd.amazonaws.connect.event.participant.returned",autoDisconnection:"application/vnd.amazonaws.connect.event.participant.autodisconnection"},w={[b.typing]:y.INCOMING_TYPING,[b.readReceipt]:y.INCOMING_READ_RECEIPT,[b.deliveredReceipt]:y.INCOMING_DELIVERED_RECEIPT,[b.participantIdle]:y.PARTICIPANT_IDLE,[b.participantReturned]:y.PARTICIPANT_RETURNED,[b.autoDisconnection]:y.AUTODISCONNECTION,default:y.INCOMING_MESSAGE},E=3540,S=n(975),C={assertTrue:function(t,n){if(!t)throw new e(n)},assertNotNull:function(e,t){return C.assertTrue(null!=e,(0,S.sprintf)("%s must be provided",t||"A value")),e},now:function(){return(new Date).getTime()},isString:function(e){return"string"==typeof e},randomId:function(){return(0,S.sprintf)("%s-%s",C.now(),Math.random().toString(36).slice(2))},assertIsNonEmptyString:function(e,t){if(!e||"string"!=typeof e)throw new r(t+" is not a non-empty string!")},assertIsList:function(e,t){if(!Array.isArray(e))throw new r(t+" is not an array")},assertIsEnum:function(e,t,n){var i;for(i=0;i<t.length;i++)if(t[i]===e)return;throw new r(n+" passed ("+e+") is not valid. Allowed values are: "+t)},makeEnum:function(e){var t={};return e.forEach((function(e){var n=e.replace(/\.?([a-z]+)_?/g,(function(e,t){return t.toUpperCase()+"_"})).replace(/_$/,"");t[n]=e})),t},contains:function(e,t){return e instanceof Array?null!==C.find(e,(function(e){return e===t})):t in e},find:function(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n];return null},containsValue:function(e,t){return e instanceof Array?null!==C.find(e,(function(e){return e===t})):null!==C.find(C.values(e),(function(e){return e===t}))},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},values:function(e){var t=[];for(var n in C.assertNotNull(e,"map"),e)t.push(e[n]);return t},isObject:function(e){return!("object"!=typeof e||null===e)},assertIsObject:function(e,t){if(!C.isObject(e))throw new r(t+" is not an object!")},delay:e=>new Promise((t=>setTimeout(t,e))),asyncWhileInterval:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=new Date;return t(r)?e(r).catch((i=>{var s=Math.max(0,n-(new Date).valueOf()+o.valueOf());return C.delay(s).then((()=>C.asyncWhileInterval(e,t,n,r+1,i)))})):Promise.reject(i||new Error("async while aborted"))},isAttachmentContentType:function(e){return e===b.applicationPdf||e===b.imageJpg||e===b.imagePng||e===b.applicationDoc||e===b.applicationXls||e===b.applicationPpt||e===b.textCsv||e===b.audioWav}};const T=C;var I={DEBUG:10,INFO:20,WARN:30,ERROR:40,ADVANCED_LOG:50},k=new class{constructor(){this.updateLoggerConfig()}writeToClientLogger(e,t,n){if(this.hasClientLogger()){var r=function(e){switch(e){case 10:return"DEBUG";case 20:return"INFO";case 30:return"WARN";case 40:return"ERROR";case 50:return"ADVANCED_LOG"}}(e);switch(e){case I.DEBUG:return this._clientLogger.debug(r,t,n)||t;case I.INFO:return this._clientLogger.info(r,t,n)||t;case I.WARN:return this._clientLogger.warn(r,t,n)||t;case I.ERROR:return this._clientLogger.error(r,t,n)||t;case I.ADVANCED_LOG:return this._advancedLogWriter&&this._clientLogger[this._advancedLogWriter]&&this._clientLogger[this._advancedLogWriter](r,t,n)||t}}}isLevelEnabled(e){return e>=this._level}hasClientLogger(){return null!==this._clientLogger}getLogger(){return new x(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}updateLoggerConfig(e){var t=e||{};this._level=t.level||I.INFO,this._advancedLogWriter="warn",function(e,t){var n=t&&Object.keys(t);if(n&&-1===n.indexOf(e))return console.error("customizedLogger: incorrect value for loggerConfig:advancedLogWriter; use valid values from list ".concat(n," but used ").concat(e)),!1;var r=["warn","info","debug","log"];return!e||-1!==r.indexOf(e)||(console.error("incorrect value for loggerConfig:advancedLogWriter; use valid values from list ".concat(r," but used ").concat(e)),!1)}(t.advancedLogWriter,t.customizedLogger)&&(this._advancedLogWriter=t.advancedLogWriter),(t.customizedLogger&&"object"==typeof t.customizedLogger||t.logger&&"object"==typeof t.logger)&&(this.useClientLogger=!0),this._clientLogger=this.selectLogger(t)}selectLogger(e){return e.customizedLogger&&"object"==typeof e.customizedLogger?e.customizedLogger:e.logger&&"object"==typeof e.logger?e.logger:e.useDefaultLogger?A():null}};class _{debug(){}info(){}warn(){}error(){}}class x extends _{constructor(e){super(),this.options=e||{}}debug(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(I.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(I.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(I.WARN,t)}error(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(I.ERROR,t)}advancedLog(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(I.ADVANCED_LOG,t)}_shouldLog(e){return k.hasClientLogger()&&k.isLevelEnabled(e)}_writeToClientLogger(e,t){return k.writeToClientLogger(e,t,this.options.logMetaData)}_log(e,t){if(this._shouldLog(e)){var n=k.useClientLogger?t:this._convertToSingleStatement(t);return this._writeToClientLogger(e,n)}}_convertToSingleStatement(e){var t=new Date(Date.now()).toISOString(),n="[".concat(t,"]");this.options&&(this.options.prefix?n+=" "+this.options.prefix+":":n+="");for(var r=0;r<e.length;r++){var i=e[r];n+=" "+this._convertToString(i)}return n}_convertToString(e){try{if(!e)return"";if(T.isString(e))return e;if(T.isObject(e)&&T.isFunction(e.toString)){var t=e.toString();if("[object Object]"!==t)return t}return JSON.stringify(e)}catch(t){return console.error("Error while converting argument to string",e,t),""}}}var A=()=>{var e=new _;return e.debug=console.debug.bind(window.console),e.info=console.info.bind(window.console),e.warn=console.warn.bind(window.console),e.error=console.error.bind(window.console),e},R=(n(228),n(493)),O=n.n(R);function N(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L(Object(n),!0).forEach((function(t){P(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function P(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class D{sendMessage(e,n,r){throw new t("sendTextMessage in ChatClient")}sendAttachment(e,n,r){throw new t("sendAttachment in ChatClient")}downloadAttachment(e,n){throw new t("downloadAttachment in ChatClient")}disconnectParticipant(e){throw new t("disconnectParticipant in ChatClient")}sendEvent(e,n,r){throw new t("sendEvent in ChatClient")}createParticipantConnection(e,n){throw new t("createParticipantConnection in ChatClient")}}class U extends D{constructor(e){super(),P(this,"throttleEvent",O()(((e,t,n)=>this._submitEvent(e,t,n)),1e4,{trailing:!1,leading:!0}));var t=new AWS.Credentials("",""),n=new AWS.Config({region:e.region,endpoint:e.endpoint,credentials:t});this.chatClient=new AWS.ConnectParticipant(n),this.invokeUrl=e.endpoint,this.logger=k.getLogger({prefix:"Amazon-Connect-ChatJS-ChatClient",logMetaData:e.logMetaData})}createParticipantConnection(e,t,n){var r=this,i={ParticipantToken:e,Type:t,ConnectParticipant:n},o=r.chatClient.createParticipantConnection(i);return r._sendRequest(o).then((e=>{var t,n;return null===(t=r.logger.info("Successfully create connection request"))||void 0===t||null===(n=t.sendInternalLogToServer)||void 0===n||n.call(t),e})).catch((e=>{var t,n;return null===(t=r.logger.error("Error when creating connection request ",e))||void 0===t||null===(n=t.sendInternalLogToServer)||void 0===n||n.call(t),Promise.reject(e)}))}disconnectParticipant(e){var t=this,n={ConnectionToken:e},r=t.chatClient.disconnectParticipant(n);return t._sendRequest(r).then((e=>{var n,r;return null===(n=t.logger.info("Successfully disconnect participant"))||void 0===n||null===(r=n.sendInternalLogToServer)||void 0===r||r.call(n),e})).catch((e=>{var n,r;return null===(n=t.logger.error("Error when disconnecting participant ",e))||void 0===n||null===(r=n.sendInternalLogToServer)||void 0===r||r.call(n),Promise.reject(e)}))}getTranscript(e,t){var n={MaxResults:t.maxResults,NextToken:t.nextToken,ScanDirection:t.scanDirection,SortOrder:t.sortOrder,StartPosition:{Id:t.startPosition.id,AbsoluteTime:t.startPosition.absoluteTime,MostRecent:t.startPosition.mostRecent},ConnectionToken:e};t.contactId&&(n.ContactId=t.contactId);var r=this.chatClient.getTranscript(n);return this._sendRequest(r).then((e=>(this.logger.info("Successfully get transcript"),e))).catch((e=>(this.logger.error("Get transcript error",e),Promise.reject(e))))}sendMessage(e,t,n){var r={Content:t,ContentType:n,ConnectionToken:e},i=this.chatClient.sendMessage(r);return this._sendRequest(i).then((e=>{var t,n={id:null===(t=e.data)||void 0===t?void 0:t.Id,contentType:r.ContentType};return this.logger.debug("Successfully send message",n),e})).catch((e=>(this.logger.error("Send message error",e,{contentType:r.ContentType}),Promise.reject(e))))}sendAttachment(e,t,n){var r=this,i={ContentType:t.type,AttachmentName:t.name,AttachmentSizeInBytes:t.size,ConnectionToken:e},o=r.chatClient.startAttachmentUpload(i),s={contentType:t.type,size:t.size};return r._sendRequest(o).then((n=>r._uploadToS3(t,n.data.UploadMetadata).then((()=>{var t,i={AttachmentIds:[n.data.AttachmentId],ConnectionToken:e};this.logger.debug("Successfully upload attachment",M(M({},s),{},{attachmentId:null===(t=n.data)||void 0===t?void 0:t.AttachmentId}));var o=r.chatClient.completeAttachmentUpload(i);return r._sendRequest(o)})))).catch((e=>(this.logger.error("Upload attachment error",e,s),Promise.reject(e))))}_uploadToS3(e,t){return fetch(t.Url,{method:"PUT",headers:t.HeadersToInclude,body:e})}downloadAttachment(e,t){var n=this,r={AttachmentId:t,ConnectionToken:e},i={attachmentId:t},o=n.chatClient.getAttachment(r);return n._sendRequest(o).then((e=>(this.logger.debug("Successfully download attachment",i),n._downloadUrl(e.data.Url)))).catch((e=>(this.logger.error("Download attachment error",e,i),Promise.reject(e))))}_downloadUrl(e){return fetch(e).then((e=>e.blob())).catch((e=>Promise.reject(e)))}sendEvent(e,t,n){return t===b.typing?this.throttleEvent(e,t,n):this._submitEvent(e,t,n)}_submitEvent(e,t,n){var r,i=this;return(r=function*(){var r=i,o={ConnectionToken:e,ContentType:t,Content:n},s=r.chatClient.sendEvent(o),a={contentType:t};try{var c,u=yield r._sendRequest(s);return i.logger.debug("Successfully send event",M(M({},a),{},{id:null===(c=u.data)||void 0===c?void 0:c.Id})),u}catch(e){return yield Promise.reject(e)}},function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){N(o,n,i,s,a,"next",e)}function a(e){N(o,n,i,s,a,"throw",e)}s(void 0)}))})()}_sendRequest(e){return new Promise(((t,n)=>{e.on("success",(function(e){t(e)})).on("error",(function(e){var t={type:e.code,message:e.message,stack:e.stack?e.stack.split("\n"):[],statusCode:e.statusCode};n(t)})).send()}))}}var q=new class{constructor(){this.clientCache={}}getCachedClient(e,t){var n=Object.assign({},e),r=e.region||s.getRegion()||"us-west-2";if(n.region=r,t.region=r,this.clientCache[r])return this.clientCache[r];var i=this._createAwsClient(n,t);return this.clientCache[r]=i,i}_createAwsClient(e,t){var n=e.region,r=s.getEndpointOverride(),i="https://participant.connect.".concat(n,".amazonaws.com");return r&&(i=r),new U({endpoint:i,region:n,logMetaData:t})}};class j{validateNewControllerDetails(e){return!0}validateSendMessage(e){if(!T.isString(e.message))throw new r(e.message+"is not a valid message");this.validateContentType(e.contentType)}validateContentType(e){T.assertIsEnum(e,Object.values(b),"contentType")}validateConnectChat(e){return!0}validateLogger(e){T.assertIsObject(e,"logger"),["debug","info","warn","error"].forEach((t=>{if(!T.isFunction(e[t]))throw new r(t+" should be a valid function on the passed logger object!")}))}validateSendEvent(e){this.validateContentType(e.contentType)}validateGetMessages(e){return!0}}class F extends j{validateChatDetails(e,t){if(T.assertIsObject(e,"chatDetails"),t===c.AGENT&&!T.isFunction(e.getConnectionToken))throw new r("getConnectionToken was not a function",e.getConnectionToken);if(T.assertIsNonEmptyString(e.contactId,"chatDetails.contactId"),T.assertIsNonEmptyString(e.participantId,"chatDetails.participantId"),t===c.CUSTOMER){if(!e.participantToken)throw new r("participantToken was not provided for a customer session type",e.participantToken);T.assertIsNonEmptyString(e.participantToken,"chatDetails.participantToken")}}validateInitiateChatResponse(){return!0}normalizeChatDetails(e){var t={};return t.contactId=e.ContactId||e.contactId,t.participantId=e.ParticipantId||e.participantId,t.initialContactId=e.InitialContactId||e.initialContactId||t.contactId||t.ContactId,t.getConnectionToken=e.getConnectionToken||e.GetConnectionToken,(e.participantToken||e.ParticipantToken)&&(t.participantToken=e.ParticipantToken||e.participantToken),this.validateChatDetails(t),t}}var W="NeverStarted",B="Starting",z="Connected",H="ConnectionLost",V="Ended",G="ConnectionLost",K="ConnectionGained",X="Ended",J="IncomingMessage";class Y{constructor(e,t){this.connectionDetailsProvider=e,this.isStarted=!1,this.logger=k.getLogger({prefix:"ChatJS-BaseConnectionHelper",logMetaData:t})}startConnectionTokenPolling(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:432e5;if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0]))return this.connectionDetailsProvider.fetchConnectionDetails().then((t=>(this.logger.info("Connection token polling succeeded."),e=this.getTimeToConnectionTokenExpiry(),this.timeout=setTimeout(this.startConnectionTokenPolling.bind(this),e),t))).catch((t=>(this.logger.error("An error occurred when attempting to fetch the connection token during Connection Token Polling",t),this.timeout=setTimeout(this.startConnectionTokenPolling.bind(this),e),t)));this.logger.info("First time polling connection token."),this.timeout=setTimeout(this.startConnectionTokenPolling.bind(this),e)}start(){return this.isStarted?this.getConnectionToken():(this.isStarted=!0,this.startConnectionTokenPolling(!0,this.getTimeToConnectionTokenExpiry()))}end(){clearTimeout(this.timeout)}getConnectionToken(){return this.connectionDetailsProvider.getFetchedConnectionToken()}getConnectionTokenExpiry(){return this.connectionDetailsProvider.getConnectionTokenExpiry()}getTimeToConnectionTokenExpiry(){return new Date(this.getConnectionTokenExpiry()).getTime()-(new Date).getTime()-6e4}}var $="<<all>>",Q=function(e,t,n){this.subMap=e,this.id=T.randomId(),this.eventName=t,this.f=n};Q.prototype.unsubscribe=function(){this.subMap.unsubscribe(this.eventName,this.id)};var Z=function(){this.subIdMap={},this.subEventNameMap={}};Z.prototype.subscribe=function(e,t){var n=new Q(this,e,t);this.subIdMap[n.id]=n;var r=this.subEventNameMap[e]||[];return r.push(n),this.subEventNameMap[e]=r,()=>n.unsubscribe()},Z.prototype.unsubscribe=function(e,t){T.contains(this.subEventNameMap,e)&&(this.subEventNameMap[e]=this.subEventNameMap[e].filter((function(e){return e.id!==t})),this.subEventNameMap[e].length<1&&delete this.subEventNameMap[e]),T.contains(this.subIdMap,t)&&delete this.subIdMap[t]},Z.prototype.getAllSubscriptions=function(){return T.values(this.subEventNameMap).reduce((function(e,t){return e.concat(t)}),[])},Z.prototype.getSubscriptions=function(e){return this.subEventNameMap[e]||[]};var ee=function(e){var t=e||{};this.subMap=new Z,this.logEvents=t.logEvents||!1};ee.prototype.subscribe=function(e,t){return T.assertNotNull(e,"eventName"),T.assertNotNull(t,"f"),T.assertTrue(T.isFunction(t),"f must be a function"),this.subMap.subscribe(e,t)},ee.prototype.subscribeAll=function(e){return T.assertNotNull(e,"f"),T.assertTrue(T.isFunction(e),"f must be a function"),this.subMap.subscribe($,e)},ee.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},ee.prototype.trigger=function(e,t){T.assertNotNull(e,"eventName");var n=this,r=this.subMap.getSubscriptions($),i=this.subMap.getSubscriptions(e);r.concat(i).forEach((function(r){try{r.f(t||null,e,n)}catch(e){}}))},ee.prototype.triggerAsync=function(e,t){setTimeout((()=>this.trigger(e,t)),0)},ee.prototype.bridge=function(){var e=this;return function(t,n){e.trigger(n,t)}},ee.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach((function(e){e.unsubscribe()}))};var te="Category",ne=new class{constructor(){this.widgetType="CustomChatWidget",this.logger=k.getLogger({prefix:"ChatJS-csmService"}),this.csmInitialized=!1,this.metricsToBePublished=[],this.agentMetricToBePublished=[],this.MAX_RETRY=5}loadCsmScriptAndExecute(){try{var e=document.createElement("script");e.type="text/javascript",e.innerHTML="(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n csm.EVENT_TYPE = {\n LOG: 'LOG',\n METRIC: 'METRIC',\n CONFIG: 'CONFIG',\n WORKFLOW_EVENT: 'WORKFLOW_EVENT',\n CUSTOM: 'CUSTOM',\n CLOSE: 'CLOSE',\n SET_AUTH: 'SET_AUTH',\n SET_CONFIG: 'SET_CONFIG',\n };\n\n csm.UNIT = {\n COUNT: 'Count',\n SECONDS: 'Seconds',\n MILLISECONDS: 'Milliseconds',\n MICROSECONDS: 'Microseconds',\n };\n})();\n\n(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n const MAX_METRIC_DIMENSIONS = 10;\n\n /** ********* Dimension Classes ***********/\n\n const Dimension = function(name, value) {\n csm.Util.assertExist(name, 'name');\n csm.Util.assertExist(value, 'value');\n\n this.name = name;\n this.value = value == null ? 'null' : (value === '' ? ' ' : value.toString());\n };\n\n\n /** ********* Metric Classes ***********/\n\n const Metric = function(metricName, unit, value, dedupeOptions) {\n csm.Util.assertExist(metricName, 'metricName');\n csm.Util.assertExist(value, 'value');\n csm.Util.assertExist(unit, 'unit');\n csm.Util.assertTrue(csm.Util.isValidUnit(unit));\n if (dedupeOptions) {\n csm.Util.assertInObject(dedupeOptions, 'dedupeOptions', 'dedupeIntervalMs');\n }\n\n this.metricName = metricName;\n this.unit = unit;\n this.value = value;\n this.timestamp = new Date();\n this.dimensions = csm.globalDimensions ? csm.Util.deepCopy(csm.globalDimensions): [];\n this.namespace = csm.configuration.namespace;\n this.dedupeOptions = dedupeOptions; // optional. { dedupeIntervalMs: (int; required), context: (string; optional) }\n\n // Currently, CloudWatch can't aggregate metrics by a subset of dimensions.\n // To bypass this limitation, we introduce the optional dimensions concept to CSM.\n // The CSM metric publisher will publish a default metric without optional dimension\n // For each optional dimension, the CSM metric publisher publishes an extra metric with that dimension.\n this.optionalDimensions = csm.globalOptionalDimensions ? csm.Util.deepCopy(csm.globalOptionalDimensions): [];\n };\n\n Metric.prototype.addDimension = function(name, value) {\n this._addDimensionHelper(this.dimensions, name, value);\n };\n\n Metric.prototype.addOptionalDimension = function(name, value) {\n this._addDimensionHelper(this.optionalDimensions, name, value);\n };\n\n Metric.prototype._addDimensionHelper = function(targetDimensions, name, value) {\n // CloudWatch metric allows maximum 10 dimensions\n // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#putMetricData-property\n if ((this.dimensions.length + this.optionalDimensions.length) >= MAX_METRIC_DIMENSIONS) {\n throw new csm.ExceedDimensionLimitException(name);\n }\n\n const existing = targetDimensions.find(function(dimension) {\n return dimension.name === name;\n });\n\n if (existing) {\n existing.value = value == null ? 'null' : (value === '' ? ' ' : value.toString());\n } else {\n targetDimensions.push(new Dimension(name, value));\n }\n };\n\n\n /** ********* Telemetry Classes ***********/\n\n const WorkflowEvent = function(params) {\n this.timestamp = params.timestamp || new Date().getTime();\n this.workflowType = params.workflow.type;\n this.instanceId = params.workflow.instanceId;\n this.userId = params.userId;\n this.organizationId = params.organizationId;\n this.accountId = params.accountId;\n this.event = params.event;\n this.appName = params.appName;\n this.data = [];\n\n // Convert 'data' map into the KeyValuePairList structure expected by the Lambda API\n for (const key in params.data) {\n if (Object.prototype.hasOwnProperty.call(params.data, key)) {\n this.data.push({'key': key, 'value': params.data[key]});\n }\n }\n };\n\n /** ********* Exceptions ***********/\n\n const NullOrUndefinedException = function(paramName) {\n this.name = 'NullOrUndefinedException';\n this.message = paramName + ' is null or undefined. ';\n };\n NullOrUndefinedException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const AssertTrueException = function() {\n this.name = 'AssertTrueException';\n this.message = 'Assertion failed. ';\n };\n AssertTrueException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const ExceedDimensionLimitException = function(dimensionName) {\n this.name = 'ExceedDimensionLimitException';\n this.message = 'Could not add dimension \\'' + dimensionName + '\\'. Metric has maximum 10 dimensions. ';\n };\n ExceedDimensionLimitException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const InitializationException = function() {\n this.name = 'InitializationException';\n this.message = 'Initialization failed. ';\n };\n InitializationException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n\n csm.Dimension = Dimension;\n csm.Metric = Metric;\n csm.WorkflowEvent = WorkflowEvent;\n csm.NullOrUndefinedException = NullOrUndefinedException;\n csm.AssertTrueException = AssertTrueException;\n csm.InitializationException = InitializationException;\n csm.ExceedDimensionLimitException = ExceedDimensionLimitException;\n})();\n\n(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n const validTimeUnits = [csm.UNIT.SECONDS, csm.UNIT.MILLISECONDS, csm.UNIT.MICROSECONDS];\n const validUnits = validTimeUnits.concat(csm.UNIT.COUNT);\n\n const Util = {\n assertExist: function(value, paramName) {\n if (value === null || value === undefined) {\n throw new csm.NullOrUndefinedException(paramName);\n }\n },\n assertTrue: function(value) {\n if (!value) {\n throw new csm.AssertTrueException();\n }\n },\n assertInObject: function(obj, objName, key) {\n if (obj === null || obj === undefined || typeof obj !== 'object') {\n throw new csm.NullOrUndefinedException(objName);\n }\n if (key === null || key === undefined || !obj[key]) {\n throw new csm.NullOrUndefinedException(`${objName}[${key}]`);\n }\n },\n isValidUnit: function(unit) {\n return validUnits.includes(unit);\n },\n isValidTimeUnit: function(unit) {\n return validTimeUnits.includes(unit);\n },\n isEmpty: function(value) {\n if (value !== null && typeof val === 'object') {\n return Objects.keys(value).length === 0;\n }\n return !value;\n },\n deepCopy: function(obj) {\n // NOTE: this will fail if obj has a circular reference\n return JSON.parse(JSON.stringify(obj));\n },\n\n /**\n * This function is used before setting the page location for default metrics and logs,\n * and the APIs that set page location\n * Can be overridden by calling csm.API.setPageLocationTransformer(function(){})\n * @param {string} pathname path for page location\n * @return {string} pathname provided\n */\n pageLocationTransformer: function(pathname) {\n return pathname;\n },\n\n /**\n * As of now, our service public claims only support for Firefox and Chrome\n * Reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent\n *\n * This function will only return firefox, chrome and others\n *\n * Best practice as indicated in MDN, \"Avoiding user agent detection\"\n */\n getBrowserDetails: function() {\n const userAgent = window.navigator.userAgent;\n const details = {};\n if (userAgent.includes('Firefox') && !userAgent.includes('Seamonkey')) {\n details.name = 'Firefox';\n details.version = getBrowserVersion('Firefox');\n } else if (userAgent.includes('Chrome') && !userAgent.includes('Chromium')) {\n details.name = 'Chrome';\n details.version = getBrowserVersion('Chrome');\n }\n },\n\n randomId: function() {\n return new Date().getTime() + '-' + Math.random().toString(36).slice(2);\n },\n\n getOrigin: function() {\n return document.location.origin;\n },\n\n getReferrerUrl: function() {\n const referrer = document.referrer || '';\n return this.getURLOrigin(referrer);\n },\n\n getWindowParent: function() {\n let parentLocation = '';\n try {\n parentLocation = window.parent.location.href;\n } catch (e) {\n parentLocation = '';\n }\n return parentLocation;\n },\n\n getURLOrigin: function(urlValue) {\n let origin = '';\n const originArray = urlValue.split( '/' );\n if (originArray.length >= 3) {\n const protocol = originArray[0];\n const host = originArray[2];\n origin = protocol + '//' + host;\n }\n return origin;\n },\n\n };\n\n const getBrowserVersion = function(browserName) {\n const userAgent = window.navigator.userAgent;\n const browserNameIndex = userAgent.indexOf(browserName);\n const nextSpaceIndex = userAgent.indexOf(' ', browserNameIndex);\n if (nextSpaceIndex === -1) {\n return userAgent.substring(browserNameIndex + browserName.length + 1, userAgent.length);\n } else {\n return userAgent.substring(browserNameIndex + browserName.length + 1, nextSpaceIndex);\n }\n };\n\n csm.Util = Util;\n})();\n\n(function() {\n const global = window;\n const csm = global.csm || {};\n global.csm = csm;\n\n csm.globalDimensions = []; // These dimensions are added to all captured metrics.\n csm.globalOptionalDimensions = [];\n csm.initFailureDimensions = [];\n\n const API = {\n getWorkflow: function(workflowType, instanceId, data) {\n return csm.workflow(workflowType, instanceId, data);\n },\n\n addMetric: function(metric) {\n csm.Util.assertExist(metric, 'metric');\n csm.putMetric(metric);\n },\n\n addMetricWithDedupe: function(metric, dedupeIntervalMs, context) {\n csm.Util.assertExist(metric, 'metric');\n csm.Util.assertExist(metric, 'dedupeIntervalMs');\n // context is optional; if present it will only dedupe on metrics with the same context. ex.) tabId\n metric.dedupeOptions = {dedupeIntervalMs, context: context || 'global'};\n csm.putMetric(metric);\n },\n\n addCount: function(metricName, count) {\n csm.Util.assertExist(metricName, 'metricName');\n csm.Util.assertExist(count, 'count');\n\n const metric = new csm.Metric(metricName, csm.UNIT.COUNT, count);\n csm.putMetric(metric);\n },\n\n addCountWithPageLocation: function(metricName) {\n csm.Util.assertExist(metricName, 'metricName');\n\n const metric = new csm.Metric(metricName, csm.UNIT.COUNT, 1.0);\n metric.addDimension('WindowLocation', csm.Util.pageLocationTransformer(window.location.pathname));\n csm.putMetric(metric);\n },\n\n addError: function(metricName, count) {\n csm.Util.assertExist(metricName, 'metricName');\n\n if (count === undefined || count == null) {\n count = 1.0;\n }\n const metric = new csm.Metric(metricName, csm.UNIT.COUNT, count);\n metric.addDimension('Metric', 'Error');\n csm.putMetric(metric);\n },\n\n addSuccess: function(metricName) {\n API.addError(metricName, 0);\n },\n\n addTime: function(metricName, time, unit) {\n csm.Util.assertExist(metricName, 'metricName');\n csm.Util.assertExist(time, 'time');\n\n let timeUnit = csm.UNIT.MILLISECONDS;\n if (unit && csm.Util.isValidTimeUnit(unit)) {\n timeUnit = unit;\n }\n const metric = new csm.Metric(metricName, timeUnit, time);\n metric.addDimension('Metric', 'Time');\n csm.putMetric(metric);\n },\n\n addTimeWithPageLocation: function(metricName, time, unit) {\n csm.Util.assertExist(metricName, 'metricName');\n csm.Util.assertExist(time, 'time');\n\n let timeUnit = csm.UNIT.MILLISECONDS;\n if (unit && csm.Util.isValidTimeUnit(unit)) {\n timeUnit = unit;\n }\n const metric = new csm.Metric(metricName, timeUnit, time);\n metric.addDimension('WindowLocation', csm.Util.pageLocationTransformer(window.location.pathname));\n csm.putMetric(metric);\n },\n\n pageReady: function() {\n if (window.performance && window.performance.now) {\n const pageLoadTime = window.performance.now();\n const metric = new csm.Metric('PageReadyLatency', csm.UNIT.MILLISECONDS, pageLoadTime);\n metric.addDimension('WindowLocation', csm.Util.pageLocationTransformer(window.location.pathname));\n csm.putMetric(metric);\n }\n },\n\n setPageLocationTransformer: function(transformFunc) {\n csm.Util.assertExist(transformFunc, 'transformFunc');\n csm.Util.assertTrue((typeof transformFunc) === 'function');\n csm.Util.pageLocationTransformer = transformFunc;\n },\n\n setGlobalDimensions: function(dimensions) {\n csm.Util.assertExist(dimensions, 'dimensions');\n csm.globalDimensions = dimensions;\n },\n\n setGlobalOptionalDimensions: function(dimensions) {\n csm.Util.assertExist(dimensions, 'dimensions');\n csm.globalOptionalDimensions = dimensions;\n },\n\n setInitFailureDimensions: function(dimensions) {\n csm.Util.assertExist(dimensions, 'dimensions');\n csm.initFailureDimensions = dimensions;\n },\n\n putCustom: function(endpoint, headers, data) {\n csm.Util.assertExist(data, 'data');\n csm.Util.assertExist(endpoint, 'endpoint');\n csm.Util.assertExist(headers, 'headers');\n csm.putCustom(endpoint, headers, data);\n },\n\n setAuthParams: function(authParams) {\n csm.setAuthParams(authParams);\n },\n\n setConfig: function(key, value) {\n csm.Util.assertExist(key, 'key');\n csm.Util.assertExist(value, 'value');\n if (!csm.configuration[key]) {\n csm.setConfig(key, value); // set configuration variables such as accountId, instanceId, userId\n }\n },\n };\n\n csm.API = API;\n})();\n\n(function() {\n const global = window;\n const csm = global.csm || {};\n global.csm = csm;\n\n const WORKFLOW_KEY_PREFIX = 'csm.workflow';\n\n /**\n * Calculates the local storage key used to store a workflow of the specified type.\n * @param {string} type of workflow\n * @return {string} storage key\n */\n const getWorkflowKeyForType = function(type) {\n return [\n WORKFLOW_KEY_PREFIX,\n type,\n ].join('.');\n };\n\n /**\n * Constructor for new Workflow objects.\n *\n * If you need to be able to share a workflow across tabs, it is recommended\n * to use \"csm.workflow\" to create/hydrate your workflows instead.\n * @param {string} type of workflow\n * @param {string} instanceId of workflow\n * @param {JSON} data blob associated with workflow\n */\n const Workflow = function(type, instanceId, data) {\n this.type = type;\n this.instanceId = instanceId || csm.Util.randomId();\n this.instanceSpecified = instanceId || false;\n this.eventMap = {};\n this.data = data || {};\n\n // Merge global dimensions into the data map.\n const dimensionData = {};\n csm.globalDimensions.forEach(function(dimension) {\n dimensionData[dimension.name] = dimension.value;\n });\n csm.globalOptionalDimensions.forEach(function(dimension) {\n dimensionData[dimension.name] = dimension.value;\n });\n this.data = this._mergeData(dimensionData);\n };\n\n /**\n * Create a new workflow or rehydrate an existing shared workflow.\n *\n * @param {string} type The type of workflow to be created.\n * @param {string} instanceId The instanceId of the workflow. If not provided, it will be\n * assigned a random ID and will not be automatically saved to local storage.\n * If provided, we will attempt to load an existing workflow of the same type\n * from local storage and rehydrate it.\n * @param {JSON} data An optional map of key/value pairs to be added as data to every\n * workflow event created with this workflow.\n * @return {Workflow} workflow event\n * NOTE: Only one workflow of each type can be stored at the same time, to avoid\n * overloading localStorage with unused workflow records.\n */\n csm.workflow = function(type, instanceId, data) {\n let workflow = new Workflow(type, instanceId, data);\n\n if (instanceId) {\n const savedWorkflow = csm._loadWorkflow(type);\n if (savedWorkflow && savedWorkflow.instanceId === instanceId) {\n workflow = savedWorkflow;\n workflow.addData(data || {});\n }\n }\n\n return workflow;\n };\n\n csm._loadWorkflow = function(type) {\n let workflow = null;\n const workflowJson = localStorage.getItem(getWorkflowKeyForType(type));\n const workflowStruct = workflowJson ? JSON.parse(workflowJson) : null;\n if (workflowStruct) {\n workflow = new Workflow(type, workflowStruct.instanceId);\n workflow.eventMap = workflowStruct.eventMap;\n }\n return workflow;\n };\n\n /**\n * Creates a new workflow event and returns it. Then this workflow event is sent upstream\n * to the CSMSharedWorker where it is provided to the backend.\n *\n * If an instanceId was specified when the workflow was created, this will also save the workflow\n * and all of its events to localStorage.\n *\n * @param {string} event The name of the event that occurred.\n * @param {JSON} data An optional free-form key attribute pair of metadata items that will be stored\n * and reported backstream with the workflow event.\n * @return {WorkflowEvent} workflowEvent\n */\n Workflow.prototype.event = function(event, data) {\n const mergedData = this._mergeData(data || {});\n const workflowEvent = new csm.WorkflowEvent({\n workflow: this,\n event: event,\n data: mergedData,\n userId: csm.configuration.userId || '',\n organizationId: csm.configuration.organizationId || '',\n accountId: csm.configuration.accountId || '',\n appName: csm.configuration.namespace || '',\n });\n csm.putWorkflowEvent(workflowEvent);\n this.eventMap[event] = workflowEvent;\n if (this.instanceSpecified) {\n this.save();\n }\n return workflowEvent;\n };\n\n /**\n * Creates a new workflow event and returns it, if the same event is not happened in ths past\n * dedupeIntervalMs milliseconds.\n * @param {string} event The name of the event that occurred.\n * @param {JSON} data An optional free-form key attribute pair of metadata items that will be stored\n * and reported backstream with the workflow event.\n * @param {int} dedupeIntervalMs defaults to 200 MS\n * @return {WorkflowEvent} workflowEvent\n */\n Workflow.prototype.eventWithDedupe = function(event, data, dedupeIntervalMs) {\n const pastEvent = this.getPastEvent(event);\n const now = new Date().getTime();\n const interval = dedupeIntervalMs || 200;\n\n // Crafting the expected workflow event data result\n const mergedData = this._mergeData(data);\n const expectedData = [];\n for (const key in mergedData) {\n if (Object.prototype.hasOwnProperty.call(mergedData, key)) {\n expectedData.push({'key': key, 'value': mergedData[key]});\n }\n }\n\n // Deduplicate same events that happened within interval\n if (!pastEvent || (pastEvent && JSON.stringify(pastEvent.data) !== JSON.stringify(expectedData)) ||\n (pastEvent && (now - pastEvent.timestamp > interval))) {\n return this.event(event, data);\n }\n return null;\n };\n\n /**\n * Get a past event if it exists in this workflow, otherwise returns null.\n * This can be helpful to emit metrics in real time based on the differences\n * between workflow event timestamps, especially for workflows shared across tabs.\n * @param {string} event key to see if workflow exists for this event\n * @return {WorkflowEvent} workflow event retrieved\n */\n Workflow.prototype.getPastEvent = function(event) {\n return event in this.eventMap ? this.eventMap[event] : null;\n };\n\n /**\n * Save the workflow to local storage. This only happens automatically when an\n * instanceId is specified on workflow creation, however if this method is called\n * explicitly by the client, the randomly generated workflow instance id can be\n * used to retrieve the workflow later and automatic save on events will be enabled.\n */\n Workflow.prototype.save = function() {\n this.instanceSpecified = true;\n localStorage.setItem(getWorkflowKeyForType(this.type), JSON.stringify(this));\n };\n\n /**\n * Remove this workflow if it is the saved instance for this workflow type in localStorage.\n */\n Workflow.prototype.close = function() {\n const storedWorkflow = csm._loadWorkflow(this.type);\n if (storedWorkflow && storedWorkflow.instanceId === this.instanceId) {\n localStorage.removeItem(getWorkflowKeyForType(this.type));\n }\n };\n\n Workflow.prototype.addData = function(data) {\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n this.data[key] = data[key];\n }\n }\n };\n\n Workflow.prototype._mergeData = function(data) {\n const mergedData = {};\n let key = null;\n for (key in this.data) {\n if (Object.prototype.hasOwnProperty.call(this.data, key)) {\n mergedData[key] = this.data[key] == null ? 'null' : (this.data[key] === '' ? ' ' : this.data[key].toString());\n }\n }\n for (key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n mergedData[key] = data[key] == null ? 'null' : (data[key] === '' ? ' ' : data[key].toString());\n }\n }\n return mergedData;\n };\n})();\n\n(function() {\n const global = window;\n const csm = global.csm || {};\n global.csm = csm;\n\n let worker = null;\n let portId = null;\n\n const MAX_INIT_MILLISECONDS = 5000;\n const preInitTaskQueue = [];\n csm.configuration = {};\n\n /**\n * Initialize CSM variables\n * @param {object} params for CSM\n * @params.namespace Define your metric namespace used in CloudWatch metrics\n * @params.sharedWorkerUrl Specify the relative url to the connect-csm-worker.js file in your service\n * @params.endpoint Specify an LDAS endpoint to use.\n * @params.dryRunMode When CSM is initialized with dry run mode, it won't actually publish metrics.\n * @params.defaultMetrics Enable default metrics. Default to false.\n */\n csm.initCSM = function(params) {\n csm.Util.assertExist(params.namespace, 'namespace');\n csm.Util.assertExist(params.sharedWorkerUrl, 'sharedWorkerUrl');\n csm.Util.assertExist(params.endpoint, 'endpoint');\n\n try {\n console.log('Starting csm shared worker with', params.sharedWorkerUrl);\n worker = new SharedWorker(params.sharedWorkerUrl, 'CSM_SharedWorker');\n worker.port.start();\n } catch (e) {\n console.log('Failed to initialize csm shared worker with', params.sharedWorkerUrl);\n console.log(e.message);\n }\n\n /**\n * Configure shared worker\n */\n csm.configuration = {\n namespace: params.namespace,\n userId: params.userId || '',\n accountId: params.accountId || '',\n organizationId: params.organizationId || '',\n endpointUrl: params.endpoint || null,\n batchSettings: params.batchSettings || null,\n addPageVisibilityDimension: params.addPageVisibilityDimension || false,\n addUrlDataDimensions: params.addUrlDataDimensions || false,\n dryRunMode: params.dryRunMode || false, // When csm is in dryRunMode it won't actually publish metrics to CSM\n };\n\n postEventToWorker(csm.EVENT_TYPE.CONFIG, csm.configuration);\n\n /**\n * Receive message from shared worker\n * @param {MessageEvent} messageEvent from shared worker\n */\n worker.port.onmessage = function(messageEvent) {\n const messageType = messageEvent.data.type;\n onMessageFromWorker(messageType, messageEvent.data);\n };\n\n /**\n * Inform shared worker window closed\n */\n global.onbeforeunload = function() {\n worker.port.postMessage(\n {\n type: csm.EVENT_TYPE.CLOSE,\n portId: portId,\n },\n );\n };\n\n /**\n * Check if initialization success\n */\n global.setTimeout(function() {\n if (!isCSMInitialized()) {\n console.log('[FATAL] CSM initialization failed! Please make sure the sharedWorkerUrl is reachable.');\n }\n }, MAX_INIT_MILLISECONDS);\n\n // Emit out of the box metrics\n if (params.defaultMetrics) {\n emitDefaultMetrics();\n }\n };\n // Final processing before sending to SharedWorker\n const processMetric = function(metric) {\n if (csm.configuration.addPageVisibilityDimension && document.visibilityState) {\n metric.addOptionalDimension('VisibilityState', document.visibilityState);\n }\n };\n\n const processWorkflowEvent = function(event) {\n if (csm.configuration.addUrlDataDimensions) {\n event.data.push({'key': 'ReferrerUrl', 'value': csm.Util.getReferrerUrl()});\n event.data.push({'key': 'Origin', 'value': csm.Util.getOrigin()});\n event.data.push({'key': 'WindowParent', 'value': csm.Util.getWindowParent()});\n }\n if (['initFailure', 'initializationLatencyInfo'].includes(event.event)) {\n csm.initFailureDimensions.forEach((dimension) => {\n Object.keys(dimension).forEach((key) => {\n event.data.push({'key': key, 'value': dimension[key]});\n });\n });\n }\n return event;\n };\n\n csm.putMetric = function(metric) {\n processMetric(metric);\n postEventToWorker(csm.EVENT_TYPE.METRIC, metric);\n };\n\n csm.putLog = function(log) {\n postEventToWorker(csm.EVENT_TYPE.LOG, log);\n };\n\n csm.putWorkflowEvent = function(event) {\n const processedEvent = processWorkflowEvent(event);\n postEventToWorker(csm.EVENT_TYPE.WORKFLOW_EVENT, processedEvent);\n };\n\n csm.putCustom = function(endpoint, headers, data) {\n postEventToWorker(csm.EVENT_TYPE.CUSTOM, data, endpoint, headers);\n };\n\n csm.setAuthParams = function(authParams) {\n postEventToWorker(csm.EVENT_TYPE.SET_AUTH, authParams);\n };\n\n csm.setConfig = function(key, value) {\n csm.configuration[key] = value;\n postEventToWorker(csm.EVENT_TYPE.SET_CONFIG, {key, value});\n };\n /** ********************** PRIVATE METHODS ************************/\n\n const onMessageFromWorker = function(messageType, data) {\n if (messageType === csm.EVENT_TYPE.CONFIG) {\n portId = data.portId;\n onCSMInitialized();\n }\n };\n\n const onCSMInitialized = function() {\n // Purge the preInitTaskQueue\n preInitTaskQueue.forEach(function(task) {\n postEventToWorker(task.type, task.message, task.endpoint, task.headers);\n });\n\n // TODO: Capture on errors and publish log to shared worker\n /**\n window.onerror = function(message, fileName, lineNumber, columnNumber, errorstack) {\n var log = new csm.Log(message, fileName, lineNumber, columnNumber, errorstack.stack);\n csm.putLog(log);\n };\n */\n };\n\n /**\n * Emit out of the box metrics automatically\n *\n * TODO allow configuration\n */\n const emitDefaultMetrics = function() {\n window.addEventListener('load', function() {\n // loadEventEnd is avaliable after the onload function finished\n // https://www.w3.org/TR/navigation-timing-2/#processing-model\n // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming\n global.setTimeout(function() {\n try {\n const perfData = window.performance.getEntriesByType('navigation')[0];\n const pageLoadTime = perfData.loadEventEnd - perfData.startTime;\n const connectTime = perfData.responseEnd - perfData.requestStart;\n const domRenderTime = perfData.domComplete - perfData.domInteractive;\n csm.API.addCountWithPageLocation('PageLoad');\n csm.API.addTimeWithPageLocation('PageLoadTime', pageLoadTime);\n csm.API.addTimeWithPageLocation('ConnectTime', connectTime);\n csm.API.addTimeWithPageLocation('DomRenderTime', domRenderTime);\n } catch (err) {\n console.log('Error emitting default metrics', err);\n }\n }, 0);\n });\n };\n\n /**\n * Try posting message to shared worker\n * If shared worker hasn't been initialized, put the task to queue to be clean up once initialized\n * @param {csm.EVENT_TYPE} eventType for CSM\n * @param {object} message event following type of eventType\n * @param {string} [endpoint] optional parameter for putCustom function (put any data to specified endpoint)\n * @param {object} [headers] optional parameter for putCustom function\n */\n const postEventToWorker = function(eventType, message, endpoint, headers) {\n if (eventType === csm.EVENT_TYPE.CONFIG || isCSMInitialized()) {\n worker.port.postMessage(\n {\n type: eventType,\n portId: portId,\n message: message,\n endpoint: endpoint,\n headers: headers,\n },\n );\n } else {\n preInitTaskQueue.push({\n type: eventType,\n message: message,\n endpoint: endpoint,\n headers: headers,\n });\n }\n };\n\n const isCSMInitialized = function() {\n return portId !== null;\n };\n})()",document.head.appendChild(e),this.initializeCSM()}catch(e){this.logger.error("Load csm script error: ",e)}}initializeCSM(){try{if(this.csmInitialized)return;var e=s.getRegion(),t="(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n csm.EVENT_TYPE = {\n LOG: 'LOG',\n METRIC: 'METRIC',\n CONFIG: 'CONFIG',\n WORKFLOW_EVENT: 'WORKFLOW_EVENT',\n CUSTOM: 'CUSTOM',\n CLOSE: 'CLOSE',\n SET_AUTH: 'SET_AUTH',\n SET_CONFIG: 'SET_CONFIG',\n };\n\n csm.UNIT = {\n COUNT: 'Count',\n SECONDS: 'Seconds',\n MILLISECONDS: 'Milliseconds',\n MICROSECONDS: 'Microseconds',\n };\n})();\n\n(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n const MAX_METRIC_DIMENSIONS = 10;\n\n /** ********* Dimension Classes ***********/\n\n const Dimension = function(name, value) {\n csm.Util.assertExist(name, 'name');\n csm.Util.assertExist(value, 'value');\n\n this.name = name;\n this.value = value == null ? 'null' : (value === '' ? ' ' : value.toString());\n };\n\n\n /** ********* Metric Classes ***********/\n\n const Metric = function(metricName, unit, value, dedupeOptions) {\n csm.Util.assertExist(metricName, 'metricName');\n csm.Util.assertExist(value, 'value');\n csm.Util.assertExist(unit, 'unit');\n csm.Util.assertTrue(csm.Util.isValidUnit(unit));\n if (dedupeOptions) {\n csm.Util.assertInObject(dedupeOptions, 'dedupeOptions', 'dedupeIntervalMs');\n }\n\n this.metricName = metricName;\n this.unit = unit;\n this.value = value;\n this.timestamp = new Date();\n this.dimensions = csm.globalDimensions ? csm.Util.deepCopy(csm.globalDimensions): [];\n this.namespace = csm.configuration.namespace;\n this.dedupeOptions = dedupeOptions; // optional. { dedupeIntervalMs: (int; required), context: (string; optional) }\n\n // Currently, CloudWatch can't aggregate metrics by a subset of dimensions.\n // To bypass this limitation, we introduce the optional dimensions concept to CSM.\n // The CSM metric publisher will publish a default metric without optional dimension\n // For each optional dimension, the CSM metric publisher publishes an extra metric with that dimension.\n this.optionalDimensions = csm.globalOptionalDimensions ? csm.Util.deepCopy(csm.globalOptionalDimensions): [];\n };\n\n Metric.prototype.addDimension = function(name, value) {\n this._addDimensionHelper(this.dimensions, name, value);\n };\n\n Metric.prototype.addOptionalDimension = function(name, value) {\n this._addDimensionHelper(this.optionalDimensions, name, value);\n };\n\n Metric.prototype._addDimensionHelper = function(targetDimensions, name, value) {\n // CloudWatch metric allows maximum 10 dimensions\n // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#putMetricData-property\n if ((this.dimensions.length + this.optionalDimensions.length) >= MAX_METRIC_DIMENSIONS) {\n throw new csm.ExceedDimensionLimitException(name);\n }\n\n const existing = targetDimensions.find(function(dimension) {\n return dimension.name === name;\n });\n\n if (existing) {\n existing.value = value == null ? 'null' : (value === '' ? ' ' : value.toString());\n } else {\n targetDimensions.push(new Dimension(name, value));\n }\n };\n\n\n /** ********* Telemetry Classes ***********/\n\n const WorkflowEvent = function(params) {\n this.timestamp = params.timestamp || new Date().getTime();\n this.workflowType = params.workflow.type;\n this.instanceId = params.workflow.instanceId;\n this.userId = params.userId;\n this.organizationId = params.organizationId;\n this.accountId = params.accountId;\n this.event = params.event;\n this.appName = params.appName;\n this.data = [];\n\n // Convert 'data' map into the KeyValuePairList structure expected by the Lambda API\n for (const key in params.data) {\n if (Object.prototype.hasOwnProperty.call(params.data, key)) {\n this.data.push({'key': key, 'value': params.data[key]});\n }\n }\n };\n\n /** ********* Exceptions ***********/\n\n const NullOrUndefinedException = function(paramName) {\n this.name = 'NullOrUndefinedException';\n this.message = paramName + ' is null or undefined. ';\n };\n NullOrUndefinedException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const AssertTrueException = function() {\n this.name = 'AssertTrueException';\n this.message = 'Assertion failed. ';\n };\n AssertTrueException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const ExceedDimensionLimitException = function(dimensionName) {\n this.name = 'ExceedDimensionLimitException';\n this.message = 'Could not add dimension ' + dimensionName + ' . Metric has maximum 10 dimensions. ';\n };\n ExceedDimensionLimitException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n const InitializationException = function() {\n this.name = 'InitializationException';\n this.message = 'Initialization failed. ';\n };\n InitializationException.prototype.toString = function() {\n return this.name + ': ' + this.message;\n };\n\n\n csm.Dimension = Dimension;\n csm.Metric = Metric;\n csm.WorkflowEvent = WorkflowEvent;\n csm.NullOrUndefinedException = NullOrUndefinedException;\n csm.AssertTrueException = AssertTrueException;\n csm.InitializationException = InitializationException;\n csm.ExceedDimensionLimitException = ExceedDimensionLimitException;\n})();\n\n(function() {\n const global = self;\n const csm = global.csm || {};\n global.csm = csm;\n\n const validTimeUnits = [csm.UNIT.SECONDS, csm.UNIT.MILLISECONDS, csm.UNIT.MICROSECONDS];\n const validUnits = validTimeUnits.concat(csm.UNIT.COUNT);\n\n const Util = {\n assertExist: function(value, paramName) {\n if (value === null || value === undefined) {\n throw new csm.NullOrUndefinedException(paramName);\n }\n },\n assertTrue: function(value) {\n if (!value) {\n throw new csm.AssertTrueException();\n }\n },\n assertInObject: function(obj, objName, key) {\n if (obj === null || obj === undefined || typeof obj !== 'object') {\n throw new csm.NullOrUndefinedException(objName);\n }\n if (key === null || key === undefined || !obj[key]) {\n throw new csm.NullOrUndefinedException(`${objName}[${key}]`);\n }\n },\n isValidUnit: function(unit) {\n return validUnits.includes(unit);\n },\n isValidTimeUnit: function(unit) {\n return validTimeUnits.includes(unit);\n },\n isEmpty: function(value) {\n if (value !== null && typeof val === 'object') {\n return Objects.keys(value).length === 0;\n }\n return !value;\n },\n deepCopy: function(obj) {\n // NOTE: this will fail if obj has a circular reference\n return JSON.parse(JSON.stringify(obj));\n },\n\n /**\n * This function is used before setting the page location for default metrics and logs,\n * and the APIs that set page location\n * Can be overridden by calling csm.API.setPageLocationTransformer(function(){})\n * @param {string} pathname path for page location\n * @return {string} pathname provided\n */\n pageLocationTransformer: function(pathname) {\n return pathname;\n },\n\n /**\n * As of now, our service public claims only support for Firefox and Chrome\n * Reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent\n *\n * This function will only return firefox, chrome and others\n *\n * Best practice as indicated in MDN, \"Avoiding user agent detection\"\n */\n getBrowserDetails: function() {\n const userAgent = window.navigator.userAgent;\n const details = {};\n if (userAgent.includes('Firefox') && !userAgent.includes('Seamonkey')) {\n details.name = 'Firefox';\n details.version = getBrowserVersion('Firefox');\n } else if (userAgent.includes('Chrome') && !userAgent.includes('Chromium')) {\n details.name = 'Chrome';\n details.version = getBrowserVersion('Chrome');\n }\n },\n\n randomId: function() {\n return new Date().getTime() + '-' + Math.random().toString(36).slice(2);\n },\n\n getOrigin: function() {\n return document.location.origin;\n },\n\n getReferrerUrl: function() {\n const referrer = document.referrer || '';\n return this.getURLOrigin(referrer);\n },\n\n getWindowParent: function() {\n let parentLocation = '';\n try {\n parentLocation = window.parent.location.href;\n } catch (e) {\n parentLocation = '';\n }\n return parentLocation;\n },\n\n getURLOrigin: function(urlValue) {\n let origin = '';\n const originArray = urlValue.split( '/' );\n if (originArray.length >= 3) {\n const protocol = originArray[0];\n const host = originArray[2];\n origin = protocol + '//' + host;\n }\n return origin;\n },\n\n };\n\n const getBrowserVersion = function(browserName) {\n const userAgent = window.navigator.userAgent;\n const browserNameIndex = userAgent.indexOf(browserName);\n const nextSpaceIndex = userAgent.indexOf(' ', browserNameIndex);\n if (nextSpaceIndex === -1) {\n return userAgent.substring(browserNameIndex + browserName.length + 1, userAgent.length);\n } else {\n return userAgent.substring(browserNameIndex + browserName.length + 1, nextSpaceIndex);\n }\n };\n\n csm.Util = Util;\n})();\n\n(function() {\n const XHR_DONE_READY_STATE = 4; // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState\n\n const global = self;\n const configuration = {};\n const batchSettings = {\n maxMetricsSize: 30,\n maxWorkflowEventsSize: 30,\n putMetricsIntervalMs: 30000,\n putWorkflowEventsIntervalMs: 2000,\n };\n const metricLists = {}; // metricList per CloudWatch Namespace\n const metricMap = {};\n const ports = {};\n let workflowEvents = {workflowEventList: []};\n\n // SharedWorker wiki: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker\n onconnect = function(connectEvent) {\n const port = connectEvent.ports[0];\n\n port.onmessage = function(event) {\n const data = event.data;\n const messageType = data.type;\n const message = data.message;\n const endpoint = data.endpoint;\n const headers = data.headers;\n\n if (data.portId && !(data.portId in ports)) {\n // This could happen when a user tries to close a tab which has a pop up alert to confirm closing,\n // and the user decides to cancel closing\n // This triggers before unload event while the tab or window is not closed actually\n ports[data.portId] = port;\n }\n\n const {METRIC, WORKFLOW_EVENT, CUSTOM, CONFIG, SET_AUTH, SET_CONFIG, CLOSE} = csm.EVENT_TYPE;\n switch (messageType) {\n case METRIC: {\n csm.Util.assertInObject(message, 'message', 'namespace');\n const namespace = message.namespace;\n if (shouldDedupe(message)) break;\n addMetricEventToMap(message);\n if (metricLists[namespace]) {\n metricLists[namespace].push(message);\n } else {\n metricLists[namespace] = [message];\n }\n if (metricLists[namespace].length >= batchSettings.maxMetricsSize) {\n putMetricsForNamespace(namespace);\n }\n break;\n }\n case WORKFLOW_EVENT: {\n workflowEvents.workflowEventList.push(message);\n if (workflowEvents.length >= batchSettings.maxWorkflowEventsSize) {\n putWorkflowEvents();\n }\n break;\n }\n case CUSTOM: {\n putCustom(endpoint, headers, message);\n break;\n }\n case CONFIG: {\n const portId = Object.keys(ports).length + 1; // portId starts from 1\n ports[portId] = port;\n for (const setting of Object.keys(message)) {\n if (!csm.Util.isEmpty(message[setting])) {\n configuration[setting] = message[setting];\n }\n }\n\n // set optional batch settings\n if (configuration.batchSettings) {\n for (const setting of Object.keys(configuration.batchSettings)) {\n batchSettings[setting] = configuration.batchSettings[setting];\n }\n }\n // send metrics and workflow events at set intervals\n putMetrics();\n putWorkflowEvents();\n global.setInterval(putMetrics, batchSettings.putMetricsIntervalMs);\n global.setInterval(putWorkflowEvents, batchSettings.putWorkflowEventsIntervalMs);\n\n port.postMessage(\n {\n type: csm.EVENT_TYPE.CONFIG,\n portId: portId,\n },\n );\n break;\n }\n case SET_AUTH: {\n configuration.authParams = message;\n authenticate();\n break;\n }\n case SET_CONFIG: {\n configuration[message.key] = message.value;\n break;\n }\n case CLOSE: {\n delete ports[data.portId];\n if (Object.keys(ports).length === 0) {\n putMetrics();\n putWorkflowEvents();\n }\n break;\n }\n default:\n break;\n }\n };\n };\n\n const shouldDedupe = function(metric) {\n try {\n const pastMetric = getPastMetricEvent(metric);\n return pastMetric && metric.dedupeOptions &&\n (metric.timestamp - pastMetric.timestamp < metric.dedupeOptions.dedupeIntervalMs);\n } catch (err) {\n console.error('Error in shouldDedupe', err);\n return false;\n }\n };\n\n const getPastMetricEvent = function(metric) {\n try {\n return metricMap[getMetricEventKey(metric)];\n } catch (err) {\n // ignore err - no previous metrics found\n return null;\n }\n };\n\n const addMetricEventToMap = function(metric) {\n try {\n metricMap[getMetricEventKey(metric)] = metric;\n } catch (err) {\n console.error('Failed to add event to metricMap', err);\n }\n csm.metricMap = metricMap;\n };\n\n const getMetricEventKey = function(metric) {\n const {namespace, metricName, unit, dedupeOptions} = metric;\n let context = 'global';\n if (dedupeOptions && dedupeOptions.context) {\n context = dedupeOptions.context;\n }\n return `${namespace}-${metricName}-${unit}-${context}`;\n };\n\n const authenticate = function() {\n postRequest(configuration.endpointUrl + '/auth', {authParams: configuration.authParams},\n {\n success: function(response) {\n if (response && response.jwtToken) {\n configuration.authParams.jwtToken = response.jwtToken;\n }\n },\n failure: function(response) {\n broadcastMessage('[ERROR] csm auth failed!');\n broadcastMessage('Response : ' + response);\n },\n }, {'x-api-key': 'auth-method-level-key'});\n };\n\n /**\n * Put metrics to service when:\n * a) metricList size is at maxMetricsSize\n * b) every putMetricsIntervalMs time if the metricList is not empty\n * c) worker is closed\n *\n * Timer is reset, and metricList emptied after each putMetrics call\n */\n const putMetrics = function() {\n for (const namespace of Object.keys(metricLists)) {\n putMetricsForNamespace(namespace);\n }\n };\n\n const putMetricsForNamespace = function(namespace) {\n csm.Util.assertInObject(metricLists, 'metricLists', namespace);\n const metricList = metricLists[namespace];\n\n if (metricList.length > 0 && !configuration.dryRunMode && configuration.endpointUrl) {\n postRequest(configuration.endpointUrl + '/put-metrics', {\n metricNamespace: namespace,\n metricList: metricList,\n authParams: configuration.authParams,\n accountId: configuration.accountId,\n organizationId: configuration.organizationId,\n agentResourceId: configuration.userId,\n }, {\n success: function(response) {\n if (response) {\n broadcastMessage('PutMetrics response : ' + response);\n if (response.unsetToken) {\n delete configuration.authParams.jwtToken;\n authenticate();\n }\n }\n },\n failure: function(response) {\n broadcastMessage('[ERROR] Put metrics to service failed! ');\n },\n });\n }\n metricLists[namespace] = [];\n };\n\n /**\n * Put metrics to service every two seconds if there are events to be put.\n */\n const putWorkflowEvents = function() {\n if (workflowEvents.workflowEventList.length > 0 && !configuration.dryRunMode && configuration.endpointUrl) {\n workflowEvents.authParams = configuration.authParams;\n postRequest(configuration.endpointUrl + '/put-workflow-events', workflowEvents,\n {\n success: function(response) {\n if (response) {\n if (response.workflowEventList && response.workflowEventList.length > 0) {\n broadcastMessage('[WARN] There are ' + response.length + ' workflow events that failed to publish');\n broadcastMessage('Response : ' + response);\n }\n if (response.unsetToken) {\n delete configuration.authParams.jwtToken;\n authenticate();\n }\n }\n },\n failure: function(response) {\n broadcastMessage('[ERROR] Put workflow events to service failed! ');\n },\n });\n }\n\n workflowEvents = {workflowEventList: []};\n };\n\n /**\n * Put data to custom endpoint on demand\n * @param {string} endpoint\n * @param {object} headers\n * @param {object} data to send to endpoint\n */\n const putCustom = function(endpoint, headers, data) {\n if (!configuration.dryRunMode && endpoint && data) {\n postRequest(endpoint, data, {\n success: function(response) {\n if (response) {\n broadcastMessage('Response : ' + response);\n }\n },\n failure: function(response) {\n broadcastMessage('[ERROR] Failed to put custom data! ');\n },\n }, headers);\n }\n };\n\n /**\n * Broadcast message to all tabs\n * @param {string} message to post to all the tabs\n */\n const broadcastMessage = function(message) {\n for (const portId in ports) {\n if (Object.prototype.hasOwnProperty.call(ports, portId)) {\n ports[portId].postMessage(message);\n }\n }\n };\n\n const postRequest = function(url, data, callbacks, headers) {\n csm.Util.assertExist(url, 'url');\n csm.Util.assertExist(data, 'data');\n\n callbacks = callbacks || {};\n callbacks.success = callbacks.success || function() {};\n callbacks.failure = callbacks.failure || function() {};\n\n const request = new XMLHttpRequest(); // new HttpRequest instance\n request.onreadystatechange = function() {\n const errorList = request.response ? JSON.parse(request.response): [];\n if (request.readyState === XHR_DONE_READY_STATE) { // request finished and response is ready\n if (request.status === 200) {\n callbacks.success(errorList);\n } else {\n broadcastMessage('AJAX request failed with status: ' + request.status);\n callbacks.failure(errorList);\n }\n }\n };\n\n request.open('POST', url);\n if (headers && typeof headers === 'object') {\n Object.keys(headers).forEach((header) => request.setRequestHeader(header, headers[header]));\n } else {\n request.setRequestHeader('Content-Type', 'application/json');\n }\n request.send(JSON.stringify(data));\n };\n})()".replace(/\\/g,""),n=URL.createObjectURL(new Blob([t],{type:"text/javascript"})),r=(e=>"https://ieluqbvv.telemetry.connect.".concat(e,".amazonaws.com/prod"))(e),i={endpoint:r,namespace:"chat-widget",sharedWorkerUrl:n};csm.initCSM(i),this.logger.info("CSMService is initialized in ".concat(e)),this.csmInitialized=!0,this.metricsToBePublished&&(this.metricsToBePublished.forEach((e=>{csm.API.addMetric(e)})),this.metricsToBePublished=null)}catch(e){this.logger.error("Failed to initialize csm: ",e)}}updateCsmConfig(e){this.widgetType="object"!=typeof e||null===e||Array.isArray(e)?this.widgetType:e.widgetType}getDefaultDimensions(){return[{name:"WidgetType",value:this.widgetType}]}addMetric(e){if(this.csmInitialized)try{csm.API.addMetric(e)}catch(e){this.logger.error("Failed to addMetric csm: ",e)}else this.metricsToBePublished&&(this.metricsToBePublished.push(e),this.logger.info("CSMService is not initialized yet. Adding metrics to queue to be published once CSMService is initialized"))}setDimensions(e,t){t.forEach((t=>{e.addDimension(t.name,t.value)}))}addLatencyMetric(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];try{var i=new csm.Metric(e,csm.UNIT.MILLISECONDS,t),o=[...this.getDefaultDimensions(),{name:"Metric",value:"Latency"},{name:te,value:n},...r];this.setDimensions(i,o),this.addMetric(i),this.logger.debug("Successfully published latency API metrics for method ".concat(e))}catch(e){this.logger.error("Failed to addLatencyMetric csm: ",e)}}addLatencyMetricWithStartTime(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=(new Date).getTime()-t;this.addLatencyMetric(e,i,n,r),this.logger.debug("Successfully published latency API metrics for method ".concat(e))}addCountAndErrorMetric(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];try{var i=[...this.getDefaultDimensions(),{name:te,value:t},...r],o=new csm.Metric(e,csm.UNIT.COUNT,1);this.setDimensions(o,[...i,{name:"Metric",value:"Count"}]);var s=n?1:0,a=new csm.Metric(e,csm.UNIT.COUNT,s);this.setDimensions(a,[...i,{name:"Metric",value:"Error"}]),this.addMetric(o),this.addMetric(a),this.logger.debug("Successfully published count and error metrics for method ".concat(e))}catch(e){this.logger.error("Failed to addCountAndErrorMetric csm: ",e)}}addCountMetric(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];try{var r=[...this.getDefaultDimensions(),{name:te,value:t},{name:"Metric",value:"Count"},...n],i=new csm.Metric(e,csm.UNIT.COUNT,1);this.setDimensions(i,r),this.addMetric(i),this.logger.debug("Successfully published count metrics for method ".concat(e))}catch(e){this.logger.error("Failed to addCountMetric csm: ",e)}}addAgentCountMetric(e,t){try{var n=this;csm&&csm.API.addCount&&e?(csm.API.addCount(e,t),n.MAX_RETRY=5):(e&&this.agentMetricToBePublished.push({metricName:e,count:t}),setTimeout((()=>{csm&&csm.API.addCount?(this.agentMetricToBePublished.forEach((e=>{csm.API.addCount(e.metricName,e.count)})),this.agentMetricToBePublished=[]):n.MAX_RETRY>0&&(n.MAX_RETRY-=1,n.addAgentCountMetric())}),3e3))}catch(e){this.logger.error("Failed to addAgentCountMetric csm: ",e)}}};function re(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}class ie{constructor(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.chatClient=t,this.participantToken=e||null,this.connectionDetails=null,this.connectionToken=null,this.connectionTokenExpiry=null,this.sessionType=n,this.getConnectionToken=r}getFetchedConnectionToken(){return this.connectionToken}getConnectionTokenExpiry(){return this.connectionTokenExpiry}getConnectionDetails(){return this.connectionDetails}fetchConnectionDetails(){return this._fetchConnectionDetails().then((e=>e))}_handleCreateParticipantConnectionResponse(e,t){return this.connectionDetails={url:e.Websocket.Url,expiry:e.Websocket.ConnectionExpiry,transportLifeTimeInSeconds:E,connectionAcknowledged:t,connectionToken:e.ConnectionCredentials.ConnectionToken,connectionTokenExpiry:e.ConnectionCredentials.Expiry},this.connectionToken=e.ConnectionCredentials.ConnectionToken,this.connectionTokenExpiry=e.ConnectionCredentials.Expiry,this.connectionDetails}_handleGetConnectionTokenResponse(e){return this.connectionDetails={url:null,expiry:null,connectionToken:e.participantToken,connectionTokenExpiry:e.expiry,transportLifeTimeInSeconds:E,connectionAcknowledged:!1},this.connectionToken=e.participantToken,this.connectionTokenExpiry=e.expiry,Promise.resolve(this.connectionDetails)}callCreateParticipantConnection(){var{Type:e=!0,ConnectParticipant:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(new Date).getTime();return this.chatClient.createParticipantConnection(this.participantToken,e?["WEBSOCKET","CONNECTION_CREDENTIALS"]:null,t||null).then((r=>{if(e)return this._addParticipantConnectionMetric(n),this._handleCreateParticipantConnectionResponse(r.data,t)})).catch((t=>(e&&this._addParticipantConnectionMetric(n,!0),Promise.reject({reason:"Failed to fetch connectionDetails with createParticipantConnection",_debug:t}))))}_addParticipantConnectionMetric(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];ne.addLatencyMetricWithStartTime(g,e,u),ne.addCountAndErrorMetric(g,u,t)}_fetchConnectionDetails(){var e,t=this;return(e=function*(){return t.sessionType===c.CUSTOMER?t.callCreateParticipantConnection():t.sessionType===c.AGENT?t.getConnectionToken().then((e=>t._handleGetConnectionTokenResponse(e.chatTokenTransport))).catch((()=>t.callCreateParticipantConnection({Type:!0,ConnectParticipant:!0}).catch((e=>{throw new Error({type:"CONN_ACK_FAILED",errorMessage:e})})))):Promise.reject({reason:"Failed to fetch connectionDetails.",_debug:new r("Failed to fetch connectionDetails.")})},function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){re(o,r,i,s,a,"next",e)}function a(e){re(o,r,i,s,a,"throw",e)}s(void 0)}))})()}}var oe=void 0!==oe?oe:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};oe.connect=oe.connect||{};var se=connect.WebSocketManager;!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t){function n(t){return e.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,n(t)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,n(t)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r;!function(){var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function o(e){return function(e,t){var n,r,s,a,c,u,l,p,d,h=1,f=e.length,m="";for(r=0;r<f;r++)if("string"==typeof e[r])m+=e[r];else if("object"==typeof e[r]){if((a=e[r]).keys)for(n=t[h],s=0;s<a.keys.length;s++){if(null==n)throw new Error(o('[sprintf] Cannot access property "%s" of undefined value "%s"',a.keys[s],a.keys[s-1]));n=n[a.keys[s]]}else n=a.param_no?t[a.param_no]:t[h++];if(i.not_type.test(a.type)&&i.not_primitive.test(a.type)&&n instanceof Function&&(n=n()),i.numeric_arg.test(a.type)&&"number"!=typeof n&&isNaN(n))throw new TypeError(o("[sprintf] expecting number but found %T",n));switch(i.number.test(a.type)&&(p=n>=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?m+=n:(!i.number.test(a.type)||p&&!a.sign?d="":(d=p?"+":"-",n=n.toString().replace(i.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(d+n).length,c=a.width&&l>0?u.repeat(l):"",m+=a.align?d+n+c:"0"===u?d+c+n:c+d+n)}return m}(function(e){if(a[e])return a[e];for(var t,n=e,r=[],o=0;n;){if(null!==(t=i.text.exec(n)))r.push(t[0]);else if(null!==(t=i.modulo.exec(n)))r.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){o|=1;var s=[],c=t[2],u=[];if(null===(u=i.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=i.key_access.exec(c)))s.push(u[1]);else{if(null===(u=i.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return a[e]=r}(e),arguments)}function s(e,t){return o.apply(null,[e].concat(t||[]))}var a=Object.create(null);t.sprintf=o,t.vsprintf=s,"undefined"!=typeof window&&(window.sprintf=o,window.vsprintf=s,void 0===(r=function(){return{sprintf:o,vsprintf:s}}.call(t,n,t,e))||(e.exports=r))}()},function(e,t,n){var r=n(8);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r=n(0).default,i=n(9);e.exports=function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,n(t,r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){n.r(t),n.d(t,"WebSocketManager",(function(){return ce}));var r=n(0),i=n.n(r),o=n(4),s="AMZ_WEB_SOCKET_MANAGER:",a="Network offline",c="Network online, connecting to WebSocket server",u="Network offline, ignoring this getWebSocketConnConfig request",l="Heartbeat response not received",p="aws/ping deep heartbeat response not received",d="Failed to send heartbeat since WebSocket is not open",h="Failed to send aws/ping deep heartbeat since WebSocket is not open",f="WebSocket connection established!",m="WebSocket connection is closed",g="WebSocketManager Error, error_event: ",v="Scheduling WebSocket reinitialization, after delay ",y="WebSocket URL cannot be used to establish connection",b="WebSocket Initialization failed - Terminating and cleaning subscriptions",w="Fetching new WebSocket connection configuration",E="Successfully fetched webSocket connection configuration",S="Failed to fetch webSocket connection configuration",C="Retrying fetching new WebSocket connection configuration",T="Initializing Websocket Manager",I="WebSocketManager Message Error",k="Message received for topic ",_="Invalid incoming message",x="aws/subscribe",A="aws/heartbeat",R="aws/ping",O="disconnected",N={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return N.assertTrue(null!==e&&void 0!==i()(e),Object(o.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&e.length>0},assertIsList:function(e,t){if(!Array.isArray(e))throw new Error(t+" is not an array")},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},isObject:function(e){return!("object"!==i()(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},L=new RegExp("^(wss://)\\w*"),M=new RegExp("^(ws://127.0.0.1:)");N.validWSUrl=function(e){return L.test(e)||M.test(e)},N.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},N.assertIsObject=function(e,t){if(!N.isObject(e))throw new Error(t+" is not an object!")},N.addJitter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;t=Math.min(t,1);var n=Math.random()>.5?1:-1;return Math.floor(e+n*e*Math.random()*t)},N.isNetworkOnline=function(){return navigator.onLine},N.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var P=N,D=n(5),U=n.n(D),q=n(6),j=n.n(q),F=n(3),W=n.n(F),B=n(7),z=n.n(B),H=n(1),V=n.n(H),G=n(2),K=n.n(G);function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var J=function(){function e(){V()(this,e)}return K()(e,[{key:"debug",value:function(e){}},{key:"info",value:function(e){}},{key:"warn",value:function(e){}},{key:"error",value:function(e){}},{key:"advancedLog",value:function(e){}}]),e}(),Y=s,$={DEBUG:10,INFO:20,WARN:30,ERROR:40,ADVANCED_LOG:50},Q=function(){function e(t){V()(this,e),this.logMetaData=t||"",this.updateLoggerConfig()}return K()(e,[{key:"hasLogMetaData",value:function(){return!!this.logMetaData}},{key:"writeToClientLogger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.hasClientLogger()){var n="string"==typeof t?t:JSON.stringify(t,te()),r="string"==typeof this.logMetaData?this.logMetaData:JSON.stringify(this.logMetaData,te()),i="".concat(function(e){switch(e){case 10:return"DEBUG";case 20:return"INFO";case 30:return"WARN";case 40:return"ERROR";case 50:return"ADVANCED_LOG"}}(e)," ").concat(n," ").concat(r);switch(e){case $.DEBUG:return this._clientLogger.debug(i)||i;case $.INFO:return this._clientLogger.info(i)||i;case $.WARN:return this._clientLogger.warn(i)||i;case $.ERROR:return this._clientLogger.error(i)||i;case $.ADVANCED_LOG:return this._advancedLogWriter?this._clientLogger[this._advancedLogWriter](i)||i:""}}}},{key:"isLevelEnabled",value:function(e){return e>=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.prefix||Y;return e.logMetaData&&this.setLogMetaData(e.logMetaData),this.logMetaData||console.info("*********Missing required option: WebSocketManager:logMetaData**********"),new ee(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X(Object(n),!0).forEach((function(t){z()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({prefix:t,logMetaData:this.logMetaData},e))}},{key:"setLogMetaData",value:function(e){this.logMetaData=e}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||$.INFO,this._advancedLogWriter="warn",t.advancedLogWriter&&(this._advancedLogWriter=t.advancedLogWriter),t.customizedLogger&&"object"===i()(t.customizedLogger)&&(this.useClientLogger=!0),this._clientLogger=t.logger||this.selectLogger(t),this._logsDestination="NULL",t.debug&&(this._logsDestination="DEBUG"),t.logger&&(this._logsDestination="CLIENT_LOGGER")}},{key:"selectLogger",value:function(e){return e.customizedLogger&&"object"===i()(e.customizedLogger)?e.customizedLogger:e.useDefaultLogger?ne():null}}]),e}(),Z=function(){function e(){V()(this,e)}return K()(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}},{key:"advancedLog",value:function(){}}]),e}(),ee=function(e){U()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=W()(e);if(t){var i=W()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j()(this,n)}}(n);function n(e,r){var i;return V()(this,n),(i=t.call(this)).options=r||{},i.prefix=r.prefix||Y,i.logManager=e,i}return K()(n,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log($.DEBUG,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log($.INFO,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log($.WARN,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log($.ERROR,t)}},{key:"advancedLog",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log($.ADVANCED_LOG,t)}},{key:"_shouldLog",value:function(e){return this.logManager.hasClientLogger()&&this.logManager.isLevelEnabled(e)}},{key:"_writeToClientLogger",value:function(e,t){return this.logManager.writeToClientLogger(e,t)}},{key:"_log",value:function(e,t){if(this._shouldLog(e)){var n=this.logManager.useClientLogger?t:this._convertToSingleStatement(t);return this._writeToClientLogger(e,n)}}},{key:"_convertToSingleStatement",value:function(e){var t=new Date(Date.now()).toISOString(),n="[".concat(t,"]");this.prefix&&(n+=this.prefix+" "),this.options&&(this.options.prefix?n+=" "+this.options.prefix+":":n+="");for(var r=0;r<e.length;r++){var i=e[r];n+=this._convertToString(i)+" "}return n}},{key:"_convertToString",value:function(e){try{if(!e)return"";if(P.isString(e))return e;if(P.isObject(e)&&P.isFunction(e.toString)){var t=e.toString();if("[object Object]"!==t)return t}return JSON.stringify(e)}catch(t){return console.error("Error while converting argument to string",e,t),""}}}]),n}(Z);function te(){var e=new WeakSet;return function(t,n){if("object"===i()(n)&&null!==n){if(e.has(n))return;e.add(n)}return n}}var ne=function(){var e=new Z;return e.debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.debug.apply(window.console,[].concat(t))},e.info=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.info.apply(window.console,[].concat(t))},e.warn=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.warn.apply(window.console,[].concat(t))},e.error=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.error.apply(window.console,[].concat(t))},e},re=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3;V()(this,e),this.numAttempts=0,this.executor=t,this.hasActiveReconnection=!1,this.defaultRetry=n}return K()(e,[{key:"retry",value:function(){var e=this;this.hasActiveReconnection||(this.hasActiveReconnection=!0,setTimeout((function(){e._execute()}),this._getDelay()))}},{key:"_execute",value:function(){this.hasActiveReconnection=!1,this.executor(),this.numAttempts++}},{key:"connected",value:function(){this.numAttempts=0}},{key:"_getDelay",value:function(){var e=Math.pow(2,this.numAttempts)*this.defaultRetry;return e<=3e4?e:3e4}},{key:"getIsConnected",value:function(){return!this.numAttempts}}]),e}(),ie=null,se=function(){var e=!1,t=ie.getLogger({prefix:s}),n=P.isNetworkOnline(),r={primary:null,secondary:null},i={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},o={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},N={pendingResponse:!1,intervalHandle:null},L={pendingResponse:!1,intervalHandle:null},M={initFailure:new Set,getWebSocketTransport:null,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set,deepHeartbeatSuccess:new Set,deepHeartbeatFailure:new Set,topicFailure:new Set},D={connConfig:null,promiseHandle:null,promiseCompleted:!0},U={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},q={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},j=new re((function(){pe()})),F=new Set([x,"aws/unsubscribe",A,R]),W=setInterval((function(){if(n!==P.isNetworkOnline()){if(!(n=P.isNetworkOnline()))return t.advancedLog(a),void fe(t.info(a));var e=X();n&&(!e||V(e,WebSocket.CLOSING)||V(e,WebSocket.CLOSED))&&(t.advancedLog(c),fe(t.info(c)),pe())}}),250),B=function(e,n){e.forEach((function(e){try{e(n)}catch(e){fe(t.error("Error executing callback",e))}}))},z=function(e){if(null===e)return"NULL";switch(e.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNDEFINED"}},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";fe(t.debug("["+e+"] Primary WebSocket: "+z(r.primary)+" | Secondary WebSocket: "+z(r.secondary)))},V=function(e,t){return e&&e.readyState===t},G=function(e){return V(e,WebSocket.OPEN)},K=function(e){return null===e||void 0===e.readyState||V(e,WebSocket.CLOSED)},X=function(){return null!==r.secondary?r.secondary:r.primary},J=function(){return G(X())},Y=function(){if(e&&L.pendingResponse&&(t.advancedLog(p),fe(t.warn(p)),B(M.deepHeartbeatFailure,{timestamp:Date.now(),error:"aws/ping response is not received"}),clearInterval(L.intervalHandle),L.pendingResponse=!1),N.pendingResponse)return t.advancedLog(l),fe(t.warn(l)),clearInterval(N.intervalHandle),N.intervalHandle=null,N.pendingResponse=!1,void pe();J()?(e&&(fe(t.debug("Sending aws/ping deep heartbeat")),X().send(ue(R)),L.pendingResponse=!0),fe(t.debug("Sending heartbeat")),X().send(ue(A)),N.pendingResponse=!0):(e&&(t.advancedLog(h),fe(t.warn(h)),B(M.deepHeartbeatFailure,{timestamp:Date.now(),error:"Unable to send message to aws/ping because websocket connection is not established."})),t.advancedLog(d),fe(t.warn(d)),H("sendHeartBeat"),pe())},$=function(){t.advancedLog("Reset Websocket state"),i.exponentialBackOffTime=1e3,N.pendingResponse=!1,L.pendingResponse=!1,i.reconnectWebSocket=!0,clearTimeout(i.lifeTimeTimeoutHandle),clearInterval(N.intervalHandle),clearInterval(L.intervalHandle),clearTimeout(i.exponentialTimeoutHandle),clearTimeout(i.webSocketInitCheckerTimeoutId),N.intervalHandle=null},Q=function(){q.consecutiveFailedSubscribeAttempts=0,q.consecutiveNoResponseRequest=0,clearInterval(q.responseCheckIntervalId),clearInterval(q.reSubscribeIntervalId)},Z=function(){o.connectWebSocketRetryCount=0,o.connectionAttemptStartTime=null,o.noOpenConnectionsTimestamp=null},ee=function(){j.connected();try{t.advancedLog(f),fe(t.info(f)),H("webSocketOnOpen"),null!==i.connState&&i.connState!==O||B(M.connectionGain),i.connState="connected";var e=Date.now();B(M.connectionOpen,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,noOpenConnectionsTimestamp:o.noOpenConnectionsTimestamp,connectionEstablishedTime:e,timeToConnect:e-o.connectionAttemptStartTime,timeWithoutConnection:o.noOpenConnectionsTimestamp?e-o.noOpenConnectionsTimestamp:null}),Z(),$(),X().openTimestamp=Date.now(),0===U.subscribed.size&&G(r.secondary)&&se(r.primary,"[Primary WebSocket] Closing WebSocket"),(U.subscribed.size>0||U.pending.size>0)&&(G(r.secondary)&&fe(t.info("Subscribing secondary websocket to topics of primary websocket")),U.subscribed.forEach((function(e){U.subscriptionHistory.add(e),U.pending.add(e)})),U.subscribed.clear(),oe()),Y(),null!==N.intervalHandle&&clearInterval(N.intervalHandle),N.intervalHandle=setInterval(Y,1e4);var n=1e3*D.connConfig.webSocketTransport.transportLifeTimeInSeconds;fe(t.debug("Scheduling WebSocket manager reconnection, after delay "+n+" ms")),i.lifeTimeTimeoutHandle=setTimeout((function(){fe(t.debug("Starting scheduled WebSocket manager reconnection")),pe()}),n)}catch(e){fe(t.error("Error after establishing WebSocket connection",e))}},te=function(e){H("webSocketOnError"),t.advancedLog(g,JSON.stringify(e)),fe(t.error(g,JSON.stringify(e))),j.getIsConnected()?pe():j.retry()},ne=function(e){var n=JSON.parse(e.data);switch(n.topic){case x:if(fe(t.debug("Subscription Message received from webSocket server",e.data)),q.requestCompleted=!0,q.consecutiveNoResponseRequest=0,"success"===n.content.status)q.consecutiveFailedSubscribeAttempts=0,n.content.topics.forEach((function(e){U.subscriptionHistory.delete(e),U.pending.delete(e),U.subscribed.add(e)})),0===U.subscriptionHistory.size?G(r.secondary)&&(fe(t.info("Successfully subscribed secondary websocket to all topics of primary websocket")),se(r.primary,"[Primary WebSocket] Closing WebSocket")):oe(),B(M.subscriptionUpdate,n);else{if(clearInterval(q.reSubscribeIntervalId),++q.consecutiveFailedSubscribeAttempts,5===q.consecutiveFailedSubscribeAttempts)return B(M.subscriptionFailure,n),void(q.consecutiveFailedSubscribeAttempts=0);q.reSubscribeIntervalId=setInterval((function(){oe()}),500)}break;case A:fe(t.debug("Heartbeat response received")),N.pendingResponse=!1,null===N.intervalHandle&&(N.intervalHandle=setInterval(Y,1e4));break;case R:fe(t.debug("aws/ping deep heartbeat received")),L.pendingResponse=!1,200===n.statusCode?B(M.deepHeartbeatSuccess,{timestamp:Date.now()}):B(M.deepHeartbeatFailure,{timestamp:Date.now(),statusCode:n.statusCode,statusContent:n.statusContent});break;default:if(n.topic){if(t.advancedLog(k,n.topic),fe(t.debug(k+n.topic)),G(r.primary)&&G(r.secondary)&&0===U.subscriptionHistory.size&&this===r.primary)return void fe(t.warn("Ignoring Message for Topic "+n.topic+", to avoid duplicates"));if(0===M.allMessage.size&&0===M.topic.size)return void fe(t.warn("No registered callback listener for Topic",n.topic));t.advancedLog("WebsocketManager invoke callbacks for topic success ",n.topic),B(M.allMessage,n),M.topic.has(n.topic)&&B(M.topic.get(n.topic),n)}else n.message?(t.advancedLog(I,n),fe(t.warn(I,n)),B(M.topicFailure,{timestamp:Date.now(),errorMessage:n.message,connectionId:n.connectionId,requestId:n.requestId})):(t.advancedLog(_,n),fe(t.warn(_,n)))}},oe=function e(){if(q.consecutiveNoResponseRequest>3)return fe(t.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void B(M.subscriptionFailure,P.getSubscriptionResponse(x,!1,Array.from(U.pending)));J()?0!==Array.from(U.pending).length&&(clearInterval(q.responseCheckIntervalId),X().send(ue(x,{topics:Array.from(U.pending)})),q.requestCompleted=!1,q.responseCheckIntervalId=setInterval((function(){q.requestCompleted||(++q.consecutiveNoResponseRequest,e())}),1e3)):fe(t.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},se=function(e,n){V(e,WebSocket.CONNECTING)||V(e,WebSocket.OPEN)?e.close(1e3,n):fe(t.warn("Ignoring WebSocket Close request, WebSocket State: "+z(e)))},ae=function(e){se(r.primary,"[Primary] WebSocket "+e),se(r.secondary,"[Secondary] WebSocket "+e)},ce=function(e){$(),Q(),t.advancedLog(b,e),fe(t.error(b)),i.websocketInitFailed=!0,ae("Terminating WebSocket Manager"),clearInterval(W),B(M.initFailure,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,reason:e}),Z()},ue=function(e,t){return JSON.stringify({topic:e,content:t})},le=function(e){return!!(P.isObject(e)&&P.isObject(e.webSocketTransport)&&P.isNonEmptyString(e.webSocketTransport.url)&&P.validWSUrl(e.webSocketTransport.url)&&1e3*e.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(fe(t.error("Invalid WebSocket Connection Configuration",e)),!1)},pe=function(){if(!P.isNetworkOnline())return t.advancedLog(u),void fe(t.info(u));if(i.websocketInitFailed)fe(t.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(D.promiseCompleted)return $(),t.advancedLog(w),fe(t.info(w)),o.connectionAttemptStartTime=o.connectionAttemptStartTime||Date.now(),D.promiseCompleted=!1,D.promiseHandle=M.getWebSocketTransport(),D.promiseHandle.then((function(e){return D.promiseCompleted=!0,t.advancedLog(E),fe(t.debug(E,e)),le(e)?(D.connConfig=e,D.connConfig.urlConnValidTime=Date.now()+85e3,de()):(ce("Invalid WebSocket connection configuration: "+e),{webSocketConnectionFailed:!0})}),(function(e){return D.promiseCompleted=!0,t.advancedLog(S),fe(t.error(S,e)),P.isNetworkFailure(e)?(t.advancedLog(C+JSON.stringify(e)),fe(t.info(C+JSON.stringify(e))),j.retry()):ce("Failed to fetch webSocket connection configuration: "+JSON.stringify(e)),{webSocketConnectionFailed:!0}}));fe(t.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}},de=function(){if(i.websocketInitFailed)return fe(t.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!P.isNetworkOnline())return fe(t.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};t.advancedLog(T),fe(t.info(T)),H("initWebSocket");try{if(le(D.connConfig)){var e=null;return G(r.primary)?(fe(t.debug("Primary Socket connection is already open")),V(r.secondary,WebSocket.CONNECTING)||(fe(t.debug("Establishing a secondary web-socket connection")),j.numAttempts=0,r.secondary=he()),e=r.secondary):(V(r.primary,WebSocket.CONNECTING)||(fe(t.debug("Establishing a primary web-socket connection")),r.primary=he()),e=r.primary),i.webSocketInitCheckerTimeoutId=setTimeout((function(){G(e)||function(){o.connectWebSocketRetryCount++;var e=P.addJitter(i.exponentialBackOffTime,.3);Date.now()+e<=D.connConfig.urlConnValidTime?(t.advancedLog(v),fe(t.debug(v+e+" ms")),i.exponentialTimeoutHandle=setTimeout((function(){return de()}),e),i.exponentialBackOffTime*=2):(t.advancedLog(y),fe(t.warn(y)),pe())}()}),1e3),{webSocketConnectionFailed:!1}}}catch(e){return fe(t.error("Error Initializing web-socket-manager",e)),ce("Failed to initialize new WebSocket: "+e.message),{webSocketConnectionFailed:!0}}},he=function(){var e=new WebSocket(D.connConfig.webSocketTransport.url);return e.addEventListener("open",ee),e.addEventListener("message",ne),e.addEventListener("error",te),e.addEventListener("close",(function(n){return function(e,n){t.advancedLog(m,JSON.stringify(e)),fe(t.info(m,JSON.stringify(e))),H("webSocketOnClose before-cleanup"),B(M.connectionClose,{openTimestamp:n.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-n.openTimestamp,code:e.code,reason:e.reason}),K(r.primary)&&(r.primary=null),K(r.secondary)&&(r.secondary=null),i.reconnectWebSocket&&(G(r.primary)||G(r.secondary)?K(r.primary)&&G(r.secondary)&&(fe(t.info("[Primary] WebSocket Cleanly Closed")),r.primary=r.secondary,r.secondary=null):(fe(t.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),i.connState===O?fe(t.info("Ignoring connectionLost callback invocation")):(B(M.connectionLost,{openTimestamp:n.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-n.openTimestamp,code:e.code,reason:e.reason}),o.noOpenConnectionsTimestamp=Date.now()),i.connState=O,pe()),H("webSocketOnClose after-cleanup"))}(n,e)})),e},fe=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(e){if(P.assertTrue(P.isFunction(e),"transportHandle must be a function"),null===M.getWebSocketTransport)return M.getWebSocketTransport=e,pe();fe(t.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(e){return t.advancedLog("Initializing Websocket Manager Failure callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.initFailure.add(e),i.websocketInitFailed&&e(),function(){return M.initFailure.delete(e)}},this.onConnectionOpen=function(e){return t.advancedLog("Websocket connection open callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.connectionOpen.add(e),function(){return M.connectionOpen.delete(e)}},this.onConnectionClose=function(e){return t.advancedLog("Websocket connection close callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.connectionClose.add(e),function(){return M.connectionClose.delete(e)}},this.onConnectionGain=function(e){return t.advancedLog("Websocket connection gain callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.connectionGain.add(e),J()&&e(),function(){return M.connectionGain.delete(e)}},this.onConnectionLost=function(e){return t.advancedLog("Websocket connection lost callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.connectionLost.add(e),i.connState===O&&e(),function(){return M.connectionLost.delete(e)}},this.onSubscriptionUpdate=function(e){return P.assertTrue(P.isFunction(e),"cb must be a function"),M.subscriptionUpdate.add(e),function(){return M.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(e){return t.advancedLog("Websocket subscription failure callback registered"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.subscriptionFailure.add(e),function(){return M.subscriptionFailure.delete(e)}},this.onMessage=function(e,t){return P.assertNotNull(e,"topicName"),P.assertTrue(P.isFunction(t),"cb must be a function"),M.topic.has(e)?M.topic.get(e).add(t):M.topic.set(e,new Set([t])),function(){return M.topic.get(e).delete(t)}},this.onAllMessage=function(e){return P.assertTrue(P.isFunction(e),"cb must be a function"),M.allMessage.add(e),function(){return M.allMessage.delete(e)}},this.subscribeTopics=function(e){P.assertNotNull(e,"topics"),P.assertIsList(e),e.forEach((function(e){U.subscribed.has(e)||U.pending.add(e)})),q.consecutiveNoResponseRequest=0,oe()},this.sendMessage=function(e){if(P.assertIsObject(e,"payload"),void 0===e.topic||F.has(e.topic))fe(t.warn("Cannot send message, Invalid topic",e));else{try{e=JSON.stringify(e)}catch(n){return void fe(t.warn("Error stringify message",e))}J()?X().send(e):fe(t.warn("Cannot send message, web socket connection is not open"))}},this.deepHeartbeatHandler=function(){e=!0},this.onDeepHeartbeatSuccess=function(e){return t.advancedLog("Deep Heartbeat is successful. WebSocketManager has received 200 response from aws/ping"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.deepHeartbeatSuccess.add(e),function(){return M.deepHeartbeatSuccess.delete(e)}},this.onDeepHeartbeatFailure=function(e){return t.advancedLog("Deep Heartbeat failed. WebSocketManager does not receive 200 response from aws/ping"),P.assertTrue(P.isFunction(e),"cb must be a function"),M.deepHeartbeatFailure.add(e),function(){return M.deepHeartbeatFailure.delete(e)}},this.onTopicFailure=function(e){return t.advancedLog("Generic topic failed."),P.assertTrue(P.isFunction(e),"cb must be a function"),M.topicFailure.add(e),function(){return M.topicFailure.delete(e)}},this.closeWebSocket=function(){$(),Q(),i.reconnectWebSocket=!1,clearInterval(W),ae("User request to close WebSocket")},this.terminateWebSocketManager=ce},ae={create:function(e){return ie||(ie=new Q(e)),ie.hasLogMetaData()||ie.setLogMetaData(e),e||console.info("********Missing metaData for logs from websocketManager: initialize websocketManager using create(metaData)*******"),new se},setGlobalConfig:function(e){var t=e&&e.loggerConfig;ie||(ie=new Q),ie.updateLoggerConfig(t);var n=e&&e.webSocketManagerConfig,r=n&&n.isNetworkOnline;r&&"function"==typeof r&&(P.isNetworkOnline=r)},LogLevel:$,Logger:J};oe.connect=oe.connect||{},connect.WebSocketManager=ae;var ce=ae;t.default=ce}]);var ae=connect.WebSocketManager;connect.WebSocketManager=se||ae;const ce=ae;class ue extends Y{constructor(e,t,n,r,i,o){super(n,i),this.customerConnection=!r,this.customerConnection?(ue.customerBaseInstances[e]||(ue.customerBaseInstances[e]=new le(n,void 0,i,o)),this.baseInstance=ue.customerBaseInstances[e]):(ue.agentBaseInstance&&ue.agentBaseInstance.getWebsocketManager()!==r&&(ue.agentBaseInstance.end(),ue.agentBaseInstance=null),ue.agentBaseInstance||(ue.agentBaseInstance=new le(void 0,r,i)),this.baseInstance=ue.agentBaseInstance),this.contactId=e,this.initialContactId=t,this.status=null,this.eventBus=new ee,this.subscriptions=[this.baseInstance.onEnded(this.handleEnded.bind(this)),this.baseInstance.onConnectionGain(this.handleConnectionGain.bind(this)),this.baseInstance.onConnectionLost(this.handleConnectionLost.bind(this)),this.baseInstance.onMessage(this.handleMessage.bind(this))]}start(){return super.start(),this.baseInstance.start()}end(){super.end(),this.eventBus.unsubscribeAll(),this.subscriptions.forEach((e=>e())),this.status=V,this.tryCleanup()}tryCleanup(){this.customerConnection&&!this.baseInstance.hasMessageSubscribers()&&(this.baseInstance.end(),delete ue.customerBaseInstances[this.contactId])}getStatus(){return this.status||this.baseInstance.getStatus()}onEnded(e){return this.eventBus.subscribe(X,e)}handleEnded(){this.eventBus.trigger(X,{})}onConnectionGain(e){return this.eventBus.subscribe(K,e)}handleConnectionGain(){this.eventBus.trigger(K,{})}onConnectionLost(e){return this.eventBus.subscribe(G,e)}handleConnectionLost(){this.eventBus.trigger(G,{})}onMessage(e){return this.eventBus.subscribe(J,e)}handleMessage(e){e.InitialContactId!==this.initialContactId&&e.ContactId!==this.contactId&&e.Type!==y.MESSAGE_METADATA||this.eventBus.trigger(J,e)}}ue.customerBaseInstances={},ue.agentBaseInstance=null;class le{constructor(e,t,n,r){this.status=W,this.eventBus=new ee,this.logger=k.getLogger({prefix:"ChatJS-LPCConnectionHelperBase",logMetaData:n}),this.initialConnectionDetails=r,this.initWebsocketManager(t,e,n)}initWebsocketManager(e,t,n){if(this.websocketManager=e||ce.create(n),this.websocketManager.subscribeTopics(["aws/chat"]),this.subscriptions=[this.websocketManager.onMessage("aws/chat",this.handleMessage.bind(this)),this.websocketManager.onConnectionGain(this.handleConnectionGain.bind(this)),this.websocketManager.onConnectionLost(this.handleConnectionLost.bind(this)),this.websocketManager.onInitFailure(this.handleEnded.bind(this))],this.logger.info("Initializing websocket manager."),!e){var r=(new Date).getTime();this.websocketManager.init((()=>this._getConnectionDetails(t,this.initialConnectionDetails,r).then((e=>(this.initialConnectionDetails=null,e)))))}}_getConnectionDetails(e,t,n){if(null!==t&&"object"==typeof t&&t.expiry&&t.connectionTokenExpiry){var r={expiry:t.expiry,transportLifeTimeInSeconds:E};return this.logger.debug("Websocket manager initialized. Connection details:",r),Promise.resolve({webSocketTransport:{url:t.url,expiry:t.expiry,transportLifeTimeInSeconds:E}})}return e.fetchConnectionDetails().then((e=>{var t={webSocketTransport:{url:e.url,expiry:e.expiry,transportLifeTimeInSeconds:E}},r={expiry:e.expiry,transportLifeTimeInSeconds:E};return this.logger.debug("Websocket manager initialized. Connection details:",r),this._addWebsocketInitCSMMetric(n),t})).catch((e=>{throw this.logger.error("Initializing Websocket Manager failed:",e),this._addWebsocketInitCSMMetric(n,!0),e}))}_addWebsocketInitCSMMetric(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];ne.addLatencyMetric(v,e,u),ne.addCountAndErrorMetric(v,u,t)}end(){this.websocketManager.closeWebSocket&&this.websocketManager.closeWebSocket(),this.eventBus.unsubscribeAll(),this.subscriptions.forEach((e=>e())),this.logger.info("Websocket closed. All event subscriptions are cleared.")}start(){return this.status===W&&(this.status=B),Promise.resolve({websocketStatus:this.status})}onEnded(e){return this.eventBus.subscribe(X,e)}handleEnded(){this.status=V,this.eventBus.trigger(X,{}),ne.addCountMetric("WebsocketEnded",u),this.logger.info("Websocket connection ended.")}onConnectionGain(e){return this.eventBus.subscribe(K,e)}handleConnectionGain(){this.status=z,this.eventBus.trigger(K,{}),ne.addCountMetric("WebsocketConnectionGained",u),this.logger.info("Websocket connection gained.")}onConnectionLost(e){return this.eventBus.subscribe(G,e)}handleConnectionLost(){this.status=H,this.eventBus.trigger(G,{}),ne.addCountMetric("WebsocketConnectionLost",u),this.logger.info("Websocket connection lost.")}onMessage(e){return this.eventBus.subscribe(J,e)}handleMessage(e){var t;try{t=JSON.parse(e.content),this.eventBus.trigger(J,t),ne.addCountMetric("WebsocketIncomingMessage",u),this.logger.info("this.eventBus trigger Websocket incoming message",J,t)}catch(e){this._sendInternalLogToServer(this.logger.error("Wrong message format"))}}getStatus(){return this.status}getWebsocketManager(){return this.websocketManager}hasMessageSubscribers(){return this.eventBus.getSubscriptions(J).length>0}_sendInternalLogToServer(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e}}const pe=ue;function de(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function he(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class fe{constructor(e){this.logger=k.getLogger({prefix:"ChatJS-MessageReceiptUtil",logMetaData:e}),this.timeout=null,this.timeoutId=null,this.readSet=new Set,this.deliveredSet=new Set,this.readPromiseMap=new Map,this.deliveredPromiseMap=new Map,this.lastReadArgs=null,this.throttleInitialEventsToPrioritizeRead=null,this.throttleSendEventApiCall=null}isMessageReceipt(e,t){return-1!==[y.INCOMING_READ_RECEIPT,y.INCOMING_DELIVERED_RECEIPT].indexOf(e)||t.Type===y.MESSAGE_METADATA}getEventTypeFromMessageMetaData(e){return Array.isArray(e.Receipts)&&e.Receipts[0]&&e.Receipts[0].ReadTimestamp?y.INCOMING_READ_RECEIPT:e.Receipts[0].DeliveredTimestamp?y.INCOMING_DELIVERED_RECEIPT:null}shouldShowMessageReceiptForCurrentParticipantId(e,t){return e!==(t.MessageMetadata&&Array.isArray(t.MessageMetadata.Receipts)&&t.MessageMetadata.Receipts[0]&&t.MessageMetadata.Receipts[0].RecipientParticipantId)}prioritizeAndSendMessageReceipt(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];try{var o,s,a=this,c=r[3],u="string"==typeof r[2]?JSON.parse(r[2]):r[2],l="object"==typeof u?u.messageId:"";if(a.readSet.has(l)||c===y.INCOMING_DELIVERED_RECEIPT&&a.deliveredSet.has(l)||!l)return this.logger.info("Event already fired ".concat(l,": sending messageReceipt ").concat(c)),Promise.resolve({message:"Event already fired"});var p=new Promise((function(e,t){o=e,s=t}));return c===y.INCOMING_DELIVERED_RECEIPT?a.deliveredPromiseMap.set(l,[o,s]):a.readPromiseMap.set(l,[o,s]),a.throttleInitialEventsToPrioritizeRead=function(){return c===y.INCOMING_DELIVERED_RECEIPT&&(a.deliveredSet.add(l),a.readSet.has(l))?(a.resolveDeliveredPromises(l,"Event already fired"),o({message:"Event already fired"})):a.readSet.has(l)?(a.resolveReadPromises(l,"Event already fired"),o({message:"Event already fired"})):(c===y.INCOMING_READ_RECEIPT&&a.readSet.add(l),u.disableThrottle?(this.logger.info("throttleFn disabled for ".concat(l,": sending messageReceipt ").concat(c)),o(t.call(e,...r))):(a.logger.debug("call next throttleFn sendMessageReceipts",r),void a.sendMessageReceipts.call(a,e,t,...r)))},a.timeout||(a.timeout=setTimeout((function(){a.timeout=null,a.throttleInitialEventsToPrioritizeRead()}),300)),c!==y.INCOMING_READ_RECEIPT||a.readSet.has(l)||(clearTimeout(a.timeout),a.timeout=null,a.throttleInitialEventsToPrioritizeRead()),p}catch(e){return Promise.reject(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?de(Object(n),!0).forEach((function(t){he(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):de(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({message:"Failed to send messageReceipt",args:r},e))}}sendMessageReceipts(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];var o=this,a=r[4]||s.getMessageReceiptsThrottleTime(),c=r[3],u=("string"==typeof r[2]?JSON.parse(r[2]):r[2]).messageId;this.lastReadArgs=c===y.INCOMING_READ_RECEIPT?r:this.lastReadArgs,o.throttleSendEventApiCall=function(){try{if(c===y.INCOMING_READ_RECEIPT){var n=t.call(e,...r);o.resolveReadPromises(u,n),o.logger.debug("send Read event:",t,r)}else{var i=[t.call(e,...r)];if(this.lastReadArgs){var s="string"==typeof this.lastReadArgs[2]?JSON.parse(this.lastReadArgs[2]):this.lastReadArgs[2],a=s.messageId;o.readPromiseMap.has(a)&&i.push(t.call(e,...this.lastReadArgs))}o.logger.debug("send Delivered event:",r,"read event:",this.lastReadArgs),Promise.all(i).then((e=>{o.resolveReadPromises(s.messageId,e[0]),o.resolveDeliveredPromises(u,e[0])}))}}catch(e){o.logger.error("send message receipt failed",e),o.resolveReadPromises(u,e,!0),o.resolveDeliveredPromises(u,e,!0)}},o.timeoutId||(o.timeoutId=setTimeout((function(){o.timeoutId=null,o.throttleSendEventApiCall()}),a))}resolveDeliveredPromises(e,t,n){return this.resolvePromises(this.deliveredPromiseMap,e,t,n)}resolveReadPromises(e,t,n){return this.resolvePromises(this.readPromiseMap,e,t,n)}resolvePromises(e,t,n,r){var i=Array.from(e.keys()),o=i.indexOf(t);if(-1!==o)for(var s=0;s<=o;s++){var a,c=null===(a=e.get(i[s]))||void 0===a?void 0:a[r?1:0];"function"==typeof c&&(e.delete(i[s]),c(n))}else this.logger.debug("Promise for messageId: ".concat(t," already resolved"))}rehydrateReceiptMappers(e,t){var n=this;return r=>{if(n.logger.debug("rehydrate chat",null==r?void 0:r.data),t){var{Transcript:i=[]}=(null==r?void 0:r.data)||{};i.forEach((e=>{if((null==e?void 0:e.Type)===y.MESSAGE_METADATA){var t,n,r,i=null==e||null===(t=e.MessageMetadata)||void 0===t||null===(n=t.Receipts)||void 0===n?void 0:n[0],o=null==e||null===(r=e.MessageMetadata)||void 0===r?void 0:r.MessageId;null!=i&&i.ReadTimestamp&&this.readSet.add(o),null!=i&&i.DeliveredTimestamp&&this.deliveredSet.add(o)}}))}return e(r)}}}class me{constructor(e){this.argsValidator=new F,this.pubsub=new ee,this.sessionType=e.sessionType,this.getConnectionToken=e.chatDetails.getConnectionToken,this.connectionDetails=e.chatDetails.connectionDetails,this.initialContactId=e.chatDetails.initialContactId,this.contactId=e.chatDetails.contactId,this.participantId=e.chatDetails.participantId,this.chatClient=e.chatClient,this.participantToken=e.chatDetails.participantToken,this.websocketManager=e.websocketManager,this._participantDisconnected=!1,this.sessionMetadata={},this.logger=k.getLogger({prefix:"ChatJS-ChatController",logMetaData:e.logMetaData}),this.logMetaData=e.logMetaData,this.messageReceiptUtil=new fe(e.logMetaData),this.logger.info("Browser info:",window.navigator.userAgent)}subscribe(e,t){this.pubsub.subscribe(e,t),this._sendInternalLogToServer(this.logger.info("Subscribed successfully to event:",e))}handleRequestSuccess(e,t,n,r){return i=>{var o=r?[{name:"ContentType",value:r}]:[];return ne.addLatencyMetricWithStartTime(t,n,u,o),ne.addCountAndErrorMetric(t,u,!1,o),i.metadata=e,i}}handleRequestFailure(e,t,n,r){return i=>{var o=r?[{name:"ContentType",value:r}]:[];return ne.addLatencyMetricWithStartTime(t,n,u,o),ne.addCountAndErrorMetric(t,u,!0,o),i.metadata=e,Promise.reject(i)}}sendMessage(e){var t=(new Date).getTime(),n=e.metadata||null;this.argsValidator.validateSendMessage(e);var r=this.connectionHelper.getConnectionToken();return this.chatClient.sendMessage(r,e.message,e.contentType).then(this.handleRequestSuccess(n,l,t,e.contentType)).catch(this.handleRequestFailure(n,l,t,e.contentType))}sendAttachment(e){var t=(new Date).getTime(),n=e.metadata||null,r=this.connectionHelper.getConnectionToken();return this.chatClient.sendAttachment(r,e.attachment,e.metadata).then(this.handleRequestSuccess(n,p,t,e.attachment.type)).catch(this.handleRequestFailure(n,p,t,e.attachment.type))}downloadAttachment(e){var t=(new Date).getTime(),n=e.metadata||null,r=this.connectionHelper.getConnectionToken();return this.chatClient.downloadAttachment(r,e.attachmentId).then(this.handleRequestSuccess(n,d,t)).catch(this.handleRequestFailure(n,d,t))}sendEvent(e){var t=(new Date).getTime(),n=e.metadata||null;this.argsValidator.validateSendEvent(e);var r=this.connectionHelper.getConnectionToken(),i=e.content||null,o=ge(e.contentType),c="string"==typeof i?JSON.parse(i):i;return this.messageReceiptUtil.isMessageReceipt(o,e)?s.isFeatureEnabled(a)&&c.messageId?this.messageReceiptUtil.prioritizeAndSendMessageReceipt(this.chatClient,this.chatClient.sendEvent,r,e.contentType,i,o,s.getMessageReceiptsThrottleTime()).then(this.handleRequestSuccess(n,h,t,e.contentType)).catch(this.handleRequestFailure(n,h,t,e.contentType)):(this.logger.warn("Ignoring messageReceipt: ".concat(s.isFeatureEnabled(a)&&"missing messageId"),e),Promise.reject({errorMessage:"Ignoring messageReceipt: ".concat(s.isFeatureEnabled(a)&&"missing messageId"),data:e})):this.chatClient.sendEvent(r,e.contentType,i).then(this.handleRequestSuccess(n,h,t,e.contentType)).catch(this.handleRequestFailure(n,h,t,e.contentType))}getTranscript(e){var t=(new Date).getTime(),n=e.metadata||null,r={startPosition:e.startPosition||{},scanDirection:e.scanDirection||"BACKWARD",sortOrder:e.sortOrder||"ASCENDING",maxResults:e.maxResults||15};e.nextToken&&(r.nextToken=e.nextToken),e.contactId&&(r.contactId=e.contactId);var i=this.connectionHelper.getConnectionToken();return this.chatClient.getTranscript(i,r).then(this.messageReceiptUtil.rehydrateReceiptMappers(this.handleRequestSuccess(n,f,t),s.isFeatureEnabled(a))).catch(this.handleRequestFailure(n,f,t))}connect(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.sessionMetadata=e.metadata||null,this.argsValidator.validateConnectChat(e);var t=this._getConnectionDetailsProvider();return t.fetchConnectionDetails().then((e=>this._initConnectionHelper(t,e))).then((e=>this._onConnectSuccess(e,t))).catch((e=>this._onConnectFailure(e)))}_initConnectionHelper(e,t){return this.connectionHelper=new pe(this.contactId,this.initialContactId,e,this.websocketManager,this.logMetaData,t),this.connectionHelper.onEnded(this._handleEndedConnection.bind(this)),this.connectionHelper.onConnectionLost(this._handleLostConnection.bind(this)),this.connectionHelper.onConnectionGain(this._handleGainedConnection.bind(this)),this.connectionHelper.onMessage(this._handleIncomingMessage.bind(this)),this.connectionHelper.start()}_getConnectionDetailsProvider(){return new ie(this.participantToken,this.chatClient,this.sessionType,this.getConnectionToken)}_handleEndedConnection(e){this._forwardChatEvent(y.CONNECTION_BROKEN,{data:e,chatDetails:this.getChatDetails()}),this.breakConnection()}_handleLostConnection(e){this._forwardChatEvent(y.CONNECTION_LOST,{data:e,chatDetails:this.getChatDetails()})}_handleGainedConnection(e){this._forwardChatEvent(y.CONNECTION_ESTABLISHED,{data:e,chatDetails:this.getChatDetails()})}_handleIncomingMessage(e){try{var t=ge(null==e?void 0:e.ContentType);if(this.messageReceiptUtil.isMessageReceipt(t,e)&&(!(t=this.messageReceiptUtil.getEventTypeFromMessageMetaData(null==e?void 0:e.MessageMetadata))||!this.messageReceiptUtil.shouldShowMessageReceiptForCurrentParticipantId(this.participantId,e)))return;this._forwardChatEvent(t,{data:e,chatDetails:this.getChatDetails()}),e.ContentType===b.chatEnded&&(this._forwardChatEvent(y.CHAT_ENDED,{data:null,chatDetails:this.getChatDetails()}),this.breakConnection())}catch(t){this._sendInternalLogToServer(this.logger.error("Error occured while handling message from Connection. eventData:",e," Causing exception:",t))}}_forwardChatEvent(e,t){this.pubsub.triggerAsync(e,t)}_onConnectSuccess(e,t){var n;this._sendInternalLogToServer(this.logger.info("Connect successful!")),console.warn("onConnectionSuccess response",e);var r={_debug:e,connectSuccess:!0,connectCalled:!0,metadata:this.sessionMetadata},i=Object.assign({chatDetails:this.getChatDetails()},r);this.pubsub.triggerAsync(y.CONNECTION_ESTABLISHED,i);var o=null===(n=t.getConnectionDetails())||void 0===n?void 0:n.connectionAcknowledged;return this._shouldAcknowledgeContact()&&!o&&(ne.addAgentCountMetric("CREATE_PARTICIPANT_CONACK_CALL_COUNT",1),t.callCreateParticipantConnection({Type:!1,ConnectParticipant:!0}).catch((e=>{this.logger.warn("ConnectParticipant failed to acknowledge Agent connection in CreateParticipantConnection: ",e),ne.addAgentCountMetric("CREATE_PARTICIPANT_CONACK_FAILURE",1)}))),console.warn("onConnectionSuccess responseObject",r),r}_onConnectFailure(e){var t={_debug:e,connectSuccess:!1,connectCalled:!0,metadata:this.sessionMetadata};return this._sendInternalLogToServer(this.logger.error("Connect Failed. Error: ",t)),Promise.reject(t)}_shouldAcknowledgeContact(){return this.sessionType===c.AGENT}breakConnection(){return this.connectionHelper?this.connectionHelper.end():Promise.resolve()}cleanUpOnParticipantDisconnect(){this.pubsub.unsubscribeAll()}disconnectParticipant(){var e=(new Date).getTime(),t=this.connectionHelper.getConnectionToken();return this.chatClient.disconnectParticipant(t).then((t=>(this._sendInternalLogToServer(this.logger.info("Disconnect participant successfully")),this._participantDisconnected=!0,this.cleanUpOnParticipantDisconnect(),this.breakConnection(),ne.addLatencyMetricWithStartTime(m,e,u),ne.addCountAndErrorMetric(m,u,!1),t)),(t=>(this._sendInternalLogToServer(this.logger.error("Disconnect participant failed. Error:",t)),ne.addLatencyMetricWithStartTime(m,e,u),ne.addCountAndErrorMetric(m,u,!0),Promise.reject(t))))}getChatDetails(){return{initialContactId:this.initialContactId,contactId:this.contactId,participantId:this.participantId,participantToken:this.participantToken,connectionDetails:this.connectionDetails}}_convertConnectionHelperStatus(e){switch(e){case W:return"NeverEstablished";case B:return"Establishing";case V:case H:return"Broken";case z:return"Established"}this._sendInternalLogToServer(this.logger.error("Reached invalid state. Unknown connectionHelperStatus: ",e))}getConnectionStatus(){return this._convertConnectionHelperStatus(this.connectionHelper.getStatus())}_sendInternalLogToServer(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e}}var ge=e=>w[e]||w.default;class ve{createAgentChatController(e,n){throw new t("createAgentChatController in ChatControllerFactory.")}createCustomerChatController(e,n){throw new t("createCustomerChatController in ChatControllerFactory.")}}class ye{constructor(e){this.controller=e}onMessage(e){this.controller.subscribe(y.INCOMING_MESSAGE,e)}onTyping(e){this.controller.subscribe(y.INCOMING_TYPING,e)}onReadReceipt(e){this.controller.subscribe(y.INCOMING_READ_RECEIPT,e)}onDeliveredReceipt(e){this.controller.subscribe(y.INCOMING_DELIVERED_RECEIPT,e)}onConnectionBroken(e){this.controller.subscribe(y.CONNECTION_BROKEN,e)}onConnectionEstablished(e){this.controller.subscribe(y.CONNECTION_ESTABLISHED,e)}onEnded(e){this.controller.subscribe(y.CHAT_ENDED,e)}onParticipantIdle(e){this.controller.subscribe(y.PARTICIPANT_IDLE,e)}onParticipantReturned(e){this.controller.subscribe(y.PARTICIPANT_RETURNED,e)}onAutoDisconnection(e){this.controller.subscribe(y.AUTODISCONNECTION,e)}onConnectionLost(e){this.controller.subscribe(y.CONNECTION_LOST,e)}sendMessage(e){return this.controller.sendMessage(e)}sendAttachment(e){return this.controller.sendAttachment(e)}downloadAttachment(e){return this.controller.downloadAttachment(e)}connect(e){return this.controller.connect(e)}sendEvent(e){return this.controller.sendEvent(e)}getTranscript(e){return this.controller.getTranscript(e)}getChatDetails(){return this.controller.getChatDetails()}}class be extends ye{constructor(e){super(e)}cleanUpOnParticipantDisconnect(){return this.controller.cleanUpOnParticipantDisconnect()}}class we extends ye{constructor(e){super(e)}disconnectParticipant(){return this.controller.disconnectParticipant()}}var Ee=new class extends ve{constructor(){super(),this.argsValidator=new F}createChatSession(e,t,n,i){var o=this._createChatController(e,t,n,i);if(e===c.AGENT)return new be(o);if(e===c.CUSTOMER)return new we(o);throw new r("Unkown value for session type, Allowed values are: "+Object.values(c),e)}_createChatController(e,t,n,r){var i=this.argsValidator.normalizeChatDetails(t),o={contactId:i.contactId,participantId:i.participantId,sessionType:e},s=q.getCachedClient(n,o);return new me({sessionType:e,chatDetails:i,chatClient:s,websocketManager:r,logMetaData:o})}},Se=e=>{s.setFeatureFlag(e)},Ce={create:e=>{var t=e.options||{},n=e.type||c.AGENT;return s.updateStageRegion(t),e.disableCSM||n!==c.CUSTOMER||ne.loadCsmScriptAndExecute(),Ee.createChatSession(n,e.chatDetails,t,e.websocketManager)},setGlobalConfig:e=>{var t,n,r,i,o=e.loggerConfig,c=e.csmConfig;s.update(e),ce.setGlobalConfig(e),k.updateLoggerConfig(o),c&&ne.updateCsmConfig(c),!1!==(null===(t=e.features)||void 0===t||null===(n=t.messageReceipts)||void 0===n?void 0:n.shouldSendMessageReceipts)&&(console.warn("enabling message-receipts by default; to disable set config.features.messageReceipts.shouldSendMessageReceipts = false"),Se(a),s.updateThrottleTime(null===(r=e.features)||void 0===r||null===(i=r.messageReceipts)||void 0===i?void 0:i.thorttleTime))},LogLevel:I,Logger:class{debug(e){}info(e){}warn(e){}error(e){}advancedLog(e){}},SessionTypes:c,csmService:ne,setFeatureFlag:Se},Te=void 0!==Te?Te:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Te.connect=Te.connect||{},connect.ChatSession=Ce,connect.LogManager=k,connect.LogLevel=I,connect.csmService=Ce.csmService})()})(); //# sourceMappingURL=amazon-connect-chat.js.map