@aws-amplify/notifications
Advanced tools
Comparing version 0.2.3-in-app-messaging.7241 to 0.2.4-in-app-messaging.7286
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("aws_amplify_core"),require("@aws-sdk/client-pinpoint"),require("aws_amplify_cache")):"function"==typeof define&&define.amd?define("aws_amplify_notifications",["aws_amplify_core","@aws-sdk/client-pinpoint","aws_amplify_cache"],t):"object"==typeof exports?exports.aws_amplify_notifications=t(require("aws_amplify_core"),require("@aws-sdk/client-pinpoint"),require("aws_amplify_cache")):e.aws_amplify_notifications=t(e.aws_amplify_core,e["@aws-sdk/client-pinpoint"],e.aws_amplify_cache)}(this,(function(e,t,n){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=53)}([function(t,n){t.exports=e},function(e,t,n){var r=n(10),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},function(e,n){e.exports=t},function(e,t,n){var r=n(38),i=n(41);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},function(e,t,n){var r=n(33),i=n(36),o=n(11),s=n(12),a=n(46),u=n(47),c=n(15),l=n(49),f=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(a(e)&&(s(e)||"string"==typeof e||"function"==typeof e.splice||u(e)||l(e)||o(e)))return!e.length;var t=i(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(c(e))return!r(e).length;for(var n in e)if(f.call(e,n))return!1;return!0}},function(e,t,n){var r=n(6),i=n(29),o=n(30),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):o(e)}},function(e,t,n){var r=n(1).Symbol;e.exports=r},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t){e.exports=n},function(e,t,n){var r=n(31),i=n(32),o=i;o.v1=r,o.v4=i,e.exports=o},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(27))},function(e,t,n){var r=n(28),i=n(7),o=Object.prototype,s=o.hasOwnProperty,a=o.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(e){return i(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t){var n=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},function(e,t,n){var r=n(5),i=n(17);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t){var n=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){var r=n(24);e.exports=function(e){return(null==e?0:e.length)?r(e,1):[]}},function(e,t){e.exports=function(){}},,function(e,t,n){var r=n(25),i=n(26);e.exports=function e(t,n,o,s,a){var u=-1,c=t.length;for(o||(o=i),a||(a=[]);++u<c;){var l=t[u];n>0&&o(l)?n>1?e(l,n-1,o,s,a):r(a,l):s||(a[a.length]=l)}return a}},function(e,t){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},function(e,t,n){var r=n(6),i=n(11),o=n(12),s=r?r.isConcatSpreadable:void 0;e.exports=function(e){return o(e)||i(e)||!!(s&&e&&e[s])}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var r=n(5),i=n(7);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},function(e,t,n){var r=n(6),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var i=s.call(e);return r&&(t?e[a]=n:delete e[a]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t,n){var r,i,o=n(13),s=n(14),a=0,u=0;e.exports=function(e,t,n){var c=t&&n||0,l=t||[],f=(e=e||{}).node||r,p=void 0!==e.clockseq?e.clockseq:i;if(null==f||null==p){var d=o();null==f&&(f=r=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=i=16383&(d[6]<<8|d[7]))}var g=void 0!==e.msecs?e.msecs:(new Date).getTime(),v=void 0!==e.nsecs?e.nsecs:u+1,h=g-a+(v-u)/1e4;if(h<0&&void 0===e.clockseq&&(p=p+1&16383),(h<0||g>a)&&void 0===e.nsecs&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=g,u=v,i=p;var y=(1e4*(268435455&(g+=122192928e5))+v)%4294967296;l[c++]=y>>>24&255,l[c++]=y>>>16&255,l[c++]=y>>>8&255,l[c++]=255&y;var b=g/4294967296*1e4&268435455;l[c++]=b>>>8&255,l[c++]=255&b,l[c++]=b>>>24&15|16,l[c++]=b>>>16&255,l[c++]=p>>>8|128,l[c++]=255&p;for(var m=0;m<6;++m)l[c+m]=f[m];return t||s(l)}},function(e,t,n){var r=n(13),i=n(14);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){var r=n(15),i=n(34),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},function(e,t,n){var r=n(35)(Object.keys,Object);e.exports=r},function(e,t){e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){var r=n(37),i=n(42),o=n(43),s=n(44),a=n(45),u=n(5),c=n(18),l=c(r),f=c(i),p=c(o),d=c(s),g=c(a),v=u;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||i&&"[object Map]"!=v(new i)||o&&"[object Promise]"!=v(o.resolve())||s&&"[object Set]"!=v(new s)||a&&"[object WeakMap]"!=v(new a))&&(v=function(e){var t=u(e),n="[object Object]"==t?e.constructor:void 0,r=n?c(n):"";if(r)switch(r){case l:return"[object DataView]";case f:return"[object Map]";case p:return"[object Promise]";case d:return"[object Set]";case g:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){var r=n(3)(n(1),"DataView");e.exports=r},function(e,t,n){var r=n(16),i=n(39),o=n(17),s=n(18),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,f=c.hasOwnProperty,p=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?p:a).test(s(e))}},function(e,t,n){var r,i=n(40),o=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!o&&o in e}},function(e,t,n){var r=n(1)["__core-js_shared__"];e.exports=r},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){var r=n(3)(n(1),"Map");e.exports=r},function(e,t,n){var r=n(3)(n(1),"Promise");e.exports=r},function(e,t,n){var r=n(3)(n(1),"Set");e.exports=r},function(e,t,n){var r=n(3)(n(1),"WeakMap");e.exports=r},function(e,t,n){var r=n(16),i=n(19);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},function(e,t,n){(function(e){var r=n(1),i=n(48),o=t&&!t.nodeType&&t,s=o&&"object"==typeof e&&e&&!e.nodeType&&e,a=s&&s.exports===o?r.Buffer:void 0,u=(a?a.isBuffer:void 0)||i;e.exports=u}).call(this,n(20)(e))},function(e,t){e.exports=function(){return!1}},function(e,t,n){var r=n(50),i=n(51),o=n(52),s=o&&o.isTypedArray,a=s?i(s):r;e.exports=a},function(e,t,n){var r=n(5),i=n(19),o=n(7),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!s[r(e)]}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){(function(e){var r=n(10),i=t&&!t.nodeType&&t,o=i&&"object"==typeof e&&e&&!e.nodeType&&e,s=o&&o.exports===i&&r.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a}).call(this,n(20)(e))},function(e,t,n){"use strict";n.r(t),n.d(t,"Notifications",(function(){return J})),n.d(t,"InAppMessageInteractionEvent",(function(){return r}));var r,i,o=n(0),s=n(21),a=n.n(s),u=n(8),c=n.n(u),l=n(2),f=n(9);!function(e){e.MESSAGE_RECEIVED="MESSAGE_RECEIVED_EVENT",e.MESSAGE_DISPLAYED="MESSAGE_DISPLAYED_EVENT",e.MESSAGE_DISMISSED="MESSAGE_DISMISSED_EVENT",e.MESSAGE_ACTION_TAKEN="MESSAGE_ACTION_TAKEN_EVENT"}(r||(r={}));var p,d,g=((i={})[r.MESSAGE_RECEIVED]=new Set,i[r.MESSAGE_DISPLAYED]=new Set,i[r.MESSAGE_DISMISSED]=new Set,i[r.MESSAGE_ACTION_TAKEN]=new Set,i),v=function(e,t){g[t].forEach((function(t){t.handleEvent(e)}))},h=function(e,t){var n={handleEvent:e,remove:function(){g[t].delete(n)}};return g[t].add(n),n},y=n(22),b=n.n(y);document&&(void 0!==document.hidden?(p="hidden",d="visibilitychange"):void 0!==document.msHidden?(p="msHidden",d="msvisibilitychange"):void 0!==document.webkitHidden&&(p="webkitHidden",d="webkitvisibilitychange"));var m,S=new o.ConsoleLogger("InAppMessagingSessionTracker"),E=function(e){var t=this;void 0===e&&(e=b.a),this.start=function(){return null===document||void 0===document||document.addEventListener(d,t.visibilityChangeHandler),t.getSessionState()},this.end=function(){return null===document||void 0===document||document.removeEventListener(d,t.visibilityChangeHandler),t.getSessionState()},this.getSessionState=function(){return document&&!document[p]?"started":"ended"},this.visibilityChangeHandler=function(){document&&(document[p]?(S.debug("App is now hidden"),t.sessionStateChangeHandler("ended")):(S.debug("App is now visible"),t.sessionStateChangeHandler("started")))},this.sessionStateChangeHandler=e};!function(e){e.MESSAGE_DISPLAYED="_inapp.message_displayed",e.MESSAGE_DISMISSED="_inapp.message_dismissed",e.MESSAGE_ACTION_TAKEN="_inapp.message_clicked"}(m||(m={}));var A=n(4),w=n.n(A),C=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},M="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",I={},_={},j={},O=new o.ConsoleLogger("AWSPinpointProvider"),x=function(e,t,n){o.Hub.dispatch("inAppMessaging",{event:e,data:t,message:n},"InAppMessaging",M)},P=function(){var e=new Date;return e.setHours(0,0,0,0),e.toISOString()},D=function(e){switch(e){case"EQUAL":return function(e,t){return e===t};case"GREATER_THAN":return function(e,t){return e<t};case"GREATER_THAN_OR_EQUAL":return function(e,t){return e<=t};case"LESS_THAN":return function(e,t){return e>t};case"LESS_THAN_OR_EQUAL":return function(e,t){return e>=t};default:return null}},T=function(e){var t,n,r=e.InAppMessage;return null!==(n=null===(t=null==r?void 0:r.Content)||void 0===t?void 0:t.map((function(e){var t=e.BackgroundColor,n=e.BodyConfig,r=e.HeaderConfig,i=e.ImageUrl,o=e.PrimaryBtn,s=e.SecondaryBtn,a=null==o?void 0:o.DefaultConfig,u=null==s?void 0:s.DefaultConfig,c={};return t&&(c.container={style:{backgroundColor:t}}),r&&(c.header={content:r.Header,style:{color:r.TextColor,textAlign:r.Alignment.toLowerCase()}}),n&&(c.body={content:n.Body,style:{color:n.TextColor,textAlign:n.Alignment.toLowerCase()}}),i&&(c.image={src:i}),a&&(c.primaryButton={title:a.Text,action:a.ButtonAction,url:a.Link,style:{backgroundColor:a.BackgroundColor,borderRadius:a.BorderRadius,color:a.TextColor}}),u&&(c.secondaryButton={title:u.Text,action:u.ButtonAction,url:u.Link,style:{backgroundColor:u.BackgroundColor,borderRadius:u.BorderRadius,color:u.TextColor}}),c})))&&void 0!==n?n:[]},N=function(e){var t=e.InAppMessage,n=e.Priority,r=e.Schedule,i=e.TreatmentId;return{customData:null==t?void 0:t.CustomConfig,endDate:null==r?void 0:r.EndDate,priority:n,treatmentId:i}},k=function(){return(k=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)},G=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())}))},L=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])}}},F=function(){function e(){var e,t=this;this.config={},this.configured=!1,this.endpointInitialized=!1,this.initialized=!1,this.configure=function(e){return void 0===e&&(e={}),t.config=k(k({},t.config),e),O.debug("configure AWSPinpointProvider",t.config),t.configured||(t.sessionTracker=new E(t.sessionStateChangeHandler),t.sessionTracker.start(),h((function(e){t.recordMessageEvent(e,m.MESSAGE_DISPLAYED)}),r.MESSAGE_DISPLAYED),h((function(e){t.recordMessageEvent(e,m.MESSAGE_DISMISSED)}),r.MESSAGE_DISMISSED),h((function(e){t.recordMessageEvent(e,m.MESSAGE_ACTION_TAKEN)}),r.MESSAGE_ACTION_TAKEN)),t.configured=!0,x("pinpointProvider_configured",null),t.config},this.getInAppMessages=function(){return G(t,void 0,void 0,(function(){var e,t,n,r,i,o,s,a,u;return L(this,(function(c){switch(c.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:c.sent(),c.label=2;case 2:I={},_={},j={},c.label=3;case 3:return c.trys.push([3,6,,7]),[4,this.updateEndpoint()];case 4:return c.sent(),e=this.config,t=e.appId,n=e.endpointId,r=e.pinpointClient,i={ApplicationId:t,EndpointId:n},o=new l.GetInAppMessagesCommand(i),O.debug("getting in-app messages",i),[4,r.send(o)];case 5:return s=c.sent(),a=s.InAppMessagesResponse.InAppMessageCampaigns,x("getInAppMessages",a),[2,a];case 6:throw u=c.sent(),O.error("Error getting in-app messages",u),u;case 7:return[2]}}))}))},this.processInAppMessages=function(e,n){return G(t,void 0,void 0,(function(){var t,r=this;return L(this,(function(i){switch(i.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:i.sent(),i.label=2;case 2:return[2,this.normalizeMessages(e.reduce((function(e,i){if(function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.name,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).EventType,a=r+":"+o;return I.hasOwnProperty(a)||(I[a]=!!(null==s?void 0:s.Values.includes(o))),I[a]}(i,n)&&function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.attributes,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).Attributes;if(w()(s))return!0;if(w()(o))return!1;var a=r+":"+JSON.stringify(o);return _.hasOwnProperty(a)||(_[a]=Object.entries(s).every((function(e){var t=C(e,2),n=t[0];return t[1].Values.includes(o[n])}))),_[a]}(i,n)&&function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.metrics,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).Metrics;if(w()(s))return!0;if(w()(o))return!1;var a=r+":"+JSON.stringify(o);return j.hasOwnProperty(a)||(j[a]=Object.entries(s).every((function(e){var t=C(e,2),n=t[0],r=t[1],i=r.ComparisonOperator,s=r.Value,a=D(i);return!!a&&a(s,o[n])}))),j[a]}(i,n)&&function(e){var t=e.Schedule;return!(null==t?void 0:t.EndDate)||new Date<new Date(t.EndDate)}(i)&&r.isBelowCap(i))if(t){if(i.Priority){if(i.Priority<t)return t=i.Priority,[i];i.Priority===t&&e.push(i)}}else{if(i.Priority)return t=i.Priority,[i];e.push(i)}return e}),[]))]}}))}))},this.identifyUser=function(e,n){return G(t,void 0,void 0,(function(){var t;return L(this,(function(r){switch(r.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.updateEndpoint(e,n)];case 3:return r.sent(),[3,5];case 4:throw t=r.sent(),O.error("Error identifying user",t),t;case 5:return[2]}}))}))},this.init=function(){return G(t,void 0,void 0,(function(){var e,t,n,r,i,o;return L(this,(function(s){switch(s.label){case 0:e=this.config,t=e.endpointId,n=e.storage,r=this.getProviderName(),s.label=1;case 1:return s.trys.push([1,6,,7]),"function"!=typeof n.sync?[3,3]:[4,n.sync()];case 2:s.sent(),s.label=3;case 3:return t?[3,5]:(i=this.config,[4,this.getEndpointId()]);case 4:i.endpointId=s.sent(),s.label=5;case 5:return this.initialized=!0,[3,7];case 6:return o=s.sent(),O.error("Failed to initialize "+r,o),[3,7];case 7:return[2]}}))}))},this.initPinpointClient=function(){return G(t,void 0,void 0,(function(){var e,t,n,r,i;return L(this,(function(s){if(e=this.config,t=e.appId,n=e.credentials,r=e.pinpointClient,i=e.region,!t||!n||!i)throw new Error("One or more of credentials, appId or region is not configured");return r&&r.destroy(),this.config.pinpointClient=new l.PinpointClient({region:i,credentials:n,customUserAgent:Object(o.getAmplifyUserAgent)()}),[2]}))}))},this.getEndpointId=function(){return G(t,void 0,void 0,(function(){var e,t,n,r,i;return L(this,(function(o){switch(o.label){case 0:return e=this.config.appId,t=this.getSubCategory()+":"+this.getProviderName()+":"+e,[4,c.a.getItem(t)];case 1:return(n=o.sent())?[2,n]:(r=Object(f.v4)(),31536e8,i=(new Date).getTime()+31536e8,c.a.setItem(t,r,{expires:i,priority:1}),[2,r])}}))}))},this.updateEndpoint=function(e,n){return void 0===e&&(e=null),void 0===n&&(n=null),G(t,void 0,void 0,(function(){var t,r,i,s,a,u,c,p,d,g,v,h,y,b,m,S,E,A,w,C,M,I,_,j,x;return L(this,(function(P){switch(P.label){case 0:return t=this.config,r=t.appId,i=t.credentials,s=t.endpointId,a=t.endpointInfo,u=void 0===a?{}:a,c=t.pinpointClient,[4,this.getCredentials()];case 1:if(p=P.sent(),d=!i||Object.keys(p).some((function(e){return p[e]!==i[e]})),this.endpointInitialized&&!d&&!e&&!n)return[2];this.config.credentials=p,P.label=2;case 2:return P.trys.push([2,6,,7]),c&&!d?[3,4]:[4,this.initPinpointClient()];case 3:P.sent(),P.label=4;case 4:return v=(g=null!=n?n:{}).address,h=g.attributes,y=g.demographic,b=g.location,m=g.metrics,S=g.optOut,E=this.clientInfo,A=E.appVersion,w=E.make,C=E.model,M=E.platform,I=E.version,_={ApplicationId:r,EndpointId:s,EndpointRequest:{RequestId:Object(f.v4)(),EffectiveDate:(new Date).toISOString(),ChannelType:l.ChannelType.IN_APP,Address:null!=v?v:u.address,Attributes:k(k({},u.attributes),h),Demographic:k({AppVersion:A,Make:w,Model:C,ModelVersion:I,Platform:M},Object(o.transferKeyToUpperCase)(k(k({},u.demographic),y))),Location:Object(o.transferKeyToUpperCase)(k(k({},u.location),b)),Metrics:k(k({},u.metrics),m),OptOut:null!=S?S:u.optOut,User:{UserId:null!==(x=null!=e?e:u.userId)&&void 0!==x?x:p.identityId,UserAttributes:null!=h?h:u.userAttributes}}},j=new l.UpdateEndpointCommand(_),O.debug("updating endpoint",_),[4,this.config.pinpointClient.send(j)];case 5:return P.sent(),this.endpointInitialized=!0,[3,7];case 6:throw P.sent();case 7:return[2]}}))}))},this.getCredentials=function(){return G(t,void 0,void 0,(function(){var e,t;return L(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,o.Credentials.get()];case 1:return(e=n.sent())?[2,o.Credentials.shear(e)]:(O.debug("no credentials found"),[2,null]);case 2:return t=n.sent(),O.error("Error getting credentials:",t),[2,null];case 3:return[2]}}))}))},this.sessionStateChangeHandler=function(e){"started"===e&&(t.sessionMessageCountMap={})},this.isBelowCap=function(e){var n=e.CampaignId,r=e.SessionCap,i=e.DailyCap,o=e.TotalCap,s=t.getMessageCounts(n),a=s.sessionCount,u=s.dailyCount,c=s.totalCount;return(!r||a<r)&&(!i||u<i)&&(!o||c<o)},this.getSessionCount=function(e){return t.sessionMessageCountMap[e]||0},this.getDailyCount=function(){var e=t.config.storage,n=P(),r=e.getItem("pinpointProvider_inAppMessages_dailyCount"),i=r?JSON.parse(r):{count:0,lastCountTimestamp:n};return i.lastCountTimestamp===n?i.count:0},this.getTotalCountMap=function(){var e=t.config.storage.getItem("pinpointProvider_inAppMessages_totalCount");return e?JSON.parse(e):{}},this.getTotalCount=function(e){return t.getTotalCountMap()[e]||0},this.getMessageCounts=function(e){try{return{sessionCount:t.getSessionCount(e),dailyCount:t.getDailyCount(),totalCount:t.getTotalCount(e)}}catch(e){O.error("Failed to get message counts from storage",e)}},this.setSessionCount=function(e,n){t.sessionMessageCountMap[e]=n},this.setDailyCount=function(e){var n=t.config.storage,r={count:e,lastCountTimestamp:P()};try{n.setItem("pinpointProvider_inAppMessages_dailyCount",JSON.stringify(r))}catch(e){O.error("Failed to save daily message count to storage",e)}},this.setTotalCountMap=function(e){var n=t.config.storage;try{n.setItem("pinpointProvider_inAppMessages_totalCount",JSON.stringify(e))}catch(e){O.error("Failed to save total count to storage",e)}},this.setTotalCount=function(e,n){var r,i=k(k({},t.getTotalCountMap()),((r={})[e]=n,r));t.setTotalCountMap(i)},this.incrementCounts=function(e){return G(t,void 0,void 0,(function(){var t,n,r,i;return L(this,(function(o){return t=this.getMessageCounts(e),n=t.sessionCount,r=t.dailyCount,i=t.totalCount,this.setSessionCount(e,n+1),this.setDailyCount(r+1),this.setTotalCount(e,i+1),[2]}))}))},this.normalizeMessages=function(e){return e.map((function(e){var t,n=e.CampaignId,r=e.InAppMessage;return{id:n,content:T(e),layout:(t=r.Layout,t===l.Layout.MOBILE_FEED?"MODAL":t===l.Layout.OVERLAYS?"FULL_SCREEN":t),metadata:N(e)}}))},this.recordMessageEvent=function(e,n){return G(t,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:t.sent(),t.label=2;case 2:return function(e,t){if(t)if(o.Amplify.Analytics&&"function"==typeof o.Amplify.Analytics.record){var n=t.id,r=t.metadata;o.Amplify.Analytics.record({name:e,attributes:{campaign_id:n,delivery_type:"IN_APP_MESSAGE",treatment_id:null==r?void 0:r.treatmentId}})}else O.debug("Analytics module is not registered into Amplify");else O.debug("Unable to record analytics event - no InAppMessage was received")}(n,e),n!==m.MESSAGE_DISPLAYED?[3,4]:[4,this.incrementCounts(e.id)];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},this.sessionMessageCountMap={},this.config={storage:(new o.StorageHelper).getStorage()},this.clientInfo=null!==(e=o.ClientDevice.clientInfo())&&void 0!==e?e:{}}return e.prototype.getCategory=function(){return e.category},e.prototype.getSubCategory=function(){return e.subCategory},e.prototype.getProviderName=function(){return e.providerName},e.category="Notifications",e.subCategory="InAppMessaging",e.providerName="AWSPinpoint",e}(),H=function(){return(H=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)},R=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())}))},V=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])}}},U=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var 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},B=new o.ConsoleLogger("Notifications.InAppMessaging"),q=function(){function e(){var e=this;this.config={},this.listeningForAnalyticEvents=!1,this.pluggables=[],this.storageSynced=!1,this.configure=function(t){void 0===t&&(t={});var n=t.listenForAnalyticsEvents,r=void 0===n||n,i=U(t,["listenForAnalyticsEvents"]);return e.config=H(H({},e.config),i),B.debug("configure InAppMessaging",e.config),e.pluggables.forEach((function(t){t.configure(e.config[t.getProviderName()])})),0===e.pluggables.length&&e.addPluggable(new F),r&&!e.listeningForAnalyticEvents&&(o.Hub.listen("analytics",e.analyticsListener),e.listeningForAnalyticEvents=!0),e.config},this.getPluggable=function(t){var n,r=null!==(n=e.pluggables.find((function(e){return e.getProviderName()===t})))&&void 0!==n?n:null;return r||B.debug("No plugin found with name "+t),r},this.addPluggable=function(t){if(t&&"Notifications"===t.getCategory()&&"InAppMessaging"===t.getSubCategory()){if(e.getPluggable(t.getProviderName()))throw new Error("Pluggable "+t.getProviderName()+" has already been added.");e.pluggables.push(t),t.configure(e.config[t.getProviderName()])}},this.removePluggable=function(t){var n=e.pluggables.findIndex((function(e){return e.getProviderName()===t}));-1===n?B.debug("No plugin found with name "+t):e.pluggables.splice(n,1)},this.syncMessages=function(){return Promise.all(e.pluggables.map((function(t){return R(e,void 0,void 0,(function(){var e,n,r;return V(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,t.getInAppMessages()];case 1:return e=i.sent(),n=t.getProviderName()+"_inAppMessages",[4,this.setMessages(n,e)];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),B.error("Failed to sync messages",r),r;case 4:return[2]}}))}))})))},this.clearMessages=function(){return Promise.all(e.pluggables.map((function(t){return R(e,void 0,void 0,(function(){var e;return V(this,(function(n){switch(n.label){case 0:return e=t.getProviderName()+"_inAppMessages",[4,this.removeMessages(e)];case 1:return n.sent(),[2]}}))}))})))},this.dispatchEvent=function(t){return R(e,void 0,void 0,(function(){var e,n,i=this;return V(this,(function(o){switch(o.label){case 0:return[4,Promise.all(this.pluggables.map((function(e){return R(i,void 0,void 0,(function(){var n,r;return V(this,(function(i){switch(i.label){case 0:return n=e.getProviderName()+"_inAppMessages",[4,this.getMessages(n)];case 1:return r=i.sent(),[2,e.processInAppMessages(r,t)]}}))}))})))];case 1:return e=o.sent(),(n=a()(e)).length&&v(this.conflictHandler(n),r.MESSAGE_RECEIVED),[2]}}))}))},this.identifyUser=function(t,n){return Promise.all(e.pluggables.map((function(r){return R(e,void 0,void 0,(function(){var e;return V(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r.identifyUser(t,n)];case 1:return i.sent(),[3,3];case 2:throw e=i.sent(),B.error("Failed to identify user",e),e;case 3:return[2]}}))}))})))},this.onMessageReceived=function(e){return h(e,r.MESSAGE_RECEIVED)},this.onMessageDisplayed=function(e){return h(e,r.MESSAGE_DISPLAYED)},this.onMessageDismissed=function(e){return h(e,r.MESSAGE_DISMISSED)},this.onMessageActionTaken=function(e){return h(e,r.MESSAGE_ACTION_TAKEN)},this.notifyMessageInteraction=function(e,t){v(e,t)},this.setConflictHandler=function(t){e.conflictHandler=t},this.analyticsListener=function(t){var n=t.payload,r=n.event,i=n.data;switch(r){case"record":e.dispatchEvent(i)}},this.syncStorage=function(){return R(e,void 0,void 0,(function(){var e,t;return V(this,(function(n){switch(n.label){case 0:e=this.config.storage,n.label=1;case 1:return n.trys.push([1,4,,5]),"function"!=typeof e.sync?[3,3]:[4,e.sync()];case 2:n.sent(),n.label=3;case 3:return this.storageSynced=!0,[3,5];case 4:return t=n.sent(),B.error("Failed to sync storage",t),[3,5];case 5:return[2]}}))}))},this.getMessages=function(t){return R(e,void 0,void 0,(function(){var e,n,r;return V(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.storageSynced?[3,2]:[4,this.syncStorage()];case 1:i.sent(),i.label=2;case 2:return e=this.config.storage,[2,(n=e.getItem(t))?JSON.parse(n):[]];case 3:return r=i.sent(),B.error("Failed to retrieve in-app messages from storage",r),[3,4];case 4:return[2]}}))}))},this.setMessages=function(t,n){return R(e,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:if(!n)return[2];r.label=1;case 1:return r.trys.push([1,4,,5]),this.storageSynced?[3,3]:[4,this.syncStorage()];case 2:r.sent(),r.label=3;case 3:return this.config.storage.setItem(t,JSON.stringify(n)),[3,5];case 4:return e=r.sent(),B.error("Failed to store in-app messages",e),[3,5];case 5:return[2]}}))}))},this.removeMessages=function(t){return R(e,void 0,void 0,(function(){var e;return V(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.storageSynced?[3,2]:[4,this.syncStorage()];case 1:n.sent(),n.label=2;case 2:return this.config.storage.removeItem(t),[3,4];case 3:return e=n.sent(),B.error("Failed to remove in-app messages from storage",e),[3,4];case 4:return[2]}}))}))},this.defaultConflictHandler=function(e){return e.sort((function(e,t){var n,r,i=null===(n=e.metadata)||void 0===n?void 0:n.endDate,o=null===(r=t.metadata)||void 0===r?void 0:r.endDate;return i===o?0:i&&!o?-1:!i&&o?1:new Date(i)<new Date(o)?-1:1}))[0]},this.config={storage:(new o.StorageHelper).getStorage()},this.setConflictHandler(this.defaultConflictHandler)}return e.prototype.getModuleName=function(){return"InAppMessaging"},e}(),z=function(){return(z=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)},K=new o.ConsoleLogger("Notifications"),Y=new(function(){function e(){var e=this;this.config={},this.configure=function(t){var n=(void 0===t?{}:t).Notifications;return e.config=z(z({},e.config),n),K.debug("configure Notifications",n),e.inAppMessaging.configure(e.config.InAppMessaging),e.config},this.inAppMessaging=new q}return e.prototype.getModuleName=function(){return"Notifications"},Object.defineProperty(e.prototype,"InAppMessaging",{get:function(){return this.inAppMessaging},enumerable:!0,configurable:!0}),e}()),J=Y;o.Amplify.register(Y)}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("aws_amplify_core"),require("@aws-sdk/client-pinpoint"),require("aws_amplify_cache")):"function"==typeof define&&define.amd?define("aws_amplify_notifications",["aws_amplify_core","@aws-sdk/client-pinpoint","aws_amplify_cache"],t):"object"==typeof exports?exports.aws_amplify_notifications=t(require("aws_amplify_core"),require("@aws-sdk/client-pinpoint"),require("aws_amplify_cache")):e.aws_amplify_notifications=t(e.aws_amplify_core,e["@aws-sdk/client-pinpoint"],e.aws_amplify_cache)}(this,(function(e,t,n){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=53)}([function(t,n){t.exports=e},function(e,t,n){var r=n(10),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},function(e,n){e.exports=t},function(e,t,n){var r=n(38),i=n(41);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},function(e,t,n){var r=n(33),i=n(36),o=n(11),s=n(12),a=n(46),u=n(47),c=n(15),l=n(49),f=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(a(e)&&(s(e)||"string"==typeof e||"function"==typeof e.splice||u(e)||l(e)||o(e)))return!e.length;var t=i(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(c(e))return!r(e).length;for(var n in e)if(f.call(e,n))return!1;return!0}},function(e,t,n){var r=n(6),i=n(29),o=n(30),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):o(e)}},function(e,t,n){var r=n(1).Symbol;e.exports=r},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t){e.exports=n},function(e,t,n){var r=n(31),i=n(32),o=i;o.v1=r,o.v4=i,e.exports=o},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(27))},function(e,t,n){var r=n(28),i=n(7),o=Object.prototype,s=o.hasOwnProperty,a=o.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(e){return i(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t){var n=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},function(e,t,n){var r=n(5),i=n(17);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t){var n=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){var r=n(24);e.exports=function(e){return(null==e?0:e.length)?r(e,1):[]}},function(e,t){e.exports=function(){}},,function(e,t,n){var r=n(25),i=n(26);e.exports=function e(t,n,o,s,a){var u=-1,c=t.length;for(o||(o=i),a||(a=[]);++u<c;){var l=t[u];n>0&&o(l)?n>1?e(l,n-1,o,s,a):r(a,l):s||(a[a.length]=l)}return a}},function(e,t){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},function(e,t,n){var r=n(6),i=n(11),o=n(12),s=r?r.isConcatSpreadable:void 0;e.exports=function(e){return o(e)||i(e)||!!(s&&e&&e[s])}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var r=n(5),i=n(7);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},function(e,t,n){var r=n(6),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var i=s.call(e);return r&&(t?e[a]=n:delete e[a]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t,n){var r,i,o=n(13),s=n(14),a=0,u=0;e.exports=function(e,t,n){var c=t&&n||0,l=t||[],f=(e=e||{}).node||r,p=void 0!==e.clockseq?e.clockseq:i;if(null==f||null==p){var d=o();null==f&&(f=r=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=i=16383&(d[6]<<8|d[7]))}var g=void 0!==e.msecs?e.msecs:(new Date).getTime(),v=void 0!==e.nsecs?e.nsecs:u+1,h=g-a+(v-u)/1e4;if(h<0&&void 0===e.clockseq&&(p=p+1&16383),(h<0||g>a)&&void 0===e.nsecs&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=g,u=v,i=p;var y=(1e4*(268435455&(g+=122192928e5))+v)%4294967296;l[c++]=y>>>24&255,l[c++]=y>>>16&255,l[c++]=y>>>8&255,l[c++]=255&y;var b=g/4294967296*1e4&268435455;l[c++]=b>>>8&255,l[c++]=255&b,l[c++]=b>>>24&15|16,l[c++]=b>>>16&255,l[c++]=p>>>8|128,l[c++]=255&p;for(var m=0;m<6;++m)l[c+m]=f[m];return t||s(l)}},function(e,t,n){var r=n(13),i=n(14);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){var r=n(15),i=n(34),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},function(e,t,n){var r=n(35)(Object.keys,Object);e.exports=r},function(e,t){e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){var r=n(37),i=n(42),o=n(43),s=n(44),a=n(45),u=n(5),c=n(18),l=c(r),f=c(i),p=c(o),d=c(s),g=c(a),v=u;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||i&&"[object Map]"!=v(new i)||o&&"[object Promise]"!=v(o.resolve())||s&&"[object Set]"!=v(new s)||a&&"[object WeakMap]"!=v(new a))&&(v=function(e){var t=u(e),n="[object Object]"==t?e.constructor:void 0,r=n?c(n):"";if(r)switch(r){case l:return"[object DataView]";case f:return"[object Map]";case p:return"[object Promise]";case d:return"[object Set]";case g:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){var r=n(3)(n(1),"DataView");e.exports=r},function(e,t,n){var r=n(16),i=n(39),o=n(17),s=n(18),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,f=c.hasOwnProperty,p=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?p:a).test(s(e))}},function(e,t,n){var r,i=n(40),o=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!o&&o in e}},function(e,t,n){var r=n(1)["__core-js_shared__"];e.exports=r},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){var r=n(3)(n(1),"Map");e.exports=r},function(e,t,n){var r=n(3)(n(1),"Promise");e.exports=r},function(e,t,n){var r=n(3)(n(1),"Set");e.exports=r},function(e,t,n){var r=n(3)(n(1),"WeakMap");e.exports=r},function(e,t,n){var r=n(16),i=n(19);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},function(e,t,n){(function(e){var r=n(1),i=n(48),o=t&&!t.nodeType&&t,s=o&&"object"==typeof e&&e&&!e.nodeType&&e,a=s&&s.exports===o?r.Buffer:void 0,u=(a?a.isBuffer:void 0)||i;e.exports=u}).call(this,n(20)(e))},function(e,t){e.exports=function(){return!1}},function(e,t,n){var r=n(50),i=n(51),o=n(52),s=o&&o.isTypedArray,a=s?i(s):r;e.exports=a},function(e,t,n){var r=n(5),i=n(19),o=n(7),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!s[r(e)]}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){(function(e){var r=n(10),i=t&&!t.nodeType&&t,o=i&&"object"==typeof e&&e&&!e.nodeType&&e,s=o&&o.exports===i&&r.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a}).call(this,n(20)(e))},function(e,t,n){"use strict";n.r(t),n.d(t,"Notifications",(function(){return W})),n.d(t,"InAppMessageInteractionEvent",(function(){return r}));var r,i,o=n(0),s=n(21),a=n.n(s),u=n(8),c=n.n(u),l=n(2),f=n(9);!function(e){e.MESSAGE_RECEIVED="MESSAGE_RECEIVED_EVENT",e.MESSAGE_DISPLAYED="MESSAGE_DISPLAYED_EVENT",e.MESSAGE_DISMISSED="MESSAGE_DISMISSED_EVENT",e.MESSAGE_ACTION_TAKEN="MESSAGE_ACTION_TAKEN_EVENT"}(r||(r={}));var p,d,g=((i={})[r.MESSAGE_RECEIVED]=new Set,i[r.MESSAGE_DISPLAYED]=new Set,i[r.MESSAGE_DISMISSED]=new Set,i[r.MESSAGE_ACTION_TAKEN]=new Set,i),v=function(e,t){g[t].forEach((function(t){t.handleEvent(e)}))},h=function(e,t){var n={handleEvent:e,remove:function(){g[t].delete(n)}};return g[t].add(n),n},y=n(22),b=n.n(y),m=Object(o.browserOrNode)().isBrowser;m&&document&&(void 0!==document.hidden?(p="hidden",d="visibilitychange"):void 0!==document.msHidden?(p="msHidden",d="msvisibilitychange"):void 0!==document.webkitHidden&&(p="webkitHidden",d="webkitvisibilitychange"));var S,E=new o.ConsoleLogger("InAppMessagingSessionTracker"),A=function(e){var t=this;void 0===e&&(e=b.a),this.start=function(){return m&&(null===document||void 0===document||document.addEventListener(d,t.visibilityChangeHandler)),t.getSessionState()},this.end=function(){return m&&(null===document||void 0===document||document.removeEventListener(d,t.visibilityChangeHandler)),t.getSessionState()},this.getSessionState=function(){return m&&document&&!document[p]?"started":"ended"},this.visibilityChangeHandler=function(){m&&document&&(document[p]?(E.debug("App is now hidden"),t.sessionStateChangeHandler("ended")):(E.debug("App is now visible"),t.sessionStateChangeHandler("started")))},this.sessionStateChangeHandler=e};!function(e){e.MESSAGE_DISPLAYED="_inapp.message_displayed",e.MESSAGE_DISMISSED="_inapp.message_dismissed",e.MESSAGE_ACTION_TAKEN="_inapp.message_clicked"}(S||(S={}));var w=n(4),C=n.n(w),M=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="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",_={},j={},O={},x=new o.ConsoleLogger("AWSPinpointProvider"),P=function(e,t,n){o.Hub.dispatch("inAppMessaging",{event:e,data:t,message:n},"InAppMessaging",I)},D=function(){var e=new Date;return e.setHours(0,0,0,0),e.toISOString()},T=function(e){switch(e){case"EQUAL":return function(e,t){return e===t};case"GREATER_THAN":return function(e,t){return e<t};case"GREATER_THAN_OR_EQUAL":return function(e,t){return e<=t};case"LESS_THAN":return function(e,t){return e>t};case"LESS_THAN_OR_EQUAL":return function(e,t){return e>=t};default:return null}},N=function(e){var t,n,r=e.InAppMessage;return null!==(n=null===(t=null==r?void 0:r.Content)||void 0===t?void 0:t.map((function(e){var t=e.BackgroundColor,n=e.BodyConfig,r=e.HeaderConfig,i=e.ImageUrl,o=e.PrimaryBtn,s=e.SecondaryBtn,a=null==o?void 0:o.DefaultConfig,u=null==s?void 0:s.DefaultConfig,c={};return t&&(c.container={style:{backgroundColor:t}}),r&&(c.header={content:r.Header,style:{color:r.TextColor,textAlign:r.Alignment.toLowerCase()}}),n&&(c.body={content:n.Body,style:{color:n.TextColor,textAlign:n.Alignment.toLowerCase()}}),i&&(c.image={src:i}),a&&(c.primaryButton={title:a.Text,action:a.ButtonAction,url:a.Link,style:{backgroundColor:a.BackgroundColor,borderRadius:a.BorderRadius,color:a.TextColor}}),u&&(c.secondaryButton={title:u.Text,action:u.ButtonAction,url:u.Link,style:{backgroundColor:u.BackgroundColor,borderRadius:u.BorderRadius,color:u.TextColor}}),c})))&&void 0!==n?n:[]},k=function(e){var t=e.InAppMessage,n=e.Priority,r=e.Schedule,i=e.TreatmentId;return{customData:null==t?void 0:t.CustomConfig,endDate:null==r?void 0:r.EndDate,priority:n,treatmentId:i}},G=function(){return(G=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)},L=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())}))},F=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])}}},H=function(){function e(){var e,t=this;this.config={},this.configured=!1,this.endpointInitialized=!1,this.initialized=!1,this.configure=function(e){return void 0===e&&(e={}),t.config=G(G({},t.config),e),x.debug("configure AWSPinpointProvider",t.config),t.configured||(t.sessionTracker=new A(t.sessionStateChangeHandler),t.sessionTracker.start(),h((function(e){t.recordMessageEvent(e,S.MESSAGE_DISPLAYED)}),r.MESSAGE_DISPLAYED),h((function(e){t.recordMessageEvent(e,S.MESSAGE_DISMISSED)}),r.MESSAGE_DISMISSED),h((function(e){t.recordMessageEvent(e,S.MESSAGE_ACTION_TAKEN)}),r.MESSAGE_ACTION_TAKEN)),t.configured=!0,P("pinpointProvider_configured",null),t.config},this.getInAppMessages=function(){return L(t,void 0,void 0,(function(){var e,t,n,r,i,o,s,a,u;return F(this,(function(c){switch(c.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:c.sent(),c.label=2;case 2:_={},j={},O={},c.label=3;case 3:return c.trys.push([3,6,,7]),[4,this.updateEndpoint()];case 4:return c.sent(),e=this.config,t=e.appId,n=e.endpointId,r=e.pinpointClient,i={ApplicationId:t,EndpointId:n},o=new l.GetInAppMessagesCommand(i),x.debug("getting in-app messages",i),[4,r.send(o)];case 5:return s=c.sent(),a=s.InAppMessagesResponse.InAppMessageCampaigns,P("getInAppMessages",a),[2,a];case 6:throw u=c.sent(),x.error("Error getting in-app messages",u),u;case 7:return[2]}}))}))},this.processInAppMessages=function(e,n){return L(t,void 0,void 0,(function(){var t,r=this;return F(this,(function(i){switch(i.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:i.sent(),i.label=2;case 2:return[2,this.normalizeMessages(e.reduce((function(e,i){if(function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.name,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).EventType,a=r+":"+o;return _.hasOwnProperty(a)||(_[a]=!!(null==s?void 0:s.Values.includes(o))),_[a]}(i,n)&&function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.attributes,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).Attributes;if(C()(s))return!0;if(C()(o))return!1;var a=r+":"+JSON.stringify(o);return j.hasOwnProperty(a)||(j[a]=Object.entries(s).every((function(e){var t=M(e,2),n=t[0];return t[1].Values.includes(o[n])}))),j[a]}(i,n)&&function(e,t){var n,r=e.CampaignId,i=e.Schedule,o=t.metrics,s=(null===(n=null==i?void 0:i.EventFilter)||void 0===n?void 0:n.Dimensions).Metrics;if(C()(s))return!0;if(C()(o))return!1;var a=r+":"+JSON.stringify(o);return O.hasOwnProperty(a)||(O[a]=Object.entries(s).every((function(e){var t=M(e,2),n=t[0],r=t[1],i=r.ComparisonOperator,s=r.Value,a=T(i);return!!a&&a(s,o[n])}))),O[a]}(i,n)&&function(e){var t=e.Schedule;return!(null==t?void 0:t.EndDate)||new Date<new Date(t.EndDate)}(i)&&r.isBelowCap(i))if(t){if(i.Priority){if(i.Priority<t)return t=i.Priority,[i];i.Priority===t&&e.push(i)}}else{if(i.Priority)return t=i.Priority,[i];e.push(i)}return e}),[]))]}}))}))},this.identifyUser=function(e,n){return L(t,void 0,void 0,(function(){var t;return F(this,(function(r){switch(r.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.updateEndpoint(e,n)];case 3:return r.sent(),[3,5];case 4:throw t=r.sent(),x.error("Error identifying user",t),t;case 5:return[2]}}))}))},this.init=function(){return L(t,void 0,void 0,(function(){var e,t,n,r,i,o;return F(this,(function(s){switch(s.label){case 0:e=this.config,t=e.endpointId,n=e.storage,r=this.getProviderName(),s.label=1;case 1:return s.trys.push([1,6,,7]),"function"!=typeof n.sync?[3,3]:[4,n.sync()];case 2:s.sent(),s.label=3;case 3:return t?[3,5]:(i=this.config,[4,this.getEndpointId()]);case 4:i.endpointId=s.sent(),s.label=5;case 5:return this.initialized=!0,[3,7];case 6:return o=s.sent(),x.error("Failed to initialize "+r,o),[3,7];case 7:return[2]}}))}))},this.initPinpointClient=function(){return L(t,void 0,void 0,(function(){var e,t,n,r,i;return F(this,(function(s){if(e=this.config,t=e.appId,n=e.credentials,r=e.pinpointClient,i=e.region,!t||!n||!i)throw new Error("One or more of credentials, appId or region is not configured");return r&&r.destroy(),this.config.pinpointClient=new l.PinpointClient({region:i,credentials:n,customUserAgent:Object(o.getAmplifyUserAgent)()}),[2]}))}))},this.getEndpointId=function(){return L(t,void 0,void 0,(function(){var e,t,n,r,i;return F(this,(function(o){switch(o.label){case 0:return e=this.config.appId,t=this.getSubCategory()+":"+this.getProviderName()+":"+e,[4,c.a.getItem(t)];case 1:return(n=o.sent())?[2,n]:(r=Object(f.v4)(),31536e8,i=(new Date).getTime()+31536e8,c.a.setItem(t,r,{expires:i,priority:1}),[2,r])}}))}))},this.updateEndpoint=function(e,n){return void 0===e&&(e=null),void 0===n&&(n=null),L(t,void 0,void 0,(function(){var t,r,i,s,a,u,c,p,d,g,v,h,y,b,m,S,E,A,w,C,M,I,_,j,O;return F(this,(function(P){switch(P.label){case 0:return t=this.config,r=t.appId,i=t.credentials,s=t.endpointId,a=t.endpointInfo,u=void 0===a?{}:a,c=t.pinpointClient,[4,this.getCredentials()];case 1:if(p=P.sent(),d=!i||Object.keys(p).some((function(e){return p[e]!==i[e]})),this.endpointInitialized&&!d&&!e&&!n)return[2];this.config.credentials=p,P.label=2;case 2:return P.trys.push([2,6,,7]),c&&!d?[3,4]:[4,this.initPinpointClient()];case 3:P.sent(),P.label=4;case 4:return v=(g=null!=n?n:{}).address,h=g.attributes,y=g.demographic,b=g.location,m=g.metrics,S=g.optOut,E=this.clientInfo,A=E.appVersion,w=E.make,C=E.model,M=E.platform,I=E.version,_={ApplicationId:r,EndpointId:s,EndpointRequest:{RequestId:Object(f.v4)(),EffectiveDate:(new Date).toISOString(),ChannelType:l.ChannelType.IN_APP,Address:null!=v?v:u.address,Attributes:G(G({},u.attributes),h),Demographic:G({AppVersion:A,Make:w,Model:C,ModelVersion:I,Platform:M},Object(o.transferKeyToUpperCase)(G(G({},u.demographic),y))),Location:Object(o.transferKeyToUpperCase)(G(G({},u.location),b)),Metrics:G(G({},u.metrics),m),OptOut:null!=S?S:u.optOut,User:{UserId:null!==(O=null!=e?e:u.userId)&&void 0!==O?O:p.identityId,UserAttributes:null!=h?h:u.userAttributes}}},j=new l.UpdateEndpointCommand(_),x.debug("updating endpoint",_),[4,this.config.pinpointClient.send(j)];case 5:return P.sent(),this.endpointInitialized=!0,[3,7];case 6:throw P.sent();case 7:return[2]}}))}))},this.getCredentials=function(){return L(t,void 0,void 0,(function(){var e,t;return F(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,o.Credentials.get()];case 1:return(e=n.sent())?[2,o.Credentials.shear(e)]:(x.debug("no credentials found"),[2,null]);case 2:return t=n.sent(),x.error("Error getting credentials:",t),[2,null];case 3:return[2]}}))}))},this.sessionStateChangeHandler=function(e){"started"===e&&(t.sessionMessageCountMap={})},this.isBelowCap=function(e){var n=e.CampaignId,r=e.SessionCap,i=e.DailyCap,o=e.TotalCap,s=t.getMessageCounts(n),a=s.sessionCount,u=s.dailyCount,c=s.totalCount;return(!r||a<r)&&(!i||u<i)&&(!o||c<o)},this.getSessionCount=function(e){return t.sessionMessageCountMap[e]||0},this.getDailyCount=function(){var e=t.config.storage,n=D(),r=e.getItem("pinpointProvider_inAppMessages_dailyCount"),i=r?JSON.parse(r):{count:0,lastCountTimestamp:n};return i.lastCountTimestamp===n?i.count:0},this.getTotalCountMap=function(){var e=t.config.storage.getItem("pinpointProvider_inAppMessages_totalCount");return e?JSON.parse(e):{}},this.getTotalCount=function(e){return t.getTotalCountMap()[e]||0},this.getMessageCounts=function(e){try{return{sessionCount:t.getSessionCount(e),dailyCount:t.getDailyCount(),totalCount:t.getTotalCount(e)}}catch(e){x.error("Failed to get message counts from storage",e)}},this.setSessionCount=function(e,n){t.sessionMessageCountMap[e]=n},this.setDailyCount=function(e){var n=t.config.storage,r={count:e,lastCountTimestamp:D()};try{n.setItem("pinpointProvider_inAppMessages_dailyCount",JSON.stringify(r))}catch(e){x.error("Failed to save daily message count to storage",e)}},this.setTotalCountMap=function(e){var n=t.config.storage;try{n.setItem("pinpointProvider_inAppMessages_totalCount",JSON.stringify(e))}catch(e){x.error("Failed to save total count to storage",e)}},this.setTotalCount=function(e,n){var r,i=G(G({},t.getTotalCountMap()),((r={})[e]=n,r));t.setTotalCountMap(i)},this.incrementCounts=function(e){return L(t,void 0,void 0,(function(){var t,n,r,i;return F(this,(function(o){return t=this.getMessageCounts(e),n=t.sessionCount,r=t.dailyCount,i=t.totalCount,this.setSessionCount(e,n+1),this.setDailyCount(r+1),this.setTotalCount(e,i+1),[2]}))}))},this.normalizeMessages=function(e){return e.map((function(e){var t,n=e.CampaignId,r=e.InAppMessage;return{id:n,content:N(e),layout:(t=r.Layout,t===l.Layout.MOBILE_FEED?"MODAL":t===l.Layout.OVERLAYS?"FULL_SCREEN":t),metadata:k(e)}}))},this.recordMessageEvent=function(e,n){return L(t,void 0,void 0,(function(){return F(this,(function(t){switch(t.label){case 0:return this.initialized?[3,2]:[4,this.init()];case 1:t.sent(),t.label=2;case 2:return function(e,t){if(t)if(o.Amplify.Analytics&&"function"==typeof o.Amplify.Analytics.record){var n=t.id,r=t.metadata;o.Amplify.Analytics.record({name:e,attributes:{campaign_id:n,delivery_type:"IN_APP_MESSAGE",treatment_id:null==r?void 0:r.treatmentId}})}else x.debug("Analytics module is not registered into Amplify");else x.debug("Unable to record analytics event - no InAppMessage was received")}(n,e),n!==S.MESSAGE_DISPLAYED?[3,4]:[4,this.incrementCounts(e.id)];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},this.sessionMessageCountMap={},this.config={storage:(new o.StorageHelper).getStorage()},this.clientInfo=null!==(e=o.ClientDevice.clientInfo())&&void 0!==e?e:{}}return e.prototype.getCategory=function(){return e.category},e.prototype.getSubCategory=function(){return e.subCategory},e.prototype.getProviderName=function(){return e.providerName},e.category="Notifications",e.subCategory="InAppMessaging",e.providerName="AWSPinpoint",e}(),R=function(){return(R=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)},V=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())}))},U=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])}}},B=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},q=new o.ConsoleLogger("Notifications.InAppMessaging"),z=function(){function e(){var e=this;this.config={},this.listeningForAnalyticEvents=!1,this.pluggables=[],this.storageSynced=!1,this.configure=function(t){void 0===t&&(t={});var n=t.listenForAnalyticsEvents,r=void 0===n||n,i=B(t,["listenForAnalyticsEvents"]);return e.config=R(R({},e.config),i),q.debug("configure InAppMessaging",e.config),e.pluggables.forEach((function(t){t.configure(e.config[t.getProviderName()])})),0===e.pluggables.length&&e.addPluggable(new H),r&&!e.listeningForAnalyticEvents&&(o.Hub.listen("analytics",e.analyticsListener),e.listeningForAnalyticEvents=!0),e.config},this.getPluggable=function(t){var n,r=null!==(n=e.pluggables.find((function(e){return e.getProviderName()===t})))&&void 0!==n?n:null;return r||q.debug("No plugin found with name "+t),r},this.addPluggable=function(t){if(t&&"Notifications"===t.getCategory()&&"InAppMessaging"===t.getSubCategory()){if(e.getPluggable(t.getProviderName()))throw new Error("Pluggable "+t.getProviderName()+" has already been added.");e.pluggables.push(t),t.configure(e.config[t.getProviderName()])}},this.removePluggable=function(t){var n=e.pluggables.findIndex((function(e){return e.getProviderName()===t}));-1===n?q.debug("No plugin found with name "+t):e.pluggables.splice(n,1)},this.syncMessages=function(){return Promise.all(e.pluggables.map((function(t){return V(e,void 0,void 0,(function(){var e,n,r;return U(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,t.getInAppMessages()];case 1:return e=i.sent(),n=t.getProviderName()+"_inAppMessages",[4,this.setMessages(n,e)];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),q.error("Failed to sync messages",r),r;case 4:return[2]}}))}))})))},this.clearMessages=function(){return Promise.all(e.pluggables.map((function(t){return V(e,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return e=t.getProviderName()+"_inAppMessages",[4,this.removeMessages(e)];case 1:return n.sent(),[2]}}))}))})))},this.dispatchEvent=function(t){return V(e,void 0,void 0,(function(){var e,n,i=this;return U(this,(function(o){switch(o.label){case 0:return[4,Promise.all(this.pluggables.map((function(e){return V(i,void 0,void 0,(function(){var n,r;return U(this,(function(i){switch(i.label){case 0:return n=e.getProviderName()+"_inAppMessages",[4,this.getMessages(n)];case 1:return r=i.sent(),[2,e.processInAppMessages(r,t)]}}))}))})))];case 1:return e=o.sent(),(n=a()(e)).length&&v(this.conflictHandler(n),r.MESSAGE_RECEIVED),[2]}}))}))},this.identifyUser=function(t,n){return Promise.all(e.pluggables.map((function(r){return V(e,void 0,void 0,(function(){var e;return U(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r.identifyUser(t,n)];case 1:return i.sent(),[3,3];case 2:throw e=i.sent(),q.error("Failed to identify user",e),e;case 3:return[2]}}))}))})))},this.onMessageReceived=function(e){return h(e,r.MESSAGE_RECEIVED)},this.onMessageDisplayed=function(e){return h(e,r.MESSAGE_DISPLAYED)},this.onMessageDismissed=function(e){return h(e,r.MESSAGE_DISMISSED)},this.onMessageActionTaken=function(e){return h(e,r.MESSAGE_ACTION_TAKEN)},this.notifyMessageInteraction=function(e,t){v(e,t)},this.setConflictHandler=function(t){e.conflictHandler=t},this.analyticsListener=function(t){var n=t.payload,r=n.event,i=n.data;switch(r){case"record":e.dispatchEvent(i)}},this.syncStorage=function(){return V(e,void 0,void 0,(function(){var e,t;return U(this,(function(n){switch(n.label){case 0:e=this.config.storage,n.label=1;case 1:return n.trys.push([1,4,,5]),"function"!=typeof e.sync?[3,3]:[4,e.sync()];case 2:n.sent(),n.label=3;case 3:return this.storageSynced=!0,[3,5];case 4:return t=n.sent(),q.error("Failed to sync storage",t),[3,5];case 5:return[2]}}))}))},this.getMessages=function(t){return V(e,void 0,void 0,(function(){var e,n,r;return U(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.storageSynced?[3,2]:[4,this.syncStorage()];case 1:i.sent(),i.label=2;case 2:return e=this.config.storage,[2,(n=e.getItem(t))?JSON.parse(n):[]];case 3:return r=i.sent(),q.error("Failed to retrieve in-app messages from storage",r),[3,4];case 4:return[2]}}))}))},this.setMessages=function(t,n){return V(e,void 0,void 0,(function(){var e;return U(this,(function(r){switch(r.label){case 0:if(!n)return[2];r.label=1;case 1:return r.trys.push([1,4,,5]),this.storageSynced?[3,3]:[4,this.syncStorage()];case 2:r.sent(),r.label=3;case 3:return this.config.storage.setItem(t,JSON.stringify(n)),[3,5];case 4:return e=r.sent(),q.error("Failed to store in-app messages",e),[3,5];case 5:return[2]}}))}))},this.removeMessages=function(t){return V(e,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.storageSynced?[3,2]:[4,this.syncStorage()];case 1:n.sent(),n.label=2;case 2:return this.config.storage.removeItem(t),[3,4];case 3:return e=n.sent(),q.error("Failed to remove in-app messages from storage",e),[3,4];case 4:return[2]}}))}))},this.defaultConflictHandler=function(e){return e.sort((function(e,t){var n,r,i=null===(n=e.metadata)||void 0===n?void 0:n.endDate,o=null===(r=t.metadata)||void 0===r?void 0:r.endDate;return i===o?0:i&&!o?-1:!i&&o?1:new Date(i)<new Date(o)?-1:1}))[0]},this.config={storage:(new o.StorageHelper).getStorage()},this.setConflictHandler(this.defaultConflictHandler)}return e.prototype.getModuleName=function(){return"InAppMessaging"},e}(),K=function(){return(K=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)},Y=new o.ConsoleLogger("Notifications"),J=new(function(){function e(){var e=this;this.config={},this.configure=function(t){var n=(void 0===t?{}:t).Notifications;return e.config=K(K({},e.config),n),Y.debug("configure Notifications",n),e.inAppMessaging.configure(e.config.InAppMessaging),e.config},this.inAppMessaging=new z}return e.prototype.getModuleName=function(){return"Notifications"},Object.defineProperty(e.prototype,"InAppMessaging",{get:function(){return this.inAppMessaging},enumerable:!0,configurable:!0}),e}()),W=J;o.Amplify.register(J)}])})); | ||
//# sourceMappingURL=aws-amplify-notifications.min.js.map |
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
import { ConsoleLogger as Logger } from '@aws-amplify/core'; | ||
import { browserOrNode, ConsoleLogger as Logger } from '@aws-amplify/core'; | ||
import noop from 'lodash/noop'; | ||
@@ -19,3 +19,4 @@ // Per https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API | ||
var visibilityChange; | ||
if (document) { | ||
var isBrowser = browserOrNode().isBrowser; | ||
if (isBrowser && document) { | ||
if (typeof document.hidden !== 'undefined') { | ||
@@ -40,11 +41,15 @@ hidden = 'hidden'; | ||
this.start = function () { | ||
document === null || document === void 0 ? void 0 : document.addEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
if (isBrowser) { | ||
document === null || document === void 0 ? void 0 : document.addEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
} | ||
return _this.getSessionState(); | ||
}; | ||
this.end = function () { | ||
document === null || document === void 0 ? void 0 : document.removeEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
if (isBrowser) { | ||
document === null || document === void 0 ? void 0 : document.removeEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
} | ||
return _this.getSessionState(); | ||
}; | ||
this.getSessionState = function () { | ||
if (document && !document[hidden]) { | ||
if (isBrowser && document && !document[hidden]) { | ||
return 'started'; | ||
@@ -56,3 +61,3 @@ } | ||
this.visibilityChangeHandler = function () { | ||
if (!document) { | ||
if (!isBrowser || !document) { | ||
return; | ||
@@ -59,0 +64,0 @@ } |
@@ -23,3 +23,4 @@ "use strict"; | ||
var visibilityChange; | ||
if (document) { | ||
var isBrowser = core_1.browserOrNode().isBrowser; | ||
if (isBrowser && document) { | ||
if (typeof document.hidden !== 'undefined') { | ||
@@ -44,11 +45,15 @@ hidden = 'hidden'; | ||
this.start = function () { | ||
document === null || document === void 0 ? void 0 : document.addEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
if (isBrowser) { | ||
document === null || document === void 0 ? void 0 : document.addEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
} | ||
return _this.getSessionState(); | ||
}; | ||
this.end = function () { | ||
document === null || document === void 0 ? void 0 : document.removeEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
if (isBrowser) { | ||
document === null || document === void 0 ? void 0 : document.removeEventListener(visibilityChange, _this.visibilityChangeHandler); | ||
} | ||
return _this.getSessionState(); | ||
}; | ||
this.getSessionState = function () { | ||
if (document && !document[hidden]) { | ||
if (isBrowser && document && !document[hidden]) { | ||
return 'started'; | ||
@@ -60,3 +65,3 @@ } | ||
this.visibilityChangeHandler = function () { | ||
if (!document) { | ||
if (!isBrowser || !document) { | ||
return; | ||
@@ -63,0 +68,0 @@ } |
{ | ||
"name": "@aws-amplify/notifications", | ||
"version": "0.2.3-in-app-messaging.7241+3322097b2", | ||
"version": "0.2.4-in-app-messaging.7286+d042ce940", | ||
"description": "Notifications category of aws-amplify", | ||
@@ -45,4 +45,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@aws-amplify/cache": "4.0.23-in-app-messaging.66+3322097b2", | ||
"@aws-amplify/core": "4.3.3-in-app-messaging.66+3322097b2", | ||
"@aws-amplify/cache": "4.0.23-in-app-messaging.69+d042ce940", | ||
"@aws-amplify/core": "4.3.3-in-app-messaging.69+d042ce940", | ||
"@aws-sdk/client-pinpoint": "^3.33.0", | ||
@@ -96,3 +96,3 @@ "lodash": "^4.17.21", | ||
}, | ||
"gitHead": "3322097b2d0bf3a3b76863fa5d85b6829d32f57c" | ||
"gitHead": "d042ce9409a94783c5eb5c05c253b2d40bb5b915" | ||
} |
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
import { ConsoleLogger as Logger } from '@aws-amplify/core'; | ||
import { browserOrNode, ConsoleLogger as Logger } from '@aws-amplify/core'; | ||
import noop from 'lodash/noop'; | ||
@@ -25,4 +25,5 @@ import { | ||
let visibilityChange: string; | ||
const { isBrowser } = browserOrNode(); | ||
if (document) { | ||
if (isBrowser && document) { | ||
if (typeof document.hidden !== 'undefined') { | ||
@@ -50,3 +51,8 @@ hidden = 'hidden'; | ||
start = (): SessionState => { | ||
document?.addEventListener(visibilityChange, this.visibilityChangeHandler); | ||
if (isBrowser) { | ||
document?.addEventListener( | ||
visibilityChange, | ||
this.visibilityChangeHandler | ||
); | ||
} | ||
return this.getSessionState(); | ||
@@ -56,6 +62,8 @@ }; | ||
end = (): SessionState => { | ||
document?.removeEventListener( | ||
visibilityChange, | ||
this.visibilityChangeHandler | ||
); | ||
if (isBrowser) { | ||
document?.removeEventListener( | ||
visibilityChange, | ||
this.visibilityChangeHandler | ||
); | ||
} | ||
return this.getSessionState(); | ||
@@ -65,3 +73,3 @@ }; | ||
private getSessionState = (): SessionState => { | ||
if (document && !document[hidden]) { | ||
if (isBrowser && document && !document[hidden]) { | ||
return 'started'; | ||
@@ -74,3 +82,3 @@ } | ||
private visibilityChangeHandler = () => { | ||
if (!document) { | ||
if (!isBrowser || !document) { | ||
return; | ||
@@ -77,0 +85,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
662244
9263