@aws-amplify/analytics 5.1.12 → 5.1.13-cloud-logging.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws-amplify-analytics.js +14 -15
- package/dist/aws-amplify-analytics.js.map +1 -1
- package/dist/aws-amplify-analytics.min.js +1 -1
- package/dist/aws-amplify-analytics.min.js.map +1 -1
- package/lib/Analytics.d.ts +36 -12
- package/lib/Analytics.js +13 -14
- package/lib/Analytics.js.map +1 -1
- package/lib/types/Analytics.d.ts +11 -0
- package/lib-esm/Analytics.d.ts +36 -12
- package/lib-esm/Analytics.js +13 -14
- package/lib-esm/Analytics.js.map +1 -1
- package/lib-esm/types/Analytics.d.ts +11 -0
- package/package.json +4 -4
- package/src/Analytics.ts +57 -28
- package/src/types/Analytics.ts +13 -1
|
@@ -36,7 +36,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
36
36
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
37
37
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
38
38
|
PERFORMANCE OF THIS SOFTWARE.
|
|
39
|
-
***************************************************************************** */function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function u(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}Object.create;function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}var f,l,d,p,h,v,g,m,y,b,w,_,S,E,A,O,I,L,k,M,P,x,R,T,j,C,D,N,U,z,B,F,q,K,V,H,G,$,W,Y,Z,J,Q,X,ee,te,ne,re,ie,oe,se,ae,ue,ce,fe,le,de,pe,he,ve,ge,me,ye,be,we,_e,Se,Ee,Ae,Oe,Ie,Le,ke,Me,Pe,xe,Re,Te,je,Ce,De,Ne,Ue,ze,Be,Fe,qe,Ke,Ve,He,Ge,$e,We,Ye,Ze,Je,Qe,Xe,et,tt,nt,rt,it,ot,st,at,ut,ct,ft,lt,dt,pt,ht,vt,gt,mt,yt,bt,wt,_t,St,Et,At,Ot,It,Lt,kt,Mt,Pt,xt,Rt;Object.create;(f||(f={})).filterSensitiveLog=function(e){return s({},e)},(l||(l={})).filterSensitiveLog=function(e){return s({},e)},(d||(d={})).filterSensitiveLog=function(e){return s({},e)},(p||(p={})).filterSensitiveLog=function(e){return s({},e)},(h||(h={})).filterSensitiveLog=function(e){return s({},e)},(v||(v={})).filterSensitiveLog=function(e){return s({},e)},(g||(g={})).filterSensitiveLog=function(e){return s({},e)},(m||(m={})).filterSensitiveLog=function(e){return s({},e)},(y||(y={})).filterSensitiveLog=function(e){return s({},e)},(b||(b={})).filterSensitiveLog=function(e){return s({},e)},(w||(w={})).filterSensitiveLog=function(e){return s({},e)},(_||(_={})).filterSensitiveLog=function(e){return s({},e)},(S||(S={})).filterSensitiveLog=function(e){return s({},e)},(E||(E={})).filterSensitiveLog=function(e){return s({},e)},(A||(A={})).filterSensitiveLog=function(e){return s({},e)},(O||(O={})).filterSensitiveLog=function(e){return s({},e)},(I||(I={})).filterSensitiveLog=function(e){return s({},e)},(L||(L={})).filterSensitiveLog=function(e){return s({},e)},(k||(k={})).filterSensitiveLog=function(e){return s({},e)},(M||(M={})).filterSensitiveLog=function(e){return s({},e)},(P||(P={})).filterSensitiveLog=function(e){return s({},e)},(x||(x={})).filterSensitiveLog=function(e){return s({},e)},(R||(R={})).filterSensitiveLog=function(e){return s({},e)},(T||(T={})).filterSensitiveLog=function(e){return s({},e)},(j||(j={})).filterSensitiveLog=function(e){return s({},e)},(C||(C={})).filterSensitiveLog=function(e){return s({},e)},(D||(D={})).filterSensitiveLog=function(e){return s({},e)},(N||(N={})).filterSensitiveLog=function(e){return s({},e)},(U||(U={})).filterSensitiveLog=function(e){return s({},e)},(z||(z={})).filterSensitiveLog=function(e){return s({},e)},(B||(B={})).filterSensitiveLog=function(e){return s({},e)},(F||(F={})).filterSensitiveLog=function(e){return s({},e)},(q||(q={})).filterSensitiveLog=function(e){return s({},e)},(K||(K={})).filterSensitiveLog=function(e){return s({},e)},(V||(V={})).filterSensitiveLog=function(e){return s({},e)},(H||(H={})).filterSensitiveLog=function(e){return s({},e)},(G||(G={})).filterSensitiveLog=function(e){return s({},e)},($||($={})).filterSensitiveLog=function(e){return s({},e)},(W||(W={})).filterSensitiveLog=function(e){return s({},e)},(Y||(Y={})).filterSensitiveLog=function(e){return s({},e)},(Z||(Z={})).filterSensitiveLog=function(e){return s({},e)},(J||(J={})).filterSensitiveLog=function(e){return s({},e)},(Q||(Q={})).filterSensitiveLog=function(e){return s({},e)},(X||(X={})).filterSensitiveLog=function(e){return s({},e)},(ee||(ee={})).filterSensitiveLog=function(e){return s({},e)},(te||(te={})).filterSensitiveLog=function(e){return s({},e)},(ne||(ne={})).filterSensitiveLog=function(e){return s({},e)},(re||(re={})).filterSensitiveLog=function(e){return s({},e)},(ie||(ie={})).filterSensitiveLog=function(e){return s({},e)},(oe||(oe={})).filterSensitiveLog=function(e){return s({},e)},(se||(se={})).filterSensitiveLog=function(e){return s({},e)},(ae||(ae={})).filterSensitiveLog=function(e){return s({},e)},(ue||(ue={})).filterSensitiveLog=function(e){return s({},e)},(ce||(ce={})).filterSensitiveLog=function(e){return s({},e)},(fe||(fe={})).filterSensitiveLog=function(e){return s({},e)},(le||(le={})).filterSensitiveLog=function(e){return s({},e)},(de||(de={})).filterSensitiveLog=function(e){return s({},e)},(pe||(pe={})).filterSensitiveLog=function(e){return s({},e)},(he||(he={})).filterSensitiveLog=function(e){return s({},e)},(ve||(ve={})).filterSensitiveLog=function(e){return s({},e)},(ge||(ge={})).filterSensitiveLog=function(e){return s({},e)},(me||(me={})).filterSensitiveLog=function(e){return s({},e)},(ye||(ye={})).filterSensitiveLog=function(e){return s({},e)},(be||(be={})).filterSensitiveLog=function(e){return s({},e)},(we||(we={})).filterSensitiveLog=function(e){return s({},e)},(_e||(_e={})).filterSensitiveLog=function(e){return s({},e)},(Se||(Se={})).filterSensitiveLog=function(e){return s({},e)},(Ee||(Ee={})).filterSensitiveLog=function(e){return s({},e)},(Ae||(Ae={})).filterSensitiveLog=function(e){return s({},e)},(Oe||(Oe={})).filterSensitiveLog=function(e){return s({},e)},(Ie||(Ie={})).filterSensitiveLog=function(e){return s({},e)},(Le||(Le={})).filterSensitiveLog=function(e){return s({},e)},(ke||(ke={})).filterSensitiveLog=function(e){return s({},e)},(Me||(Me={})).filterSensitiveLog=function(e){return s({},e)},(Pe||(Pe={})).filterSensitiveLog=function(e){return s({},e)},(xe||(xe={})).filterSensitiveLog=function(e){return s({},e)},(Re||(Re={})).filterSensitiveLog=function(e){return s({},e)},(Te||(Te={})).filterSensitiveLog=function(e){return s({},e)},(je||(je={})).filterSensitiveLog=function(e){return s({},e)},(Ce||(Ce={})).filterSensitiveLog=function(e){return s({},e)},(De||(De={})).filterSensitiveLog=function(e){return s({},e)},(Ne||(Ne={})).filterSensitiveLog=function(e){return s({},e)},(Ue||(Ue={})).filterSensitiveLog=function(e){return s({},e)},(ze||(ze={})).filterSensitiveLog=function(e){return s({},e)},(Be||(Be={})).filterSensitiveLog=function(e){return s({},e)},(Fe||(Fe={})).filterSensitiveLog=function(e){return s({},e)},(qe||(qe={})).filterSensitiveLog=function(e){return s({},e)},(Ke||(Ke={})).filterSensitiveLog=function(e){return s({},e)},(Ve||(Ve={})).filterSensitiveLog=function(e){return s({},e)},(He||(He={})).filterSensitiveLog=function(e){return s({},e)},(Ge||(Ge={})).filterSensitiveLog=function(e){return s({},e)},($e||($e={})).filterSensitiveLog=function(e){return s({},e)},(We||(We={})).filterSensitiveLog=function(e){return s({},e)},(Ye||(Ye={})).filterSensitiveLog=function(e){return s({},e)},(Ze||(Ze={})).filterSensitiveLog=function(e){return s({},e)},(Je||(Je={})).filterSensitiveLog=function(e){return s({},e)},(Qe||(Qe={})).filterSensitiveLog=function(e){return s({},e)},(Xe||(Xe={})).filterSensitiveLog=function(e){return s({},e)},(et||(et={})).filterSensitiveLog=function(e){return s({},e)},(tt||(tt={})).filterSensitiveLog=function(e){return s({},e)},(nt||(nt={})).filterSensitiveLog=function(e){return s({},e)},(rt||(rt={})).filterSensitiveLog=function(e){return s({},e)},(it||(it={})).filterSensitiveLog=function(e){return s({},e)},(ot||(ot={})).filterSensitiveLog=function(e){return s({},e)},(st||(st={})).filterSensitiveLog=function(e){return s({},e)},(at||(at={})).filterSensitiveLog=function(e){return s({},e)},(ut||(ut={})).filterSensitiveLog=function(e){return s({},e)},(ct||(ct={})).filterSensitiveLog=function(e){return s({},e)},(ft||(ft={})).filterSensitiveLog=function(e){return s({},e)},(lt||(lt={})).filterSensitiveLog=function(e){return s({},e)},(dt||(dt={})).filterSensitiveLog=function(e){return s({},e)},(pt||(pt={})).filterSensitiveLog=function(e){return s({},e)},(ht||(ht={})).filterSensitiveLog=function(e){return s({},e)},(vt||(vt={})).filterSensitiveLog=function(e){return s({},e)},(gt||(gt={})).filterSensitiveLog=function(e){return s({},e)},(mt||(mt={})).filterSensitiveLog=function(e){return s({},e)},(yt||(yt={})).filterSensitiveLog=function(e){return s({},e)},(bt||(bt={})).filterSensitiveLog=function(e){return s({},e)},(wt||(wt={})).filterSensitiveLog=function(e){return s({},e)},(_t||(_t={})).filterSensitiveLog=function(e){return s({},e)},(St||(St={})).filterSensitiveLog=function(e){return s({},e)},(Et||(Et={})).filterSensitiveLog=function(e){return s({},e)},(At||(At={})).filterSensitiveLog=function(e){return s({},e)},(Ot||(Ot={})).filterSensitiveLog=function(e){return s({},e)},(It||(It={})).filterSensitiveLog=function(e){return s({},e)},(Lt||(Lt={})).filterSensitiveLog=function(e){return s({},e)},(kt||(kt={})).filterSensitiveLog=function(e){return s({},e)},(Mt||(Mt={})).filterSensitiveLog=function(e){return s({},e)},(Pt||(Pt={})).filterSensitiveLog=function(e){return s({},e)},(xt||(xt={})).filterSensitiveLog=function(e){return s({},e)},(Rt||(Rt={})).filterSensitiveLog=function(e){return s({},e)};var Tt=function(){function e(e){this.statusCode=e.statusCode,this.headers=e.headers||{},this.body=e.body}return e.isInstance=function(e){if(!e)return!1;var t=e;return"number"==typeof t.statusCode&&"object"==typeof t.headers},e}(),jt=n(0),Ct=function(){function e(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?":"!==e.protocol.substr(-1)?e.protocol+":":e.protocol:"https:",this.path=e.path?"/"!==e.path.charAt(0)?"/"+e.path:e.path:"/"}return e.isInstance=function(e){if(!e)return!1;var t=e;return"method"in t&&"protocol"in t&&"hostname"in t&&"path"in t&&"object"==typeof t.query&&"object"==typeof t.headers},e.prototype.clone=function(){var t,n=new e(Object(jt.__assign)(Object(jt.__assign)({},this),{headers:Object(jt.__assign)({},this.headers)}));return n.query&&(n.query=(t=n.query,Object.keys(t).reduce((function(e,n){var r,i=t[n];return Object(jt.__assign)(Object(jt.__assign)({},e),((r={})[n]=Array.isArray(i)?Object(jt.__spread)(i):i,r))}),{}))),n},e}();var Dt=function(){var e=[],t=[],n=new Set,r=function(n){return e.forEach((function(e){n.add(e.middleware,Object(jt.__assign)({},e))})),t.forEach((function(e){n.addRelativeTo(e.middleware,Object(jt.__assign)({},e))})),n},i=function(e){var t=[];return e.before.forEach((function(e){0===e.before.length&&0===e.after.length?t.push(e):t.push.apply(t,Object(jt.__spread)(i(e)))})),t.push(e),e.after.reverse().forEach((function(e){0===e.before.length&&0===e.after.length?t.push(e):t.push.apply(t,Object(jt.__spread)(i(e)))})),t},o=function(){var n,r=[],o=[],s={};return e.forEach((function(e){var t=Object(jt.__assign)(Object(jt.__assign)({},e),{before:[],after:[]});t.name&&(s[t.name]=t),r.push(t)})),t.forEach((function(e){var t=Object(jt.__assign)(Object(jt.__assign)({},e),{before:[],after:[]});t.name&&(s[t.name]=t),o.push(t)})),o.forEach((function(e){if(e.toMiddleware){var t=s[e.toMiddleware];if(void 0===t)throw new Error(e.toMiddleware+" is not found when adding "+(e.name||"anonymous")+" middleware "+e.relation+" "+e.toMiddleware);"after"===e.relation&&t.after.push(e),"before"===e.relation&&t.before.push(e)}})),(n=r,n.sort((function(e,t){return Nt[t.step]-Nt[e.step]||Ut[t.priority||"normal"]-Ut[e.priority||"normal"]}))).map(i).reduce((function(e,t){return e.push.apply(e,Object(jt.__spread)(t)),e}),[]).map((function(e){return e.middleware}))},s={add:function(t,r){void 0===r&&(r={});var i=r.name,o=r.override,s=Object(jt.__assign)({step:"initialize",priority:"normal",middleware:t},r);if(i){if(n.has(i)){if(!o)throw new Error("Duplicate middleware name '"+i+"'");var a=e.findIndex((function(e){return e.name===i})),u=e[a];if(u.step!==s.step||u.priority!==s.priority)throw new Error('"'+i+'" middleware with '+u.priority+" priority in "+u.step+" step cannot be overridden by same-name middleware with "+s.priority+" priority in "+s.step+" step.");e.splice(a,1)}n.add(i)}e.push(s)},addRelativeTo:function(e,r){var i=r.name,o=r.override,s=Object(jt.__assign)({middleware:e},r);if(i){if(n.has(i)){if(!o)throw new Error("Duplicate middleware name '"+i+"'");var a=t.findIndex((function(e){return e.name===i})),u=t[a];if(u.toMiddleware!==s.toMiddleware||u.relation!==s.relation)throw new Error('"'+i+'" middleware '+u.relation+' "'+u.toMiddleware+'" middleware cannot be overridden by same-name middleware '+s.relation+' "'+s.toMiddleware+'" middleware.');t.splice(a,1)}n.add(i)}t.push(s)},clone:function(){return r(Dt())},use:function(e){e.applyToStack(s)},remove:function(r){return"string"==typeof r?function(r){var i=!1,o=function(e){return!e.name||e.name!==r||(i=!0,n.delete(r),!1)};return e=e.filter(o),t=t.filter(o),i}(r):function(r){var i=!1,o=function(e){return e.middleware!==r||(i=!0,e.name&&n.delete(e.name),!1)};return e=e.filter(o),t=t.filter(o),i}(r)},removeByTag:function(r){var i=!1,o=function(e){var t=e.tags,o=e.name;return!t||!t.includes(r)||(o&&n.delete(o),i=!0,!1)};return e=e.filter(o),t=t.filter(o),i},concat:function(e){var t=r(Dt());return t.use(e),t},applyToStack:r,resolve:function(e,t){var n,r;try{for(var i=Object(jt.__values)(o().reverse()),s=i.next();!s.done;s=i.next()){e=(0,s.value)(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e}};return s},Nt={initialize:5,serialize:4,build:3,finalizeRequest:2,deserialize:1},Ut={high:3,normal:2,low:1},zt=function(){function e(e){this.middlewareStack=Dt(),this.config=e}return e.prototype.send=function(e,t,n){var r="function"!=typeof t?t:void 0,i="function"==typeof t?t:n,o=e.resolveMiddleware(this.middlewareStack,this.config,r);if(!i)return o(e).then((function(e){return e.output}));o(e).then((function(e){return i(null,e.output)}),(function(e){return i(e)})).catch((function(){}))},e.prototype.destroy=function(){this.config.requestHandler.destroy&&this.config.requestHandler.destroy()},e}(),Bt=function(){this.middlewareStack=Dt()};function Ft(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}var qt=function(){var e=Object.getPrototypeOf(this).constructor,t=Function.bind.apply(String,Object(jt.__spread)([null],arguments)),n=new t;return Object.setPrototypeOf(n,e.prototype),n};qt.prototype=Object.create(String.prototype,{constructor:{value:qt,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(qt,String);var Kt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(jt.__extends)(t,e),t.prototype.deserializeJSON=function(){return JSON.parse(e.prototype.toString.call(this))},t.prototype.toJSON=function(){return e.prototype.toString.call(this)},t.fromObject=function(e){return e instanceof t?e:new t(e instanceof String||"string"==typeof e?e:JSON.stringify(e))},t}(qt);var Vt="***SensitiveInformation***",Ht=function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,a,c,f,l,d,p,h,v,g,m;return u(this,(function(u){switch(u.label){case 0:return r=[s({},e)],m={},[4,_n(e.body,t)];case 1:switch(n=s.apply(void 0,r.concat([(m.body=u.sent(),m)])),o="UnknownError",o=Sn(e,n.body),o){case"BadRequestException":case"com.amazonaws.pinpoint#BadRequestException":return[3,2];case"ForbiddenException":case"com.amazonaws.pinpoint#ForbiddenException":return[3,4];case"InternalServerErrorException":case"com.amazonaws.pinpoint#InternalServerErrorException":return[3,6];case"MethodNotAllowedException":case"com.amazonaws.pinpoint#MethodNotAllowedException":return[3,8];case"NotFoundException":case"com.amazonaws.pinpoint#NotFoundException":return[3,10];case"PayloadTooLargeException":case"com.amazonaws.pinpoint#PayloadTooLargeException":return[3,12];case"TooManyRequestsException":case"com.amazonaws.pinpoint#TooManyRequestsException":return[3,14]}return[3,16];case 2:return a=[{}],[4,$t(n,t)];case 3:return i=s.apply(void 0,[s.apply(void 0,a.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 4:return c=[{}],[4,Wt(n,t)];case 5:return i=s.apply(void 0,[s.apply(void 0,c.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 6:return f=[{}],[4,Yt(n,t)];case 7:return i=s.apply(void 0,[s.apply(void 0,f.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 8:return l=[{}],[4,Zt(n,t)];case 9:return i=s.apply(void 0,[s.apply(void 0,l.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 10:return d=[{}],[4,Jt(n,t)];case 11:return i=s.apply(void 0,[s.apply(void 0,d.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 12:return p=[{}],[4,Qt(n,t)];case 13:return i=s.apply(void 0,[s.apply(void 0,p.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 14:return h=[{}],[4,Xt(n,t)];case 15:return i=s.apply(void 0,[s.apply(void 0,h.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 16:v=n.body,o=v.code||v.Code||o,i=s(s({},v),{name:""+o,message:v.message||v.Message||o,$fault:"client",$metadata:bn(e)}),u.label=17;case 17:return g=i.message||i.Message||o,i.message=g,delete i.Message,[2,Promise.reject(Object.assign(new Error(g),i))]}}))}))},Gt=function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,a,c,f,l,d,p,h,v,g,m;return u(this,(function(u){switch(u.label){case 0:return r=[s({},e)],m={},[4,_n(e.body,t)];case 1:switch(n=s.apply(void 0,r.concat([(m.body=u.sent(),m)])),o="UnknownError",o=Sn(e,n.body),o){case"BadRequestException":case"com.amazonaws.pinpoint#BadRequestException":return[3,2];case"ForbiddenException":case"com.amazonaws.pinpoint#ForbiddenException":return[3,4];case"InternalServerErrorException":case"com.amazonaws.pinpoint#InternalServerErrorException":return[3,6];case"MethodNotAllowedException":case"com.amazonaws.pinpoint#MethodNotAllowedException":return[3,8];case"NotFoundException":case"com.amazonaws.pinpoint#NotFoundException":return[3,10];case"PayloadTooLargeException":case"com.amazonaws.pinpoint#PayloadTooLargeException":return[3,12];case"TooManyRequestsException":case"com.amazonaws.pinpoint#TooManyRequestsException":return[3,14]}return[3,16];case 2:return a=[{}],[4,$t(n,t)];case 3:return i=s.apply(void 0,[s.apply(void 0,a.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 4:return c=[{}],[4,Wt(n,t)];case 5:return i=s.apply(void 0,[s.apply(void 0,c.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 6:return f=[{}],[4,Yt(n,t)];case 7:return i=s.apply(void 0,[s.apply(void 0,f.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 8:return l=[{}],[4,Zt(n,t)];case 9:return i=s.apply(void 0,[s.apply(void 0,l.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 10:return d=[{}],[4,Jt(n,t)];case 11:return i=s.apply(void 0,[s.apply(void 0,d.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 12:return p=[{}],[4,Qt(n,t)];case 13:return i=s.apply(void 0,[s.apply(void 0,p.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 14:return h=[{}],[4,Xt(n,t)];case 15:return i=s.apply(void 0,[s.apply(void 0,h.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 16:v=n.body,o=v.code||v.Code||o,i=s(s({},v),{name:""+o,message:v.message||v.Message||o,$fault:"client",$metadata:bn(e)}),u.label=17;case 17:return g=i.message||i.Message||o,i.message=g,delete i.Message,[2,Promise.reject(Object.assign(new Error(g),i))]}}))}))},$t=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"BadRequestException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Wt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"ForbiddenException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Yt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"InternalServerErrorException",$fault:"server",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Zt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"MethodNotAllowedException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Jt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"NotFoundException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Qt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"PayloadTooLargeException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Xt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"TooManyRequestsException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},en=function(e,t){return s(s(s(s(s(s(s(s({},void 0!==e.AppVersion&&null!==e.AppVersion&&{AppVersion:e.AppVersion}),void 0!==e.Locale&&null!==e.Locale&&{Locale:e.Locale}),void 0!==e.Make&&null!==e.Make&&{Make:e.Make}),void 0!==e.Model&&null!==e.Model&&{Model:e.Model}),void 0!==e.ModelVersion&&null!==e.ModelVersion&&{ModelVersion:e.ModelVersion}),void 0!==e.Platform&&null!==e.Platform&&{Platform:e.Platform}),void 0!==e.PlatformVersion&&null!==e.PlatformVersion&&{PlatformVersion:e.PlatformVersion}),void 0!==e.Timezone&&null!==e.Timezone&&{Timezone:e.Timezone})},tn=function(e,t){return s(s(s(s(s(s({},void 0!==e.City&&null!==e.City&&{City:e.City}),void 0!==e.Country&&null!==e.Country&&{Country:e.Country}),void 0!==e.Latitude&&null!==e.Latitude&&{Latitude:e.Latitude}),void 0!==e.Longitude&&null!==e.Longitude&&{Longitude:e.Longitude}),void 0!==e.PostalCode&&null!==e.PostalCode&&{PostalCode:e.PostalCode}),void 0!==e.Region&&null!==e.Region&&{Region:e.Region})},nn=function(e,t){return s(s(s(s(s(s(s(s(s(s(s({},void 0!==e.Address&&null!==e.Address&&{Address:e.Address}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:ln(e.Attributes,t)}),void 0!==e.ChannelType&&null!==e.ChannelType&&{ChannelType:e.ChannelType}),void 0!==e.Demographic&&null!==e.Demographic&&{Demographic:en(e.Demographic,t)}),void 0!==e.EffectiveDate&&null!==e.EffectiveDate&&{EffectiveDate:e.EffectiveDate}),void 0!==e.EndpointStatus&&null!==e.EndpointStatus&&{EndpointStatus:e.EndpointStatus}),void 0!==e.Location&&null!==e.Location&&{Location:tn(e.Location,t)}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.OptOut&&null!==e.OptOut&&{OptOut:e.OptOut}),void 0!==e.RequestId&&null!==e.RequestId&&{RequestId:e.RequestId}),void 0!==e.User&&null!==e.User&&{User:rn(e.User,t)})},rn=function(e,t){return s(s({},void 0!==e.UserAttributes&&null!==e.UserAttributes&&{UserAttributes:ln(e.UserAttributes,t)}),void 0!==e.UserId&&null!==e.UserId&&{UserId:e.UserId})},on=function(e,t){return s({},void 0!==e.BatchItem&&null!==e.BatchItem&&{BatchItem:fn(e.BatchItem,t)})},sn=function(e,t){return e.filter((function(e){return null!=e})).map((function(e){return null===e?null:e}))},an=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=o,n))}),{})},un=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=o,n))}),{})},cn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return s(s(s(s(s(s(s(s(s(s({},void 0!==e.AppPackageName&&null!==e.AppPackageName&&{AppPackageName:e.AppPackageName}),void 0!==e.AppTitle&&null!==e.AppTitle&&{AppTitle:e.AppTitle}),void 0!==e.AppVersionCode&&null!==e.AppVersionCode&&{AppVersionCode:e.AppVersionCode}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:un(e.Attributes,t)}),void 0!==e.ClientSdkVersion&&null!==e.ClientSdkVersion&&{ClientSdkVersion:e.ClientSdkVersion}),void 0!==e.EventType&&null!==e.EventType&&{EventType:e.EventType}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.SdkName&&null!==e.SdkName&&{SdkName:e.SdkName}),void 0!==e.Session&&null!==e.Session&&{Session:pn(e.Session,t)}),void 0!==e.Timestamp&&null!==e.Timestamp&&{Timestamp:e.Timestamp})}(a,t),r))}),{})},fn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return s(s({},void 0!==e.Endpoint&&null!==e.Endpoint&&{Endpoint:dn(e.Endpoint,t)}),void 0!==e.Events&&null!==e.Events&&{Events:cn(e.Events,t)})}(a,t),r))}),{})},ln=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=sn(a,t),r))}),{})},dn=function(e,t){return s(s(s(s(s(s(s(s(s(s(s({},void 0!==e.Address&&null!==e.Address&&{Address:e.Address}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:ln(e.Attributes,t)}),void 0!==e.ChannelType&&null!==e.ChannelType&&{ChannelType:e.ChannelType}),void 0!==e.Demographic&&null!==e.Demographic&&{Demographic:en(e.Demographic,t)}),void 0!==e.EffectiveDate&&null!==e.EffectiveDate&&{EffectiveDate:e.EffectiveDate}),void 0!==e.EndpointStatus&&null!==e.EndpointStatus&&{EndpointStatus:e.EndpointStatus}),void 0!==e.Location&&null!==e.Location&&{Location:tn(e.Location,t)}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.OptOut&&null!==e.OptOut&&{OptOut:e.OptOut}),void 0!==e.RequestId&&null!==e.RequestId&&{RequestId:e.RequestId}),void 0!==e.User&&null!==e.User&&{User:rn(e.User,t)})},pn=function(e,t){return s(s(s(s({},void 0!==e.Duration&&null!==e.Duration&&{Duration:e.Duration}),void 0!==e.Id&&null!==e.Id&&{Id:e.Id}),void 0!==e.StartTimestamp&&null!==e.StartTimestamp&&{StartTimestamp:e.StartTimestamp}),void 0!==e.StopTimestamp&&null!==e.StopTimestamp&&{StopTimestamp:e.StopTimestamp})},hn=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,StatusCode:void 0!==e.StatusCode&&null!==e.StatusCode?e.StatusCode:void 0}},vn=function(e,t){return{Results:void 0!==e.Results&&null!==e.Results?mn(e.Results,t):void 0}},gn=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,StatusCode:void 0!==e.StatusCode&&null!==e.StatusCode?e.StatusCode:void 0}}(o),n))}),{})},mn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return{EndpointItemResponse:void 0!==e.EndpointItemResponse&&null!==e.EndpointItemResponse?hn(e.EndpointItemResponse):void 0,EventsItemResponse:void 0!==e.EventsItemResponse&&null!==e.EventsItemResponse?gn(e.EventsItemResponse,t):void 0}}(a,t),r))}),{})},yn=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,RequestID:void 0!==e.RequestID&&null!==e.RequestID?e.RequestID:void 0}},bn=function(e){var t;return{httpStatusCode:e.statusCode,requestId:null!==(t=e.headers["x-amzn-requestid"])&&void 0!==t?t:e.headers["x-amzn-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}},wn=function(e,t){return void 0===e&&(e=new Uint8Array),e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array)},_n=function(e,t){return function(e,t){return wn(e,t).then((function(e){return t.utf8Encoder(e)}))}(e,t).then((function(e){return e.length?JSON.parse(e):{}}))},Sn=function(e,t){var n,r,i=function(e){var t=e;return t.indexOf(":")>=0&&(t=t.split(":")[0]),t.indexOf("#")>=0&&(t=t.split("#")[1]),t},o=(n=e.headers,r="x-amzn-errortype",Object.keys(n).find((function(e){return e.toLowerCase()===r.toLowerCase()})));return void 0!==o?i(e.headers[o]):void 0!==t.code?i(t.code):void 0!==t.__type?i(t.__type):""},En={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},An={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0};function On(e,t,n){return{applyToStack:function(r){r.add(function(e,t){return function(n,r){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i,o;return Object(jt.__generator)(this,(function(s){switch(s.label){case 0:return[4,n(r)];case 1:return i=s.sent().response,[4,t(i,e)];case 2:return o=s.sent(),[2,{response:i,output:o}]}}))}))}}}(e,n),En),r.add(function(e,t){return function(n,r){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i;return Object(jt.__generator)(this,(function(o){switch(o.label){case 0:return[4,t(r.input,e)];case 1:return i=o.sent(),[2,n(Object(jt.__assign)(Object(jt.__assign)({},r),{request:i}))]}}))}))}}}(e,t),An)}}}var In=function(e){function t(t){var n=e.call(this)||this;return n.input=t,n}return o(t,e),t.prototype.resolveMiddleware=function(e,t,n){this.middlewareStack.use(On(t,this.serialize,this.deserialize));var r=e.concat(this.middlewareStack),i={logger:t.logger,clientName:"PinpointClient",commandName:"PutEventsCommand",inputFilterSensitiveLog:we.filterSensitiveLog,outputFilterSensitiveLog:_e.filterSensitiveLog},o=t.requestHandler;return r.resolve((function(e){return o.handle(e.request,n||{})}),i)},t.prototype.serialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,s,a,c,f,l;return u(this,(function(u){switch(u.label){case 0:if(n={"content-type":"application/json"},r="/v1/apps/{ApplicationId}/events",void 0===e.ApplicationId)throw new Error("No value provided for input HTTP label: ApplicationId.");if((i=e.ApplicationId).length<=0)throw new Error("Empty value provided for input HTTP label: ApplicationId.");return r=r.replace("{ApplicationId}",Ft(i)),void 0!==e.EventsRequest&&(o=on(e.EventsRequest,t)),void 0===o&&(o={}),o=JSON.stringify(o),[4,t.endpoint()];case 1:return s=u.sent(),a=s.hostname,c=s.protocol,f=void 0===c?"https":c,l=s.port,[2,new Ct({protocol:f,hostname:a,port:l,method:"POST",headers:n,path:r,body:o})]}}))}))}(e,t)},t.prototype.deserialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return 202!==e.statusCode&&e.statusCode>=300?[2,Ht(e,t)]:(n={$metadata:bn(e),EventsResponse:void 0},[4,_n(e.body,t)]);case 1:return r=i.sent(),n.EventsResponse=vn(r,t),[2,Promise.resolve(n)]}}))}))}(e,t)},t}(Bt),Ln=function(e){function t(t){var n=e.call(this)||this;return n.input=t,n}return o(t,e),t.prototype.resolveMiddleware=function(e,t,n){this.middlewareStack.use(On(t,this.serialize,this.deserialize));var r=e.concat(this.middlewareStack),i={logger:t.logger,clientName:"PinpointClient",commandName:"UpdateEndpointCommand",inputFilterSensitiveLog:rt.filterSensitiveLog,outputFilterSensitiveLog:it.filterSensitiveLog},o=t.requestHandler;return r.resolve((function(e){return o.handle(e.request,n||{})}),i)},t.prototype.serialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,s,a,c,f,l;return u(this,(function(u){switch(u.label){case 0:if(n={"content-type":"application/json"},r="/v1/apps/{ApplicationId}/endpoints/{EndpointId}",void 0===e.ApplicationId)throw new Error("No value provided for input HTTP label: ApplicationId.");if((i=e.ApplicationId).length<=0)throw new Error("Empty value provided for input HTTP label: ApplicationId.");if(r=r.replace("{ApplicationId}",Ft(i)),void 0===e.EndpointId)throw new Error("No value provided for input HTTP label: EndpointId.");if((i=e.EndpointId).length<=0)throw new Error("Empty value provided for input HTTP label: EndpointId.");return r=r.replace("{EndpointId}",Ft(i)),void 0!==e.EndpointRequest&&(o=nn(e.EndpointRequest,t)),void 0===o&&(o={}),o=JSON.stringify(o),[4,t.endpoint()];case 1:return s=u.sent(),a=s.hostname,c=s.protocol,f=void 0===c?"https":c,l=s.port,[2,new Ct({protocol:f,hostname:a,port:l,method:"PUT",headers:n,path:r,body:o})]}}))}))}(e,t)},t.prototype.deserialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return 202!==e.statusCode&&e.statusCode>=300?[2,Gt(e,t)]:(n={$metadata:bn(e),MessageBody:void 0},[4,_n(e.body,t)]);case 1:return r=i.sent(),n.MessageBody=yn(r,t),[2,Promise.resolve(n)]}}))}))}(e,t)},t}(Bt),kn=n(47),Mn=n(6),Pn=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,xn)},xn=function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()};for(var Rn=function(){function e(e){var t=(void 0===e?{}:e).requestTimeout;this.requestTimeout=t}return e.prototype.destroy=function(){},e.prototype.handle=function(e,t){var n=(void 0===t?{}:t).abortSignal,r=this.requestTimeout;if(null==n?void 0:n.aborted){var i=new Error("Request aborted");return i.name="AbortError",Promise.reject(i)}var o=e.path;if(e.query){var s=function(e){var t,n,r=[];try{for(var i=Object(jt.__values)(Object.keys(e).sort()),o=i.next();!o.done;o=i.next()){var s=o.value,a=e[s];if(s=Pn(s),Array.isArray(a))for(var u=0,c=a.length;u<c;u++)r.push(s+"="+Pn(a[u]));else{var f=s;(a||"string"==typeof a)&&(f+="="+Pn(a)),r.push(f)}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r.join("&")}(e.query);s&&(o+="?"+s)}var a=e.port,u=e.method,c=e.protocol+"//"+e.hostname+(a?":"+a:"")+o,f={body:"GET"===u||"HEAD"===u?void 0:e.body,headers:new Headers(e.headers),method:u};"undefined"!=typeof AbortController&&(f.signal=n);var l,d=new Request(c,f),p=[fetch(d).then((function(e){var t,n,r=e.headers,i={};try{for(var o=Object(jt.__values)(r.entries()),s=o.next();!s.done;s=o.next()){var a=s.value;i[a[0]]=a[1]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return void 0!==e.body?{response:new Tt({headers:i,statusCode:e.status,body:e.body})}:e.blob().then((function(t){return{response:new Tt({headers:i,statusCode:e.status,body:t})}}))})),(l=r,void 0===l&&(l=0),new Promise((function(e,t){l&&setTimeout((function(){var e=new Error("Request did not complete within "+l+" ms");e.name="TimeoutError",t(e)}),l)})))];return n&&p.push(new Promise((function(e,t){n.onabort=function(){var e=new Error("Request aborted");e.name="AbortError",t(e)}}))),Promise.race(p)},e}(),Tn={},jn=new Array(64),Cn=0,Dn="A".charCodeAt(0),Nn="Z".charCodeAt(0);Cn+Dn<=Nn;Cn++){var Un=String.fromCharCode(Cn+Dn);Tn[Un]=Cn,jn[Cn]=Un}for(Cn=0,Dn="a".charCodeAt(0),Nn="z".charCodeAt(0);Cn+Dn<=Nn;Cn++){Un=String.fromCharCode(Cn+Dn);var zn=Cn+26;Tn[Un]=zn,jn[zn]=Un}for(Cn=0;Cn<10;Cn++){Tn[Cn.toString(10)]=Cn+52;Un=Cn.toString(10),zn=Cn+52;Tn[Un]=zn,jn[zn]=Un}Tn["+"]=62,jn[62]="+",Tn["/"]=63,jn[63]="/";function Bn(e){var t=e.length/4*3;"=="===e.substr(-2)?t-=2:"="===e.substr(-1)&&t--;for(var n=new ArrayBuffer(t),r=new DataView(n),i=0;i<e.length;i+=4){for(var o=0,s=0,a=i,u=i+3;a<=u;a++)"="!==e[a]?(o|=Tn[e[a]]<<6*(u-a),s+=6):o>>=6;var c=i/4*3;o>>=s%8;for(var f=Math.floor(s/8),l=0;l<f;l++){var d=8*(f-l-1);r.setUint8(c+l,(o&255<<d)>>d)}}return new Uint8Array(n)}function Fn(e){for(var t="",n=0;n<e.length;n+=3){for(var r=0,i=0,o=n,s=Math.min(n+3,e.length);o<s;o++)r|=e[o]<<8*(s-o-1),i+=8;var a=Math.ceil(i/6);r<<=6*a-i;for(var u=1;u<=a;u++){var c=6*(a-u);t+=jn[(r&63<<c)>>c]}t+="==".slice(0,4-a)}return t}var qn=function(e){return"function"==typeof Blob&&e instanceof Blob?function(e){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n;return Object(jt.__generator)(this,(function(r){switch(r.label){case 0:return[4,Kn(e)];case 1:return t=r.sent(),n=Bn(t),[2,new Uint8Array(n)]}}))}))}(e):function(e){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Object(jt.__generator)(this,(function(u){switch(u.label){case 0:t=new Uint8Array(0),n=e.getReader(),r=!1,u.label=1;case 1:return r?[3,3]:[4,n.read()];case 2:return i=u.sent(),o=i.done,(s=i.value)&&(a=t,(t=new Uint8Array(a.length+s.length)).set(a),t.set(s,a.length)),r=o,[3,1];case 3:return[2,t]}}))}))}(e)};function Kn(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){var e;if(2!==r.readyState)return n(new Error("Reader aborted too early"));var i=null!==(e=r.result)&&void 0!==e?e:"",o=i.indexOf(","),s=o>-1?o+1:i.length;t(i.substring(s))},r.onabort=function(){return n(new Error("Read aborted"))},r.onerror=function(){return n(r.error)},r.readAsDataURL(e)}))}var Vn=function(e){return function(){return Promise.reject(e)}},Hn={name:"retryMiddleware",tags:["RETRY"],step:"finalizeRequest",priority:"high",override:!0},Gn=function(e){return{applyToStack:function(t){t.add(function(e){return function(t,n){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i;return Object(jt.__generator)(this,(function(o){return(null===(i=null==e?void 0:e.retryStrategy)||void 0===i?void 0:i.mode)&&(n.userAgent=Object(jt.__spread)(n.userAgent||[],[["cfg/retry-mode",e.retryStrategy.mode]])),[2,e.retryStrategy.retry(t,r)]}))}))}}}(e),Hn)}}},$n=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch"],Wn=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException","TransactionInProgressException"],Yn=["AbortError","TimeoutError","RequestTimeout","RequestTimeoutException"],Zn=[500,502,503,504],Jn=function(e){var t,n;return 429===(null===(t=e.$metadata)||void 0===t?void 0:t.httpStatusCode)||Wn.includes(e.name)||1==(null===(n=e.$retryable)||void 0===n?void 0:n.throttling)},Qn=n(3),Xn=function(e,t){return Math.floor(Math.min(2e4,Math.random()*Math.pow(2,t)*e))},er=function(e){return!!e&&(function(e){return void 0!==e.$retryable}(e)||function(e){return $n.includes(e.name)}(e)||Jn(e)||function(e){var t;return Yn.includes(e.name)||Zn.includes((null===(t=e.$metadata)||void 0===t?void 0:t.httpStatusCode)||0)}(e))},tr=function(){function e(e,t){var n,r,i,o,s,a,u,c;this.maxAttemptsProvider=e,this.mode="standard",this.retryDecider=null!==(n=null==t?void 0:t.retryDecider)&&void 0!==n?n:er,this.delayDecider=null!==(r=null==t?void 0:t.delayDecider)&&void 0!==r?r:Xn,this.retryQuota=null!==(i=null==t?void 0:t.retryQuota)&&void 0!==i?i:(s=o=500,a=o,u=function(e){return"TimeoutError"===e.name?10:5},c=function(e){return u(e)<=a},Object.freeze({hasRetryTokens:c,retrieveRetryTokens:function(e){if(!c(e))throw new Error("No retry token available");var t=u(e);return a-=t,t},releaseRetryTokens:function(e){a+=null!=e?e:1,a=Math.min(a,s)}}))}return e.prototype.shouldRetry=function(e,t,n){return t<n&&this.retryDecider(e)&&this.retryQuota.hasRetryTokens(e)},e.prototype.getMaxAttempts=function(){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e;return Object(jt.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.maxAttemptsProvider()];case 1:return e=t.sent(),[3,3];case 2:return t.sent(),e=3,[3,3];case 3:return[2,e]}}))}))},e.prototype.retry=function(e,t){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c;return Object(jt.__generator)(this,(function(f){switch(f.label){case 0:return r=0,i=0,[4,this.getMaxAttempts()];case 1:o=f.sent(),s=t.request,Ct.isInstance(s)&&(s.headers["amz-sdk-invocation-id"]=Object(Qn.v4)()),a=function(){var a,c,f,l,d;return Object(jt.__generator)(this,(function(p){switch(p.label){case 0:return p.trys.push([0,2,,5]),Ct.isInstance(s)&&(s.headers["amz-sdk-request"]="attempt="+(r+1)+"; max="+o),[4,e(t)];case 1:return a=p.sent(),c=a.response,f=a.output,u.retryQuota.releaseRetryTokens(n),f.$metadata.attempts=r+1,f.$metadata.totalRetryDelay=i,[2,{value:{response:c,output:f}}];case 2:return l=p.sent(),r++,u.shouldRetry(l,r,o)?(n=u.retryQuota.retrieveRetryTokens(l),d=u.delayDecider(Jn(l)?500:100,r),i+=d,[4,new Promise((function(e){return setTimeout(e,d)}))]):[3,4];case 3:return p.sent(),[2,"continue"];case 4:throw l.$metadata||(l.$metadata={}),l.$metadata.attempts=r,l.$metadata.totalRetryDelay=i,l;case 5:return[2]}}))},u=this,f.label=2;case 2:return[5,a()];case 3:return"object"==typeof(c=f.sent())?[2,c.value]:[3,2];case 4:return[2]}}))}))},e}(),nr=function(e){var t=rr(e.maxAttempts);return Object(jt.__assign)(Object(jt.__assign)({},e),{maxAttempts:t,retryStrategy:e.retryStrategy||new tr(t)})},rr=function(e){if(void 0===e&&(e=3),"number"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};function ir(e){if("string"==typeof e){for(var t=e.length,n=t-1;n>=0;n--){var r=e.charCodeAt(n);r>127&&r<=2047?t++:r>2047&&r<=65535&&(t+=2)}return t}return"number"==typeof e.byteLength?e.byteLength:"number"==typeof e.size?e.size:void 0}var or=n(46),sr=n.n(or),ar=function(e){var t=e.serviceId,n=e.clientVersion;return function(){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var e,r,i,o,s,a,u,c,f;return Object(jt.__generator)(this,(function(l){return e=(null===(i=null===window||void 0===window?void 0:window.navigator)||void 0===i?void 0:i.userAgent)?sr.a.parse(window.navigator.userAgent):void 0,r=[["aws-sdk-js",n],["os/"+((null===(o=null==e?void 0:e.os)||void 0===o?void 0:o.name)||"other"),null===(s=null==e?void 0:e.os)||void 0===s?void 0:s.version],["lang/js"],["md/browser",(null!==(u=null===(a=null==e?void 0:e.browser)||void 0===a?void 0:a.name)&&void 0!==u?u:"unknown")+"_"+(null!==(f=null===(c=null==e?void 0:e.browser)||void 0===c?void 0:c.version)&&void 0!==f?f:"unknown")]],t&&r.push(["api/"+t,n]),[2,r]}))}))}},ur=n(2),cr=new Set(["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","eu-central-1","eu-north-1","eu-south-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2"]),fr=new Set(["cn-north-1","cn-northwest-1"]),lr=new Set(["us-iso-east-1"]),dr=new Set(["us-isob-east-1"]),pr=new Set(["us-gov-east-1","us-gov-west-1"]);var hr=function(e){var t,n=new URL(e),r=n.hostname,i=n.pathname,o=n.port,s=n.protocol,a=n.search;return a&&(t=function(e){var t,n,r={};if(e=e.replace(/^\?/,""))try{for(var i=Object(jt.__values)(e.split("&")),o=i.next();!o.done;o=i.next()){var s=o.value,a=Object(jt.__read)(s.split("="),2),u=a[0],c=a[1],f=void 0===c?null:c;u=decodeURIComponent(u),f&&(f=decodeURIComponent(f)),u in r?Array.isArray(r[u])?r[u].push(f):r[u]=[r[u],f]:r[u]=f}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(a)),{hostname:r,port:o?parseInt(o):void 0,protocol:s,path:i,query:t}},vr={apiVersion:"2016-12-01",disableHostPrefix:!1,logger:{},regionInfoProvider:function(e,t){var n=void 0;switch(e){case"ap-northeast-1":n={hostname:"pinpoint.ap-northeast-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-northeast-2":n={hostname:"pinpoint.ap-northeast-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-south-1":n={hostname:"pinpoint.ap-south-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-southeast-1":n={hostname:"pinpoint.ap-southeast-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-southeast-2":n={hostname:"pinpoint.ap-southeast-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ca-central-1":n={hostname:"pinpoint.ca-central-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-central-1":n={hostname:"pinpoint.eu-central-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-west-1":n={hostname:"pinpoint.eu-west-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-west-2":n={hostname:"pinpoint.eu-west-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"fips-us-east-1":n={hostname:"pinpoint-fips.us-east-1.amazonaws.com",partition:"aws",signingRegion:"us-east-1"};break;case"fips-us-gov-west-1":n={hostname:"pinpoint-fips.us-gov-west-1.amazonaws.com",partition:"aws-us-gov",signingRegion:"us-gov-west-1"};break;case"fips-us-west-2":n={hostname:"pinpoint-fips.us-west-2.amazonaws.com",partition:"aws",signingRegion:"us-west-2"};break;case"us-east-1":n={hostname:"pinpoint.us-east-1.amazonaws.com",partition:"aws",signingRegion:"us-east-1"};break;case"us-gov-west-1":n={hostname:"pinpoint.us-gov-west-1.amazonaws.com",partition:"aws-us-gov",signingRegion:"us-gov-west-1"};break;case"us-west-2":n={hostname:"pinpoint.us-west-2.amazonaws.com",partition:"aws",signingRegion:"us-west-2"};break;default:cr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws",signingService:"mobiletargeting"}),fr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com.cn".replace("{region}",e),partition:"aws-cn"}),lr.has(e)&&(n={hostname:"pinpoint.{region}.c2s.ic.gov".replace("{region}",e),partition:"aws-iso"}),dr.has(e)&&(n={hostname:"pinpoint.{region}.sc2s.sgov.gov".replace("{region}",e),partition:"aws-iso-b"}),pr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws-us-gov",signingService:"mobiletargeting"}),void 0===n&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws",signingService:"mobiletargeting"})}return Promise.resolve(s({signingService:"mobiletargeting"},n))},serviceId:"Pinpoint",urlParser:hr},gr=s(s({},vr),{runtime:"browser",base64Decoder:Bn,base64Encoder:Fn,bodyLengthChecker:ir,credentialDefaultProvider:function(e){return function(){return Promise.reject(new Error("Credential is missing"))}},defaultUserAgentProvider:ar({serviceId:vr.serviceId,clientVersion:kn.version}),maxAttempts:3,region:Vn("Region is missing"),requestHandler:new Rn,sha256:Mn.Sha256,streamCollector:qn,utf8Decoder:ur.fromUtf8,utf8Encoder:ur.toUtf8}),mr=function(e){var t;return Object(jt.__assign)(Object(jt.__assign)({},e),{tls:null===(t=e.tls)||void 0===t||t,endpoint:e.endpoint?yr(e):function(){return br(e)},isCustomEndpoint:!!e.endpoint})},yr=function(e){var t=e.endpoint,n=e.urlParser;if("string"==typeof t){var r=Promise.resolve(n(t));return function(){return r}}if("object"==typeof t){var i=Promise.resolve(t);return function(){return i}}return t},br=function(e){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var t,n,r,i,o;return Object(jt.__generator)(this,(function(s){switch(s.label){case 0:return t=e.tls,n=void 0===t||t,[4,e.region()];case 1:if(r=s.sent(),!new RegExp(/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/).test(r))throw new Error("Invalid region in client config");return[4,e.regionInfoProvider(r)];case 2:if(!(i=(null!==(o=s.sent())&&void 0!==o?o:{}).hostname))throw new Error("Cannot resolve hostname from client config");return[2,e.urlParser((n?"https:":"http:")+"//"+i)]}}))}))},wr=function(e){if(!e.region)throw new Error("Region is missing");return Object(jt.__assign)(Object(jt.__assign)({},e),{region:_r(e.region)})},_r=function(e){if("string"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};var Sr={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:!0},Er=function(e){return{applyToStack:function(t){t.add(function(e){var t=this;return function(n){return function(r){return Object(jt.__awaiter)(t,void 0,void 0,(function(){var t,i,o,s,a;return Object(jt.__generator)(this,(function(u){return t=r.request,Ct.isInstance(t)&&(i=t.body,o=t.headers,i&&-1===Object.keys(o).map((function(e){return e.toLowerCase()})).indexOf("content-length")&&void 0!==(s=e(i))&&(t.headers=Object(jt.__assign)(Object(jt.__assign)({},t.headers),((a={})["content-length"]=String(s),a)))),[2,n(Object(jt.__assign)(Object(jt.__assign)({},r),{request:t}))]}))}))}}}(e.bodyLengthChecker),Sr)}}};for(var Ar={name:"hostHeaderMiddleware",step:"build",priority:"low",tags:["HOST"],override:!0},Or=function(e){return{applyToStack:function(t){t.add(function(e){return function(t){return function(n){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var r,i;return Object(jt.__generator)(this,(function(o){return Ct.isInstance(n.request)?(r=n.request,i=(e.requestHandler.metadata||{}).handlerProtocol,(void 0===i?"":i).indexOf("h2")>=0&&!r.headers[":authority"]?(delete r.headers.host,r.headers[":authority"]=""):r.headers.host||(r.headers.host=r.hostname),[2,t(n)]):[2,t(n)]}))}))}}}(e),Ar)}}},Ir={name:"loggerMiddleware",tags:["LOGGER"],step:"initialize",override:!0},Lr=function(e){return{applyToStack:function(e){e.add((function(e,t){return function(n){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var r,i,o,s,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return r=t.clientName,i=t.commandName,o=t.inputFilterSensitiveLog,s=t.logger,a=t.outputFilterSensitiveLog,[4,e(n)];case 1:return u=d.sent(),s?("function"==typeof s.info&&(c=u.output,f=c.$metadata,l=Object(jt.__rest)(c,["$metadata"]),s.info({clientName:r,commandName:i,input:o(n.input),output:a(l),metadata:f})),[2,u]):[2,u]}}))}))}}),Ir)}}},kr={},Mr={},Pr=0;Pr<256;Pr++){var xr=Pr.toString(16).toLowerCase();1===xr.length&&(xr="0"+xr),kr[Pr]=xr,Mr[xr]=Pr}function Rr(e){for(var t="",n=0;n<e.byteLength;n++)t+=kr[e[n]];return t}var Tr="X-Amz-Date".toLowerCase(),jr=["authorization",Tr,"date"],Cr="X-Amz-Signature".toLowerCase(),Dr="X-Amz-Security-Token".toLowerCase(),Nr={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},Ur=/^proxy-/,zr=/^sec-/,Br="AWS4-HMAC-SHA256-PAYLOAD",Fr={},qr=[];function Kr(e,t,n){return e+"/"+t+"/"+n+"/aws4_request"}function Vr(e,t,n){var r=new e(t);return r.update(n),r.digest()}function Hr(e,t,n){var r,i,o=e.headers,s={};try{for(var a=Object(jt.__values)(Object.keys(o).sort()),u=a.next();!u.done;u=a.next()){var c=u.value,f=c.toLowerCase();(f in Nr||(null==t?void 0:t.has(f))||Ur.test(f)||zr.test(f))&&(!n||n&&!n.has(f))||(s[f]=o[c].trim().replace(/\s+/g," "))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return s}var Gr=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,$r)},$r=function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()};function Wr(e,t){var n=e.headers,r=e.body;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e,i,o,s,a,u,c;return Object(jt.__generator)(this,(function(f){switch(f.label){case 0:try{for(e=Object(jt.__values)(Object.keys(n)),i=e.next();!i.done;i=e.next())if("x-amz-content-sha256"===(o=i.value).toLowerCase())return[2,n[o]]}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}}return null!=r?[3,1]:[2,"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"];case 1:return"string"==typeof r||ArrayBuffer.isView(r)||(l=r,"function"==typeof ArrayBuffer&&l instanceof ArrayBuffer||"[object ArrayBuffer]"===Object.prototype.toString.call(l))?((s=new t).update(r),a=Rr,[4,s.digest()]):[3,3];case 2:return[2,a.apply(void 0,[f.sent()])];case 3:return[2,"UNSIGNED-PAYLOAD"]}var l}))}))}function Yr(e){var t=e.headers,n=e.query,r=Object(jt.__rest)(e,["headers","query"]);return Object(jt.__assign)(Object(jt.__assign)({},r),{headers:Object(jt.__assign)({},t),query:n?Zr(n):void 0})}function Zr(e){return Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object(jt.__assign)(Object(jt.__assign)({},t),((r={})[n]=Array.isArray(i)?Object(jt.__spread)(i):i,r))}),{})}function Jr(e){var t,n;e="function"==typeof e.clone?e.clone():Yr(e);try{for(var r=Object(jt.__values)(Object.keys(e.headers)),i=r.next();!i.done;i=r.next()){var o=i.value;jr.indexOf(o.toLowerCase())>-1&&delete e.headers[o]}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return e}function Qr(e){return function(e){if("number"==typeof e)return new Date(1e3*e);if("string"==typeof e)return Number(e)?new Date(1e3*Number(e)):new Date(e);return e}(e).toISOString().replace(/\.\d{3}Z$/,"Z")}var Xr=function(){function e(e){var t=e.applyChecksum,n=e.credentials,r=e.region,i=e.service,o=e.sha256,s=e.uriEscapePath,a=void 0===s||s;this.service=i,this.sha256=o,this.uriEscapePath=a,this.applyChecksum="boolean"!=typeof t||t,this.regionProvider=ni(r),this.credentialProvider=ri(n)}return e.prototype.presign=function(e,t){return void 0===t&&(t={}),Object(jt.__awaiter)(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c,f,l,d,p,h,v,g,m,y,b,w,_,S,E,A,O;return Object(jt.__generator)(this,(function(I){switch(I.label){case 0:return n=t.signingDate,r=void 0===n?new Date:n,i=t.expiresIn,o=void 0===i?3600:i,s=t.unsignableHeaders,a=t.unhoistableHeaders,u=t.signableHeaders,c=t.signingRegion,f=t.signingService,[4,this.credentialProvider()];case 1:return l=I.sent(),null==c?[3,2]:(p=c,[3,4]);case 2:return[4,this.regionProvider()];case 3:p=I.sent(),I.label=4;case 4:return d=p,h=ei(r),v=h.longDate,g=h.shortDate,o>604800?[2,Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future")]:(m=Kr(g,d,null!=f?f:this.service),y=function(e,t){var n,r,i;void 0===t&&(t={});var o="function"==typeof e.clone?e.clone():Yr(e),s=o.headers,a=o.query,u=void 0===a?{}:a;try{for(var c=Object(jt.__values)(Object.keys(s)),f=c.next();!f.done;f=c.next()){var l=f.value,d=l.toLowerCase();"x-amz-"!==d.substr(0,6)||(null===(i=t.unhoistableHeaders)||void 0===i?void 0:i.has(d))||(u[l]=s[l],delete s[l])}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return Object(jt.__assign)(Object(jt.__assign)({},e),{headers:s,query:u})}(Jr(e),{unhoistableHeaders:a}),l.sessionToken&&(y.query["X-Amz-Security-Token"]=l.sessionToken),y.query["X-Amz-Algorithm"]="AWS4-HMAC-SHA256",y.query["X-Amz-Credential"]=l.accessKeyId+"/"+m,y.query["X-Amz-Date"]=v,y.query["X-Amz-Expires"]=o.toString(10),b=Hr(y,s,u),y.query["X-Amz-SignedHeaders"]=ti(b),w=y.query,_="X-Amz-Signature",S=this.getSignature,E=[v,m,this.getSigningKey(l,d,g,f)],A=this.createCanonicalRequest,O=[y,b],[4,Wr(e,this.sha256)]);case 5:return[4,S.apply(this,E.concat([A.apply(this,O.concat([I.sent()]))]))];case 6:return w[_]=I.sent(),[2,y]}}))}))},e.prototype.sign=function(e,t){return Object(jt.__awaiter)(this,void 0,void 0,(function(){return Object(jt.__generator)(this,(function(n){return"string"==typeof e?[2,this.signString(e,t)]:e.headers&&e.payload?[2,this.signEvent(e,t)]:[2,this.signRequest(e,t)]}))}))},e.prototype.signEvent=function(e,t){var n=e.headers,r=e.payload,i=t.signingDate,o=void 0===i?new Date:i,s=t.priorSignature,a=t.signingRegion,u=t.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e,t,i,c,f,l,d,p,h,v,g;return Object(jt.__generator)(this,(function(m){switch(m.label){case 0:return null==a?[3,1]:(t=a,[3,3]);case 1:return[4,this.regionProvider()];case 2:t=m.sent(),m.label=3;case 3:return e=t,i=ei(o),c=i.shortDate,f=i.longDate,l=Kr(c,e,null!=u?u:this.service),[4,Wr({headers:{},body:r},this.sha256)];case 4:return d=m.sent(),(p=new this.sha256).update(n),v=Rr,[4,p.digest()];case 5:return h=v.apply(void 0,[m.sent()]),g=[Br,f,l,s,h,d].join("\n"),[2,this.signString(g,{signingDate:o,signingRegion:e,signingService:u})]}}))}))},e.prototype.signString=function(e,t){var n=void 0===t?{}:t,r=n.signingDate,i=void 0===r?new Date:r,o=n.signingRegion,s=n.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return[4,this.credentialProvider()];case 1:return t=d.sent(),null==o?[3,2]:(r=o,[3,4]);case 2:return[4,this.regionProvider()];case 3:r=d.sent(),d.label=4;case 4:return n=r,a=ei(i).shortDate,f=(c=this.sha256).bind,[4,this.getSigningKey(t,n,a,s)];case 5:return(u=new(f.apply(c,[void 0,d.sent()]))).update(e),l=Rr,[4,u.digest()];case 6:return[2,l.apply(void 0,[d.sent()])]}}))}))},e.prototype.signRequest=function(e,t){var n=void 0===t?{}:t,r=n.signingDate,i=void 0===r?new Date:r,o=n.signableHeaders,s=n.unsignableHeaders,a=n.signingRegion,u=n.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,c,f,l,d,p,h,v,g;return Object(jt.__generator)(this,(function(m){switch(m.label){case 0:return[4,this.credentialProvider()];case 1:return t=m.sent(),null==a?[3,2]:(r=a,[3,4]);case 2:return[4,this.regionProvider()];case 3:r=m.sent(),m.label=4;case 4:return n=r,c=Jr(e),f=ei(i),l=f.longDate,d=f.shortDate,p=Kr(d,n,null!=u?u:this.service),c.headers[Tr]=l,t.sessionToken&&(c.headers[Dr]=t.sessionToken),[4,Wr(c,this.sha256)];case 5:return h=m.sent(),!function(e,t){var n,r;e=e.toLowerCase();try{for(var i=Object(jt.__values)(Object.keys(t)),o=i.next();!o.done;o=i.next()){if(e===o.value.toLowerCase())return!0}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!1}("x-amz-content-sha256",c.headers)&&this.applyChecksum&&(c.headers["x-amz-content-sha256"]=h),v=Hr(c,s,o),[4,this.getSignature(l,p,this.getSigningKey(t,n,d,u),this.createCanonicalRequest(c,v,h))];case 6:return g=m.sent(),c.headers.authorization="AWS4-HMAC-SHA256 Credential="+t.accessKeyId+"/"+p+", SignedHeaders="+ti(v)+", Signature="+g,[2,c]}}))}))},e.prototype.createCanonicalRequest=function(e,t,n){var r=Object.keys(t).sort();return e.method+"\n"+this.getCanonicalPath(e)+"\n"+function(e){var t,n,r=e.query,i=void 0===r?{}:r,o=[],s={},a=function(e){if(e.toLowerCase()===Cr)return"continue";o.push(e);var t=i[e];"string"==typeof t?s[e]=Gr(e)+"="+Gr(t):Array.isArray(t)&&(s[e]=t.slice(0).sort().reduce((function(t,n){return t.concat([Gr(e)+"="+Gr(n)])}),[]).join("&"))};try{for(var u=Object(jt.__values)(Object.keys(i).sort()),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return o.map((function(e){return s[e]})).filter((function(e){return e})).join("&")}(e)+"\n"+r.map((function(e){return e+":"+t[e]})).join("\n")+"\n\n"+r.join(";")+"\n"+n},e.prototype.createStringToSign=function(e,t,n){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var r,i;return Object(jt.__generator)(this,(function(o){switch(o.label){case 0:return(r=new this.sha256).update(n),[4,r.digest()];case 1:return i=o.sent(),[2,"AWS4-HMAC-SHA256\n"+e+"\n"+t+"\n"+Rr(i)]}}))}))},e.prototype.getCanonicalPath=function(e){var t=e.path;return this.uriEscapePath?"/"+encodeURIComponent(t.replace(/^\//,"")).replace(/%2F/g,"/"):t},e.prototype.getSignature=function(e,t,n,r){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var i,o,s,a,u;return Object(jt.__generator)(this,(function(c){switch(c.label){case 0:return[4,this.createStringToSign(e,t,r)];case 1:return i=c.sent(),a=(s=this.sha256).bind,[4,n];case 2:return(o=new(a.apply(s,[void 0,c.sent()]))).update(i),u=Rr,[4,o.digest()];case 3:return[2,u.apply(void 0,[c.sent()])]}}))}))},e.prototype.getSigningKey=function(e,t,n,r){return function(e,t,n,r,i){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var o,s,a,u,c,f,l,d,p;return Object(jt.__generator)(this,(function(h){switch(h.label){case 0:return[4,Vr(e,t.secretAccessKey,t.accessKeyId)];case 1:if(o=h.sent(),(s=n+":"+r+":"+i+":"+Rr(o)+":"+t.sessionToken)in Fr)return[2,Fr[s]];for(qr.push(s);qr.length>50;)delete Fr[qr.shift()];a="AWS4"+t.secretAccessKey,h.label=2;case 2:h.trys.push([2,7,8,9]),u=Object(jt.__values)([n,r,i,"aws4_request"]),c=u.next(),h.label=3;case 3:return c.done?[3,6]:(f=c.value,[4,Vr(e,a,f)]);case 4:a=h.sent(),h.label=5;case 5:return c=u.next(),[3,3];case 6:return[3,9];case 7:return l=h.sent(),d={error:l},[3,9];case 8:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(d)throw d.error}return[7];case 9:return[2,Fr[s]=a]}}))}))}(this.sha256,e,n,t,r||this.service)},e}(),ei=function(e){var t=Qr(e).replace(/[\-:]/g,"");return{longDate:t,shortDate:t.substr(0,8)}},ti=function(e){return Object.keys(e).sort().join(";")},ni=function(e){if("string"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e},ri=function(e){if("object"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};function ii(e){var t,n=this,r=oi(e.credentials||e.credentialDefaultProvider(e)),i=e.signingEscapePath,o=void 0===i||i,s=e.systemClockOffset,a=void 0===s?e.systemClockOffset||0:s,u=e.sha256;return t=e.signer?oi(e.signer):function(){return oi(e.region)().then((function(t){return Object(jt.__awaiter)(n,void 0,void 0,(function(){return Object(jt.__generator)(this,(function(n){switch(n.label){case 0:return[4,e.regionInfoProvider(t)];case 1:return[2,[n.sent()||{},t]]}}))}))})).then((function(t){var n=Object(jt.__read)(t,2),i=n[0],s=n[1],a=i.signingRegion,c=i.signingService;return e.signingRegion=e.signingRegion||a||s,e.signingName=e.signingName||c||e.serviceId,new Xr({credentials:r,region:e.signingRegion,service:e.signingName,sha256:u,uriEscapePath:o})}))},Object(jt.__assign)(Object(jt.__assign)({},e),{systemClockOffset:a,signingEscapePath:o,credentials:r,signer:t})}function oi(e){if("object"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e}var si=function(e){return new Date(Date.now()+e)};function ai(e){return function(t,n){return function(r){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var i,o,s,a,u,c,f,l,d;return Object(jt.__generator)(this,(function(p){switch(p.label){case 0:return Ct.isInstance(r.request)?"function"!=typeof e.signer?[3,2]:[4,e.signer()]:[2,t(r)];case 1:return o=p.sent(),[3,3];case 2:o=e.signer,p.label=3;case 3:return i=o,a=t,u=[Object(jt.__assign)({},r)],d={},[4,i.sign(r.request,{signingDate:new Date(Date.now()+e.systemClockOffset),signingRegion:n.signing_region,signingService:n.signing_service})];case 4:return[4,a.apply(void 0,[jt.__assign.apply(void 0,u.concat([(d.request=p.sent(),d)]))])];case 5:return s=p.sent(),c=s.response.headers,(f=c&&(c.date||c.Date))&&(l=Date.parse(f),h=l,v=e.systemClockOffset,Math.abs(si(v).getTime()-h)>=3e5&&(e.systemClockOffset=l-Date.now())),[2,s]}var h,v}))}))}}}var ui={name:"awsAuthMiddleware",tags:["SIGNATURE","AWSAUTH"],relation:"after",toMiddleware:"retryMiddleware",override:!0},ci=function(e){return{applyToStack:function(t){t.addRelativeTo(ai(e),ui)}}};function fi(e){return Object(jt.__assign)(Object(jt.__assign)({},e),{customUserAgent:"string"==typeof e.customUserAgent?[[e.customUserAgent]]:e.customUserAgent})}var li=/[^\!\#\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g,di=function(e){var t=Object(jt.__read)(e,2),n=t[0],r=t[1],i=n.indexOf("/"),o=n.substring(0,i),s=n.substring(i+1);return"api"===o&&(s=s.toLowerCase()),[o,s,r].filter((function(e){return e&&e.length>0})).map((function(e){return null==e?void 0:e.replace(li,"_")})).join("/")},pi={name:"getUserAgentMiddleware",step:"build",priority:"low",tags:["SET_USER_AGENT","USER_AGENT"],override:!0},hi=function(e){return{applyToStack:function(t){var n;t.add((n=e,function(e,t){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i,o,s,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return i=r.request,Ct.isInstance(i)?(o=i.headers,s=(null===(f=null==t?void 0:t.userAgent)||void 0===f?void 0:f.map(di))||[],[4,n.defaultUserAgentProvider()]):[2,e(r)];case 1:return a=d.sent().map(di),u=(null===(l=null==n?void 0:n.customUserAgent)||void 0===l?void 0:l.map(di))||[],o["x-amz-user-agent"]=Object(jt.__spread)(a,s,u).join(" "),c=Object(jt.__spread)(a.filter((function(e){return e.startsWith("aws-sdk-")})),u).join(" "),"browser"!==n.runtime&&c&&(o["user-agent"]=o["user-agent"]?o["user-agent"]+" "+c:c),[2,e(Object(jt.__assign)(Object(jt.__assign)({},r),{request:i}))]}}))}))}}),pi)}}},vi=function(e){function t(t){var n=this,r=s(s({},gr),t),i=wr(r),o=ii(mr(i)),a=fi(nr(o));return(n=e.call(this,a)||this).config=a,n.middlewareStack.use(ci(n.config)),n.middlewareStack.use(Gn(n.config)),n.middlewareStack.use(Er(n.config)),n.middlewareStack.use(Or(n.config)),n.middlewareStack.use(Lr(n.config)),n.middlewareStack.use(hi(n.config)),n}return o(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this)},t}(zt),gi=n(9),mi=n.n(gi),yi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},bi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},wi=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},_i=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(wi(arguments[t]));return e},Si=new r.ConsoleLogger("EventsBuffer"),Ei=[429,500],Ai=[202],Oi=function(){function e(e,t){this._pause=!1,this._flush=!1,Si.debug("Instantiating buffer with config:",t),this._buffer=[],this._client=e,this._config=t,this._sendBatch=this._sendBatch.bind(this),this._startLoop()}return e.prototype.push=function(e){var t;if(this._buffer>this._config.bufferSize)return Si.debug("Exceeded analytics events buffer size"),e.handlers.reject(new Error("Exceeded the size of analytics events buffer"));var n=((t={})[e.params.event.eventId]=e,t);this._buffer.push(n)},e.prototype.pause=function(){this._pause=!0},e.prototype.resume=function(){this._pause=!1},e.prototype.updateClient=function(e){this._client=e},e.prototype.flush=function(){this._flush=!0},e.prototype._startLoop=function(){this._interval&&clearInterval(this._interval);var e=this._config.flushInterval;this._interval=setInterval(this._sendBatch,e)},e.prototype._sendBatch=function(){var e=this._buffer.length;if(this._flush&&!e&&clearInterval(this._interval),!this._pause&&e){var t=this._config.flushSize,n=Math.min(t,e),r=this._buffer.splice(0,n);this._putEvents(r)}},e.prototype._putEvents=function(e){return yi(this,void 0,void 0,(function(){var t,n,r,i,o;return bi(this,(function(s){switch(s.label){case 0:t=this._bufferToMap(e),n=this._generateBatchEventParams(t),s.label=1;case 1:return s.trys.push([1,3,,4]),r=new In(n),[4,this._client.send(r)];case 2:return i=s.sent(),this._processPutEventsSuccessResponse(i,t),[3,4];case 3:return o=s.sent(),[2,this._handlePutEventsFailure(o,t)];case 4:return[2]}}))}))},e.prototype._generateBatchEventParams=function(e){var t={ApplicationId:"",EventsRequest:{BatchItem:{}}};return Object.values(e).forEach((function(e){var n=e.params,r=n.event,i=n.timestamp,o=n.config,s=r.name,a=r.attributes,u=r.metrics,c=r.eventId,f=r.session,l=o.appId,d=o.endpointId,p=t.EventsRequest.BatchItem;t.ApplicationId=t.ApplicationId||l,p[d]||(p[d]={Endpoint:{},Events:{}}),p[d].Events[c]={EventType:s,Timestamp:new Date(i).toISOString(),Attributes:a,Metrics:u,Session:f}})),t},e.prototype._handlePutEventsFailure=function(e,t){Si.debug("_putEvents Failed: ",e);var n=e.$metadata&&e.$metadata.httpStatusCode;if(Ei.includes(n)){var r=Object.values(t);this._retry(r)}else;},e.prototype._processPutEventsSuccessResponse=function(e,t){var n=e.EventsResponse.Results,r=[];Object.entries(n).forEach((function(e){var n=wi(e,2),i=n[0],o=n[1].EventsItemResponse;Object.entries(o).forEach((function(e){var n,o,s=wi(e,2),a=s[0],u=s[1],c=u.StatusCode,f=u.Message,l=t[a],d={EventsResponse:{Results:(n={},n[i]={EventsItemResponse:(o={},o[a]={StatusCode:c,Message:f},o)},n)}};if(Ai.includes(c))l.handlers.resolve(d);else{if(!Ei.includes(c)){var p=l.params.event.name;return Si.error("event "+a+" : "+p+" failed with error: "+f),l.handlers.reject(d)}r.push(l)}}))})),r.length&&this._retry(r)},e.prototype._retry=function(e){var t,n=[];e.forEach((function(e){var t,r=e.params,i=r.event,o=i.eventId,s=i.name;if(r.resendLimit-- >0)return Si.debug("resending event "+o+" : "+s+" with "+r.resendLimit+" retry attempts remaining"),void n.push((t={},t[o]=e,t));Si.debug("no retry attempts remaining for event "+o+" : "+s)})),(t=this._buffer).unshift.apply(t,_i(n))},e.prototype._bufferToMap=function(e){return e.reduce((function(e,t){var n=wi(Object.entries(t),1),r=wi(n[0],2),i=r[0],o=r[1];return e[i]=o,e}),{})},e}();function Ii(e){return(Ii="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)}var Li=function(){return(Li=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ki=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Mi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},Pi=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},xi="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",Ri=function(e,t){r.Hub.dispatch("analytics",{event:e,data:t},"Analytics",xi)},Ti=new r.ConsoleLogger("AWSPinpointProvider"),ji=[429,500],Ci=[202],Di="undefined"!=typeof navigator&&navigator&&"function"==typeof navigator.sendBeacon,Ni=function(){function e(e){this._endpointGenerating=!0,this._endpointUpdateInProgress=!1,this._buffer=null,this._endpointBuffer=[],this._config=e||{},this._config.bufferSize=this._config.bufferSize||1e3,this._config.flushSize=this._config.flushSize||100,this._config.flushInterval=this._config.flushInterval||5e3,this._config.resendLimit=this._config.resendLimit||5,this._clientInfo=r.ClientDevice.clientInfo()}return e.prototype.getCategory=function(){return e.category},e.prototype.getProviderName=function(){return e.providerName},e.prototype.configure=function(e){var t=this;Ti.debug("configure Analytics",e);var n=e||{};if(this._config=Object.assign({},this._config,n),this._endpointGenerating=!!e.autoSessionRecord,this._config.appId&&!this._config.disabled)if(this._config.endpointId)Ri("pinpointProvider_configured",null);else{var r=this.getProviderName()+"_"+this._config.appId;this._getEndpointId(r).then((function(e){Ti.debug("setting endpoint id from the cache",e),t._config.endpointId=e,Ri("pinpointProvider_configured",null)})).catch((function(e){Ti.debug("Failed to generate endpointId",e)}))}else this._flushBuffer();return this._config},e.prototype.record=function(e,t){return ki(this,void 0,void 0,(function(){var n,r;return Mi(this,(function(i){switch(i.label){case 0:return Ti.debug("_public record",e),[4,this._getCredentials()];case 1:return(n=i.sent())&&this._config.appId&&this._config.region?(this._initClients(n),r=(new Date).getTime(),this._generateSession(e),e.event.eventId=Object(Qn.v1)(),Object.assign(e,{timestamp:r,config:this._config}),e.event.immediate?[2,this._send(e,t)]:(this._putToBuffer(e,t),[2])):(Ti.debug("cannot send events without credentials, applicationId or region"),[2,t.reject(new Error("No credentials, applicationId or region"))])}}))}))},e.prototype._sendEndpointUpdate=function(e){return ki(this,void 0,void 0,(function(){var t;return Mi(this,(function(n){switch(n.label){case 0:return this._endpointUpdateInProgress?(this._endpointBuffer.push(e),[2]):(this._endpointUpdateInProgress=!0,[4,this._updateEndpoint(e)]);case 1:return n.sent(),t=this._endpointBuffer.shift(),this._endpointUpdateInProgress=!1,t&&this._sendEndpointUpdate(t),[2]}}))}))},e.prototype._putToBuffer=function(e,t){"_update_endpoint"!==e.event.name?this._buffer&&this._buffer.push({params:e,handlers:t}):this._sendEndpointUpdate({params:e,handlers:t})},e.prototype._generateSession=function(e){this._sessionId=this._sessionId||Object(Qn.v1)();var t=e.event;switch(t.name){case"_session.start":this._sessionStartTimestamp=(new Date).getTime(),this._sessionId=Object(Qn.v1)(),t.session={Id:this._sessionId,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString()};break;case"_session.stop":var n=(new Date).getTime();this._sessionStartTimestamp=this._sessionStartTimestamp||(new Date).getTime(),this._sessionId=this._sessionId||Object(Qn.v1)(),t.session={Id:this._sessionId,Duration:n-this._sessionStartTimestamp,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString(),StopTimestamp:new Date(n).toISOString()},this._sessionId=void 0,this._sessionStartTimestamp=void 0;break;default:this._sessionStartTimestamp=this._sessionStartTimestamp||(new Date).getTime(),this._sessionId=this._sessionId||Object(Qn.v1)(),t.session={Id:this._sessionId,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString()}}},e.prototype._send=function(e,t){return ki(this,void 0,void 0,(function(){return Mi(this,(function(n){switch(e.event.name){case"_update_endpoint":return[2,this._updateEndpoint({params:e,handlers:t})];case"_session.stop":return[2,this._pinpointSendStopSession(e,t)];default:return[2,this._pinpointPutEvents(e,t)]}return[2]}))}))},e.prototype._generateBatchItemContext=function(e){var t,n=e.event,r=e.timestamp,i=e.config,o=n.name,s=n.attributes,a=n.metrics,u=n.eventId,c=n.session,f=i.appId,l=i.endpointId,d={ApplicationId:f,EventsRequest:{BatchItem:{}}},p={Endpoint:{}};return p.Events=((t={})[u]={EventType:o,Timestamp:new Date(r).toISOString(),Attributes:s,Metrics:a,Session:c},t),d.EventsRequest.BatchItem[l]=p,d},e.prototype._pinpointPutEvents=function(e,t){return ki(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c,f,l,d;return Mi(this,(function(p){switch(p.label){case 0:n=e.event.eventId,r=e.config.endpointId,i=this._generateBatchItemContext(e),o=new In(i),p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.pinpointClient.send(o)];case 2:return s=p.sent(),a=r,u=n,c=s.EventsResponse.Results[a].EventsItemResponse[u],f=c.StatusCode,l=c.Message,Ci.includes(f)?(Ti.debug("record event success. ",s),[2,t.resolve(s)]):ji.includes(f)?(this._retry(e,t),[3,4]):(Ti.error("Event "+n+" is not accepted, the error is "+l),[2,t.reject(s)]);case 3:return d=p.sent(),this._eventError(d),[2,t.reject(d)];case 4:return[2]}}))}))},e.prototype._pinpointSendStopSession=function(e,t){if(Di){var n=this._generateBatchItemContext(e),i=this._config.region,o=n.ApplicationId,s=n.EventsRequest,a={secret_key:this._config.credentials.secretAccessKey,access_key:this._config.credentials.accessKeyId,session_token:this._config.credentials.sessionToken},u="https://pinpoint."+i+".amazonaws.com/v1/apps/"+o+"/events/legacy",c=JSON.stringify(s),f={url:u,body:c,method:"POST"},l={region:i,service:"mobiletargeting"},d=r.Signer.signUrl(f,a,l,null);return navigator.sendBeacon(d,c)?t.resolve("sendBeacon success"):t.reject("sendBeacon failure")}this._pinpointPutEvents(e,t)},e.prototype._retry=function(e,t){var n=e.config.resendLimit;e.resendLimit="number"==typeof e.resendLimit?e.resendLimit:n,e.resendLimit-- >0?(Ti.debug("resending event "+e.eventName+" with "+e.resendLimit+" retry times left"),this._pinpointPutEvents(e,t)):Ti.debug("retry times used up for event "+e.eventName)},e.prototype._updateEndpoint=function(e){return ki(this,void 0,void 0,(function(){var t,n,i,o,s,a,u,c,f,l,d,p;return Mi(this,(function(h){switch(h.label){case 0:t=e.params,n=e.handlers,i=t.config,o=t.event,s=i.appId,a=i.endpointId,u=this._endpointRequest(i,r.JS.transferKeyToLowerCase(o,[],["attributes","userAttributes","Attributes","UserAttributes"])),c={ApplicationId:s,EndpointId:a,EndpointRequest:u},h.label=1;case 1:return h.trys.push([1,3,,4]),f=new Ln(c),[4,this.pinpointClient.send(f)];case 2:return l=h.sent(),Ti.debug("updateEndpoint success",l),this._endpointGenerating=!1,this._resumeBuffer(),n.resolve(l),[2];case 3:return d=h.sent(),p={err:d,update_params:c,endpointObject:e},[2,this._handleEndpointUpdateFailure(p)];case 4:return[2]}}))}))},e.prototype._handleEndpointUpdateFailure=function(e){return ki(this,void 0,void 0,(function(){var t,n,r;return Mi(this,(function(i){switch(t=e.err,n=e.endpointObject,r=t.$metadata&&t.$metadata.httpStatusCode,Ti.debug("updateEndpoint error",t),r){case 403:return[2,this._handleEndpointUpdateForbidden(e)];default:if(ji.includes(r))return!0,[2,this._retryEndpointUpdate(n,!0)];Ti.error("updateEndpoint failed",t),n.handlers.reject(t)}return[2]}))}))},e.prototype._handleEndpointUpdateForbidden=function(e){var t=e.err,n=e.endpointObject,r=t.code,i=t.retryable;if("ExpiredTokenException"!==r&&!i)return n.handlers.reject(t);this._retryEndpointUpdate(n)},e.prototype._retryEndpointUpdate=function(e,t){void 0===t&&(t=!1),Ti.debug("_retryEndpointUpdate",e);var n=e.params,r=n.config.resendLimit;if(n.resendLimit="number"==typeof n.resendLimit?n.resendLimit:r,n.resendLimit-- >0)return Ti.debug("resending endpoint update "+n.event.eventId+" with "+n.resendLimit+" retry attempts remaining"),void(this._endpointBuffer.length?this._endpointBuffer.unshift(e):this._updateEndpoint(e));Ti.warn("resending endpoint update "+n.event.eventId+" failed after "+n.config.resendLimit+" attempts"),this._endpointGenerating&&Ti.error("Initial endpoint update failed. ")},e.prototype._initClients=function(e){return ki(this,void 0,void 0,(function(){var t,n;return Mi(this,(function(i){return Ti.debug("init clients"),this.pinpointClient&&this._config.credentials&&this._config.credentials.sessionToken===e.sessionToken&&this._config.credentials.identityId===e.identityId?(Ti.debug("no change for aws credentials, directly return from init"),[2]):(t=this._config.credentials?this._config.credentials.identityId:null,this._config.credentials=e,n=this._config.region,Ti.debug("init clients with credentials",e),this.pinpointClient=new vi({region:n,credentials:e,customUserAgent:Object(r.getAmplifyUserAgent)()}),this.pinpointClient.middlewareStack.addRelativeTo((function(e){return function(t){return delete t.request.headers["amz-sdk-invocation-id"],delete t.request.headers["amz-sdk-request"],e(t)}}),{step:"finalizeRequest",relation:"after",toMiddleware:"retryMiddleware"}),this._bufferExists()&&t===e.identityId?this._updateBufferClient():this._initBuffer(),this._customizePinpointClientReq(),[2])}))}))},e.prototype._bufferExists=function(){return this._buffer&&this._buffer instanceof Oi},e.prototype._initBuffer=function(){this._bufferExists()&&this._flushBuffer(),this._buffer=new Oi(this.pinpointClient,this._config),this._endpointGenerating&&this._buffer.pause()},e.prototype._updateBufferClient=function(){this._bufferExists()&&this._buffer.updateClient(this.pinpointClient)},e.prototype._flushBuffer=function(){this._bufferExists()&&(this._buffer.flush(),this._buffer=null)},e.prototype._resumeBuffer=function(){this._bufferExists()&&this._buffer.resume()},e.prototype._customizePinpointClientReq=function(){},e.prototype._getEndpointId=function(e){return ki(this,void 0,void 0,(function(){var t,n;return Mi(this,(function(r){switch(r.label){case 0:return[4,mi.a.getItem(e)];case 1:return t=r.sent(),Ti.debug("endpointId from cache",t,"type",Ii(t)),t||(t=Object(Qn.v1)(),31536e8,n=(new Date).getTime()+31536e8,mi.a.setItem(e,t,{expires:n,priority:1})),[2,t]}}))}))},e.prototype._endpointRequest=function(e,t){var n=e.credentials,i=this._clientInfo||{},o=e.clientContext||{},s=e.endpoint||{},a={appVersion:i.appVersion,make:i.make,model:i.model,modelVersion:i.version,platform:i.platform},u=(o.clientId,o.appTitle,o.appVersionName,o.appVersionCode,o.appPackageName,Pi(o,["clientId","appTitle","appVersionName","appVersionCode","appPackageName"])),c=t.address?"android"===i.platform?"GCM":"APNS":void 0,f=Li(Li(Li({channelType:c,requestId:Object(Qn.v1)(),effectiveDate:(new Date).toISOString()},s),t),{attributes:Li(Li({},s.attributes),t.attributes),demographic:Li(Li(Li(Li({},a),u),s.demographic),t.demographic),location:Li(Li({},s.location),t.location),metrics:Li(Li({},s.metrics),t.metrics),user:{userId:t.userId||s.userId||n.identityId,userAttributes:Li(Li({},s.userAttributes),t.userAttributes)}}),l=(f.userId,f.userAttributes,f.name,f.session,f.eventId,f.immediate,Pi(f,["userId","userAttributes","name","session","eventId","immediate"]));return r.JS.transferKeyToUpperCase(l,[],["metrics","userAttributes","attributes"])},e.prototype._eventError=function(e){Ti.error("record event failed.",e),Ti.warn('Please ensure you have updated your Pinpoint IAM Policy with the Action: "mobiletargeting:PutEvents" in order to record events')},e.prototype._getCredentials=function(){return ki(this,void 0,void 0,(function(){var e,t;return Mi(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r.Credentials.get()];case 1:return(e=n.sent())?(Ti.debug("set credentials for analytics",e),[2,r.Credentials.shear(e)]):[2,null];case 2:return t=n.sent(),Ti.debug("ensure credentials error",t),[2,null];case 3:return[2]}}))}))},e.category="Analytics",e.providerName="AWSPinpoint",e}(),Ui=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},zi=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ui(arguments[t]));return e},Bi=[],Fi=function(){function e(e,t){this.context=e,this.methodName=t,this._originalMethod=e[t].bind(e)}return e.add=function(e,t,n){qi(e,t).set(n)},e.remove=function(e,t){qi(e,t).remove()},e.prototype.set=function(e){var t=this;this.context[this.methodName]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e(t._originalMethod.apply(t,zi(n)))}},e.prototype.remove=function(){this.context[this.methodName]=this._originalMethod},e}();function qi(e,t){var n=Bi.filter((function(n){return n.context===e&&n.methodName===t}))[0];return n||(n=new Fi(e,t),Bi.push(n)),n}var Ki=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Vi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},Hi=new r.ConsoleLogger("PageViewTracker"),Gi="aws-amplify-analytics-prevUrl",$i={enable:!1,provider:"AWSPinpoint",getUrl:function(){return r.JS.browserOrNode().isBrowser?window.location.origin+window.location.pathname:""}},Wi=function(){function e(e,t){Hi.debug("initialize pageview tracker with opts",t),this._config=Object.assign({},$i,t),this._tracker=e,this._hasEnabled=!1,this._trackFunc=this._trackFunc.bind(this),"SPA"===this._config.type?this._pageViewTrackSPA():this._pageViewTrackDefault()}return e.prototype.configure=function(e){return Object.assign(this._config,e),"SPA"===this._config.type&&this._pageViewTrackSPA(),this._config},e.prototype._isSameUrl=function(){return sessionStorage.getItem(Gi)===this._config.getUrl()&&(Hi.debug("the url is same"),!0)},e.prototype._pageViewTrackDefault=function(){return Ki(this,void 0,void 0,(function(){var e,t,n,i;return Vi(this,(function(o){switch(o.label){case 0:return r.JS.browserOrNode().isBrowser&&window.addEventListener&&window.sessionStorage?(e=this._config.getUrl(),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]):(Hi.debug("not in the supported web enviroment"),[2]);case 1:return n=o.sent(),[3,3];case 2:n=this._config.attributes,o.label=3;case 3:return t=n,i=Object.assign({url:e},t),this._config.enable&&!this._isSameUrl()&&(this._tracker({name:this._config.eventName||"pageView",attributes:i},this._config.provider).catch((function(e){Hi.debug("Failed to record the page view event",e)})),sessionStorage.setItem(Gi,e)),[2]}}))}))},e.prototype._trackFunc=function(){return Ki(this,void 0,void 0,(function(){var e,t,n,i;return Vi(this,(function(o){switch(o.label){case 0:return r.JS.browserOrNode().isBrowser&&window.addEventListener&&history.pushState&&window.sessionStorage?(e=this._config.getUrl(),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]):(Hi.debug("not in the supported web enviroment"),[2]);case 1:return n=o.sent(),[3,3];case 2:n=this._config.attributes,o.label=3;case 3:return t=n,i=Object.assign({url:e},t),this._isSameUrl()||(this._tracker({name:this._config.eventName||"pageView",attributes:i},this._config.provider).catch((function(e){Hi.debug("Failed to record the page view event",e)})),sessionStorage.setItem(Gi,e)),[2]}}))}))},e.prototype._pageViewTrackSPA=function(){r.JS.browserOrNode().isBrowser&&window.addEventListener&&history.pushState?this._config.enable&&!this._hasEnabled?(Fi.add(history,"pushState",this._trackFunc),Fi.add(history,"replaceState",this._trackFunc),window.addEventListener("popstate",this._trackFunc),this._trackFunc(),this._hasEnabled=!0):(Fi.remove(history,"pushState"),Fi.remove(history,"replaceState"),window.removeEventListener("popstate",this._trackFunc),this._hasEnabled=!1):Hi.debug("not in the supported web enviroment")},e}(),Yi=r.JS.browserOrNode().isBrowser&&window.Element?window.Element.prototype:null,Zi=Yi?Yi.matches||Yi.matchesSelector||Yi.webkitMatchesSelector||Yi.mozMatchesSelector||Yi.msMatchesSelector||Yi.oMatchesSelector:null;function Ji(e,t){if(e&&1===e.nodeType&&t){if("string"==typeof t||1===t.nodeType)return e===t||Qi(e,t);if("length"in t)for(var n=0,r=void 0;r=t[n];n++)if(e===r||Qi(e,r))return!0}return!1}function Qi(e,t){if("string"!=typeof t)return!1;if(Zi)return Zi.call(e,t);for(var n=e.parentNode.querySelectorAll(t),r=0,i=void 0;i=n[r];r++)if(i===e)return!0;return!1}function Xi(e,t,n,r,i){void 0===i&&(i={});var o=function(e){var t;if(i.composed&&"function"==typeof e.composedPath)for(var o=e.composedPath(),s=0,a=void 0;a=o[s];s++)1===a.nodeType&&Ji(a,n)&&(t=a);else t=function(e,t,n){if(void 0===n&&(n=!1),e&&1===e.nodeType&&t)for(var r,i=(n?[e]:[]).concat(function(e){for(var t=[],n=e;n&&n.parentNode&&1===n.parentNode.nodeType;)n=n.parentNode,t.push(n);return t}(e)),o=0;r=i[o];o++)if(Ji(r,t))return r}(e.target,n,!0);t&&r.call(t,e,t)};return e.addEventListener(t,o,i.useCapture),{destroy:function(){e.removeEventListener(t,o,i.useCapture)}}}var eo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},to=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},no=new r.ConsoleLogger("EventTracker"),ro={enable:!1,events:["click"],selectorPrefix:"data-amplify-analytics-",provider:"AWSPinpoint"},io=function(){function e(e,t){r.JS.browserOrNode().isBrowser&&window.addEventListener?(this._config=Object.assign({},ro,t),this._tracker=e,this._delegates={},this._trackFunc=this._trackFunc.bind(this),no.debug("initialize pageview tracker with opts",this._config),this.configure(this._config)):no.debug("not in the supported web environment")}return e.prototype.configure=function(e){var t=this;if(Object.assign(this._config,e),this._config.enable){if(this._config.enable&&0===Object.keys(this._delegates).length){var n="["+this._config.selectorPrefix+"on]";this._config.events.forEach((function(e){t._delegates[e]=Xi(document,e,n,t._trackFunc,{composed:!0,useCapture:!0})}))}}else Object.keys(this._delegates).forEach((function(e){"function"==typeof t._delegates[e].destroy&&t._delegates[e].destroy()})),this._delegates={};return this._config},e.prototype._trackFunc=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,i,o,s,a,u;return to(this,(function(c){switch(c.label){case 0:return n={},r=t.getAttribute(this._config.selectorPrefix+"on").split(/\s*,\s*/),i=t.getAttribute(this._config.selectorPrefix+"name"),(o=t.getAttribute(this._config.selectorPrefix+"attrs"))&&o.split(/\s*,\s*/).forEach((function(e){var t=e.trim().split(/\s*:\s*/);n[t[0]]=t[1]})),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()];case 1:return a=c.sent(),[3,3];case 2:a=this._config.attributes,c.label=3;case 3:return s=a,u=Object.assign({type:e.type,target:e.target.localName+" with id "+e.target.id},s,n),no.debug("events needed to be recorded",r),no.debug("attributes needed to be attached",n),r.indexOf(e.type)<0?(no.debug("event "+e.type+" is not selected to be recorded"),[2]):(this._tracker({name:i||"event",attributes:u},this._config.provider).catch((function(t){no.debug("Failed to record the "+e.type+" event', "+t)})),[2])}}))}))},e}(),oo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},so=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},ao=new r.ConsoleLogger("SessionTracker"),uo={enable:!1,provider:"AWSPinpoint"},co=!1,fo=function(){function e(e,t){this._config=Object.assign({},uo,t),this._tracker=e,this._hasEnabled=!1,this._trackFunc=this._trackFunc.bind(this),this._trackBeforeUnload=this._trackBeforeUnload.bind(this),this.configure(this._config)}return e.prototype._envCheck=function(){if(!r.JS.browserOrNode().isBrowser)return!1;if(!document||!document.addEventListener)return ao.debug("not in the supported web environment"),!1;if(void 0!==document.hidden)this._hidden="hidden",this._visibilityChange="visibilitychange";else if(void 0!==document.msHidden)this._hidden="msHidden",this._visibilityChange="msvisibilitychange";else{if(void 0===document.webkitHidden)return ao.debug("not in the supported web environment"),!1;this._hidden="webkitHidden",this._visibilityChange="webkitvisibilitychange"}return!0},e.prototype._trackFunc=function(){return oo(this,void 0,void 0,(function(){var e,t,n;return so(this,(function(r){switch(r.label){case 0:return"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()];case 1:return t=r.sent(),[3,3];case 2:t=this._config.attributes,r.label=3;case 3:return e=t,n=Object.assign({},e),document.visibilityState===this._hidden?this._tracker({name:"_session.stop",attributes:n},this._config.provider).catch((function(e){ao.debug("record session stop event failed.",e)})):this._tracker({name:"_session.start",attributes:n},this._config.provider).catch((function(e){ao.debug("record session start event failed.",e)})),[2]}}))}))},e.prototype._trackBeforeUnload=function(e){var t=this;("function"==typeof this._config.attributes?Promise.resolve(this._config.attributes()):Promise.resolve(this._config.attributes)).then((function(e){var n=Object.assign({},e);t._tracker({name:"_session.stop",attributes:n,immediate:!0},t._config.provider).catch((function(e){ao.debug("record session stop event failed.",e)}))}))},e.prototype._sendInitialEvent=function(){return oo(this,void 0,void 0,(function(){var e,t,n;return so(this,(function(r){switch(r.label){case 0:return co?(ao.debug("the start session has been sent when the page is loaded"),[2]):(co=!0,"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]);case 1:return t=r.sent(),[3,3];case 2:t=this._config.attributes,r.label=3;case 3:return e=t,n=Object.assign({},e),this._tracker({name:"_session.start",attributes:n},this._config.provider).catch((function(e){ao.debug("record session start event failed.",e)})),[2]}}))}))},e.prototype.configure=function(e){return this._envCheck()?(Object.assign(this._config,e),this._config.enable&&!this._hasEnabled?(this._sendInitialEvent(),document.addEventListener(this._visibilityChange,this._trackFunc,!1),window.addEventListener("beforeunload",this._trackBeforeUnload,!1),this._hasEnabled=!0):!this._config.enable&&this._hasEnabled&&(document.removeEventListener(this._visibilityChange,this._trackFunc,!1),window.removeEventListener("beforeunload",this._trackBeforeUnload,!1),this._hasEnabled=!1),this._config):this._config},e}(),lo=function(){return(lo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},ho=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},vo=new r.ConsoleLogger("AnalyticsClass"),go="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",mo={pageView:Wi,event:io,session:fo},yo=null,bo=function(){function e(){this._config={},this._pluggables=[],this._disabled=!1,this._trackers={},yo=this,this.record=this.record.bind(this),r.Hub.listen("auth",Eo),r.Hub.listen("storage",Eo),r.Hub.listen("analytics",Eo)}return e.prototype.getModuleName=function(){return"Analytics"},e.prototype.configure=function(e){var t=this;if(!e)return this._config;vo.debug("configure Analytics",e);var n,i,o,s=r.Parser.parseMobilehubConfig(e);return this._config=Object.assign({},this._config,s.Analytics,e),this._config.disabled&&(this._disabled=!0),void 0===this._config.autoSessionRecord&&(this._config.autoSessionRecord=!0),this._pluggables.forEach((function(e){var n="AWSPinpoint"!==e.getProviderName()||t._config.AWSPinpoint?t._config[e.getProviderName()]:t._config;e.configure(lo({disabled:t._config.disabled,autoSessionRecord:t._config.autoSessionRecord},n))})),0===this._pluggables.length&&this.addPluggable(new Ni),n="configured",i=null,o="The Analytics category has been configured successfully",r.Hub.dispatch("analytics",{event:n,data:i,message:o},"Analytics",go),vo.debug("current configuration",this._config),this._config},e.prototype.addPluggable=function(e){if(e&&"Analytics"===e.getCategory()){this._pluggables.push(e);var t="AWSPinpoint"!==e.getProviderName()||this._config.AWSPinpoint?this._config[e.getProviderName()]:this._config,n=lo({disabled:this._config.disabled},t);return e.configure(n),n}},e.prototype.getPluggable=function(e){for(var t=0;t<this._pluggables.length;t+=1){var n=this._pluggables[t];if(n.getProviderName()===e)return n}return vo.debug("No plugin found with providerName",e),null},e.prototype.removePluggable=function(e){for(var t=0;t<this._pluggables.length&&this._pluggables[t].getProviderName()!==e;)t+=1;return t===this._pluggables.length?void vo.debug("No plugin found with providerName",e):void this._pluggables.splice(t,t+1)},e.prototype.disable=function(){this._disabled=!0},e.prototype.enable=function(){this._disabled=!1},e.prototype.startSession=function(e){return po(this,void 0,void 0,(function(){var t;return ho(this,(function(n){return t={event:{name:"_session.start"},provider:e},[2,this._sendEvent(t)]}))}))},e.prototype.stopSession=function(e){return po(this,void 0,void 0,(function(){var t;return ho(this,(function(n){return t={event:{name:"_session.stop"},provider:e},[2,this._sendEvent(t)]}))}))},e.prototype.record=function(e,t,n){return po(this,void 0,void 0,(function(){var r;return ho(this,(function(i){return r=null,r="string"==typeof e?{event:{name:e,attributes:t,metrics:n},provider:"AWSPinpoint"}:{event:e,provider:t},[2,this._sendEvent(r)]}))}))},e.prototype.updateEndpoint=function(e,t){return po(this,void 0,void 0,(function(){var n;return ho(this,(function(r){return n=lo(lo({},e),{name:"_update_endpoint"}),[2,this.record(n,t)]}))}))},e.prototype._sendEvent=function(e){var t=this;if(this._disabled)return vo.debug("Analytics has been disabled"),Promise.resolve();var n=e.provider?e.provider:"AWSPinpoint";return new Promise((function(r,i){t._pluggables.forEach((function(t){t.getProviderName()===n&&t.record(e,{resolve:r,reject:i})}))}))},e.prototype.autoTrack=function(e,t){if(mo[e]){"session"===e&&(this._config.autoSessionRecord=t.enable);var n=this._trackers[e];n?n.configure(t):this._trackers[e]=new mo[e](this.record,t)}else vo.debug("invalid tracker type")},e}(),wo=!1,_o=!1,So=!1,Eo=function(e){var t=e.channel,n=e.payload;switch(vo.debug("on hub capsule "+t,n),t){case"auth":Oo(n);break;case"storage":Ao(n);break;case"analytics":Io(n)}},Ao=function(e){var t=e.data,n=t.attrs,r=t.metrics;n&&So&&yo.record({name:"Storage",attributes:n,metrics:r}).catch((function(e){vo.debug("Failed to send the storage event automatically",e)}))},Oo=function(e){var t=e.event;if(t){var n=function(e){return po(void 0,void 0,void 0,(function(){var t;return ho(this,(function(n){switch(n.label){case 0:if(!_o||!So)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,yo.record({name:"_userauth."+e})];case 2:return[2,n.sent()];case 3:return t=n.sent(),vo.debug("Failed to send the "+e+" event automatically",t),[3,4];case 4:return[2]}}))}))};switch(t){case"signIn":return n("sign_in");case"signUp":return n("sign_up");case"signOut":return n("sign_out");case"signIn_failure":return n("auth_fail");case"configured":(_o=!0)&&So&&Lo()}}},Io=function(e){var t=e.event;if(t)switch(t){case"pinpointProvider_configured":So=!0,_o&&So&&Lo()}},Lo=function(){var e=yo.configure();!wo&&e.autoSessionRecord&&(yo.updateEndpoint({immediate:!0}).catch((function(e){vo.debug("Failed to update the endpoint",e)})),wo=!0),yo.autoTrack("session",{enable:e.autoSessionRecord})},ko=new bo;r.Amplify.register(ko);
|
|
39
|
+
***************************************************************************** */function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function u(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}Object.create;function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}var f,l,d,p,h,v,g,m,y,b,w,_,S,E,A,O,I,L,k,M,P,x,R,T,j,C,D,N,U,z,B,F,q,K,V,H,G,$,W,Y,Z,J,Q,X,ee,te,ne,re,ie,oe,se,ae,ue,ce,fe,le,de,pe,he,ve,ge,me,ye,be,we,_e,Se,Ee,Ae,Oe,Ie,Le,ke,Me,Pe,xe,Re,Te,je,Ce,De,Ne,Ue,ze,Be,Fe,qe,Ke,Ve,He,Ge,$e,We,Ye,Ze,Je,Qe,Xe,et,tt,nt,rt,it,ot,st,at,ut,ct,ft,lt,dt,pt,ht,vt,gt,mt,yt,bt,wt,_t,St,Et,At,Ot,It,Lt,kt,Mt,Pt,xt,Rt;Object.create;(f||(f={})).filterSensitiveLog=function(e){return s({},e)},(l||(l={})).filterSensitiveLog=function(e){return s({},e)},(d||(d={})).filterSensitiveLog=function(e){return s({},e)},(p||(p={})).filterSensitiveLog=function(e){return s({},e)},(h||(h={})).filterSensitiveLog=function(e){return s({},e)},(v||(v={})).filterSensitiveLog=function(e){return s({},e)},(g||(g={})).filterSensitiveLog=function(e){return s({},e)},(m||(m={})).filterSensitiveLog=function(e){return s({},e)},(y||(y={})).filterSensitiveLog=function(e){return s({},e)},(b||(b={})).filterSensitiveLog=function(e){return s({},e)},(w||(w={})).filterSensitiveLog=function(e){return s({},e)},(_||(_={})).filterSensitiveLog=function(e){return s({},e)},(S||(S={})).filterSensitiveLog=function(e){return s({},e)},(E||(E={})).filterSensitiveLog=function(e){return s({},e)},(A||(A={})).filterSensitiveLog=function(e){return s({},e)},(O||(O={})).filterSensitiveLog=function(e){return s({},e)},(I||(I={})).filterSensitiveLog=function(e){return s({},e)},(L||(L={})).filterSensitiveLog=function(e){return s({},e)},(k||(k={})).filterSensitiveLog=function(e){return s({},e)},(M||(M={})).filterSensitiveLog=function(e){return s({},e)},(P||(P={})).filterSensitiveLog=function(e){return s({},e)},(x||(x={})).filterSensitiveLog=function(e){return s({},e)},(R||(R={})).filterSensitiveLog=function(e){return s({},e)},(T||(T={})).filterSensitiveLog=function(e){return s({},e)},(j||(j={})).filterSensitiveLog=function(e){return s({},e)},(C||(C={})).filterSensitiveLog=function(e){return s({},e)},(D||(D={})).filterSensitiveLog=function(e){return s({},e)},(N||(N={})).filterSensitiveLog=function(e){return s({},e)},(U||(U={})).filterSensitiveLog=function(e){return s({},e)},(z||(z={})).filterSensitiveLog=function(e){return s({},e)},(B||(B={})).filterSensitiveLog=function(e){return s({},e)},(F||(F={})).filterSensitiveLog=function(e){return s({},e)},(q||(q={})).filterSensitiveLog=function(e){return s({},e)},(K||(K={})).filterSensitiveLog=function(e){return s({},e)},(V||(V={})).filterSensitiveLog=function(e){return s({},e)},(H||(H={})).filterSensitiveLog=function(e){return s({},e)},(G||(G={})).filterSensitiveLog=function(e){return s({},e)},($||($={})).filterSensitiveLog=function(e){return s({},e)},(W||(W={})).filterSensitiveLog=function(e){return s({},e)},(Y||(Y={})).filterSensitiveLog=function(e){return s({},e)},(Z||(Z={})).filterSensitiveLog=function(e){return s({},e)},(J||(J={})).filterSensitiveLog=function(e){return s({},e)},(Q||(Q={})).filterSensitiveLog=function(e){return s({},e)},(X||(X={})).filterSensitiveLog=function(e){return s({},e)},(ee||(ee={})).filterSensitiveLog=function(e){return s({},e)},(te||(te={})).filterSensitiveLog=function(e){return s({},e)},(ne||(ne={})).filterSensitiveLog=function(e){return s({},e)},(re||(re={})).filterSensitiveLog=function(e){return s({},e)},(ie||(ie={})).filterSensitiveLog=function(e){return s({},e)},(oe||(oe={})).filterSensitiveLog=function(e){return s({},e)},(se||(se={})).filterSensitiveLog=function(e){return s({},e)},(ae||(ae={})).filterSensitiveLog=function(e){return s({},e)},(ue||(ue={})).filterSensitiveLog=function(e){return s({},e)},(ce||(ce={})).filterSensitiveLog=function(e){return s({},e)},(fe||(fe={})).filterSensitiveLog=function(e){return s({},e)},(le||(le={})).filterSensitiveLog=function(e){return s({},e)},(de||(de={})).filterSensitiveLog=function(e){return s({},e)},(pe||(pe={})).filterSensitiveLog=function(e){return s({},e)},(he||(he={})).filterSensitiveLog=function(e){return s({},e)},(ve||(ve={})).filterSensitiveLog=function(e){return s({},e)},(ge||(ge={})).filterSensitiveLog=function(e){return s({},e)},(me||(me={})).filterSensitiveLog=function(e){return s({},e)},(ye||(ye={})).filterSensitiveLog=function(e){return s({},e)},(be||(be={})).filterSensitiveLog=function(e){return s({},e)},(we||(we={})).filterSensitiveLog=function(e){return s({},e)},(_e||(_e={})).filterSensitiveLog=function(e){return s({},e)},(Se||(Se={})).filterSensitiveLog=function(e){return s({},e)},(Ee||(Ee={})).filterSensitiveLog=function(e){return s({},e)},(Ae||(Ae={})).filterSensitiveLog=function(e){return s({},e)},(Oe||(Oe={})).filterSensitiveLog=function(e){return s({},e)},(Ie||(Ie={})).filterSensitiveLog=function(e){return s({},e)},(Le||(Le={})).filterSensitiveLog=function(e){return s({},e)},(ke||(ke={})).filterSensitiveLog=function(e){return s({},e)},(Me||(Me={})).filterSensitiveLog=function(e){return s({},e)},(Pe||(Pe={})).filterSensitiveLog=function(e){return s({},e)},(xe||(xe={})).filterSensitiveLog=function(e){return s({},e)},(Re||(Re={})).filterSensitiveLog=function(e){return s({},e)},(Te||(Te={})).filterSensitiveLog=function(e){return s({},e)},(je||(je={})).filterSensitiveLog=function(e){return s({},e)},(Ce||(Ce={})).filterSensitiveLog=function(e){return s({},e)},(De||(De={})).filterSensitiveLog=function(e){return s({},e)},(Ne||(Ne={})).filterSensitiveLog=function(e){return s({},e)},(Ue||(Ue={})).filterSensitiveLog=function(e){return s({},e)},(ze||(ze={})).filterSensitiveLog=function(e){return s({},e)},(Be||(Be={})).filterSensitiveLog=function(e){return s({},e)},(Fe||(Fe={})).filterSensitiveLog=function(e){return s({},e)},(qe||(qe={})).filterSensitiveLog=function(e){return s({},e)},(Ke||(Ke={})).filterSensitiveLog=function(e){return s({},e)},(Ve||(Ve={})).filterSensitiveLog=function(e){return s({},e)},(He||(He={})).filterSensitiveLog=function(e){return s({},e)},(Ge||(Ge={})).filterSensitiveLog=function(e){return s({},e)},($e||($e={})).filterSensitiveLog=function(e){return s({},e)},(We||(We={})).filterSensitiveLog=function(e){return s({},e)},(Ye||(Ye={})).filterSensitiveLog=function(e){return s({},e)},(Ze||(Ze={})).filterSensitiveLog=function(e){return s({},e)},(Je||(Je={})).filterSensitiveLog=function(e){return s({},e)},(Qe||(Qe={})).filterSensitiveLog=function(e){return s({},e)},(Xe||(Xe={})).filterSensitiveLog=function(e){return s({},e)},(et||(et={})).filterSensitiveLog=function(e){return s({},e)},(tt||(tt={})).filterSensitiveLog=function(e){return s({},e)},(nt||(nt={})).filterSensitiveLog=function(e){return s({},e)},(rt||(rt={})).filterSensitiveLog=function(e){return s({},e)},(it||(it={})).filterSensitiveLog=function(e){return s({},e)},(ot||(ot={})).filterSensitiveLog=function(e){return s({},e)},(st||(st={})).filterSensitiveLog=function(e){return s({},e)},(at||(at={})).filterSensitiveLog=function(e){return s({},e)},(ut||(ut={})).filterSensitiveLog=function(e){return s({},e)},(ct||(ct={})).filterSensitiveLog=function(e){return s({},e)},(ft||(ft={})).filterSensitiveLog=function(e){return s({},e)},(lt||(lt={})).filterSensitiveLog=function(e){return s({},e)},(dt||(dt={})).filterSensitiveLog=function(e){return s({},e)},(pt||(pt={})).filterSensitiveLog=function(e){return s({},e)},(ht||(ht={})).filterSensitiveLog=function(e){return s({},e)},(vt||(vt={})).filterSensitiveLog=function(e){return s({},e)},(gt||(gt={})).filterSensitiveLog=function(e){return s({},e)},(mt||(mt={})).filterSensitiveLog=function(e){return s({},e)},(yt||(yt={})).filterSensitiveLog=function(e){return s({},e)},(bt||(bt={})).filterSensitiveLog=function(e){return s({},e)},(wt||(wt={})).filterSensitiveLog=function(e){return s({},e)},(_t||(_t={})).filterSensitiveLog=function(e){return s({},e)},(St||(St={})).filterSensitiveLog=function(e){return s({},e)},(Et||(Et={})).filterSensitiveLog=function(e){return s({},e)},(At||(At={})).filterSensitiveLog=function(e){return s({},e)},(Ot||(Ot={})).filterSensitiveLog=function(e){return s({},e)},(It||(It={})).filterSensitiveLog=function(e){return s({},e)},(Lt||(Lt={})).filterSensitiveLog=function(e){return s({},e)},(kt||(kt={})).filterSensitiveLog=function(e){return s({},e)},(Mt||(Mt={})).filterSensitiveLog=function(e){return s({},e)},(Pt||(Pt={})).filterSensitiveLog=function(e){return s({},e)},(xt||(xt={})).filterSensitiveLog=function(e){return s({},e)},(Rt||(Rt={})).filterSensitiveLog=function(e){return s({},e)};var Tt=function(){function e(e){this.statusCode=e.statusCode,this.headers=e.headers||{},this.body=e.body}return e.isInstance=function(e){if(!e)return!1;var t=e;return"number"==typeof t.statusCode&&"object"==typeof t.headers},e}(),jt=n(0),Ct=function(){function e(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?":"!==e.protocol.substr(-1)?e.protocol+":":e.protocol:"https:",this.path=e.path?"/"!==e.path.charAt(0)?"/"+e.path:e.path:"/"}return e.isInstance=function(e){if(!e)return!1;var t=e;return"method"in t&&"protocol"in t&&"hostname"in t&&"path"in t&&"object"==typeof t.query&&"object"==typeof t.headers},e.prototype.clone=function(){var t,n=new e(Object(jt.__assign)(Object(jt.__assign)({},this),{headers:Object(jt.__assign)({},this.headers)}));return n.query&&(n.query=(t=n.query,Object.keys(t).reduce((function(e,n){var r,i=t[n];return Object(jt.__assign)(Object(jt.__assign)({},e),((r={})[n]=Array.isArray(i)?Object(jt.__spread)(i):i,r))}),{}))),n},e}();var Dt=function(){var e=[],t=[],n=new Set,r=function(n){return e.forEach((function(e){n.add(e.middleware,Object(jt.__assign)({},e))})),t.forEach((function(e){n.addRelativeTo(e.middleware,Object(jt.__assign)({},e))})),n},i=function(e){var t=[];return e.before.forEach((function(e){0===e.before.length&&0===e.after.length?t.push(e):t.push.apply(t,Object(jt.__spread)(i(e)))})),t.push(e),e.after.reverse().forEach((function(e){0===e.before.length&&0===e.after.length?t.push(e):t.push.apply(t,Object(jt.__spread)(i(e)))})),t},o=function(){var n,r=[],o=[],s={};return e.forEach((function(e){var t=Object(jt.__assign)(Object(jt.__assign)({},e),{before:[],after:[]});t.name&&(s[t.name]=t),r.push(t)})),t.forEach((function(e){var t=Object(jt.__assign)(Object(jt.__assign)({},e),{before:[],after:[]});t.name&&(s[t.name]=t),o.push(t)})),o.forEach((function(e){if(e.toMiddleware){var t=s[e.toMiddleware];if(void 0===t)throw new Error(e.toMiddleware+" is not found when adding "+(e.name||"anonymous")+" middleware "+e.relation+" "+e.toMiddleware);"after"===e.relation&&t.after.push(e),"before"===e.relation&&t.before.push(e)}})),(n=r,n.sort((function(e,t){return Nt[t.step]-Nt[e.step]||Ut[t.priority||"normal"]-Ut[e.priority||"normal"]}))).map(i).reduce((function(e,t){return e.push.apply(e,Object(jt.__spread)(t)),e}),[]).map((function(e){return e.middleware}))},s={add:function(t,r){void 0===r&&(r={});var i=r.name,o=r.override,s=Object(jt.__assign)({step:"initialize",priority:"normal",middleware:t},r);if(i){if(n.has(i)){if(!o)throw new Error("Duplicate middleware name '"+i+"'");var a=e.findIndex((function(e){return e.name===i})),u=e[a];if(u.step!==s.step||u.priority!==s.priority)throw new Error('"'+i+'" middleware with '+u.priority+" priority in "+u.step+" step cannot be overridden by same-name middleware with "+s.priority+" priority in "+s.step+" step.");e.splice(a,1)}n.add(i)}e.push(s)},addRelativeTo:function(e,r){var i=r.name,o=r.override,s=Object(jt.__assign)({middleware:e},r);if(i){if(n.has(i)){if(!o)throw new Error("Duplicate middleware name '"+i+"'");var a=t.findIndex((function(e){return e.name===i})),u=t[a];if(u.toMiddleware!==s.toMiddleware||u.relation!==s.relation)throw new Error('"'+i+'" middleware '+u.relation+' "'+u.toMiddleware+'" middleware cannot be overridden by same-name middleware '+s.relation+' "'+s.toMiddleware+'" middleware.');t.splice(a,1)}n.add(i)}t.push(s)},clone:function(){return r(Dt())},use:function(e){e.applyToStack(s)},remove:function(r){return"string"==typeof r?function(r){var i=!1,o=function(e){return!e.name||e.name!==r||(i=!0,n.delete(r),!1)};return e=e.filter(o),t=t.filter(o),i}(r):function(r){var i=!1,o=function(e){return e.middleware!==r||(i=!0,e.name&&n.delete(e.name),!1)};return e=e.filter(o),t=t.filter(o),i}(r)},removeByTag:function(r){var i=!1,o=function(e){var t=e.tags,o=e.name;return!t||!t.includes(r)||(o&&n.delete(o),i=!0,!1)};return e=e.filter(o),t=t.filter(o),i},concat:function(e){var t=r(Dt());return t.use(e),t},applyToStack:r,resolve:function(e,t){var n,r;try{for(var i=Object(jt.__values)(o().reverse()),s=i.next();!s.done;s=i.next()){e=(0,s.value)(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e}};return s},Nt={initialize:5,serialize:4,build:3,finalizeRequest:2,deserialize:1},Ut={high:3,normal:2,low:1},zt=function(){function e(e){this.middlewareStack=Dt(),this.config=e}return e.prototype.send=function(e,t,n){var r="function"!=typeof t?t:void 0,i="function"==typeof t?t:n,o=e.resolveMiddleware(this.middlewareStack,this.config,r);if(!i)return o(e).then((function(e){return e.output}));o(e).then((function(e){return i(null,e.output)}),(function(e){return i(e)})).catch((function(){}))},e.prototype.destroy=function(){this.config.requestHandler.destroy&&this.config.requestHandler.destroy()},e}(),Bt=function(){this.middlewareStack=Dt()};function Ft(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}var qt=function(){var e=Object.getPrototypeOf(this).constructor,t=Function.bind.apply(String,Object(jt.__spread)([null],arguments)),n=new t;return Object.setPrototypeOf(n,e.prototype),n};qt.prototype=Object.create(String.prototype,{constructor:{value:qt,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(qt,String);var Kt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(jt.__extends)(t,e),t.prototype.deserializeJSON=function(){return JSON.parse(e.prototype.toString.call(this))},t.prototype.toJSON=function(){return e.prototype.toString.call(this)},t.fromObject=function(e){return e instanceof t?e:new t(e instanceof String||"string"==typeof e?e:JSON.stringify(e))},t}(qt);var Vt="***SensitiveInformation***",Ht=function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,a,c,f,l,d,p,h,v,g,m;return u(this,(function(u){switch(u.label){case 0:return r=[s({},e)],m={},[4,_n(e.body,t)];case 1:switch(n=s.apply(void 0,r.concat([(m.body=u.sent(),m)])),o="UnknownError",o=Sn(e,n.body),o){case"BadRequestException":case"com.amazonaws.pinpoint#BadRequestException":return[3,2];case"ForbiddenException":case"com.amazonaws.pinpoint#ForbiddenException":return[3,4];case"InternalServerErrorException":case"com.amazonaws.pinpoint#InternalServerErrorException":return[3,6];case"MethodNotAllowedException":case"com.amazonaws.pinpoint#MethodNotAllowedException":return[3,8];case"NotFoundException":case"com.amazonaws.pinpoint#NotFoundException":return[3,10];case"PayloadTooLargeException":case"com.amazonaws.pinpoint#PayloadTooLargeException":return[3,12];case"TooManyRequestsException":case"com.amazonaws.pinpoint#TooManyRequestsException":return[3,14]}return[3,16];case 2:return a=[{}],[4,$t(n,t)];case 3:return i=s.apply(void 0,[s.apply(void 0,a.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 4:return c=[{}],[4,Wt(n,t)];case 5:return i=s.apply(void 0,[s.apply(void 0,c.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 6:return f=[{}],[4,Yt(n,t)];case 7:return i=s.apply(void 0,[s.apply(void 0,f.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 8:return l=[{}],[4,Zt(n,t)];case 9:return i=s.apply(void 0,[s.apply(void 0,l.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 10:return d=[{}],[4,Jt(n,t)];case 11:return i=s.apply(void 0,[s.apply(void 0,d.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 12:return p=[{}],[4,Qt(n,t)];case 13:return i=s.apply(void 0,[s.apply(void 0,p.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 14:return h=[{}],[4,Xt(n,t)];case 15:return i=s.apply(void 0,[s.apply(void 0,h.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 16:v=n.body,o=v.code||v.Code||o,i=s(s({},v),{name:""+o,message:v.message||v.Message||o,$fault:"client",$metadata:bn(e)}),u.label=17;case 17:return g=i.message||i.Message||o,i.message=g,delete i.Message,[2,Promise.reject(Object.assign(new Error(g),i))]}}))}))},Gt=function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,a,c,f,l,d,p,h,v,g,m;return u(this,(function(u){switch(u.label){case 0:return r=[s({},e)],m={},[4,_n(e.body,t)];case 1:switch(n=s.apply(void 0,r.concat([(m.body=u.sent(),m)])),o="UnknownError",o=Sn(e,n.body),o){case"BadRequestException":case"com.amazonaws.pinpoint#BadRequestException":return[3,2];case"ForbiddenException":case"com.amazonaws.pinpoint#ForbiddenException":return[3,4];case"InternalServerErrorException":case"com.amazonaws.pinpoint#InternalServerErrorException":return[3,6];case"MethodNotAllowedException":case"com.amazonaws.pinpoint#MethodNotAllowedException":return[3,8];case"NotFoundException":case"com.amazonaws.pinpoint#NotFoundException":return[3,10];case"PayloadTooLargeException":case"com.amazonaws.pinpoint#PayloadTooLargeException":return[3,12];case"TooManyRequestsException":case"com.amazonaws.pinpoint#TooManyRequestsException":return[3,14]}return[3,16];case 2:return a=[{}],[4,$t(n,t)];case 3:return i=s.apply(void 0,[s.apply(void 0,a.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 4:return c=[{}],[4,Wt(n,t)];case 5:return i=s.apply(void 0,[s.apply(void 0,c.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 6:return f=[{}],[4,Yt(n,t)];case 7:return i=s.apply(void 0,[s.apply(void 0,f.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 8:return l=[{}],[4,Zt(n,t)];case 9:return i=s.apply(void 0,[s.apply(void 0,l.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 10:return d=[{}],[4,Jt(n,t)];case 11:return i=s.apply(void 0,[s.apply(void 0,d.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 12:return p=[{}],[4,Qt(n,t)];case 13:return i=s.apply(void 0,[s.apply(void 0,p.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 14:return h=[{}],[4,Xt(n,t)];case 15:return i=s.apply(void 0,[s.apply(void 0,h.concat([u.sent()])),{name:o,$metadata:bn(e)}]),[3,17];case 16:v=n.body,o=v.code||v.Code||o,i=s(s({},v),{name:""+o,message:v.message||v.Message||o,$fault:"client",$metadata:bn(e)}),u.label=17;case 17:return g=i.message||i.Message||o,i.message=g,delete i.Message,[2,Promise.reject(Object.assign(new Error(g),i))]}}))}))},$t=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"BadRequestException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Wt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"ForbiddenException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Yt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"InternalServerErrorException",$fault:"server",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Zt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"MethodNotAllowedException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Jt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"NotFoundException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Qt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"PayloadTooLargeException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},Xt=function(e,t){return a(void 0,void 0,void 0,(function(){var t,n;return u(this,(function(r){return t={name:"TooManyRequestsException",$fault:"client",$metadata:bn(e),Message:void 0,RequestID:void 0},void 0!==(n=e.body).Message&&null!==n.Message&&(t.Message=n.Message),void 0!==n.RequestID&&null!==n.RequestID&&(t.RequestID=n.RequestID),[2,t]}))}))},en=function(e,t){return s(s(s(s(s(s(s(s({},void 0!==e.AppVersion&&null!==e.AppVersion&&{AppVersion:e.AppVersion}),void 0!==e.Locale&&null!==e.Locale&&{Locale:e.Locale}),void 0!==e.Make&&null!==e.Make&&{Make:e.Make}),void 0!==e.Model&&null!==e.Model&&{Model:e.Model}),void 0!==e.ModelVersion&&null!==e.ModelVersion&&{ModelVersion:e.ModelVersion}),void 0!==e.Platform&&null!==e.Platform&&{Platform:e.Platform}),void 0!==e.PlatformVersion&&null!==e.PlatformVersion&&{PlatformVersion:e.PlatformVersion}),void 0!==e.Timezone&&null!==e.Timezone&&{Timezone:e.Timezone})},tn=function(e,t){return s(s(s(s(s(s({},void 0!==e.City&&null!==e.City&&{City:e.City}),void 0!==e.Country&&null!==e.Country&&{Country:e.Country}),void 0!==e.Latitude&&null!==e.Latitude&&{Latitude:e.Latitude}),void 0!==e.Longitude&&null!==e.Longitude&&{Longitude:e.Longitude}),void 0!==e.PostalCode&&null!==e.PostalCode&&{PostalCode:e.PostalCode}),void 0!==e.Region&&null!==e.Region&&{Region:e.Region})},nn=function(e,t){return s(s(s(s(s(s(s(s(s(s(s({},void 0!==e.Address&&null!==e.Address&&{Address:e.Address}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:ln(e.Attributes,t)}),void 0!==e.ChannelType&&null!==e.ChannelType&&{ChannelType:e.ChannelType}),void 0!==e.Demographic&&null!==e.Demographic&&{Demographic:en(e.Demographic,t)}),void 0!==e.EffectiveDate&&null!==e.EffectiveDate&&{EffectiveDate:e.EffectiveDate}),void 0!==e.EndpointStatus&&null!==e.EndpointStatus&&{EndpointStatus:e.EndpointStatus}),void 0!==e.Location&&null!==e.Location&&{Location:tn(e.Location,t)}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.OptOut&&null!==e.OptOut&&{OptOut:e.OptOut}),void 0!==e.RequestId&&null!==e.RequestId&&{RequestId:e.RequestId}),void 0!==e.User&&null!==e.User&&{User:rn(e.User,t)})},rn=function(e,t){return s(s({},void 0!==e.UserAttributes&&null!==e.UserAttributes&&{UserAttributes:ln(e.UserAttributes,t)}),void 0!==e.UserId&&null!==e.UserId&&{UserId:e.UserId})},on=function(e,t){return s({},void 0!==e.BatchItem&&null!==e.BatchItem&&{BatchItem:fn(e.BatchItem,t)})},sn=function(e,t){return e.filter((function(e){return null!=e})).map((function(e){return null===e?null:e}))},an=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=o,n))}),{})},un=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=o,n))}),{})},cn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return s(s(s(s(s(s(s(s(s(s({},void 0!==e.AppPackageName&&null!==e.AppPackageName&&{AppPackageName:e.AppPackageName}),void 0!==e.AppTitle&&null!==e.AppTitle&&{AppTitle:e.AppTitle}),void 0!==e.AppVersionCode&&null!==e.AppVersionCode&&{AppVersionCode:e.AppVersionCode}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:un(e.Attributes,t)}),void 0!==e.ClientSdkVersion&&null!==e.ClientSdkVersion&&{ClientSdkVersion:e.ClientSdkVersion}),void 0!==e.EventType&&null!==e.EventType&&{EventType:e.EventType}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.SdkName&&null!==e.SdkName&&{SdkName:e.SdkName}),void 0!==e.Session&&null!==e.Session&&{Session:pn(e.Session,t)}),void 0!==e.Timestamp&&null!==e.Timestamp&&{Timestamp:e.Timestamp})}(a,t),r))}),{})},fn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return s(s({},void 0!==e.Endpoint&&null!==e.Endpoint&&{Endpoint:dn(e.Endpoint,t)}),void 0!==e.Events&&null!==e.Events&&{Events:cn(e.Events,t)})}(a,t),r))}),{})},ln=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=sn(a,t),r))}),{})},dn=function(e,t){return s(s(s(s(s(s(s(s(s(s(s({},void 0!==e.Address&&null!==e.Address&&{Address:e.Address}),void 0!==e.Attributes&&null!==e.Attributes&&{Attributes:ln(e.Attributes,t)}),void 0!==e.ChannelType&&null!==e.ChannelType&&{ChannelType:e.ChannelType}),void 0!==e.Demographic&&null!==e.Demographic&&{Demographic:en(e.Demographic,t)}),void 0!==e.EffectiveDate&&null!==e.EffectiveDate&&{EffectiveDate:e.EffectiveDate}),void 0!==e.EndpointStatus&&null!==e.EndpointStatus&&{EndpointStatus:e.EndpointStatus}),void 0!==e.Location&&null!==e.Location&&{Location:tn(e.Location,t)}),void 0!==e.Metrics&&null!==e.Metrics&&{Metrics:an(e.Metrics,t)}),void 0!==e.OptOut&&null!==e.OptOut&&{OptOut:e.OptOut}),void 0!==e.RequestId&&null!==e.RequestId&&{RequestId:e.RequestId}),void 0!==e.User&&null!==e.User&&{User:rn(e.User,t)})},pn=function(e,t){return s(s(s(s({},void 0!==e.Duration&&null!==e.Duration&&{Duration:e.Duration}),void 0!==e.Id&&null!==e.Id&&{Id:e.Id}),void 0!==e.StartTimestamp&&null!==e.StartTimestamp&&{StartTimestamp:e.StartTimestamp}),void 0!==e.StopTimestamp&&null!==e.StopTimestamp&&{StopTimestamp:e.StopTimestamp})},hn=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,StatusCode:void 0!==e.StatusCode&&null!==e.StatusCode?e.StatusCode:void 0}},vn=function(e,t){return{Results:void 0!==e.Results&&null!==e.Results?mn(e.Results,t):void 0}},gn=function(e,t){return Object.entries(e).reduce((function(e,t){var n,r=c(t,2),i=r[0],o=r[1];return null===o?e:s(s({},e),((n={})[i]=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,StatusCode:void 0!==e.StatusCode&&null!==e.StatusCode?e.StatusCode:void 0}}(o),n))}),{})},mn=function(e,t){return Object.entries(e).reduce((function(e,n){var r,i=c(n,2),o=i[0],a=i[1];return null===a?e:s(s({},e),((r={})[o]=function(e,t){return{EndpointItemResponse:void 0!==e.EndpointItemResponse&&null!==e.EndpointItemResponse?hn(e.EndpointItemResponse):void 0,EventsItemResponse:void 0!==e.EventsItemResponse&&null!==e.EventsItemResponse?gn(e.EventsItemResponse,t):void 0}}(a,t),r))}),{})},yn=function(e,t){return{Message:void 0!==e.Message&&null!==e.Message?e.Message:void 0,RequestID:void 0!==e.RequestID&&null!==e.RequestID?e.RequestID:void 0}},bn=function(e){var t;return{httpStatusCode:e.statusCode,requestId:null!==(t=e.headers["x-amzn-requestid"])&&void 0!==t?t:e.headers["x-amzn-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}},wn=function(e,t){return void 0===e&&(e=new Uint8Array),e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array)},_n=function(e,t){return function(e,t){return wn(e,t).then((function(e){return t.utf8Encoder(e)}))}(e,t).then((function(e){return e.length?JSON.parse(e):{}}))},Sn=function(e,t){var n,r,i=function(e){var t=e;return t.indexOf(":")>=0&&(t=t.split(":")[0]),t.indexOf("#")>=0&&(t=t.split("#")[1]),t},o=(n=e.headers,r="x-amzn-errortype",Object.keys(n).find((function(e){return e.toLowerCase()===r.toLowerCase()})));return void 0!==o?i(e.headers[o]):void 0!==t.code?i(t.code):void 0!==t.__type?i(t.__type):""},En={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},An={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0};function On(e,t,n){return{applyToStack:function(r){r.add(function(e,t){return function(n,r){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i,o;return Object(jt.__generator)(this,(function(s){switch(s.label){case 0:return[4,n(r)];case 1:return i=s.sent().response,[4,t(i,e)];case 2:return o=s.sent(),[2,{response:i,output:o}]}}))}))}}}(e,n),En),r.add(function(e,t){return function(n,r){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i;return Object(jt.__generator)(this,(function(o){switch(o.label){case 0:return[4,t(r.input,e)];case 1:return i=o.sent(),[2,n(Object(jt.__assign)(Object(jt.__assign)({},r),{request:i}))]}}))}))}}}(e,t),An)}}}var In=function(e){function t(t){var n=e.call(this)||this;return n.input=t,n}return o(t,e),t.prototype.resolveMiddleware=function(e,t,n){this.middlewareStack.use(On(t,this.serialize,this.deserialize));var r=e.concat(this.middlewareStack),i={logger:t.logger,clientName:"PinpointClient",commandName:"PutEventsCommand",inputFilterSensitiveLog:we.filterSensitiveLog,outputFilterSensitiveLog:_e.filterSensitiveLog},o=t.requestHandler;return r.resolve((function(e){return o.handle(e.request,n||{})}),i)},t.prototype.serialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,s,a,c,f,l;return u(this,(function(u){switch(u.label){case 0:if(n={"content-type":"application/json"},r="/v1/apps/{ApplicationId}/events",void 0===e.ApplicationId)throw new Error("No value provided for input HTTP label: ApplicationId.");if((i=e.ApplicationId).length<=0)throw new Error("Empty value provided for input HTTP label: ApplicationId.");return r=r.replace("{ApplicationId}",Ft(i)),void 0!==e.EventsRequest&&(o=on(e.EventsRequest,t)),void 0===o&&(o={}),o=JSON.stringify(o),[4,t.endpoint()];case 1:return s=u.sent(),a=s.hostname,c=s.protocol,f=void 0===c?"https":c,l=s.port,[2,new Ct({protocol:f,hostname:a,port:l,method:"POST",headers:n,path:r,body:o})]}}))}))}(e,t)},t.prototype.deserialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return 202!==e.statusCode&&e.statusCode>=300?[2,Ht(e,t)]:(n={$metadata:bn(e),EventsResponse:void 0},[4,_n(e.body,t)]);case 1:return r=i.sent(),n.EventsResponse=vn(r,t),[2,Promise.resolve(n)]}}))}))}(e,t)},t}(Bt),Ln=function(e){function t(t){var n=e.call(this)||this;return n.input=t,n}return o(t,e),t.prototype.resolveMiddleware=function(e,t,n){this.middlewareStack.use(On(t,this.serialize,this.deserialize));var r=e.concat(this.middlewareStack),i={logger:t.logger,clientName:"PinpointClient",commandName:"UpdateEndpointCommand",inputFilterSensitiveLog:rt.filterSensitiveLog,outputFilterSensitiveLog:it.filterSensitiveLog},o=t.requestHandler;return r.resolve((function(e){return o.handle(e.request,n||{})}),i)},t.prototype.serialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r,i,o,s,a,c,f,l;return u(this,(function(u){switch(u.label){case 0:if(n={"content-type":"application/json"},r="/v1/apps/{ApplicationId}/endpoints/{EndpointId}",void 0===e.ApplicationId)throw new Error("No value provided for input HTTP label: ApplicationId.");if((i=e.ApplicationId).length<=0)throw new Error("Empty value provided for input HTTP label: ApplicationId.");if(r=r.replace("{ApplicationId}",Ft(i)),void 0===e.EndpointId)throw new Error("No value provided for input HTTP label: EndpointId.");if((i=e.EndpointId).length<=0)throw new Error("Empty value provided for input HTTP label: EndpointId.");return r=r.replace("{EndpointId}",Ft(i)),void 0!==e.EndpointRequest&&(o=nn(e.EndpointRequest,t)),void 0===o&&(o={}),o=JSON.stringify(o),[4,t.endpoint()];case 1:return s=u.sent(),a=s.hostname,c=s.protocol,f=void 0===c?"https":c,l=s.port,[2,new Ct({protocol:f,hostname:a,port:l,method:"PUT",headers:n,path:r,body:o})]}}))}))}(e,t)},t.prototype.deserialize=function(e,t){return function(e,t){return a(void 0,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return 202!==e.statusCode&&e.statusCode>=300?[2,Gt(e,t)]:(n={$metadata:bn(e),MessageBody:void 0},[4,_n(e.body,t)]);case 1:return r=i.sent(),n.MessageBody=yn(r,t),[2,Promise.resolve(n)]}}))}))}(e,t)},t}(Bt),kn=n(47),Mn=n(6),Pn=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,xn)},xn=function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()};for(var Rn=function(){function e(e){var t=(void 0===e?{}:e).requestTimeout;this.requestTimeout=t}return e.prototype.destroy=function(){},e.prototype.handle=function(e,t){var n=(void 0===t?{}:t).abortSignal,r=this.requestTimeout;if(null==n?void 0:n.aborted){var i=new Error("Request aborted");return i.name="AbortError",Promise.reject(i)}var o=e.path;if(e.query){var s=function(e){var t,n,r=[];try{for(var i=Object(jt.__values)(Object.keys(e).sort()),o=i.next();!o.done;o=i.next()){var s=o.value,a=e[s];if(s=Pn(s),Array.isArray(a))for(var u=0,c=a.length;u<c;u++)r.push(s+"="+Pn(a[u]));else{var f=s;(a||"string"==typeof a)&&(f+="="+Pn(a)),r.push(f)}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r.join("&")}(e.query);s&&(o+="?"+s)}var a=e.port,u=e.method,c=e.protocol+"//"+e.hostname+(a?":"+a:"")+o,f={body:"GET"===u||"HEAD"===u?void 0:e.body,headers:new Headers(e.headers),method:u};"undefined"!=typeof AbortController&&(f.signal=n);var l,d=new Request(c,f),p=[fetch(d).then((function(e){var t,n,r=e.headers,i={};try{for(var o=Object(jt.__values)(r.entries()),s=o.next();!s.done;s=o.next()){var a=s.value;i[a[0]]=a[1]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return void 0!==e.body?{response:new Tt({headers:i,statusCode:e.status,body:e.body})}:e.blob().then((function(t){return{response:new Tt({headers:i,statusCode:e.status,body:t})}}))})),(l=r,void 0===l&&(l=0),new Promise((function(e,t){l&&setTimeout((function(){var e=new Error("Request did not complete within "+l+" ms");e.name="TimeoutError",t(e)}),l)})))];return n&&p.push(new Promise((function(e,t){n.onabort=function(){var e=new Error("Request aborted");e.name="AbortError",t(e)}}))),Promise.race(p)},e}(),Tn={},jn=new Array(64),Cn=0,Dn="A".charCodeAt(0),Nn="Z".charCodeAt(0);Cn+Dn<=Nn;Cn++){var Un=String.fromCharCode(Cn+Dn);Tn[Un]=Cn,jn[Cn]=Un}for(Cn=0,Dn="a".charCodeAt(0),Nn="z".charCodeAt(0);Cn+Dn<=Nn;Cn++){Un=String.fromCharCode(Cn+Dn);var zn=Cn+26;Tn[Un]=zn,jn[zn]=Un}for(Cn=0;Cn<10;Cn++){Tn[Cn.toString(10)]=Cn+52;Un=Cn.toString(10),zn=Cn+52;Tn[Un]=zn,jn[zn]=Un}Tn["+"]=62,jn[62]="+",Tn["/"]=63,jn[63]="/";function Bn(e){var t=e.length/4*3;"=="===e.substr(-2)?t-=2:"="===e.substr(-1)&&t--;for(var n=new ArrayBuffer(t),r=new DataView(n),i=0;i<e.length;i+=4){for(var o=0,s=0,a=i,u=i+3;a<=u;a++)"="!==e[a]?(o|=Tn[e[a]]<<6*(u-a),s+=6):o>>=6;var c=i/4*3;o>>=s%8;for(var f=Math.floor(s/8),l=0;l<f;l++){var d=8*(f-l-1);r.setUint8(c+l,(o&255<<d)>>d)}}return new Uint8Array(n)}function Fn(e){for(var t="",n=0;n<e.length;n+=3){for(var r=0,i=0,o=n,s=Math.min(n+3,e.length);o<s;o++)r|=e[o]<<8*(s-o-1),i+=8;var a=Math.ceil(i/6);r<<=6*a-i;for(var u=1;u<=a;u++){var c=6*(a-u);t+=jn[(r&63<<c)>>c]}t+="==".slice(0,4-a)}return t}var qn=function(e){return"function"==typeof Blob&&e instanceof Blob?function(e){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n;return Object(jt.__generator)(this,(function(r){switch(r.label){case 0:return[4,Kn(e)];case 1:return t=r.sent(),n=Bn(t),[2,new Uint8Array(n)]}}))}))}(e):function(e){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return Object(jt.__generator)(this,(function(u){switch(u.label){case 0:t=new Uint8Array(0),n=e.getReader(),r=!1,u.label=1;case 1:return r?[3,3]:[4,n.read()];case 2:return i=u.sent(),o=i.done,(s=i.value)&&(a=t,(t=new Uint8Array(a.length+s.length)).set(a),t.set(s,a.length)),r=o,[3,1];case 3:return[2,t]}}))}))}(e)};function Kn(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){var e;if(2!==r.readyState)return n(new Error("Reader aborted too early"));var i=null!==(e=r.result)&&void 0!==e?e:"",o=i.indexOf(","),s=o>-1?o+1:i.length;t(i.substring(s))},r.onabort=function(){return n(new Error("Read aborted"))},r.onerror=function(){return n(r.error)},r.readAsDataURL(e)}))}var Vn=function(e){return function(){return Promise.reject(e)}},Hn={name:"retryMiddleware",tags:["RETRY"],step:"finalizeRequest",priority:"high",override:!0},Gn=function(e){return{applyToStack:function(t){t.add(function(e){return function(t,n){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i;return Object(jt.__generator)(this,(function(o){return(null===(i=null==e?void 0:e.retryStrategy)||void 0===i?void 0:i.mode)&&(n.userAgent=Object(jt.__spread)(n.userAgent||[],[["cfg/retry-mode",e.retryStrategy.mode]])),[2,e.retryStrategy.retry(t,r)]}))}))}}}(e),Hn)}}},$n=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch"],Wn=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException","TransactionInProgressException"],Yn=["AbortError","TimeoutError","RequestTimeout","RequestTimeoutException"],Zn=[500,502,503,504],Jn=function(e){var t,n;return 429===(null===(t=e.$metadata)||void 0===t?void 0:t.httpStatusCode)||Wn.includes(e.name)||1==(null===(n=e.$retryable)||void 0===n?void 0:n.throttling)},Qn=n(3),Xn=function(e,t){return Math.floor(Math.min(2e4,Math.random()*Math.pow(2,t)*e))},er=function(e){return!!e&&(function(e){return void 0!==e.$retryable}(e)||function(e){return $n.includes(e.name)}(e)||Jn(e)||function(e){var t;return Yn.includes(e.name)||Zn.includes((null===(t=e.$metadata)||void 0===t?void 0:t.httpStatusCode)||0)}(e))},tr=function(){function e(e,t){var n,r,i,o,s,a,u,c;this.maxAttemptsProvider=e,this.mode="standard",this.retryDecider=null!==(n=null==t?void 0:t.retryDecider)&&void 0!==n?n:er,this.delayDecider=null!==(r=null==t?void 0:t.delayDecider)&&void 0!==r?r:Xn,this.retryQuota=null!==(i=null==t?void 0:t.retryQuota)&&void 0!==i?i:(s=o=500,a=o,u=function(e){return"TimeoutError"===e.name?10:5},c=function(e){return u(e)<=a},Object.freeze({hasRetryTokens:c,retrieveRetryTokens:function(e){if(!c(e))throw new Error("No retry token available");var t=u(e);return a-=t,t},releaseRetryTokens:function(e){a+=null!=e?e:1,a=Math.min(a,s)}}))}return e.prototype.shouldRetry=function(e,t,n){return t<n&&this.retryDecider(e)&&this.retryQuota.hasRetryTokens(e)},e.prototype.getMaxAttempts=function(){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e;return Object(jt.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.maxAttemptsProvider()];case 1:return e=t.sent(),[3,3];case 2:return t.sent(),e=3,[3,3];case 3:return[2,e]}}))}))},e.prototype.retry=function(e,t){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c;return Object(jt.__generator)(this,(function(f){switch(f.label){case 0:return r=0,i=0,[4,this.getMaxAttempts()];case 1:o=f.sent(),s=t.request,Ct.isInstance(s)&&(s.headers["amz-sdk-invocation-id"]=Object(Qn.v4)()),a=function(){var a,c,f,l,d;return Object(jt.__generator)(this,(function(p){switch(p.label){case 0:return p.trys.push([0,2,,5]),Ct.isInstance(s)&&(s.headers["amz-sdk-request"]="attempt="+(r+1)+"; max="+o),[4,e(t)];case 1:return a=p.sent(),c=a.response,f=a.output,u.retryQuota.releaseRetryTokens(n),f.$metadata.attempts=r+1,f.$metadata.totalRetryDelay=i,[2,{value:{response:c,output:f}}];case 2:return l=p.sent(),r++,u.shouldRetry(l,r,o)?(n=u.retryQuota.retrieveRetryTokens(l),d=u.delayDecider(Jn(l)?500:100,r),i+=d,[4,new Promise((function(e){return setTimeout(e,d)}))]):[3,4];case 3:return p.sent(),[2,"continue"];case 4:throw l.$metadata||(l.$metadata={}),l.$metadata.attempts=r,l.$metadata.totalRetryDelay=i,l;case 5:return[2]}}))},u=this,f.label=2;case 2:return[5,a()];case 3:return"object"==typeof(c=f.sent())?[2,c.value]:[3,2];case 4:return[2]}}))}))},e}(),nr=function(e){var t=rr(e.maxAttempts);return Object(jt.__assign)(Object(jt.__assign)({},e),{maxAttempts:t,retryStrategy:e.retryStrategy||new tr(t)})},rr=function(e){if(void 0===e&&(e=3),"number"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};function ir(e){if("string"==typeof e){for(var t=e.length,n=t-1;n>=0;n--){var r=e.charCodeAt(n);r>127&&r<=2047?t++:r>2047&&r<=65535&&(t+=2)}return t}return"number"==typeof e.byteLength?e.byteLength:"number"==typeof e.size?e.size:void 0}var or=n(46),sr=n.n(or),ar=function(e){var t=e.serviceId,n=e.clientVersion;return function(){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var e,r,i,o,s,a,u,c,f;return Object(jt.__generator)(this,(function(l){return e=(null===(i=null===window||void 0===window?void 0:window.navigator)||void 0===i?void 0:i.userAgent)?sr.a.parse(window.navigator.userAgent):void 0,r=[["aws-sdk-js",n],["os/"+((null===(o=null==e?void 0:e.os)||void 0===o?void 0:o.name)||"other"),null===(s=null==e?void 0:e.os)||void 0===s?void 0:s.version],["lang/js"],["md/browser",(null!==(u=null===(a=null==e?void 0:e.browser)||void 0===a?void 0:a.name)&&void 0!==u?u:"unknown")+"_"+(null!==(f=null===(c=null==e?void 0:e.browser)||void 0===c?void 0:c.version)&&void 0!==f?f:"unknown")]],t&&r.push(["api/"+t,n]),[2,r]}))}))}},ur=n(2),cr=new Set(["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","eu-central-1","eu-north-1","eu-south-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2"]),fr=new Set(["cn-north-1","cn-northwest-1"]),lr=new Set(["us-iso-east-1"]),dr=new Set(["us-isob-east-1"]),pr=new Set(["us-gov-east-1","us-gov-west-1"]);var hr=function(e){var t,n=new URL(e),r=n.hostname,i=n.pathname,o=n.port,s=n.protocol,a=n.search;return a&&(t=function(e){var t,n,r={};if(e=e.replace(/^\?/,""))try{for(var i=Object(jt.__values)(e.split("&")),o=i.next();!o.done;o=i.next()){var s=o.value,a=Object(jt.__read)(s.split("="),2),u=a[0],c=a[1],f=void 0===c?null:c;u=decodeURIComponent(u),f&&(f=decodeURIComponent(f)),u in r?Array.isArray(r[u])?r[u].push(f):r[u]=[r[u],f]:r[u]=f}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(a)),{hostname:r,port:o?parseInt(o):void 0,protocol:s,path:i,query:t}},vr={apiVersion:"2016-12-01",disableHostPrefix:!1,logger:{},regionInfoProvider:function(e,t){var n=void 0;switch(e){case"ap-northeast-1":n={hostname:"pinpoint.ap-northeast-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-northeast-2":n={hostname:"pinpoint.ap-northeast-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-south-1":n={hostname:"pinpoint.ap-south-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-southeast-1":n={hostname:"pinpoint.ap-southeast-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ap-southeast-2":n={hostname:"pinpoint.ap-southeast-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"ca-central-1":n={hostname:"pinpoint.ca-central-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-central-1":n={hostname:"pinpoint.eu-central-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-west-1":n={hostname:"pinpoint.eu-west-1.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"eu-west-2":n={hostname:"pinpoint.eu-west-2.amazonaws.com",partition:"aws",signingService:"mobiletargeting"};break;case"fips-us-east-1":n={hostname:"pinpoint-fips.us-east-1.amazonaws.com",partition:"aws",signingRegion:"us-east-1"};break;case"fips-us-gov-west-1":n={hostname:"pinpoint-fips.us-gov-west-1.amazonaws.com",partition:"aws-us-gov",signingRegion:"us-gov-west-1"};break;case"fips-us-west-2":n={hostname:"pinpoint-fips.us-west-2.amazonaws.com",partition:"aws",signingRegion:"us-west-2"};break;case"us-east-1":n={hostname:"pinpoint.us-east-1.amazonaws.com",partition:"aws",signingRegion:"us-east-1"};break;case"us-gov-west-1":n={hostname:"pinpoint.us-gov-west-1.amazonaws.com",partition:"aws-us-gov",signingRegion:"us-gov-west-1"};break;case"us-west-2":n={hostname:"pinpoint.us-west-2.amazonaws.com",partition:"aws",signingRegion:"us-west-2"};break;default:cr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws",signingService:"mobiletargeting"}),fr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com.cn".replace("{region}",e),partition:"aws-cn"}),lr.has(e)&&(n={hostname:"pinpoint.{region}.c2s.ic.gov".replace("{region}",e),partition:"aws-iso"}),dr.has(e)&&(n={hostname:"pinpoint.{region}.sc2s.sgov.gov".replace("{region}",e),partition:"aws-iso-b"}),pr.has(e)&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws-us-gov",signingService:"mobiletargeting"}),void 0===n&&(n={hostname:"pinpoint.{region}.amazonaws.com".replace("{region}",e),partition:"aws",signingService:"mobiletargeting"})}return Promise.resolve(s({signingService:"mobiletargeting"},n))},serviceId:"Pinpoint",urlParser:hr},gr=s(s({},vr),{runtime:"browser",base64Decoder:Bn,base64Encoder:Fn,bodyLengthChecker:ir,credentialDefaultProvider:function(e){return function(){return Promise.reject(new Error("Credential is missing"))}},defaultUserAgentProvider:ar({serviceId:vr.serviceId,clientVersion:kn.version}),maxAttempts:3,region:Vn("Region is missing"),requestHandler:new Rn,sha256:Mn.Sha256,streamCollector:qn,utf8Decoder:ur.fromUtf8,utf8Encoder:ur.toUtf8}),mr=function(e){var t;return Object(jt.__assign)(Object(jt.__assign)({},e),{tls:null===(t=e.tls)||void 0===t||t,endpoint:e.endpoint?yr(e):function(){return br(e)},isCustomEndpoint:!!e.endpoint})},yr=function(e){var t=e.endpoint,n=e.urlParser;if("string"==typeof t){var r=Promise.resolve(n(t));return function(){return r}}if("object"==typeof t){var i=Promise.resolve(t);return function(){return i}}return t},br=function(e){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var t,n,r,i,o;return Object(jt.__generator)(this,(function(s){switch(s.label){case 0:return t=e.tls,n=void 0===t||t,[4,e.region()];case 1:if(r=s.sent(),!new RegExp(/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/).test(r))throw new Error("Invalid region in client config");return[4,e.regionInfoProvider(r)];case 2:if(!(i=(null!==(o=s.sent())&&void 0!==o?o:{}).hostname))throw new Error("Cannot resolve hostname from client config");return[2,e.urlParser((n?"https:":"http:")+"//"+i)]}}))}))},wr=function(e){if(!e.region)throw new Error("Region is missing");return Object(jt.__assign)(Object(jt.__assign)({},e),{region:_r(e.region)})},_r=function(e){if("string"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};var Sr={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:!0},Er=function(e){return{applyToStack:function(t){t.add(function(e){var t=this;return function(n){return function(r){return Object(jt.__awaiter)(t,void 0,void 0,(function(){var t,i,o,s,a;return Object(jt.__generator)(this,(function(u){return t=r.request,Ct.isInstance(t)&&(i=t.body,o=t.headers,i&&-1===Object.keys(o).map((function(e){return e.toLowerCase()})).indexOf("content-length")&&void 0!==(s=e(i))&&(t.headers=Object(jt.__assign)(Object(jt.__assign)({},t.headers),((a={})["content-length"]=String(s),a)))),[2,n(Object(jt.__assign)(Object(jt.__assign)({},r),{request:t}))]}))}))}}}(e.bodyLengthChecker),Sr)}}};for(var Ar={name:"hostHeaderMiddleware",step:"build",priority:"low",tags:["HOST"],override:!0},Or=function(e){return{applyToStack:function(t){t.add(function(e){return function(t){return function(n){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var r,i;return Object(jt.__generator)(this,(function(o){return Ct.isInstance(n.request)?(r=n.request,i=(e.requestHandler.metadata||{}).handlerProtocol,(void 0===i?"":i).indexOf("h2")>=0&&!r.headers[":authority"]?(delete r.headers.host,r.headers[":authority"]=""):r.headers.host||(r.headers.host=r.hostname),[2,t(n)]):[2,t(n)]}))}))}}}(e),Ar)}}},Ir={name:"loggerMiddleware",tags:["LOGGER"],step:"initialize",override:!0},Lr=function(e){return{applyToStack:function(e){e.add((function(e,t){return function(n){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var r,i,o,s,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return r=t.clientName,i=t.commandName,o=t.inputFilterSensitiveLog,s=t.logger,a=t.outputFilterSensitiveLog,[4,e(n)];case 1:return u=d.sent(),s?("function"==typeof s.info&&(c=u.output,f=c.$metadata,l=Object(jt.__rest)(c,["$metadata"]),s.info({clientName:r,commandName:i,input:o(n.input),output:a(l),metadata:f})),[2,u]):[2,u]}}))}))}}),Ir)}}},kr={},Mr={},Pr=0;Pr<256;Pr++){var xr=Pr.toString(16).toLowerCase();1===xr.length&&(xr="0"+xr),kr[Pr]=xr,Mr[xr]=Pr}function Rr(e){for(var t="",n=0;n<e.byteLength;n++)t+=kr[e[n]];return t}var Tr="X-Amz-Date".toLowerCase(),jr=["authorization",Tr,"date"],Cr="X-Amz-Signature".toLowerCase(),Dr="X-Amz-Security-Token".toLowerCase(),Nr={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},Ur=/^proxy-/,zr=/^sec-/,Br="AWS4-HMAC-SHA256-PAYLOAD",Fr={},qr=[];function Kr(e,t,n){return e+"/"+t+"/"+n+"/aws4_request"}function Vr(e,t,n){var r=new e(t);return r.update(n),r.digest()}function Hr(e,t,n){var r,i,o=e.headers,s={};try{for(var a=Object(jt.__values)(Object.keys(o).sort()),u=a.next();!u.done;u=a.next()){var c=u.value,f=c.toLowerCase();(f in Nr||(null==t?void 0:t.has(f))||Ur.test(f)||zr.test(f))&&(!n||n&&!n.has(f))||(s[f]=o[c].trim().replace(/\s+/g," "))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return s}var Gr=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,$r)},$r=function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()};function Wr(e,t){var n=e.headers,r=e.body;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e,i,o,s,a,u,c;return Object(jt.__generator)(this,(function(f){switch(f.label){case 0:try{for(e=Object(jt.__values)(Object.keys(n)),i=e.next();!i.done;i=e.next())if("x-amz-content-sha256"===(o=i.value).toLowerCase())return[2,n[o]]}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}}return null!=r?[3,1]:[2,"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"];case 1:return"string"==typeof r||ArrayBuffer.isView(r)||(l=r,"function"==typeof ArrayBuffer&&l instanceof ArrayBuffer||"[object ArrayBuffer]"===Object.prototype.toString.call(l))?((s=new t).update(r),a=Rr,[4,s.digest()]):[3,3];case 2:return[2,a.apply(void 0,[f.sent()])];case 3:return[2,"UNSIGNED-PAYLOAD"]}var l}))}))}function Yr(e){var t=e.headers,n=e.query,r=Object(jt.__rest)(e,["headers","query"]);return Object(jt.__assign)(Object(jt.__assign)({},r),{headers:Object(jt.__assign)({},t),query:n?Zr(n):void 0})}function Zr(e){return Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object(jt.__assign)(Object(jt.__assign)({},t),((r={})[n]=Array.isArray(i)?Object(jt.__spread)(i):i,r))}),{})}function Jr(e){var t,n;e="function"==typeof e.clone?e.clone():Yr(e);try{for(var r=Object(jt.__values)(Object.keys(e.headers)),i=r.next();!i.done;i=r.next()){var o=i.value;jr.indexOf(o.toLowerCase())>-1&&delete e.headers[o]}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return e}function Qr(e){return function(e){if("number"==typeof e)return new Date(1e3*e);if("string"==typeof e)return Number(e)?new Date(1e3*Number(e)):new Date(e);return e}(e).toISOString().replace(/\.\d{3}Z$/,"Z")}var Xr=function(){function e(e){var t=e.applyChecksum,n=e.credentials,r=e.region,i=e.service,o=e.sha256,s=e.uriEscapePath,a=void 0===s||s;this.service=i,this.sha256=o,this.uriEscapePath=a,this.applyChecksum="boolean"!=typeof t||t,this.regionProvider=ni(r),this.credentialProvider=ri(n)}return e.prototype.presign=function(e,t){return void 0===t&&(t={}),Object(jt.__awaiter)(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c,f,l,d,p,h,v,g,m,y,b,w,_,S,E,A,O;return Object(jt.__generator)(this,(function(I){switch(I.label){case 0:return n=t.signingDate,r=void 0===n?new Date:n,i=t.expiresIn,o=void 0===i?3600:i,s=t.unsignableHeaders,a=t.unhoistableHeaders,u=t.signableHeaders,c=t.signingRegion,f=t.signingService,[4,this.credentialProvider()];case 1:return l=I.sent(),null==c?[3,2]:(p=c,[3,4]);case 2:return[4,this.regionProvider()];case 3:p=I.sent(),I.label=4;case 4:return d=p,h=ei(r),v=h.longDate,g=h.shortDate,o>604800?[2,Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future")]:(m=Kr(g,d,null!=f?f:this.service),y=function(e,t){var n,r,i;void 0===t&&(t={});var o="function"==typeof e.clone?e.clone():Yr(e),s=o.headers,a=o.query,u=void 0===a?{}:a;try{for(var c=Object(jt.__values)(Object.keys(s)),f=c.next();!f.done;f=c.next()){var l=f.value,d=l.toLowerCase();"x-amz-"!==d.substr(0,6)||(null===(i=t.unhoistableHeaders)||void 0===i?void 0:i.has(d))||(u[l]=s[l],delete s[l])}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return Object(jt.__assign)(Object(jt.__assign)({},e),{headers:s,query:u})}(Jr(e),{unhoistableHeaders:a}),l.sessionToken&&(y.query["X-Amz-Security-Token"]=l.sessionToken),y.query["X-Amz-Algorithm"]="AWS4-HMAC-SHA256",y.query["X-Amz-Credential"]=l.accessKeyId+"/"+m,y.query["X-Amz-Date"]=v,y.query["X-Amz-Expires"]=o.toString(10),b=Hr(y,s,u),y.query["X-Amz-SignedHeaders"]=ti(b),w=y.query,_="X-Amz-Signature",S=this.getSignature,E=[v,m,this.getSigningKey(l,d,g,f)],A=this.createCanonicalRequest,O=[y,b],[4,Wr(e,this.sha256)]);case 5:return[4,S.apply(this,E.concat([A.apply(this,O.concat([I.sent()]))]))];case 6:return w[_]=I.sent(),[2,y]}}))}))},e.prototype.sign=function(e,t){return Object(jt.__awaiter)(this,void 0,void 0,(function(){return Object(jt.__generator)(this,(function(n){return"string"==typeof e?[2,this.signString(e,t)]:e.headers&&e.payload?[2,this.signEvent(e,t)]:[2,this.signRequest(e,t)]}))}))},e.prototype.signEvent=function(e,t){var n=e.headers,r=e.payload,i=t.signingDate,o=void 0===i?new Date:i,s=t.priorSignature,a=t.signingRegion,u=t.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var e,t,i,c,f,l,d,p,h,v,g;return Object(jt.__generator)(this,(function(m){switch(m.label){case 0:return null==a?[3,1]:(t=a,[3,3]);case 1:return[4,this.regionProvider()];case 2:t=m.sent(),m.label=3;case 3:return e=t,i=ei(o),c=i.shortDate,f=i.longDate,l=Kr(c,e,null!=u?u:this.service),[4,Wr({headers:{},body:r},this.sha256)];case 4:return d=m.sent(),(p=new this.sha256).update(n),v=Rr,[4,p.digest()];case 5:return h=v.apply(void 0,[m.sent()]),g=[Br,f,l,s,h,d].join("\n"),[2,this.signString(g,{signingDate:o,signingRegion:e,signingService:u})]}}))}))},e.prototype.signString=function(e,t){var n=void 0===t?{}:t,r=n.signingDate,i=void 0===r?new Date:r,o=n.signingRegion,s=n.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return[4,this.credentialProvider()];case 1:return t=d.sent(),null==o?[3,2]:(r=o,[3,4]);case 2:return[4,this.regionProvider()];case 3:r=d.sent(),d.label=4;case 4:return n=r,a=ei(i).shortDate,f=(c=this.sha256).bind,[4,this.getSigningKey(t,n,a,s)];case 5:return(u=new(f.apply(c,[void 0,d.sent()]))).update(e),l=Rr,[4,u.digest()];case 6:return[2,l.apply(void 0,[d.sent()])]}}))}))},e.prototype.signRequest=function(e,t){var n=void 0===t?{}:t,r=n.signingDate,i=void 0===r?new Date:r,o=n.signableHeaders,s=n.unsignableHeaders,a=n.signingRegion,u=n.signingService;return Object(jt.__awaiter)(this,void 0,void 0,(function(){var t,n,r,c,f,l,d,p,h,v,g;return Object(jt.__generator)(this,(function(m){switch(m.label){case 0:return[4,this.credentialProvider()];case 1:return t=m.sent(),null==a?[3,2]:(r=a,[3,4]);case 2:return[4,this.regionProvider()];case 3:r=m.sent(),m.label=4;case 4:return n=r,c=Jr(e),f=ei(i),l=f.longDate,d=f.shortDate,p=Kr(d,n,null!=u?u:this.service),c.headers[Tr]=l,t.sessionToken&&(c.headers[Dr]=t.sessionToken),[4,Wr(c,this.sha256)];case 5:return h=m.sent(),!function(e,t){var n,r;e=e.toLowerCase();try{for(var i=Object(jt.__values)(Object.keys(t)),o=i.next();!o.done;o=i.next()){if(e===o.value.toLowerCase())return!0}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!1}("x-amz-content-sha256",c.headers)&&this.applyChecksum&&(c.headers["x-amz-content-sha256"]=h),v=Hr(c,s,o),[4,this.getSignature(l,p,this.getSigningKey(t,n,d,u),this.createCanonicalRequest(c,v,h))];case 6:return g=m.sent(),c.headers.authorization="AWS4-HMAC-SHA256 Credential="+t.accessKeyId+"/"+p+", SignedHeaders="+ti(v)+", Signature="+g,[2,c]}}))}))},e.prototype.createCanonicalRequest=function(e,t,n){var r=Object.keys(t).sort();return e.method+"\n"+this.getCanonicalPath(e)+"\n"+function(e){var t,n,r=e.query,i=void 0===r?{}:r,o=[],s={},a=function(e){if(e.toLowerCase()===Cr)return"continue";o.push(e);var t=i[e];"string"==typeof t?s[e]=Gr(e)+"="+Gr(t):Array.isArray(t)&&(s[e]=t.slice(0).sort().reduce((function(t,n){return t.concat([Gr(e)+"="+Gr(n)])}),[]).join("&"))};try{for(var u=Object(jt.__values)(Object.keys(i).sort()),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return o.map((function(e){return s[e]})).filter((function(e){return e})).join("&")}(e)+"\n"+r.map((function(e){return e+":"+t[e]})).join("\n")+"\n\n"+r.join(";")+"\n"+n},e.prototype.createStringToSign=function(e,t,n){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var r,i;return Object(jt.__generator)(this,(function(o){switch(o.label){case 0:return(r=new this.sha256).update(n),[4,r.digest()];case 1:return i=o.sent(),[2,"AWS4-HMAC-SHA256\n"+e+"\n"+t+"\n"+Rr(i)]}}))}))},e.prototype.getCanonicalPath=function(e){var t=e.path;return this.uriEscapePath?"/"+encodeURIComponent(t.replace(/^\//,"")).replace(/%2F/g,"/"):t},e.prototype.getSignature=function(e,t,n,r){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var i,o,s,a,u;return Object(jt.__generator)(this,(function(c){switch(c.label){case 0:return[4,this.createStringToSign(e,t,r)];case 1:return i=c.sent(),a=(s=this.sha256).bind,[4,n];case 2:return(o=new(a.apply(s,[void 0,c.sent()]))).update(i),u=Rr,[4,o.digest()];case 3:return[2,u.apply(void 0,[c.sent()])]}}))}))},e.prototype.getSigningKey=function(e,t,n,r){return function(e,t,n,r,i){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var o,s,a,u,c,f,l,d,p;return Object(jt.__generator)(this,(function(h){switch(h.label){case 0:return[4,Vr(e,t.secretAccessKey,t.accessKeyId)];case 1:if(o=h.sent(),(s=n+":"+r+":"+i+":"+Rr(o)+":"+t.sessionToken)in Fr)return[2,Fr[s]];for(qr.push(s);qr.length>50;)delete Fr[qr.shift()];a="AWS4"+t.secretAccessKey,h.label=2;case 2:h.trys.push([2,7,8,9]),u=Object(jt.__values)([n,r,i,"aws4_request"]),c=u.next(),h.label=3;case 3:return c.done?[3,6]:(f=c.value,[4,Vr(e,a,f)]);case 4:a=h.sent(),h.label=5;case 5:return c=u.next(),[3,3];case 6:return[3,9];case 7:return l=h.sent(),d={error:l},[3,9];case 8:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(d)throw d.error}return[7];case 9:return[2,Fr[s]=a]}}))}))}(this.sha256,e,n,t,r||this.service)},e}(),ei=function(e){var t=Qr(e).replace(/[\-:]/g,"");return{longDate:t,shortDate:t.substr(0,8)}},ti=function(e){return Object.keys(e).sort().join(";")},ni=function(e){if("string"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e},ri=function(e){if("object"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e};function ii(e){var t,n=this,r=oi(e.credentials||e.credentialDefaultProvider(e)),i=e.signingEscapePath,o=void 0===i||i,s=e.systemClockOffset,a=void 0===s?e.systemClockOffset||0:s,u=e.sha256;return t=e.signer?oi(e.signer):function(){return oi(e.region)().then((function(t){return Object(jt.__awaiter)(n,void 0,void 0,(function(){return Object(jt.__generator)(this,(function(n){switch(n.label){case 0:return[4,e.regionInfoProvider(t)];case 1:return[2,[n.sent()||{},t]]}}))}))})).then((function(t){var n=Object(jt.__read)(t,2),i=n[0],s=n[1],a=i.signingRegion,c=i.signingService;return e.signingRegion=e.signingRegion||a||s,e.signingName=e.signingName||c||e.serviceId,new Xr({credentials:r,region:e.signingRegion,service:e.signingName,sha256:u,uriEscapePath:o})}))},Object(jt.__assign)(Object(jt.__assign)({},e),{systemClockOffset:a,signingEscapePath:o,credentials:r,signer:t})}function oi(e){if("object"==typeof e){var t=Promise.resolve(e);return function(){return t}}return e}var si=function(e){return new Date(Date.now()+e)};function ai(e){return function(t,n){return function(r){return Object(jt.__awaiter)(this,void 0,void 0,(function(){var i,o,s,a,u,c,f,l,d;return Object(jt.__generator)(this,(function(p){switch(p.label){case 0:return Ct.isInstance(r.request)?"function"!=typeof e.signer?[3,2]:[4,e.signer()]:[2,t(r)];case 1:return o=p.sent(),[3,3];case 2:o=e.signer,p.label=3;case 3:return i=o,a=t,u=[Object(jt.__assign)({},r)],d={},[4,i.sign(r.request,{signingDate:new Date(Date.now()+e.systemClockOffset),signingRegion:n.signing_region,signingService:n.signing_service})];case 4:return[4,a.apply(void 0,[jt.__assign.apply(void 0,u.concat([(d.request=p.sent(),d)]))])];case 5:return s=p.sent(),c=s.response.headers,(f=c&&(c.date||c.Date))&&(l=Date.parse(f),h=l,v=e.systemClockOffset,Math.abs(si(v).getTime()-h)>=3e5&&(e.systemClockOffset=l-Date.now())),[2,s]}var h,v}))}))}}}var ui={name:"awsAuthMiddleware",tags:["SIGNATURE","AWSAUTH"],relation:"after",toMiddleware:"retryMiddleware",override:!0},ci=function(e){return{applyToStack:function(t){t.addRelativeTo(ai(e),ui)}}};function fi(e){return Object(jt.__assign)(Object(jt.__assign)({},e),{customUserAgent:"string"==typeof e.customUserAgent?[[e.customUserAgent]]:e.customUserAgent})}var li=/[^\!\#\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g,di=function(e){var t=Object(jt.__read)(e,2),n=t[0],r=t[1],i=n.indexOf("/"),o=n.substring(0,i),s=n.substring(i+1);return"api"===o&&(s=s.toLowerCase()),[o,s,r].filter((function(e){return e&&e.length>0})).map((function(e){return null==e?void 0:e.replace(li,"_")})).join("/")},pi={name:"getUserAgentMiddleware",step:"build",priority:"low",tags:["SET_USER_AGENT","USER_AGENT"],override:!0},hi=function(e){return{applyToStack:function(t){var n;t.add((n=e,function(e,t){return function(r){return Object(jt.__awaiter)(void 0,void 0,void 0,(function(){var i,o,s,a,u,c,f,l;return Object(jt.__generator)(this,(function(d){switch(d.label){case 0:return i=r.request,Ct.isInstance(i)?(o=i.headers,s=(null===(f=null==t?void 0:t.userAgent)||void 0===f?void 0:f.map(di))||[],[4,n.defaultUserAgentProvider()]):[2,e(r)];case 1:return a=d.sent().map(di),u=(null===(l=null==n?void 0:n.customUserAgent)||void 0===l?void 0:l.map(di))||[],o["x-amz-user-agent"]=Object(jt.__spread)(a,s,u).join(" "),c=Object(jt.__spread)(a.filter((function(e){return e.startsWith("aws-sdk-")})),u).join(" "),"browser"!==n.runtime&&c&&(o["user-agent"]=o["user-agent"]?o["user-agent"]+" "+c:c),[2,e(Object(jt.__assign)(Object(jt.__assign)({},r),{request:i}))]}}))}))}}),pi)}}},vi=function(e){function t(t){var n=this,r=s(s({},gr),t),i=wr(r),o=ii(mr(i)),a=fi(nr(o));return(n=e.call(this,a)||this).config=a,n.middlewareStack.use(ci(n.config)),n.middlewareStack.use(Gn(n.config)),n.middlewareStack.use(Er(n.config)),n.middlewareStack.use(Or(n.config)),n.middlewareStack.use(Lr(n.config)),n.middlewareStack.use(hi(n.config)),n}return o(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this)},t}(zt),gi=n(9),mi=n.n(gi),yi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},bi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},wi=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},_i=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(wi(arguments[t]));return e},Si=new r.ConsoleLogger("EventsBuffer"),Ei=[429,500],Ai=[202],Oi=function(){function e(e,t){this._pause=!1,this._flush=!1,Si.debug("Instantiating buffer with config:",t),this._buffer=[],this._client=e,this._config=t,this._sendBatch=this._sendBatch.bind(this),this._startLoop()}return e.prototype.push=function(e){var t;if(this._buffer>this._config.bufferSize)return Si.debug("Exceeded analytics events buffer size"),e.handlers.reject(new Error("Exceeded the size of analytics events buffer"));var n=((t={})[e.params.event.eventId]=e,t);this._buffer.push(n)},e.prototype.pause=function(){this._pause=!0},e.prototype.resume=function(){this._pause=!1},e.prototype.updateClient=function(e){this._client=e},e.prototype.flush=function(){this._flush=!0},e.prototype._startLoop=function(){this._interval&&clearInterval(this._interval);var e=this._config.flushInterval;this._interval=setInterval(this._sendBatch,e)},e.prototype._sendBatch=function(){var e=this._buffer.length;if(this._flush&&!e&&clearInterval(this._interval),!this._pause&&e){var t=this._config.flushSize,n=Math.min(t,e),r=this._buffer.splice(0,n);this._putEvents(r)}},e.prototype._putEvents=function(e){return yi(this,void 0,void 0,(function(){var t,n,r,i,o;return bi(this,(function(s){switch(s.label){case 0:t=this._bufferToMap(e),n=this._generateBatchEventParams(t),s.label=1;case 1:return s.trys.push([1,3,,4]),r=new In(n),[4,this._client.send(r)];case 2:return i=s.sent(),this._processPutEventsSuccessResponse(i,t),[3,4];case 3:return o=s.sent(),[2,this._handlePutEventsFailure(o,t)];case 4:return[2]}}))}))},e.prototype._generateBatchEventParams=function(e){var t={ApplicationId:"",EventsRequest:{BatchItem:{}}};return Object.values(e).forEach((function(e){var n=e.params,r=n.event,i=n.timestamp,o=n.config,s=r.name,a=r.attributes,u=r.metrics,c=r.eventId,f=r.session,l=o.appId,d=o.endpointId,p=t.EventsRequest.BatchItem;t.ApplicationId=t.ApplicationId||l,p[d]||(p[d]={Endpoint:{},Events:{}}),p[d].Events[c]={EventType:s,Timestamp:new Date(i).toISOString(),Attributes:a,Metrics:u,Session:f}})),t},e.prototype._handlePutEventsFailure=function(e,t){Si.debug("_putEvents Failed: ",e);var n=e.$metadata&&e.$metadata.httpStatusCode;if(Ei.includes(n)){var r=Object.values(t);this._retry(r)}else;},e.prototype._processPutEventsSuccessResponse=function(e,t){var n=e.EventsResponse.Results,r=[];Object.entries(n).forEach((function(e){var n=wi(e,2),i=n[0],o=n[1].EventsItemResponse;Object.entries(o).forEach((function(e){var n,o,s=wi(e,2),a=s[0],u=s[1],c=u.StatusCode,f=u.Message,l=t[a],d={EventsResponse:{Results:(n={},n[i]={EventsItemResponse:(o={},o[a]={StatusCode:c,Message:f},o)},n)}};if(Ai.includes(c))l.handlers.resolve(d);else{if(!Ei.includes(c)){var p=l.params.event.name;return Si.error("event "+a+" : "+p+" failed with error: "+f),l.handlers.reject(d)}r.push(l)}}))})),r.length&&this._retry(r)},e.prototype._retry=function(e){var t,n=[];e.forEach((function(e){var t,r=e.params,i=r.event,o=i.eventId,s=i.name;if(r.resendLimit-- >0)return Si.debug("resending event "+o+" : "+s+" with "+r.resendLimit+" retry attempts remaining"),void n.push((t={},t[o]=e,t));Si.debug("no retry attempts remaining for event "+o+" : "+s)})),(t=this._buffer).unshift.apply(t,_i(n))},e.prototype._bufferToMap=function(e){return e.reduce((function(e,t){var n=wi(Object.entries(t),1),r=wi(n[0],2),i=r[0],o=r[1];return e[i]=o,e}),{})},e}();function Ii(e){return(Ii="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)}var Li=function(){return(Li=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ki=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Mi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},Pi=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},xi="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",Ri=function(e,t){r.Hub.dispatch("analytics",{event:e,data:t},"Analytics",xi)},Ti=new r.ConsoleLogger("AWSPinpointProvider"),ji=[429,500],Ci=[202],Di="undefined"!=typeof navigator&&navigator&&"function"==typeof navigator.sendBeacon,Ni=function(){function e(e){this._endpointGenerating=!0,this._endpointUpdateInProgress=!1,this._buffer=null,this._endpointBuffer=[],this._config=e||{},this._config.bufferSize=this._config.bufferSize||1e3,this._config.flushSize=this._config.flushSize||100,this._config.flushInterval=this._config.flushInterval||5e3,this._config.resendLimit=this._config.resendLimit||5,this._clientInfo=r.ClientDevice.clientInfo()}return e.prototype.getCategory=function(){return e.category},e.prototype.getProviderName=function(){return e.providerName},e.prototype.configure=function(e){var t=this;Ti.debug("configure Analytics",e);var n=e||{};if(this._config=Object.assign({},this._config,n),this._endpointGenerating=!!e.autoSessionRecord,this._config.appId&&!this._config.disabled)if(this._config.endpointId)Ri("pinpointProvider_configured",null);else{var r=this.getProviderName()+"_"+this._config.appId;this._getEndpointId(r).then((function(e){Ti.debug("setting endpoint id from the cache",e),t._config.endpointId=e,Ri("pinpointProvider_configured",null)})).catch((function(e){Ti.debug("Failed to generate endpointId",e)}))}else this._flushBuffer();return this._config},e.prototype.record=function(e,t){return ki(this,void 0,void 0,(function(){var n,r;return Mi(this,(function(i){switch(i.label){case 0:return Ti.debug("_public record",e),[4,this._getCredentials()];case 1:return(n=i.sent())&&this._config.appId&&this._config.region?(this._initClients(n),r=(new Date).getTime(),this._generateSession(e),e.event.eventId=Object(Qn.v1)(),Object.assign(e,{timestamp:r,config:this._config}),e.event.immediate?[2,this._send(e,t)]:(this._putToBuffer(e,t),[2])):(Ti.debug("cannot send events without credentials, applicationId or region"),[2,t.reject(new Error("No credentials, applicationId or region"))])}}))}))},e.prototype._sendEndpointUpdate=function(e){return ki(this,void 0,void 0,(function(){var t;return Mi(this,(function(n){switch(n.label){case 0:return this._endpointUpdateInProgress?(this._endpointBuffer.push(e),[2]):(this._endpointUpdateInProgress=!0,[4,this._updateEndpoint(e)]);case 1:return n.sent(),t=this._endpointBuffer.shift(),this._endpointUpdateInProgress=!1,t&&this._sendEndpointUpdate(t),[2]}}))}))},e.prototype._putToBuffer=function(e,t){"_update_endpoint"!==e.event.name?this._buffer&&this._buffer.push({params:e,handlers:t}):this._sendEndpointUpdate({params:e,handlers:t})},e.prototype._generateSession=function(e){this._sessionId=this._sessionId||Object(Qn.v1)();var t=e.event;switch(t.name){case"_session.start":this._sessionStartTimestamp=(new Date).getTime(),this._sessionId=Object(Qn.v1)(),t.session={Id:this._sessionId,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString()};break;case"_session.stop":var n=(new Date).getTime();this._sessionStartTimestamp=this._sessionStartTimestamp||(new Date).getTime(),this._sessionId=this._sessionId||Object(Qn.v1)(),t.session={Id:this._sessionId,Duration:n-this._sessionStartTimestamp,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString(),StopTimestamp:new Date(n).toISOString()},this._sessionId=void 0,this._sessionStartTimestamp=void 0;break;default:this._sessionStartTimestamp=this._sessionStartTimestamp||(new Date).getTime(),this._sessionId=this._sessionId||Object(Qn.v1)(),t.session={Id:this._sessionId,StartTimestamp:new Date(this._sessionStartTimestamp).toISOString()}}},e.prototype._send=function(e,t){return ki(this,void 0,void 0,(function(){return Mi(this,(function(n){switch(e.event.name){case"_update_endpoint":return[2,this._updateEndpoint({params:e,handlers:t})];case"_session.stop":return[2,this._pinpointSendStopSession(e,t)];default:return[2,this._pinpointPutEvents(e,t)]}return[2]}))}))},e.prototype._generateBatchItemContext=function(e){var t,n=e.event,r=e.timestamp,i=e.config,o=n.name,s=n.attributes,a=n.metrics,u=n.eventId,c=n.session,f=i.appId,l=i.endpointId,d={ApplicationId:f,EventsRequest:{BatchItem:{}}},p={Endpoint:{}};return p.Events=((t={})[u]={EventType:o,Timestamp:new Date(r).toISOString(),Attributes:s,Metrics:a,Session:c},t),d.EventsRequest.BatchItem[l]=p,d},e.prototype._pinpointPutEvents=function(e,t){return ki(this,void 0,void 0,(function(){var n,r,i,o,s,a,u,c,f,l,d;return Mi(this,(function(p){switch(p.label){case 0:n=e.event.eventId,r=e.config.endpointId,i=this._generateBatchItemContext(e),o=new In(i),p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.pinpointClient.send(o)];case 2:return s=p.sent(),a=r,u=n,c=s.EventsResponse.Results[a].EventsItemResponse[u],f=c.StatusCode,l=c.Message,Ci.includes(f)?(Ti.debug("record event success. ",s),[2,t.resolve(s)]):ji.includes(f)?(this._retry(e,t),[3,4]):(Ti.error("Event "+n+" is not accepted, the error is "+l),[2,t.reject(s)]);case 3:return d=p.sent(),this._eventError(d),[2,t.reject(d)];case 4:return[2]}}))}))},e.prototype._pinpointSendStopSession=function(e,t){if(Di){var n=this._generateBatchItemContext(e),i=this._config.region,o=n.ApplicationId,s=n.EventsRequest,a={secret_key:this._config.credentials.secretAccessKey,access_key:this._config.credentials.accessKeyId,session_token:this._config.credentials.sessionToken},u="https://pinpoint."+i+".amazonaws.com/v1/apps/"+o+"/events/legacy",c=JSON.stringify(s),f={url:u,body:c,method:"POST"},l={region:i,service:"mobiletargeting"},d=r.Signer.signUrl(f,a,l,null);return navigator.sendBeacon(d,c)?t.resolve("sendBeacon success"):t.reject("sendBeacon failure")}this._pinpointPutEvents(e,t)},e.prototype._retry=function(e,t){var n=e.config.resendLimit;e.resendLimit="number"==typeof e.resendLimit?e.resendLimit:n,e.resendLimit-- >0?(Ti.debug("resending event "+e.eventName+" with "+e.resendLimit+" retry times left"),this._pinpointPutEvents(e,t)):Ti.debug("retry times used up for event "+e.eventName)},e.prototype._updateEndpoint=function(e){return ki(this,void 0,void 0,(function(){var t,n,i,o,s,a,u,c,f,l,d,p;return Mi(this,(function(h){switch(h.label){case 0:t=e.params,n=e.handlers,i=t.config,o=t.event,s=i.appId,a=i.endpointId,u=this._endpointRequest(i,r.JS.transferKeyToLowerCase(o,[],["attributes","userAttributes","Attributes","UserAttributes"])),c={ApplicationId:s,EndpointId:a,EndpointRequest:u},h.label=1;case 1:return h.trys.push([1,3,,4]),f=new Ln(c),[4,this.pinpointClient.send(f)];case 2:return l=h.sent(),Ti.debug("updateEndpoint success",l),this._endpointGenerating=!1,this._resumeBuffer(),n.resolve(l),[2];case 3:return d=h.sent(),p={err:d,update_params:c,endpointObject:e},[2,this._handleEndpointUpdateFailure(p)];case 4:return[2]}}))}))},e.prototype._handleEndpointUpdateFailure=function(e){return ki(this,void 0,void 0,(function(){var t,n,r;return Mi(this,(function(i){switch(t=e.err,n=e.endpointObject,r=t.$metadata&&t.$metadata.httpStatusCode,Ti.debug("updateEndpoint error",t),r){case 403:return[2,this._handleEndpointUpdateForbidden(e)];default:if(ji.includes(r))return!0,[2,this._retryEndpointUpdate(n,!0)];Ti.error("updateEndpoint failed",t),n.handlers.reject(t)}return[2]}))}))},e.prototype._handleEndpointUpdateForbidden=function(e){var t=e.err,n=e.endpointObject,r=t.code,i=t.retryable;if("ExpiredTokenException"!==r&&!i)return n.handlers.reject(t);this._retryEndpointUpdate(n)},e.prototype._retryEndpointUpdate=function(e,t){void 0===t&&(t=!1),Ti.debug("_retryEndpointUpdate",e);var n=e.params,r=n.config.resendLimit;if(n.resendLimit="number"==typeof n.resendLimit?n.resendLimit:r,n.resendLimit-- >0)return Ti.debug("resending endpoint update "+n.event.eventId+" with "+n.resendLimit+" retry attempts remaining"),void(this._endpointBuffer.length?this._endpointBuffer.unshift(e):this._updateEndpoint(e));Ti.warn("resending endpoint update "+n.event.eventId+" failed after "+n.config.resendLimit+" attempts"),this._endpointGenerating&&Ti.error("Initial endpoint update failed. ")},e.prototype._initClients=function(e){return ki(this,void 0,void 0,(function(){var t,n;return Mi(this,(function(i){return Ti.debug("init clients"),this.pinpointClient&&this._config.credentials&&this._config.credentials.sessionToken===e.sessionToken&&this._config.credentials.identityId===e.identityId?(Ti.debug("no change for aws credentials, directly return from init"),[2]):(t=this._config.credentials?this._config.credentials.identityId:null,this._config.credentials=e,n=this._config.region,Ti.debug("init clients with credentials",e),this.pinpointClient=new vi({region:n,credentials:e,customUserAgent:Object(r.getAmplifyUserAgent)()}),this.pinpointClient.middlewareStack.addRelativeTo((function(e){return function(t){return delete t.request.headers["amz-sdk-invocation-id"],delete t.request.headers["amz-sdk-request"],e(t)}}),{step:"finalizeRequest",relation:"after",toMiddleware:"retryMiddleware"}),this._bufferExists()&&t===e.identityId?this._updateBufferClient():this._initBuffer(),this._customizePinpointClientReq(),[2])}))}))},e.prototype._bufferExists=function(){return this._buffer&&this._buffer instanceof Oi},e.prototype._initBuffer=function(){this._bufferExists()&&this._flushBuffer(),this._buffer=new Oi(this.pinpointClient,this._config),this._endpointGenerating&&this._buffer.pause()},e.prototype._updateBufferClient=function(){this._bufferExists()&&this._buffer.updateClient(this.pinpointClient)},e.prototype._flushBuffer=function(){this._bufferExists()&&(this._buffer.flush(),this._buffer=null)},e.prototype._resumeBuffer=function(){this._bufferExists()&&this._buffer.resume()},e.prototype._customizePinpointClientReq=function(){},e.prototype._getEndpointId=function(e){return ki(this,void 0,void 0,(function(){var t,n;return Mi(this,(function(r){switch(r.label){case 0:return[4,mi.a.getItem(e)];case 1:return t=r.sent(),Ti.debug("endpointId from cache",t,"type",Ii(t)),t||(t=Object(Qn.v1)(),31536e8,n=(new Date).getTime()+31536e8,mi.a.setItem(e,t,{expires:n,priority:1})),[2,t]}}))}))},e.prototype._endpointRequest=function(e,t){var n=e.credentials,i=this._clientInfo||{},o=e.clientContext||{},s=e.endpoint||{},a={appVersion:i.appVersion,make:i.make,model:i.model,modelVersion:i.version,platform:i.platform},u=(o.clientId,o.appTitle,o.appVersionName,o.appVersionCode,o.appPackageName,Pi(o,["clientId","appTitle","appVersionName","appVersionCode","appPackageName"])),c=t.address?"android"===i.platform?"GCM":"APNS":void 0,f=Li(Li(Li({channelType:c,requestId:Object(Qn.v1)(),effectiveDate:(new Date).toISOString()},s),t),{attributes:Li(Li({},s.attributes),t.attributes),demographic:Li(Li(Li(Li({},a),u),s.demographic),t.demographic),location:Li(Li({},s.location),t.location),metrics:Li(Li({},s.metrics),t.metrics),user:{userId:t.userId||s.userId||n.identityId,userAttributes:Li(Li({},s.userAttributes),t.userAttributes)}}),l=(f.userId,f.userAttributes,f.name,f.session,f.eventId,f.immediate,Pi(f,["userId","userAttributes","name","session","eventId","immediate"]));return r.JS.transferKeyToUpperCase(l,[],["metrics","userAttributes","attributes"])},e.prototype._eventError=function(e){Ti.error("record event failed.",e),Ti.warn('Please ensure you have updated your Pinpoint IAM Policy with the Action: "mobiletargeting:PutEvents" in order to record events')},e.prototype._getCredentials=function(){return ki(this,void 0,void 0,(function(){var e,t;return Mi(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r.Credentials.get()];case 1:return(e=n.sent())?(Ti.debug("set credentials for analytics",e),[2,r.Credentials.shear(e)]):[2,null];case 2:return t=n.sent(),Ti.debug("ensure credentials error",t),[2,null];case 3:return[2]}}))}))},e.category="Analytics",e.providerName="AWSPinpoint",e}(),Ui=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},zi=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ui(arguments[t]));return e},Bi=[],Fi=function(){function e(e,t){this.context=e,this.methodName=t,this._originalMethod=e[t].bind(e)}return e.add=function(e,t,n){qi(e,t).set(n)},e.remove=function(e,t){qi(e,t).remove()},e.prototype.set=function(e){var t=this;this.context[this.methodName]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e(t._originalMethod.apply(t,zi(n)))}},e.prototype.remove=function(){this.context[this.methodName]=this._originalMethod},e}();function qi(e,t){var n=Bi.filter((function(n){return n.context===e&&n.methodName===t}))[0];return n||(n=new Fi(e,t),Bi.push(n)),n}var Ki=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Vi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},Hi=new r.ConsoleLogger("PageViewTracker"),Gi="aws-amplify-analytics-prevUrl",$i={enable:!1,provider:"AWSPinpoint",getUrl:function(){return r.JS.browserOrNode().isBrowser?window.location.origin+window.location.pathname:""}},Wi=function(){function e(e,t){Hi.debug("initialize pageview tracker with opts",t),this._config=Object.assign({},$i,t),this._tracker=e,this._hasEnabled=!1,this._trackFunc=this._trackFunc.bind(this),"SPA"===this._config.type?this._pageViewTrackSPA():this._pageViewTrackDefault()}return e.prototype.configure=function(e){return Object.assign(this._config,e),"SPA"===this._config.type&&this._pageViewTrackSPA(),this._config},e.prototype._isSameUrl=function(){return sessionStorage.getItem(Gi)===this._config.getUrl()&&(Hi.debug("the url is same"),!0)},e.prototype._pageViewTrackDefault=function(){return Ki(this,void 0,void 0,(function(){var e,t,n,i;return Vi(this,(function(o){switch(o.label){case 0:return r.JS.browserOrNode().isBrowser&&window.addEventListener&&window.sessionStorage?(e=this._config.getUrl(),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]):(Hi.debug("not in the supported web enviroment"),[2]);case 1:return n=o.sent(),[3,3];case 2:n=this._config.attributes,o.label=3;case 3:return t=n,i=Object.assign({url:e},t),this._config.enable&&!this._isSameUrl()&&(this._tracker({name:this._config.eventName||"pageView",attributes:i},this._config.provider).catch((function(e){Hi.debug("Failed to record the page view event",e)})),sessionStorage.setItem(Gi,e)),[2]}}))}))},e.prototype._trackFunc=function(){return Ki(this,void 0,void 0,(function(){var e,t,n,i;return Vi(this,(function(o){switch(o.label){case 0:return r.JS.browserOrNode().isBrowser&&window.addEventListener&&history.pushState&&window.sessionStorage?(e=this._config.getUrl(),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]):(Hi.debug("not in the supported web enviroment"),[2]);case 1:return n=o.sent(),[3,3];case 2:n=this._config.attributes,o.label=3;case 3:return t=n,i=Object.assign({url:e},t),this._isSameUrl()||(this._tracker({name:this._config.eventName||"pageView",attributes:i},this._config.provider).catch((function(e){Hi.debug("Failed to record the page view event",e)})),sessionStorage.setItem(Gi,e)),[2]}}))}))},e.prototype._pageViewTrackSPA=function(){r.JS.browserOrNode().isBrowser&&window.addEventListener&&history.pushState?this._config.enable&&!this._hasEnabled?(Fi.add(history,"pushState",this._trackFunc),Fi.add(history,"replaceState",this._trackFunc),window.addEventListener("popstate",this._trackFunc),this._trackFunc(),this._hasEnabled=!0):(Fi.remove(history,"pushState"),Fi.remove(history,"replaceState"),window.removeEventListener("popstate",this._trackFunc),this._hasEnabled=!1):Hi.debug("not in the supported web enviroment")},e}(),Yi=r.JS.browserOrNode().isBrowser&&window.Element?window.Element.prototype:null,Zi=Yi?Yi.matches||Yi.matchesSelector||Yi.webkitMatchesSelector||Yi.mozMatchesSelector||Yi.msMatchesSelector||Yi.oMatchesSelector:null;function Ji(e,t){if(e&&1===e.nodeType&&t){if("string"==typeof t||1===t.nodeType)return e===t||Qi(e,t);if("length"in t)for(var n=0,r=void 0;r=t[n];n++)if(e===r||Qi(e,r))return!0}return!1}function Qi(e,t){if("string"!=typeof t)return!1;if(Zi)return Zi.call(e,t);for(var n=e.parentNode.querySelectorAll(t),r=0,i=void 0;i=n[r];r++)if(i===e)return!0;return!1}function Xi(e,t,n,r,i){void 0===i&&(i={});var o=function(e){var t;if(i.composed&&"function"==typeof e.composedPath)for(var o=e.composedPath(),s=0,a=void 0;a=o[s];s++)1===a.nodeType&&Ji(a,n)&&(t=a);else t=function(e,t,n){if(void 0===n&&(n=!1),e&&1===e.nodeType&&t)for(var r,i=(n?[e]:[]).concat(function(e){for(var t=[],n=e;n&&n.parentNode&&1===n.parentNode.nodeType;)n=n.parentNode,t.push(n);return t}(e)),o=0;r=i[o];o++)if(Ji(r,t))return r}(e.target,n,!0);t&&r.call(t,e,t)};return e.addEventListener(t,o,i.useCapture),{destroy:function(){e.removeEventListener(t,o,i.useCapture)}}}var eo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},to=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},no=new r.ConsoleLogger("EventTracker"),ro={enable:!1,events:["click"],selectorPrefix:"data-amplify-analytics-",provider:"AWSPinpoint"},io=function(){function e(e,t){r.JS.browserOrNode().isBrowser&&window.addEventListener?(this._config=Object.assign({},ro,t),this._tracker=e,this._delegates={},this._trackFunc=this._trackFunc.bind(this),no.debug("initialize pageview tracker with opts",this._config),this.configure(this._config)):no.debug("not in the supported web environment")}return e.prototype.configure=function(e){var t=this;if(Object.assign(this._config,e),this._config.enable){if(this._config.enable&&0===Object.keys(this._delegates).length){var n="["+this._config.selectorPrefix+"on]";this._config.events.forEach((function(e){t._delegates[e]=Xi(document,e,n,t._trackFunc,{composed:!0,useCapture:!0})}))}}else Object.keys(this._delegates).forEach((function(e){"function"==typeof t._delegates[e].destroy&&t._delegates[e].destroy()})),this._delegates={};return this._config},e.prototype._trackFunc=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,i,o,s,a,u;return to(this,(function(c){switch(c.label){case 0:return n={},r=t.getAttribute(this._config.selectorPrefix+"on").split(/\s*,\s*/),i=t.getAttribute(this._config.selectorPrefix+"name"),(o=t.getAttribute(this._config.selectorPrefix+"attrs"))&&o.split(/\s*,\s*/).forEach((function(e){var t=e.trim().split(/\s*:\s*/);n[t[0]]=t[1]})),"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()];case 1:return a=c.sent(),[3,3];case 2:a=this._config.attributes,c.label=3;case 3:return s=a,u=Object.assign({type:e.type,target:e.target.localName+" with id "+e.target.id},s,n),no.debug("events needed to be recorded",r),no.debug("attributes needed to be attached",n),r.indexOf(e.type)<0?(no.debug("event "+e.type+" is not selected to be recorded"),[2]):(this._tracker({name:i||"event",attributes:u},this._config.provider).catch((function(t){no.debug("Failed to record the "+e.type+" event', "+t)})),[2])}}))}))},e}(),oo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},so=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},ao=new r.ConsoleLogger("SessionTracker"),uo={enable:!1,provider:"AWSPinpoint"},co=!1,fo=function(){function e(e,t){this._config=Object.assign({},uo,t),this._tracker=e,this._hasEnabled=!1,this._trackFunc=this._trackFunc.bind(this),this._trackBeforeUnload=this._trackBeforeUnload.bind(this),this.configure(this._config)}return e.prototype._envCheck=function(){if(!r.JS.browserOrNode().isBrowser)return!1;if(!document||!document.addEventListener)return ao.debug("not in the supported web environment"),!1;if(void 0!==document.hidden)this._hidden="hidden",this._visibilityChange="visibilitychange";else if(void 0!==document.msHidden)this._hidden="msHidden",this._visibilityChange="msvisibilitychange";else{if(void 0===document.webkitHidden)return ao.debug("not in the supported web environment"),!1;this._hidden="webkitHidden",this._visibilityChange="webkitvisibilitychange"}return!0},e.prototype._trackFunc=function(){return oo(this,void 0,void 0,(function(){var e,t,n;return so(this,(function(r){switch(r.label){case 0:return"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()];case 1:return t=r.sent(),[3,3];case 2:t=this._config.attributes,r.label=3;case 3:return e=t,n=Object.assign({},e),document.visibilityState===this._hidden?this._tracker({name:"_session.stop",attributes:n},this._config.provider).catch((function(e){ao.debug("record session stop event failed.",e)})):this._tracker({name:"_session.start",attributes:n},this._config.provider).catch((function(e){ao.debug("record session start event failed.",e)})),[2]}}))}))},e.prototype._trackBeforeUnload=function(e){var t=this;("function"==typeof this._config.attributes?Promise.resolve(this._config.attributes()):Promise.resolve(this._config.attributes)).then((function(e){var n=Object.assign({},e);t._tracker({name:"_session.stop",attributes:n,immediate:!0},t._config.provider).catch((function(e){ao.debug("record session stop event failed.",e)}))}))},e.prototype._sendInitialEvent=function(){return oo(this,void 0,void 0,(function(){var e,t,n;return so(this,(function(r){switch(r.label){case 0:return co?(ao.debug("the start session has been sent when the page is loaded"),[2]):(co=!0,"function"!=typeof this._config.attributes?[3,2]:[4,this._config.attributes()]);case 1:return t=r.sent(),[3,3];case 2:t=this._config.attributes,r.label=3;case 3:return e=t,n=Object.assign({},e),this._tracker({name:"_session.start",attributes:n},this._config.provider).catch((function(e){ao.debug("record session start event failed.",e)})),[2]}}))}))},e.prototype.configure=function(e){return this._envCheck()?(Object.assign(this._config,e),this._config.enable&&!this._hasEnabled?(this._sendInitialEvent(),document.addEventListener(this._visibilityChange,this._trackFunc,!1),window.addEventListener("beforeunload",this._trackBeforeUnload,!1),this._hasEnabled=!0):!this._config.enable&&this._hasEnabled&&(document.removeEventListener(this._visibilityChange,this._trackFunc,!1),window.removeEventListener("beforeunload",this._trackBeforeUnload,!1),this._hasEnabled=!1),this._config):this._config},e}(),lo=function(){return(lo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},ho=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},vo=new r.ConsoleLogger("AnalyticsClass"),go="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",mo={pageView:Wi,event:io,session:fo},yo=null,bo=function(){function e(){this._config={},this._pluggables=[],this._disabled=!1,yo=this,this.record=this.record.bind(this),r.Hub.listen("auth",Eo),r.Hub.listen("storage",Eo),r.Hub.listen("analytics",Eo)}return e.prototype.getModuleName=function(){return"Analytics"},e.prototype.configure=function(e){var t=this;if(!e)return this._config;vo.debug("configure Analytics",e);var n,i,o,s=r.Parser.parseMobilehubConfig(e);return this._config=Object.assign({},this._config,s.Analytics,e),this._config.disabled&&(this._disabled=!0),void 0===this._config.autoSessionRecord&&(this._config.autoSessionRecord=!0),this._pluggables.forEach((function(e){var n="AWSPinpoint"!==e.getProviderName()||t._config.AWSPinpoint?t._config[e.getProviderName()]:t._config;e.configure(lo({disabled:t._config.disabled,autoSessionRecord:t._config.autoSessionRecord},n))})),0===this._pluggables.length&&this.addPluggable(new Ni),n="configured",i=null,o="The Analytics category has been configured successfully",r.Hub.dispatch("analytics",{event:n,data:i,message:o},"Analytics",go),vo.debug("current configuration",this._config),this._config},e.prototype.addPluggable=function(e){if(e&&"Analytics"===e.getCategory()){this._pluggables.push(e);var t="AWSPinpoint"!==e.getProviderName()||this._config.AWSPinpoint?this._config[e.getProviderName()]:this._config,n=lo({disabled:this._config.disabled},t);return e.configure(n),n}},e.prototype.getPluggable=function(e){for(var t=0;t<this._pluggables.length;t+=1){var n=this._pluggables[t];if(n.getProviderName()===e)return n}return vo.debug("No plugin found with providerName",e),null},e.prototype.removePluggable=function(e){for(var t=0;t<this._pluggables.length&&this._pluggables[t].getProviderName()!==e;)t+=1;return t===this._pluggables.length?void vo.debug("No plugin found with providerName",e):void this._pluggables.splice(t,t+1)},e.prototype.disable=function(){this._disabled=!0},e.prototype.enable=function(){this._disabled=!1},e.prototype.startSession=function(e){return po(this,void 0,void 0,(function(){var t;return ho(this,(function(n){return t={event:{name:"_session.start"},provider:e},[2,this._sendEvent(t)]}))}))},e.prototype.stopSession=function(e){return po(this,void 0,void 0,(function(){var t;return ho(this,(function(n){return t={event:{name:"_session.stop"},provider:e},[2,this._sendEvent(t)]}))}))},e.prototype.record=function(e,t,n){return po(this,void 0,void 0,(function(){var r;return ho(this,(function(i){return r=null,r="string"==typeof e?{event:{name:e,attributes:t,metrics:n},provider:"AWSPinpoint"}:{event:e,provider:t},[2,this._sendEvent(r)]}))}))},e.prototype.updateEndpoint=function(e,t){return po(this,void 0,void 0,(function(){var n;return ho(this,(function(r){return n=lo(lo({},e),{name:"_update_endpoint"}),[2,this.record(n,t)]}))}))},e.prototype._sendEvent=function(e){var t=this;if(this._disabled)return vo.debug("Analytics has been disabled"),Promise.resolve();var n=e.provider?e.provider:"AWSPinpoint";return new Promise((function(r,i){t._pluggables.forEach((function(t){t.getProviderName()===n&&t.record(e,{resolve:r,reject:i})}))}))},e.prototype.autoTrack=function(e,t){if(mo[e]){"session"===e&&(this._config.autoSessionRecord=t.enable);var n=this._trackers[e];n?n.configure(t):this._trackers[e]=new mo[e](this.record,t)}else vo.debug("invalid tracker type")},e}(),wo=!1,_o=!1,So=!1,Eo=function(e){var t=e.channel,n=e.payload;switch(vo.debug("on hub capsule "+t,n),t){case"auth":Oo(n);break;case"storage":Ao(n);break;case"analytics":Io(n)}},Ao=function(e){var t=e.data,n=t.attrs,r=t.metrics;n&&So&&yo.record({name:"Storage",attributes:n,metrics:r}).catch((function(e){vo.debug("Failed to send the storage event automatically",e)}))},Oo=function(e){var t=e.event;if(t){var n=function(e){return po(void 0,void 0,void 0,(function(){var t;return ho(this,(function(n){switch(n.label){case 0:if(!_o||!So)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,yo.record({name:"_userauth."+e})];case 2:return[2,n.sent()];case 3:return t=n.sent(),vo.debug("Failed to send the "+e+" event automatically",t),[3,4];case 4:return[2]}}))}))};switch(t){case"signIn":return n("sign_in");case"signUp":return n("sign_up");case"signOut":return n("sign_out");case"signIn_failure":return n("auth_fail");case"configured":(_o=!0)&&So&&Lo()}}},Io=function(e){var t=e.event;if(t)switch(t){case"pinpointProvider_configured":So=!0,_o&&So&&Lo()}},Lo=function(){var e=yo.configure();!wo&&e.autoSessionRecord&&(yo.updateEndpoint({immediate:!0}).catch((function(e){vo.debug("Failed to update the endpoint",e)})),wo=!0),yo.autoTrack("session",{enable:e.autoSessionRecord})},ko=new bo;r.Amplify.register(ko);
|
|
40
40
|
/*! *****************************************************************************
|
|
41
41
|
Copyright (c) Microsoft Corporation.
|
|
42
42
|
|