web-push-notifications 3.40.1 → 3.44.1

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.
Files changed (149) hide show
  1. package/.editorconfig +11 -0
  2. package/.gitlab-ci.yml +190 -0
  3. package/babel.config.js +7 -0
  4. package/ci/cdn/Dockerfile +12 -0
  5. package/ci/dev/Dockerfile +30 -0
  6. package/ci/dev/rootfs/entrypoint.sh +18 -0
  7. package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +6 -0
  8. package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +5 -0
  9. package/ci/dev/rootfs/etc/nginx/_real_ip.conf +2 -0
  10. package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +20 -0
  11. package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +11 -0
  12. package/ci/github/Dockerfile +59 -0
  13. package/ci/github/release-zip.js +61 -0
  14. package/ci/npm/Dockerfile +19 -0
  15. package/config/config.js +24 -0
  16. package/config/configBuilder.js +126 -0
  17. package/config/helpers.js +9 -0
  18. package/config/index.js +1 -0
  19. package/develop/README.md +42 -0
  20. package/develop/favicon.png +0 -0
  21. package/develop/index.html +511 -0
  22. package/eslint.config.mjs +114 -0
  23. package/package.json +4 -34
  24. package/{lib → public}/index.d.ts +10 -10
  25. package/scripts/zip.js +26 -0
  26. package/src/core/Pushwoosh.ts +768 -0
  27. package/src/core/Pushwoosh.types.ts +254 -0
  28. package/src/core/Safari.types.ts +26 -0
  29. package/src/core/constants.ts +58 -0
  30. package/src/core/events.types.ts +46 -0
  31. package/src/core/functions.ts +33 -0
  32. package/src/core/legacyEventsMap.ts +64 -0
  33. package/src/core/logger.ts +64 -0
  34. package/src/core/modules/EventBus/EventBus.ts +66 -0
  35. package/src/core/modules/EventBus/index.ts +1 -0
  36. package/src/core/storage.ts +254 -0
  37. package/src/helpers/logger.ts +81 -0
  38. package/src/helpers/pwlogger/Logger.constants.ts +31 -0
  39. package/src/helpers/pwlogger/Logger.ts +218 -0
  40. package/src/helpers/pwlogger/Logger.types.ts +66 -0
  41. package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +40 -0
  42. package/src/helpers/pwlogger/index.ts +2 -0
  43. package/src/helpers/unescape.ts +36 -0
  44. package/src/models/InboxMessages.ts +202 -0
  45. package/src/models/InboxMessages.types.ts +111 -0
  46. package/src/models/NotificationPayload.ts +216 -0
  47. package/src/models/NotificationPayload.types.ts +65 -0
  48. package/src/modules/Api/Api.ts +386 -0
  49. package/src/modules/Api/Api.types.ts +7 -0
  50. package/src/modules/ApiClient/ApiClient.ts +153 -0
  51. package/src/modules/ApiClient/ApiClient.types.ts +222 -0
  52. package/src/modules/Data/Data.ts +345 -0
  53. package/src/modules/DateModule.ts +53 -0
  54. package/src/modules/InboxMessagesPublic.ts +222 -0
  55. package/src/modules/PlatformChecker/PlatformChecker.ts +170 -0
  56. package/src/modules/PlatformChecker/PlatformChecker.types.ts +5 -0
  57. package/src/modules/PlatformChecker/index.ts +1 -0
  58. package/src/modules/storage/Storage.ts +164 -0
  59. package/src/modules/storage/Storage.types.ts +54 -0
  60. package/src/modules/storage/Store.ts +104 -0
  61. package/src/modules/storage/migrations/26-11-2018.ts +25 -0
  62. package/src/modules/storage/migrations/MigrationExecutor.ts +31 -0
  63. package/src/modules/storage/migrations/Migrations.ts +41 -0
  64. package/src/modules/storage/migrations/constants.ts +8 -0
  65. package/src/modules/storage/migrations/helpers.ts +16 -0
  66. package/src/modules/storage/migrations/initial.ts +47 -0
  67. package/src/modules/storage/version.ts +2 -0
  68. package/src/npm.ts +1 -0
  69. package/src/pushwoosh-web-notifications.ts +47 -0
  70. package/src/pushwoosh-widget-inbox.ts +8 -0
  71. package/src/pushwoosh-widget-subscribe-popup.ts +9 -0
  72. package/src/pushwoosh-widget-subscription-button.ts +8 -0
  73. package/src/pushwoosh-widget-subscription-prompt.ts +6 -0
  74. package/src/service-worker.ts +455 -0
  75. package/src/services/PushService/PushService.ts +2 -0
  76. package/src/services/PushService/PushService.types.ts +74 -0
  77. package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +235 -0
  78. package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts +3 -0
  79. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +125 -0
  80. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +4 -0
  81. package/src/widget-inbox.ts +1 -0
  82. package/src/widget-subscribe-popup.ts +1 -0
  83. package/src/widget-subscription-button.ts +1 -0
  84. package/src/widget-subscription-prompt.ts +33 -0
  85. package/src/widgets/Inbox/InboxWidget.ts +564 -0
  86. package/src/widgets/Inbox/constants.ts +49 -0
  87. package/src/widgets/Inbox/css/inboxWidgetStyle.css +274 -0
  88. package/src/widgets/Inbox/helpers.ts +63 -0
  89. package/src/widgets/Inbox/inbox.d.ts +9 -0
  90. package/src/widgets/Inbox/inbox_widget.types.ts +41 -0
  91. package/src/widgets/Inbox/index.ts +1 -0
  92. package/src/widgets/Inbox/widgetTemplates.ts +55 -0
  93. package/src/widgets/SubscribePopup/SubscribePopup.ts +241 -0
  94. package/src/widgets/SubscribePopup/constants.ts +66 -0
  95. package/src/widgets/SubscribePopup/helpers.ts +11 -0
  96. package/src/widgets/SubscribePopup/index.ts +1 -0
  97. package/src/widgets/SubscribePopup/popupTemplates.ts +24 -0
  98. package/src/widgets/SubscribePopup/styles/popup.css +226 -0
  99. package/src/widgets/SubscribePopup/types/subscribe-popup.ts +68 -0
  100. package/src/widgets/SubscriptionButton/assets/css/main.css +205 -0
  101. package/src/widgets/SubscriptionButton/bell.ts +67 -0
  102. package/src/widgets/SubscriptionButton/constants.ts +28 -0
  103. package/src/widgets/SubscriptionButton/index.ts +377 -0
  104. package/src/widgets/SubscriptionButton/positioning.ts +165 -0
  105. package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +53 -0
  106. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +1 -0
  107. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +110 -0
  108. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +102 -0
  109. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +23 -0
  110. package/src/widgets/SubscriptionPrompt/constants.ts +22 -0
  111. package/src/widgets/SubscriptionPrompt/helpers.ts +42 -0
  112. package/src/widgets/widgets.d.ts +4 -0
  113. package/src/worker/global.ts +36 -0
  114. package/src/worker/notification.ts +34 -0
  115. package/src/worker/worker.types.ts +4 -0
  116. package/test/__helpers__/apiHelpers.ts +22 -0
  117. package/test/__helpers__/keyValueHelpers.ts +15 -0
  118. package/test/__helpers__/platformHelpers.ts +54 -0
  119. package/test/__helpers__/sinonHelpers.ts +7 -0
  120. package/test/__helpers__/storageHelpers.ts +56 -0
  121. package/test/__mocks__/apiRequests.ts +26 -0
  122. package/test/__mocks__/idbMock.ts +12 -0
  123. package/test/__mocks__/idbObjectStoreMock.ts +38 -0
  124. package/test/__mocks__/inboxMessages.ts +292 -0
  125. package/test/__mocks__/models/inboxModel.ts +71 -0
  126. package/test/__mocks__/modules/apiClientModule.ts +18 -0
  127. package/test/__mocks__/modules/dateModule.ts +34 -0
  128. package/test/__mocks__/modules/inboxParamsModule.ts +21 -0
  129. package/test/__mocks__/modules/paramsBuilder.ts +12 -0
  130. package/test/__mocks__/modules/paramsModule.ts +35 -0
  131. package/test/__mocks__/modules/payloadBuilderModule.ts +15 -0
  132. package/test/__mocks__/modules/storageModule.ts +58 -0
  133. package/test/__mocks__/navigator.ts +38 -0
  134. package/test/__mocks__/notification.ts +84 -0
  135. package/test/__mocks__/pushwoosh.ts +12 -0
  136. package/test/__mocks__/userAgents +8 -0
  137. package/test/functions.test.ts +22 -0
  138. package/test/ignore-html.js +6 -0
  139. package/test/mocha.opts +6 -0
  140. package/test/modules/DateModule/unit.test.ts +80 -0
  141. package/test/modules/storage/Storage/unit.test.ts +180 -0
  142. package/test/modules/storage/Store/unit.test.ts +192 -0
  143. package/testRegister.js +24 -0
  144. package/tsconfig.json +31 -0
  145. package/webpack.config.js +163 -0
  146. package/lib/index.js +0 -2
  147. package/lib/index.js.map +0 -1
  148. package/lib/service-worker.js +0 -2
  149. package/lib/service-worker.js.map +0 -1
@@ -0,0 +1,163 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports, no-undef */
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
7
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
8
+ const TerserPlugin = require('terser-webpack-plugin');
9
+ const webpack = require('webpack');
10
+ const { merge } = require('webpack-merge');
11
+
12
+ const config = require('./config').configBuilder;
13
+ const { mapValues } = require('./config/helpers');
14
+
15
+ const isProduction = process.env.NODE_ENV === 'production';
16
+
17
+ const defines = mapValues({
18
+ __VERSION__: require('./package.json').version,
19
+ __SDK_PATH__: isProduction ? 'https://cdn.pushwoosh.com/webpush/v3/' : '',
20
+ }, (value) => JSON.stringify(value));
21
+
22
+ const devServer = {
23
+ host: 'localhost',
24
+ port: 8003,
25
+ };
26
+
27
+ if (config.ssl && config.ssl.key && config.ssl.cert) {
28
+ devServer.server = {
29
+ type: 'https',
30
+ options: {
31
+ key: fs.readFileSync(config.ssl.key),
32
+ cert: fs.readFileSync(config.ssl.cert),
33
+ },
34
+ };
35
+ }
36
+
37
+ class RemoveUnusedTypesPlugin {
38
+ apply(compiler) {
39
+ compiler.hooks.done.tap('RemoveUnusedTypesPlugin', () => {
40
+ const outputPath = compiler.options.output.path;
41
+ console.log(`Cleaning up unused types in ${outputPath}`);
42
+
43
+ // Get all .d.ts files in outputPath
44
+ const files = fs.readdirSync(outputPath);
45
+ files.forEach((file) => {
46
+ if (file.endsWith('.d.ts')) {
47
+ const base = file.slice(0, -5); // remove .d.ts
48
+ const jsFile = base + '.js';
49
+ if (!files.includes(jsFile)) {
50
+ // Delete .d.ts if no .js with same name
51
+ fs.unlinkSync(path.join(outputPath, file));
52
+ console.log(`Deleted unused type: ${file}`);
53
+ }
54
+ }
55
+ });
56
+ });
57
+ }
58
+ }
59
+
60
+ const commonConfig = {
61
+ mode: isProduction ? 'production' : 'development',
62
+ devtool: 'source-map',
63
+
64
+ resolve: {
65
+ extensions: ['.ts', '.js', '.json', '.html'],
66
+ },
67
+
68
+ module: {
69
+ rules: [
70
+ {
71
+ test: /\.ts$/,
72
+ use: {
73
+ loader: 'ts-loader',
74
+ options: {
75
+ compilerOptions: {
76
+ declaration: isProduction,
77
+ },
78
+ },
79
+ },
80
+ exclude: /node_modules/,
81
+ },
82
+ {
83
+ test: /\.js$/,
84
+ use: 'babel-loader',
85
+ exclude: /node_modules\/.*/,
86
+ },
87
+ {
88
+ test: /\.css$/,
89
+ type: 'asset/source',
90
+ },
91
+ ],
92
+ },
93
+
94
+ optimization: {
95
+ minimize: isProduction,
96
+ minimizer: [new TerserPlugin()],
97
+ },
98
+ };
99
+
100
+ const cdnConfig = merge(commonConfig, {
101
+ name: 'cdn',
102
+
103
+ entry: {
104
+ 'pushwoosh-web-notifications': './src/pushwoosh-web-notifications.ts',
105
+ 'pushwoosh-service-worker': './src/service-worker.ts',
106
+
107
+ 'pushwoosh-widget-inbox': './src/pushwoosh-widget-inbox.ts',
108
+ 'pushwoosh-widget-subscribe-popup': './src/pushwoosh-widget-subscribe-popup.ts',
109
+ 'pushwoosh-widget-subscription-button': './src/pushwoosh-widget-subscription-button.ts',
110
+ 'pushwoosh-widget-subscription-prompt': './src/pushwoosh-widget-subscription-prompt.ts',
111
+ },
112
+
113
+ output: {
114
+ path: path.join(__dirname, 'output/cdn'),
115
+ filename: `[name].${isProduction ? '' : 'uncompress.'}js`,
116
+ globalObject: 'this',
117
+ },
118
+
119
+ plugins: [
120
+ new CleanWebpackPlugin(),
121
+ new webpack.DefinePlugin(defines),
122
+ !isProduction && new HtmlWebpackPlugin({
123
+ inject: true,
124
+ template: 'develop/index.html',
125
+ externals: {
126
+ initParams: JSON.stringify(config.initParams),
127
+ },
128
+ chunks: ['pushwoosh-web-notifications'],
129
+ minify: false,
130
+ }),
131
+ ].filter(Boolean),
132
+
133
+ devServer,
134
+ });
135
+
136
+ const npmConfig = merge(commonConfig, {
137
+ name: 'npm',
138
+
139
+ entry: {
140
+ npm: './src/npm.ts',
141
+ 'service-worker': './src/service-worker.ts',
142
+
143
+ 'widget-inbox': './src/widget-inbox.ts',
144
+ 'widget-subscribe-popup': './src/widget-subscribe-popup.ts',
145
+ 'widget-subscription-button': './src/widget-subscription-button.ts',
146
+ 'widget-subscription-prompt': './src/widget-subscription-prompt.ts',
147
+ },
148
+
149
+ output: {
150
+ path: path.join(__dirname, 'output/npm'),
151
+ filename: '[name].js',
152
+ libraryTarget: 'umd',
153
+ globalObject: 'this', // service worker self
154
+ },
155
+
156
+ plugins: [
157
+ new CleanWebpackPlugin(),
158
+ new webpack.DefinePlugin(defines),
159
+ new RemoveUnusedTypesPlugin(),
160
+ ],
161
+ });
162
+
163
+ module.exports = [cdnConfig, npmConfig];
package/lib/index.js DELETED
@@ -1,2 +0,0 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Pushwoosh:()=>ut});const i="deviceRegistrationStatus",s="registered",n="unregistered",a="denied",o="granted",r="default",c="onReady",p="onSubscribe",d="onUnsubscribe",h="onRegister",l="onPermissionPrompt",u="onPermissionDenied",g="onPermissionGranted",b="onSWInitError",w="onPushDelivery",m="onNotificationClick",f="onNotificationClose",x="onChangeCommunicationEnabled",v="onPutNewMessageToInboxStore",y="onUpdateInboxMessages",_="onShowNotificationPermissionDialog",C="onHideNotificationPermissionDialog",k="onShowSubscriptionWidget",S="onHideSubscriptionWidget",E="PW_SiteOpened",T={headerText:"Subscribe to our news",headerTextColor:"#000000",subheaderText:"Don't miss out on the latest news and updates!",subheaderTextColor:"#000000",buttonAcceptText:"Agree",buttonAcceptTextColor:"#1A72E8",buttonAcceptRound:"4px",buttonAcceptBackgroundColor:"#FFFFFF",buttonAcceptBorderColor:"#E3E4E8",buttonCancelText:"Deny",buttonCancelTextColor:"#1A72E8",buttonCancelRound:"4px",buttonCancelBackgroundColor:"#FFFFFF",buttonCancelBorderColor:"#E3E4E8",cappingCount:3,cappingDelay:144e5,backgroundColor:"#FFFFFF"};function P(){return globalThis}function I(){return crypto.randomUUID?.()||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}const M=t=>"function"==typeof t;class B{constructor(){this.addEventHandler=(t,e)=>{let i=this.handlers[t];i||(i=[]),i.push(e),this.handlers[t]=i},this.removeEventHandler=(t,e)=>{const i=this.handlers[t];i&&(this.handlers[t]=i.filter((t=>t!==e)))},this.dispatchEvent=(t,e)=>{const i=e.eventId||I(),s=this.handlers[t];return s?(s.forEach((t=>{M(t)&&setTimeout((()=>{t({...e,eventId:i})}),0)})),i):i},this.handlers={}}}const D="pushwoosh-subscription-widget";class W{constructor(t,e){this.eventBus=t,this.pw=e}init(t){if(!this.getRootElement()){const e=(t=>`\n <div id="${D}-root" class="${D}">\n <div class="${D}__body">\n <div class="${D}__header">\n ${t.headerText}\n </div>\n <div class="${D}__description">\n ${t.subheaderText}\n </div>\n <div class="${D}__controls">\n <button type="button" id="${D}-decline" class="${D}__control ${D}__control_decline">\n ${t.buttonCancelText}\n </button>\n <button type="button" id="${D}-accept" class="${D}__control ${D}__control_accept">\n ${t.buttonAcceptText}\n </button>\n </div>\n </div>\n </div>\n `)(t),i=(t=>{const e=document.createElement("style");return e.innerHTML=`\n .${D} * {\n box-sizing: border-box!important;\n }\n \n .${D} {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n margin: 0 auto;\n width: 320px;\n display: none;\n z-index: 2147483648;\n opacity: 0.99;\n }\n \n .${D}_show {\n display: block;\n }\n \n .${D}__body {\n width: 320px;\n background-color: ${t.backgroundColor?t.backgroundColor:"#FFFFFF"};\n box-shadow: 0 9px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.06);\n border-radius: 4px;\n padding: 20px 20px 12px;\n }\n \n .${D}__header {\n color: ${t.headerTextColor};\n font-size: 18px;\n font-weight: bold; \n }\n \n .${D}__description {\n color: ${t.subheaderTextColor};\n font-size: 14px;\n line-height: 1.5;\n margin-top: 14px;\n }\n \n .${D}__description:empty {\n display: none;\n }\n \n .${D}__controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-end;\n margin: 20px 0 0;\n }\n \n .${D}__control {\n -webkit-appearance: none;\n border: 1px solid transparent;\n font-size: 12px;\n font-weight: bold;\n padding: 0 20px;\n height: 32px;\n cursor: pointer;\n }\n \n .${D}__control_decline {\n color: ${t.buttonCancelTextColor};\n background-color: ${t.buttonCancelBackgroundColor};\n border-radius: ${t.buttonCancelRound};\n border-color: ${t.buttonCancelBorderColor};\n }\n \n .${D}__control_accept {\n color: ${t.buttonAcceptTextColor};\n background-color: ${t.buttonAcceptBackgroundColor};\n border-radius: ${t.buttonAcceptRound};\n border-color: ${t.buttonAcceptBorderColor};\n margin: 0 0 0 12px;\n }\n `,e})(t);document.body.insertAdjacentHTML("beforeend",e),document.head.appendChild(i)}this.addEventListeners()}show(){const t=this.getRootElementWithCheckExist();this.eventBus.dispatchEvent("show-subscription-widget",{}),t.classList.add(`${D}_show`)}hide(){const t=this.getRootElementWithCheckExist();t.classList.contains(`${D}_show`)&&(this.eventBus.dispatchEvent("hide-subscription-widget",{}),t.classList.remove(`${D}_show`))}getRootElement(){return document.getElementById(`${D}-root`)}getRootElementWithCheckExist(){const t=this.getRootElement();if(!t)throw new Error(`Can't find element by id "${D}-root", please use method init first.`);return t}getDeclineButtonWithCheckExist(){const t=document.getElementById(`${D}-decline`);if(!t)throw new Error(`Can't find element by id "${D}-decline", please use method init first.`);return t}getAcceptButtonWithCheckExist(){const t=document.getElementById(`${D}-accept`);if(!t)throw new Error(`Can't find element by id "${D}-accept", please use method init first.`);return t}addEventListeners(){const t=this.getRootElementWithCheckExist(),e=this.getDeclineButtonWithCheckExist(),i=this.getAcceptButtonWithCheckExist();document.addEventListener("click",(e=>{t.contains(e.target)||this.hide()})),e.addEventListener("click",(()=>{this.hide()})),i.addEventListener("click",(()=>{this.hide(),this.pw.subscribe()}))}}const R={[h]:{name:"register"},[p]:{name:"subscribe"},[d]:{name:"unsubscribe"},[b]:{name:"initialize-service-worker-error",prop:"error"},[w]:{name:"receive-push",prop:"notification"},[m]:{name:"open-notification",prop:"notification"},[f]:{name:"hide-notification",prop:"notification"},[x]:{name:"change-enabled-communication",prop:"isEnabled"},[v]:{name:"receive-inbox-message",prop:"message"},[y]:{name:"update-inbox-messages",prop:"messages"},[_]:{name:"show-notification-permission-dialog"},[C]:{name:"hide-notification-permission-dialog",prop:"permission"},[k]:{name:"show-subscription-widget"},[S]:{name:"hide-subscription-widget"},[u]:{name:"permission-denied"},[l]:{name:"permission-default"},[g]:{name:"permission-granted"}},L="keyValue",O="messages",A="log",$="inboxMessages";function N(t,e){return function(i){i.objectStoreNames.contains(t)||e(i)}}const U=[N($,(function(t){const e="status",i=t.createObjectStore($,{keyPath:"inbox_id",autoIncrement:!1});i.createIndex(e,e,{unique:!1,multiEntry:!0}),i.createIndex("rt","rt",{unique:!1,multiEntry:!0})}))];const q=[N(L,(function(t){t.createObjectStore(L,{keyPath:"key"})})),N(A,(function(t){const e=t.createObjectStore(A,{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})})),N(O,(function(t){t.createObjectStore(O,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}))];class H{constructor(t=new Date){this._date=t}set date(t){this._date=t}get date(){return this._date}getUtcTimestamp(){return Math.floor((this.date.getTime()+60*this.date.getTimezoneOffset()*1e3)/1e3)}getTimestamp(){return Math.round(this.date.getTime()/1e3)}setLocal(){const t=this._date.getTime()-60*this.date.getTimezoneOffset()*1e3;this._date=new Date(t)}addDays(t){const e=this._date.getTime()+24*t*60*60*1e3;this._date=new Date(e)}getInboxFakeOrder(){return(100*this._date.getTime()+9e9).toString()}}class F{constructor(t=new H){this.migrations={initial:q,"2018/11/26":U},this.dateModule=t}get initial(){return this.migrations.initial}get dateSorted(){return Object.keys(this.migrations).filter((t=>"initial"!==t)).sort(((t,e)=>{const i=new H(new Date(t)),s=new H(new Date(e));return i.getTimestamp()-s.getTimestamp()})).map((t=>this.migrations[t]))}}class z{constructor(t,e=new F){this.db=t,this.migrationsBuilder=e}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.initial),this.migrationsBuilder.dateSorted.forEach((t=>{this.applyMigrationsPack(t)}))}applyMigrationsPack(t){t.forEach((t=>{t(this.db)}))}}function V(t,e){console.info("onversionchange",e),t.close()}let j;function Y(t){return(j||(j=new Promise(((t,e)=>{const i=indexedDB.open("PUSHWOOSH_SDK_STORE",7);i.onsuccess=i=>{const s=i.target.result;s.onversionchange=V.bind(null,s,e),t(s)},i.onerror=()=>e(i.error),i.onupgradeneeded=t=>{const i=t.target.result;i.onversionchange=V.bind(null,i,e),new z(i).applyMigrations()}}))),j).then((e=>new Promise(((i,s)=>t(e,i,s)))))}class K{_add(t){return Y(((e,i,s)=>{const n=e.transaction([this.name],"readwrite").objectStore(this.name).add(t);n.onsuccess=()=>{i(t)},n.onerror=()=>{s(n.error)}})).then((t=>this.getAll().then((e=>{if(Array.isArray(e)){const i=e.map((t=>t.id)).sort(((t,e)=>t==e?0:t<e?1:-1));if(i.length>this.maxItems)return Promise.all(i.slice(this.maxItems).map((t=>this.delete(t)))).then((()=>t))}return t}))))}delete(t){return Y(((e,i,s)=>{const n=e.transaction([this.name],"readwrite").objectStore(this.name).delete(t);n.onsuccess=()=>{i(n.result)},n.onerror=()=>{s(n.error)}}))}getAll(){return Y(((t,e,i)=>{const s=[],n=t.transaction(this.name).objectStore(this.name).openCursor();n.onsuccess=t=>{const i=t.target.result;i?(i.value&&s.push(i.value),i.continue()):e(s)},n.onerror=()=>{i(n.error)}}))}}const G=(X=L,{get:(t,e)=>Y(((i,s,n)=>{const a=i.transaction(X).objectStore(X).get(t);let o,r=!1,c=!1;const p=()=>{clearTimeout(o),r?s(a.result?.value||e):c?n(a.error):o=setTimeout(p,0)};a.onsuccess=()=>r=!0,a.onerror=()=>c=!0,p()})),getAll:()=>Y(((t,e,i)=>{const s={},n=t.transaction(X).objectStore(X).openCursor();let a,o=!1,r=!1;const c=()=>{clearTimeout(a),o?e(s):r?i(n.error):a=setTimeout(c,0)};n.onsuccess=t=>{const e=t.target.result;e?(s[e.key]=e.value.value,e.continue()):o=!0},n.onerror=()=>r=!0,c()})),async extend(t,e){const i=await this.get(t),{...s}=e;await this.set(t,{...i,...s})},set:(t,e)=>Y(((i,s,n)=>{const a=i.transaction([X],"readwrite").objectStore(X).put({key:t,value:e});let o,r=!1,c=!1;const p=()=>{clearTimeout(o),r?s(t):c?n(a.error):o=setTimeout(p,0)};a.onsuccess=()=>r=!0,a.onerror=()=>c=!0,p()}))});var X;const J=new class extends K{constructor(){super(...arguments),this.name=A,this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(t,e,i){const s={type:t,environment:this.environment,message:`${e}`,date:new Date};return e instanceof Error&&(s.stack=e.stack),i&&(s.additional=i),this._add(s)}},Q=new class extends K{constructor(){super(...arguments),this.name=O,this.maxItems=25}add(t){return this._add({...t,date:new Date})}},Z={error:1,info:2,debug:3};let tt=3;!function(){const t=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],e=P(),i=e.console=e.console||{};for(const e of t)i[e]||(i[e]=()=>{})}();const et={setLevel(t){Z[t]||(t="error"),tt=Z[t]},write(t,e,i){return"error"===t?this.error(e):this.info(e),J.add(t,e,i)}};Object.keys(Z).forEach((t=>{const e=Z[t];et[t]=(...i)=>{e<=tt&&(console.groupCollapsed(t),console.info("",...i),console.trace("trace"),console.groupEnd())}}));class it{constructor(t,e,i,s=new H){this.data=t,this.api=e,this.inboxModel=i,this.dateModule=s,this.publicMessageBuilder=this.publicMessageBuilder.bind(this)}messageTypeFactory(t,e){let i=0;return 2===t?i=1:"l"in e&&null!=e.l&&(i=e.l.startsWith("http")?2:3),i}async updateMessagesStatusWithCodes(t,e,i){const s=[],n=[];e.forEach((async e=>{-1!==t.indexOf(e.inbox_id)&&(e.status=i,s.push(e),n.push(this.api.inboxStatus(e.order,e.status)))})),await this.inboxModel.putBulkMessages(s),await Promise.all(n)}async publicMessageBuilder({action_type:t,action_params:e,image:i,title:s,send_date:n,inbox_id:a,text:o,status:r}){const c=i||await this.data.getDefaultNotificationImage(),p=s||await this.data.getDefaultNotificationTitle(),d=JSON.parse(e);return this.dateModule.date=new Date(1e3*parseInt(n)),this.dateModule.setLocal(),{title:p,imageUrl:c,code:a,message:o,sendDate:this.dateModule.date.toISOString(),type:this.messageTypeFactory(t,d),link:d?.l||"/",isRead:2===r||3===r,isActionPerformed:3===r}}messagesWithNoActionPerformedCount(){return this.inboxModel.getDeliveredReadMessagesCount()}unreadMessagesCount(){return this.inboxModel.getDeliveredMessagesCount()}messagesCount(){return this.inboxModel.messagesCount()}async loadMessages(){const t=[...await this.inboxModel.getReadOpenMessages(),...await this.inboxModel.getDeliveredMessages()].sort(((t,e)=>parseInt(e.send_date,10)-parseInt(t.send_date,10))).sort(((t,e)=>parseInt(e.order||"0",10)-parseInt(t.order||"0",10))).map(this.publicMessageBuilder);return Promise.all(t)}async readMessagesWithCodes(t){const e=await this.inboxModel.getDeliveredMessages();await this.updateMessagesStatusWithCodes(t,e,2)}async performActionForMessageWithCode(t){const e=await this.inboxModel.getMessage(t),i=JSON.parse(e.action_params),s=this.messageTypeFactory(e.action_type,i);2===s&&null!=i.l?document.location.href=i.l:3===s&&null!=i.l&&window.history.go(i.l),e.status=3,await this.inboxModel.putMessage(e),await this.api.inboxStatus(e.order,e.status)}async deleteMessagesWithCodes(t){const e=await this.inboxModel.getReadOpenMessages(),i=await this.inboxModel.getDeliveredMessages();await this.updateMessagesStatusWithCodes(t,[...e,...i],4)}async syncMessages(){await this.inboxModel.updateMessages()}}class st{constructor(t,e){this.name=e,this.store=t.transaction(this.name,"readwrite").objectStore(this.name)}set index(t){this.store.indexNames.contains(t)?this._index=this.store.index(t):console.warn(`Index "${t}" in `)}writeRequestPromise(t,e){return new Promise(((i,s)=>{t.onsuccess=()=>{i(e)},t.onerror=()=>{s(t.error)}}))}readRequestPromise(t,e){return new Promise(((i,s)=>{t.onsuccess=t=>{const s=t.target;i(s.result||e)},t.onerror=()=>{s(t.error)}}))}put(t,e){const i=this.store.put(t,e);return this.writeRequestPromise(i,e)}add(t,e){return this.put(t,e)}delete(t){const e=this.store.delete(t);return this.writeRequestPromise(e)}get(t,e){const i=this.store.get(t);return this.readRequestPromise(i,e)}getAll(){const t=this.store.openCursor(),e=[];return new Promise(((i,s)=>{t.onsuccess=t=>{const s=t.target.result;s?(e.push(s.value),s.continue()):i(e)},t.onerror=()=>{s(t.error)}}))}count(t){const e=this.store.count(t);return this.readRequestPromise(e,0)}countByIndex(t){const e=this._index.count(t);return this.readRequestPromise(e,0)}}class nt{dbVersionChangeHandler(t,e){console.info("onversionchange",e),t.close()}dbRequestSuccessHandler(t,e){const i=e.target.result;i.onversionchange=t=>{this.dbVersionChangeHandler(i,t)},t(i)}dbRequestUpgradeNeededHandler(t){const e=t.target.result;e.onversionchange=t=>{this.dbVersionChangeHandler(e,t)};new z(e).applyMigrations()}getDB(){return new Promise(((t,e)=>{const i=indexedDB.open("PUSHWOOSH_SDK_STORE",7);i.onsuccess=e=>{this.dbRequestSuccessHandler(t,e)},i.onupgradeneeded=t=>{this.dbRequestUpgradeNeededHandler(t)},i.onerror=()=>e(i.error)}))}async put(t,e,i){const s=await this.getDB(),n=new st(s,t),a=await n.put(e,i);return s.close(),a}async delete(t,e){const i=await this.getDB(),s=new st(i,t),n=await s.delete(e);return i.close(),n}async get(t,e,i){const s=await this.getDB(),n=new st(s,t),a=await n.get(e,i);return s.close(),a}async getAll(t){const e=await this.getDB(),i=new st(e,t),s=await i.getAll();return e.close(),s||[]}async count(t,e){const i=await this.getDB(),s=new st(i,t),n=await s.count(e);return i.close(),n}async countByIndex(t,e,i){const s=await this.getDB(),n=new st(s,t);n.index=e;const a=await n.countByIndex(i);return s.close(),a}}class at{constructor(t,e,i,s=new nt,n=new H){this.eventBus=t,this.data=e,this.api=i,this.storage=s,this.storeName="inboxMessages",this.dateModule=n}async getInboxMessages(){const t=await this.api.getInboxMessages();return await this.storeGetInboxMessagesRequestParams(t.next,t.new_inbox),t}async storeGetInboxMessagesRequestParams(t,e){this.dateModule.date=new Date,await this.data.setInboxLastRequestTime(this.dateModule.getUtcTimestamp()),await this.data.setInboxLastRequestCode(t),await this.data.setInboxNewMessagesCount(e)}async putServerMessages(t){const e=t.map((async t=>{const e=await this.storage.get(this.storeName,t.inbox_id,{});return"status"in e&&(t.status=e.status),this.putMessage(t)}));return Promise.all(e)}putMessage(t){return this.storage.put(this.storeName,t)}putBulkMessages(t){const e=t.map((t=>this.putMessage(t)));return Promise.all(e)}deleteMessages(t){const e=t.map((t=>this.storage.delete(this.storeName,t)));return Promise.all(e)}async deleteExpiredMessages(){this.dateModule.date=new Date;const t=this.dateModule.getTimestamp().toString(),e=(await this.storage.getAll(this.storeName)).filter((e=>e.rt<t)).map((t=>t.inbox_id));return this.deleteMessages(e)}getMessage(t){return this.storage.get(this.storeName,t)}async getReadOpenMessages(){return(await this.storage.getAll(this.storeName)).filter((t=>2===t.status||3===t.status))}async getDeliveredMessages(){return(await this.storage.getAll(this.storeName)).filter((t=>1===t.status))}async messagesCount(){return this.storage.count(this.storeName)}async getDeliveredMessagesCount(){return this.storage.countByIndex(this.storeName,"status",1)}async getReadMessagesCount(){return this.storage.countByIndex(this.storeName,"status",2)}async getDeliveredReadMessagesCount(){const[t,e]=[2,3],i=IDBKeyRange.bound(t,e);return this.storage.countByIndex(this.storeName,"status",i)}async updateMessages(){const t=await this.getInboxMessages();await this.deleteExpiredMessages(),t.deleted&&await this.deleteMessages(t.deleted),await this.putServerMessages(t.messages),this.eventBus.dispatchEvent("update-inbox-messages",{messages:new it(this.data,this.api,this)})}}class ot{constructor(t=G){this.store=t}async clearAll(){await this.store.set("params.applicationCode",void 0),await this.store.set("params.hwid",void 0),await this.store.set("params.deviceType",void 0),await this.store.set("params.deviceModel",void 0),await this.store.set("params.language",void 0),await this.store.set("params.apiEntrypoint",void 0),await this.store.set("params.tokens",void 0),await this.store.set("params.applicationServerKey",void 0),await this.store.set("params.senderId",void 0),await this.store.set("params.webSitePushId",void 0),await this.store.set("params.defaultNotificationImage",void 0),await this.store.set("params.defaultNotificationTitle",void 0),await this.store.set("params.userId",void 0),await this.store.set("params.email",void 0),await this.store.set("params.userIdWasChanged",void 0),await this.store.set("params.isLastPermissionStatus",void 0),await this.store.set("params.isManualUnsubscribed",void 0),await this.store.set("params.isCommunicationDisabled",void 0),await this.store.set("params.isDropAllData",void 0),await this.store.set("params.sdkVersion",void 0),await this.store.set("params.serviceWorkerVersion",void 0),await this.store.set("params.serviceWorkerUrl",void 0),await this.store.set("params.serviceWorkerScope",void 0),await this.store.set("params.lastOpenMessage",void 0),await this.store.set("params.lastOpenApplicationTime",void 0),await this.store.set("params.features",void 0),await this.store.set("params.init",void 0)}async setApplicationCode(t){await this.store.set("params.applicationCode",t)}async getApplicationCode(){return await this.store.get("params.applicationCode")}async setApiToken(t){return await this.store.set("params.apiToken",t)}async getApiToken(){return await this.store.get("params.apiToken")}async setHwid(t){await this.store.set("params.hwid",t)}async getHwid(){return await this.store.get("params.hwid")}async setDeviceType(t){await this.store.set("params.deviceType",t)}async getDeviceType(){return await this.store.get("params.deviceType")}async setDeviceModel(t){await this.store.set("params.deviceModel",t)}async getDeviceModel(){return await this.store.get("params.deviceModel")}async setLanguage(t){await this.store.set("params.language",t)}async getLanguage(){return await this.store.get("params.language","en")}async setApiEntrypoint(t){await this.store.set("params.apiEntrypoint",t)}async getApiEntrypoint(){return await this.store.get("params.apiEntrypoint","https://cp.pushwoosh.com/json/1.3/")}async setTokens(t){await this.store.set("params.tokens",t)}getTokens(){return this.store.get("params.tokens")}async setApplicationServerKey(t){await this.store.set("params.applicationServerKey",t)}async getApplicationServerKey(){return await this.store.get("params.applicationServerKey")}async setIsVapidChanged(t){await this.store.set("params.isVapidChanged",t)}async getIsVapidChanged(){return await this.store.get("params.isVapidChanged",!1)}async setWebSitePushId(t){await this.store.set("params.webSitePushId",t)}async getWebSitePushId(){return await this.store.get("params.webSitePushId")}async setDefaultNotificationImage(t){await this.store.set("params.defaultNotificationImage",t)}async getDefaultNotificationImage(){return await this.store.get("params.defaultNotificationImage","https://cp.pushwoosh.com/img/logo-medium.png")}async setDefaultNotificationTitle(t){await this.store.set("params.defaultNotificationTitle",t)}async getDefaultNotificationTitle(){return await this.store.get("params.defaultNotificationTitle","Pushwoosh notification")}async setUserId(t){t?await this.store.set("params.userId",t.toString()):await this.store.set("params.userId",void 0)}async getUserId(){return await this.store.get("params.userId")}async setStatusUserIdWasChanged(t){await this.store.set("params.userIdWasChanged",t)}async getStatusUserIdWasChanged(){return await this.store.get("params.userIdWasChanged",!1)}async setEmail(t){t?await this.store.set("params.email",t.toString()):await this.store.set("params.email",void 0)}async getEmail(){return await this.store.get("params.email")}async setStatusEmailWasChanged(t){await this.store.set("params.emailWasChanged",t)}async getStatusEmailWasChanged(){return await this.store.get("params.emailWasChanged",!1)}async setLastPermissionStatus(t){await this.store.set("params.isLastPermissionStatus",t)}async getLastPermissionStatus(){return await this.store.get("params.isLastPermissionStatus")}async setStatusManualUnsubscribed(t){await this.store.set("params.isManualUnsubscribed",t)}getStatusManualUnsubscribed(){return this.store.get("params.isManualUnsubscribed",!1)}async setStatusCommunicationDisabled(t){await this.store.set("params.isCommunicationDisabled",t)}getStatusCommunicationDisabled(){return this.store.get("params.isCommunicationDisabled",!1)}async setStatusDropAllData(t){await this.store.set("params.isDropAllData",t)}getStatusDropAllData(){return this.store.get("params.isDropAllData",!1)}async setSdkVersion(t){await this.store.set("params.sdkVersion",t)}async getSdkVersion(){return await this.store.get("params.sdkVersion")}async setServiceWorkerVersion(t){await this.store.set("params.serviceWorkerVersion",t)}getServiceWorkerVersion(){return this.store.get("params.serviceWorkerVersion")}async setServiceWorkerUrl(t){t&&await this.store.set("params.serviceWorkerUrl",t)}async getServiceWorkerUrl(){return await this.store.get("params.serviceWorkerUrl","/pushwoosh-service-worker.js")}async setServiceWorkerScope(t){t&&await this.store.set("params.serviceWorkerScope",t)}async getServiceWorkerScope(){return await this.store.get("params.serviceWorkerScope")}async setLastOpenMessage(t){await this.store.set("params.lastOpenMessage",t)}getLastOpenMessage(){return this.store.get("params.lastOpenMessage")}async setLastOpenApplicationTime(t){await this.store.set("params.lastOpenApplicationTime",t)}async getLastOpenApplicationTime(){return await this.store.get("params.lastOpenApplicationTime")}async setFeatures(t){await this.store.set("params.features",t)}async getFeatures(){return await this.store.get("params.features")}async setInitParams(t){await this.store.set("params.init",t)}async getInitParams(){return await this.store.get("params.init")}async setInboxLastRequestCode(t){await this.store.set("params.inbox.lastRequestCode",t)}async getInboxLastRequestCode(){return await this.store.get("params.inbox.lastRequestCode","")}async setInboxLastRequestTime(t){await this.store.set("params.inbox.lastRequestTime",t)}async getInboxLastRequestTime(){return this.store.get("params.inbox.lastRequestTime",0)}async setInboxNewMessagesCount(t){await this.store.set("params.inbox.newMessagesCount",t)}async getInboxNewMessagesCount(){return this.store.get("params.inbox.newMessagesCount",0)}async setDelayedEvent(t){await this.store.set("params.delayedEvent",t)}getDelayedEvent(){return this.store.get("params.delayedEvent")}async setPromptDisplayCount(t){await this.store.set("params.promptDisplayCount",t)}async getPromptDisplayCount(){return this.store.get("params.promptDisplayCount",0)}async setPromptLastSeenTime(t){await this.store.set("params.promptLastSeenTime",t)}async getPromptLastSeenTime(){return this.store.get("params.promptLastSeenTime",0)}}class rt{constructor(t=new ot,e=et){this.data=t,this.logger=e}checkDevice(t){return this.createRequest("checkDevice",t)}getConfig(t){return this.createRequest("getConfig",t,"",!0)}applicationOpen(t){return this.createRequest("applicationOpen",t)}registerDevice(t){return this.createRequest("registerDevice",t)}unregisterDevice(t){return this.createRequest("unregisterDevice",t)}deleteDevice(t){return this.createRequest("deleteDevice",t)}messageDeliveryEvent(t){return this.createRequest("messageDeliveryEvent",t)}pushStat(t){return this.createRequest("pushStat",t)}setTags(t){return this.createRequest("setTags",t)}getTags(t){return this.createRequest("getTags",t)}registerUser(t){return this.createRequest("registerUser",t)}registerEmail(t){return this.createRequest("registerEmail",t)}registerEmailUser(t){return this.createRequest("registerEmailUser",t)}setEmailTags(t){return this.createRequest("setEmailTags",t)}postEvent(t){return this.createRequest("postEvent",t)}getInboxMessages(t){return this.createRequest("getInboxMessages",t)}inboxStatus(t){return this.createRequest("inboxStatus",t)}pageVisit(t,e){return this.createRequest("pageVisit",t,e)}setPurchase(t){return this.createRequest("setPurchase",t)}async createRequest(t,e,i,s){const n=await this.data.getApiEntrypoint(),a=s?"":await this.data.getApiToken(),o=i||n+t,r=a?{headers:{Authorization:`Token ${a}`,"Content-Type":"text/plain;charset=UTF-8",Origin:globalThis.location.origin},credentials:"include"}:{},c=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify({request:e}),...r}),p=await this.checkResponse(c);return p.base_url&&await this.data.setApiEntrypoint(p.base_url),await this.logger.write("apirequest",`${t} call with arguments: ${JSON.stringify(e)} to Pushwoosh has been successful. Result: ${JSON.stringify(p.response)}`),p.response}async checkResponse(t){if(200!==t.status)throw new Error(`Error code: ${t.status}. Error text: ${t.statusText}`);const e=await t.json();if(200!==e.status_code)throw new Error(`Error code: ${e.status_code}. Error text: ${e.status_message}`);return e}}class ct{constructor(t,e=new ot,i=new rt){this.eventBus=t,this.data=e,this.apiClient=i}async checkDevice(){const t=await this.getRequestParams();return await this.apiClient.checkDevice(t)}async checkDeviceSubscribeForPushNotifications(t=!0){let e=localStorage.getItem(i);if(void 0===e||!t){const{exist:t,push_token_exist:a}=await this.checkDevice();localStorage.setItem(i,t&&a?s:n),e=localStorage.getItem(i)}return e===s}async getConfig(t){const e=await this.getRequestParams();return this.apiClient.getConfig({...e,features:t})}async applicationOpen(){const t=await this.getRequestParams();return await this.data.setLastOpenApplicationTime(Date.now()),this.apiClient.applicationOpen(t)}async registerDevice(){if(await this.data.getStatusCommunicationDisabled())throw new Error("Can't register device: Communication is disabled!");const t=await this.getRequestParams(),e=await this.data.getTokens();if(!e.pushToken)throw new Error("Can't register device: pushToken is not exist!");const n=await this.apiClient.registerDevice({...t,push_token:e.pushToken,auth_token:e.authToken,public_key:e.publicKey});return await this.data.setStatusManualUnsubscribed(!1),localStorage.setItem(i,s),this.eventBus.dispatchEvent("register",{}),n}async unregisterDevice(){const t=await this.getRequestParams(),e=this.apiClient.unregisterDevice(t);return localStorage.setItem(i,n),this.eventBus.dispatchEvent("unsubscribe",{}),e}async deleteDevice(){const t=await this.getRequestParams(),e=this.apiClient.deleteDevice(t);return await this.data.setStatusManualUnsubscribed(!0),localStorage.setItem(i,n),this.eventBus.dispatchEvent("unsubscribe",{}),e}async messageDeliveryEvent(t,e,i={}){const s=await this.getRequestParams();return await this.apiClient.messageDeliveryEvent({...s,hash:t,metaData:i})}async pushStat(t,e,i={}){const s=await this.getRequestParams();return await this.apiClient.pushStat({...s,hash:t,metaData:i})}async setTags(t){const{hwid:e,device_type:i,...s}=await this.getRequestParams(),n=await this.data.getEmail();return n&&await this.apiClient.setEmailTags({...s,email:n,tags:t}),this.apiClient.setTags({...s,hwid:e,device_type:i,tags:t})}async getTags(){const t=await this.getRequestParams();return this.apiClient.getTags(t)}async registerUser(t){const{hwid:e,device_type:i,...s}=await this.getRequestParams(),n=await this.data.getDeviceType(),a=`${t}`,o=await this.data.getEmail(),r=await this.apiClient.registerUser({...s,hwid:e,userId:a,ts_offset:60*-(new Date).getTimezoneOffset(),device_type:n});return o&&await this.apiClient.registerEmailUser({...s,email:o,userId:a,ts_offset:60*-(new Date).getTimezoneOffset()}),await this.data.setUserId(`${t}`),await this.data.setStatusUserIdWasChanged(!0),r}async registerEmail(t){const{hwid:e,device_type:i,...s}=await this.getRequestParams(),n=await this.apiClient.registerEmail({...s,email:t,ts_offset:60*-(new Date).getTimezoneOffset()});return await this.data.setEmail(`${t}`),await this.data.setStatusEmailWasChanged(!0),n}async postEvent(t,e){const i=await this.getRequestParams(),s=new Date,n=s.getTime(),a=Math.floor(n/1e3),o=a-s.getTimezoneOffset()/60*3600,r=await this.data.getLastOpenMessage();if(r&&r.expiry>Date.now()){if(e.msgHash)return Promise.reject("attribute msgHash already defined");e={...e,msgHash:r.messageHash}}await this.data.setLastOpenMessage(void 0);const c=await this.apiClient.postEvent({...i,event:t,timestampUTC:a,timestampCurrent:o,attributes:e});return c&&c.code&&this.eventBus.dispatchEvent("receive-in-app-code",{code:c.code}),c}async getInboxMessages(t=0){const e=await this.getRequestParams(),i=await this.data.getInboxLastRequestCode(),s=await this.data.getInboxLastRequestTime();return this.apiClient.getInboxMessages({...e,count:t,last_code:i,last_request_time:s})}async inboxStatus(t,e){const i=await this.getRequestParams();return this.apiClient.inboxStatus({...i,inbox_code:t,status:e,time:(new Date).getTime()})}async triggerEvent(){throw new Error("Method has been deprecated, because we don't aggregate this statistics.")}async pageVisit(t){const e=await this.getRequestParams(),i=await this.data.getFeatures(),s=i&&i.page_visit&&i.page_visit.entrypoint;if(s)return this.apiClient.pageVisit({...e,...t},s)}async setPurchase(t){const e=await this.getRequestParams();return this.apiClient.setPurchase({...e,...t})}async getParams(){return{applicationCode:await this.data.getApplicationCode(),hwid:await this.data.getHwid(),...await this.data.getTokens(),...await this.data.getInitParams()}}get params(){throw new Error('Property "Pushwoosh.api.params" have been deprecated. Use the async method "Pushwoosh.api.getParams()"')}async getRequestParams(){const t=await this.data.getApplicationCode(),e=await this.data.getHwid(),i=await this.data.getUserId(),s=await this.data.getDeviceType(),n=await this.data.getDeviceModel(),a=await this.data.getLanguage(),o=await this.data.getSdkVersion();return{application:t,hwid:e,userId:i||e,device_type:s,device_model:n,timezone:60*-(new Date).getTimezoneOffset(),language:a,v:o}}}class pt{constructor(t){this.global=t,this._isSafari=this.isSafariBrowser(),this._isOpera=this.isOperaBrowser(),this._isEdge=this.isEdgeBrowser(),this._isFirefox=this.isFirefoxBrowser(),this._isChrome=this.isChromeBrowser(),this._isMacOS=this.isMacOS(),this._isAvailableServiceWorker=this.canUseServiceWorkers(),this._isAvailableNotifications=this.canReceiveNotifications(),this._platform=this.getPlatformType(),this._browserVersion=this.getBrowserVersion()}get isEdge(){return this._isEdge}get isSafari(){return this._isSafari}get isOpera(){return this._isOpera}get isAvailableServiceWorker(){return this._isAvailableServiceWorker}get isAvailableNotifications(){return this._isAvailableNotifications}get platform(){return this._platform}get browserVersion(){return this._browserVersion}isSafariBrowser(){return"safari"in this.global&&navigator.userAgent.indexOf("Safari")>-1}isOperaBrowser(){return-1!==navigator.userAgent.indexOf("Opera")||-1!==navigator.userAgent.indexOf("OPR")}isEdgeBrowser(){return navigator.userAgent.indexOf("Edge")>-1}isFirefoxBrowser(){return-1!==navigator.userAgent.toLowerCase().indexOf("firefox")}isChromeBrowser(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)&&!this._isOpera&&!this._isEdge}isMacOS(){return"platform"in navigator&&-1!==navigator.platform.toLowerCase().indexOf("mac")}canUseServiceWorkers(){return!!navigator.serviceWorker&&"PushManager"in this.global&&"Notification"in this.global}canReceiveNotifications(){return this._isSafari&&this._isMacOS||this._isAvailableServiceWorker&&!this._isEdge}getPlatformType(){let t=11;switch(!0){case this._isSafari:t=10;break;case this._isOpera||this._isChrome:t=11;break;case this._isFirefox:t=12;break;case this._isEdge:t=150}return t}getBrowserVersion(){const{userAgent:t}=navigator,e=t.match(/\bOPR\/(\d+)/);if(null!==e)return`Opera ${e[1]}`;const i=t.match(/\bEdge\/(\d+)/);if(null!==i)return`Edge ${i[1]}`;const s=t.match(/\bEdg\/(\d+)/);if(null!==s)return`Edge ${s[1]}`;let n=t.match(/(opera|chrome|safari|firefox(?=\/))\/?\s*(\d+)/i)||[];const[,a=""]=n;n=n[2]?[a,n[2]]:[navigator.appName,navigator.appVersion,"-?"];const o=t.match(/version\/([.\d]+)/i);return null!==o&&n.splice(1,1,o[1]),n.join(" ")}}const dt=new pt(P());class ht{constructor(t,e,i){this.api=t,this.data=e,this.config=i}getPermission(){return Notification.permission}checkIsPermissionGranted(){return this.getPermission()===o}checkIsPermissionDefault(){return this.getPermission()===r}async checkIsManualUnsubscribed(){return this.data.getStatusManualUnsubscribed()}async askPermission(){await Notification.requestPermission()}async getTokens(){return this.data.getTokens()}async subscribe(t){const e=t||await this.trySubscribe();if(!this.checkIsPermissionGranted())return void et.error("You must have permission granted before subscribe!");const i=this.getPushToken(e),s=e.getKey("p256dh"),n=e.getKey("auth");if(!s||!n)throw new Error("Can't get subscription keys!");const a=btoa(String.fromCharCode.apply(String,new Uint8Array(s))),o=btoa(String.fromCharCode.apply(String,new Uint8Array(n)));await this.data.setTokens({publicKey:a,pushToken:i,authToken:o,endpoint:e.endpoint}),await this.api.registerDevice()}async unsubscribe(){const t=await this.getServiceWorkerRegistration(),e=await t.pushManager.getSubscription();await this.data.setTokens({}),await this.data.setStatusManualUnsubscribed(!0),await this.api.unregisterDevice(),e&&await e.unsubscribe()}async checkIsRegister(){return this.api.checkDeviceSubscribeForPushNotifications()}async checkIsNeedResubscribe(){const t=await this.data.getLastPermissionStatus(),e=this.getPermission();if(t!==e)return await this.data.setLastPermissionStatus(e),!0;const i=await this.getCredentials(),s=this.getPushToken(i),n=await this.data.getTokens(),a=s===(n&&n.pushToken||""),o=await this.data.getIsVapidChanged();return!a||o}async getServiceWorkerRegistration(){if(!this.registration){await this.registerServiceWorker();const t=await this.data.getServiceWorkerUrl();this.registration=await navigator.serviceWorker.getRegistration(t),await this.registration.update()}if(!this.registration)throw new Error("Internal Error: Can't register service worker!");return this.registration}async registerServiceWorker(){const t=await this.data.getServiceWorkerUrl(),e=await this.data.getServiceWorkerScope();let i="";await this.data.getSdkVersion()!==await this.data.getServiceWorkerVersion()&&(i=`?cache_clean=${I()}`),await navigator.serviceWorker.register(`${t}${i}`,{scope:e})}async trySubscribe(){try{return await this.subscribePushManager()}catch(t){return console.error(t),await this.unsubscribe(),this.subscribePushManager()}}async subscribePushManager(){const t=await this.getServiceWorkerRegistration(),e=await this.getApplicationServerKey();return t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e?this.urlBase64ToUint8Array(e):null})}async getCredentials(){const t=await this.getServiceWorkerRegistration();return await t.pushManager.getSubscription()}getPushToken(t){return t?t.endpoint:""}async getApplicationServerKey(){if(11===await this.data.getDeviceType())return await this.data.getApplicationServerKey()}urlBase64ToUint8Array(t){const e=(t+"=".repeat((4-t.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),i=atob(e),s=new Uint8Array(i.length);for(let t=0;t<i.length;++t)s[t]=i.charCodeAt(t);return s}}class lt{constructor(t,e,i){this.api=t,this.config=i,this.data=e}getPermission(){const{permission:t}=this.getPermissionInfo();return t}checkIsPermissionGranted(){return this.getPermission()===o}checkIsPermissionDefault(){return this.getPermission()===r}async checkIsManualUnsubscribed(){return await this.data.getStatusManualUnsubscribed()}async askPermission(){const t={application:await this.data.getApplicationCode(),hwid:await this.data.getHwid()};return new Promise((e=>{safari.pushNotification.requestPermission(this.config.entrypoint||"https://cp.pushwoosh.com/json/1.3/safari",this.config.webSitePushId,t,(()=>e()))}))}getTokens(){return this.data.getTokens()}async subscribe(){if(!this.checkIsPermissionGranted())return void et.error("You must have permission granted before subscribe!");const{deviceToken:t}=this.getPermissionInfo();await this.data.setTokens({pushToken:t}),await this.api.registerDevice()}async unsubscribe(){await this.data.setTokens({}),await this.data.setStatusManualUnsubscribed(!0),await this.api.unregisterDevice()}async checkIsRegister(){return this.api.checkDeviceSubscribeForPushNotifications()}async checkIsNeedResubscribe(){const t=await this.data.getWebSitePushId(),e=void 0!==t&&this.config.webSitePushId!==t;await this.data.setWebSitePushId(this.config.webSitePushId);const i=await this.data.getLastPermissionStatus(),s=this.getPermission();return i!==s?(await this.data.setLastPermissionStatus(s),!0):e}getPermissionInfo(){return safari.pushNotification.permission(this.config.webSitePushId)}}class ut{constructor(){this.ready=!1,this.addEventHandler=(t,e)=>this.eventBus.addEventHandler(t,e),this.removeEventHandler=(t,e)=>this.eventBus.removeEventHandler(t,e),this.dispatchEvent=(t,e)=>this.eventBus.dispatchEvent(t,e),this.debug={async showLog(){const t=await J.getAll();console.log(t)},async showKeyValues(){const t=await G.getAll();console.log(t)},async showMessages(){(await Q.getAll()).forEach((t=>console.log(t)))}},this.eventBus=new B,this.data=new ot,this.apiClient=new rt(this.data),this.api=new ct(this.eventBus,this.data,this.apiClient),this.platformChecker=new pt(P()),this.inboxModel=new at(this.eventBus,this.data,this.api),this.pwinbox=new it(this.data,this.api,this.inboxModel),this.subscriptionPromptWidget=new W(this.eventBus,this)}push(t){if(M(t))this.subscribeToLegacyEvents(c,t);else{if(!Array.isArray(t))throw new Error("Invalid command!");if("init"===t[0])this.initialize(t[1]).catch((t=>{console.error("Pushwoosh: Error during initialization",t)}));else if(!this.subscribeToLegacyEvents(t[0],t[1]))throw console.log("Pushwoosh: Unknown command",t),new Error("Unknown command!")}}async subscribe(t=!0){this.isCommunicationDisabled&&et.error("Communication is disabled!");if(this.driver.checkIsPermissionDefault()){this.eventBus.dispatchEvent("show-notification-permission-dialog",{}),await this.driver.askPermission();const t=this.driver.getPermission();this.eventBus.dispatchEvent("hide-notification-permission-dialog",{permission:t})}const e=this.driver.getPermission(),i=await this.data.getStatusManualUnsubscribed(),s=await this.api.checkDeviceSubscribeForPushNotifications(!1);if(e===o){this.eventBus.dispatchEvent("permission-granted",{});return(!s&&!i||t)&&await this.driver.subscribe(),void this.eventBus.dispatchEvent("subscribe",{})}if(e===a)return this.eventBus.dispatchEvent("permission-denied",{}),void(s&&await this.driver.unsubscribe())}async unsubscribe(){try{await this.driver.unsubscribe()}catch(t){et.error(t,"Error occurred during the unsubscribe")}}async forceSubscribe(){await this.subscribe(!0)}isDeviceRegistered(){return localStorage.getItem(i)===s}isDeviceUnregistered(){return localStorage.getItem(i)===n}async isSubscribed(){return this.api.checkDeviceSubscribeForPushNotifications()}async isCommunicationEnabled(){return!await this.data.getStatusCommunicationDisabled()}async setCommunicationEnabled(t=!0){const e=await this.data.getDeviceType(),i=this.driver.checkIsPermissionGranted();await this.data.setStatusCommunicationDisabled(!t),t?(await this.data.setStatusDropAllData(!1),i&&await this.api.registerDevice()):await this.api.unregisterDevice(),this.eventBus.dispatchEvent("change-enabled-communication",{isEnabled:t}),await this.api.postEvent("GDPRConsent",{channel:t,device_type:e})}async removeAllDeviceData(){const t=await this.data.getDeviceType();await this.api.postEvent("GDPRDelete",{status:!0,device_type:t}),await this.api.deleteDevice(),await this.data.clearAll(),await this.data.setStatusDropAllData(!0)}async getHWID(){return await this.data.getHwid()}async getPushToken(){const{pushToken:t}=await this.data.getTokens();return t}async getUserId(){return await this.data.getUserId()}async getParams(){return await this.api.getParams()}isAvailableNotifications(){return this.platformChecker.isAvailableNotifications}async sendStatisticsVisitedPage(){const{document:{title:t},location:{origin:e,pathname:i,href:s}}=window;await this.api.pageVisit({title:t,url_path:`${e}${i}`,url:s})}async initialize(t){const e=localStorage.getItem("PW_SET_LOGGER_LEVEL");if(et.setLevel(e||t.logLevel||"error"),!this.platformChecker.isAvailableNotifications)return;if(!t.applicationCode)throw new Error("Can't find application code!");const i=await this.data.getApplicationCode();i&&i===t.applicationCode||(await this.data.clearAll(),await this.data.setApplicationCode(t.applicationCode));if(!await this.data.getHwid()){const e=t.applicationCode+"_"+I();await this.data.setHwid(e)}await this.data.setDeviceType(this.platformChecker.getPlatformType()),await this.data.setDeviceModel(this.platformChecker.getBrowserVersion()),await this.data.setLanguage(t.tags&&t.tags.Language||navigator.language),await this.data.setApiEntrypoint(t.pushwooshUrl||""),await this.data.setApiToken(t.apiToken||""),await this.data.setSdkVersion("3.40.1");const s=await this.api.getConfig(["page_visit","vapid_key","web_in_apps","events","subscription_prompt"]);this.onGetConfig(s&&s.features),this.subscribeWidgetConfig={enable:!1,...t.subscribeWidget},this.inboxWidgetConfig={enable:!1,...t.inboxWidget},this.subscribePopupConfig={enable:!1,...t.subscribePopup},this.isCommunicationDisabled=await this.data.getStatusCommunicationDisabled(),await this.open();const n=await this.data.getStatusUserIdWasChanged();t.userId&&"user_id"!==t.userId&&!n&&await this.api.registerUser(t.userId);const a=await this.data.getStatusEmailWasChanged();t.email&&""!==t.email&&!a&&(/^\S+@\S+\.\S+$/.test(t.email)?await this.api.registerEmail(t.email):et.write("error",`can't register invalid email: ${t.email}`)),t.tags&&this.api.setTags(t.tags);const o=await this.data.getApplicationServerKey();this.platformChecker.isAvailableNotifications&&o&&await this.initPushNotifications(t);try{await this.inboxModel.updateMessages()}catch(t){et.write("error",t)}this.ready=!0,this.eventBus.dispatchEvent("ready",{});const r=await this.data.getDelayedEvent();if(r){const{type:t,payload:e}=r;this.emitLegacyEventsFromServiceWorker(t,e),await this.data.setDelayedEvent(null)}if("serviceWorker"in navigator&&(navigator.serviceWorker.onmessage=t=>this.onServiceWorkerMessage(t)),localStorage.setItem("pushwoosh-websdk-status","init"),document.dispatchEvent(new CustomEvent("pushwoosh.initialized",{detail:{pw:this}})),this.platformChecker.isSafari){const t=/#P(.*)/,e=decodeURIComponent(document.location.hash);t.test(e)&&this.api.pushStat(t.exec(e)[1]).then((()=>history.pushState(null,"","#")))}}async defaultProcess(t){const e=this.driver.getPermission();"granted"===e&&await this.data.setLastPermissionStatus(e);const i=await this.data.getStatusCommunicationDisabled(),s=await this.data.getStatusDropAllData(),n=await this.driver.checkIsNeedResubscribe(),c=await this.data.getFeatures(),p=c.subscription_prompt&&c.subscription_prompt.use_case;if(i||s)return void await this.unsubscribe();n&&(await this.unsubscribe(),await this.data.setStatusManualUnsubscribed(!1),await this.data.setIsVapidChanged(!1));const{autoSubscribe:d}=t,h=await this.data.getStatusManualUnsubscribed(),l=await this.api.checkDeviceSubscribeForPushNotifications(!1);switch(e){case r:{this.eventBus.dispatchEvent("permission-default",{}),l&&await this.unsubscribe();const t=await this.getWidgetConfig();if(!await this.checkCanShowByCapping(t))break;("default"===p||"not-set"===p&&d)&&(this.subscriptionPromptWidget.init(t),this.subscriptionPromptWidget.show()),await this.updateCappingParams();break}case a:this.eventBus.dispatchEvent("permission-denied",{}),l&&await this.unsubscribe();break;case o:this.eventBus.dispatchEvent("permission-granted",{}),h&&l&&await this.unsubscribe(),(!l&&!h||n)&&await this.subscribe(!0)}}async getWidgetConfig(){const t=await this.data.getFeatures(),e=t.subscription_prompt_widget&&t.subscription_prompt_widget.params,i={cappingCount:T.cappingCount,cappingDelay:T.cappingDelay,...e};return e?i:T}async checkCanShowByCapping(t){const e=(new Date).getTime(),i=await this.data.getPromptDisplayCount(),s=await this.data.getPromptLastSeenTime(),n=t.cappingCount>i,a=e-s>t.cappingDelay;return n&&a}async updateCappingParams(){const t=await this.data.getPromptDisplayCount(),e=(new Date).getTime();await this.data.setPromptDisplayCount(t+1),await this.data.setPromptLastSeenTime(e)}onServiceWorkerMessage(t){const{data:e={}}=t||{},{type:i="",payload:s={}}=e||{};this.emitLegacyEventsFromServiceWorker(i,s)}async open(t){let e=await this.data.getLastOpenApplicationTime();const i=Date.now();e||(e=0);(t||!(i-e<36e5))&&(await this.data.setLastOpenApplicationTime(i),await this.api.applicationOpen())}async onGetConfig(t){if(await this.data.setFeatures(t),t){if(t.page_visit&&t.page_visit.enabled&&(await G.set("PAGE_VISITED_URL",t.page_visit.entrypoint),this.sendStatisticsVisitedPage()),t.events&&t.events.length){t.events.some((t=>t===E))&&this.sendPostEventVisitedPage()}if(t.vapid_key){const e=await this.data.getApplicationServerKey();await this.data.setApplicationServerKey(t.vapid_key),e!==t.vapid_key&&await this.data.setIsVapidChanged(!0)}}}async initPushNotifications(t){await this.data.setDefaultNotificationImage(t.defaultNotificationImage),await this.data.setDefaultNotificationTitle(t.defaultNotificationTitle),await this.data.setServiceWorkerUrl(t.serviceWorkerUrl),await this.data.setServiceWorkerScope(t.scope),await this.data.setInitParams({autoSubscribe:!0,...t}),await this.initDriver();try{await this.defaultProcess(t)}catch(t){et.error(t,"Internal error: defaultProcess fail")}}async initDriver(){if(this.platformChecker.isSafari){const{safariWebsitePushID:t}=await this.data.getInitParams();return t?void(this.driver=new lt(this.api,this.data,{webSitePushId:t})):void et.info("For work with Safari Push Notification add safariWebsitePushID to initParams!")}this.platformChecker.isAvailableServiceWorker&&(this.driver=new ht(this.api,this.data,{}))}sendPostEventVisitedPage(){const{document:{title:t},location:{href:e}}=window;this.api.postEvent(E,{url:e,title:t,device_type:this.platformChecker.platform})}subscribeToLegacyEvents(t,e){let i=!0;switch(!0){case"onLoad"===t:e();break;case t===c:if(this.ready){e(this.api);break}this.eventBus.addEventHandler("ready",(()=>e(this.api)));break;case t in R:this.eventBus.addEventHandler(R[t].name,(i=>{const{prop:s}=R[t];e(this.api,s?i[s]:void 0)}));break;default:i=!1}return i}emitLegacyEventsFromServiceWorker(t,e){switch(t){case w:this.eventBus.dispatchEvent("receive-push",{notification:e});break;case m:this.eventBus.dispatchEvent("open-notification",{notification:e});break;case f:this.eventBus.dispatchEvent("hide-notification",{notification:e});break;case v:this.eventBus.dispatchEvent("receive-inbox-message",{message:e})}}}const gt=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"],bt=[{name:"widgetWidth",type:"size"},{name:"borderRadius",type:"size"},{name:"zIndex",type:"number"},{name:"fontFamily",type:"string"},{name:"bgColor",type:"color"},{name:"textColor",type:"color"},{name:"arrowBorderColor",type:"color"},{name:"borderColor",type:"color"},{name:"badgeBgColor",type:"color"},{name:"badgeTextColor",type:"color"},{name:"timeTextColor",type:"color"},{name:"messageTitleColor",type:"color"},{name:"emptyInboxTitleColor",type:"color"},{name:"emptyInboxTextColor",type:"color"}],wt={enable:!1,triggerId:"pwInbox",position:"bottom",appendTo:"body",title:"Inbox",bgColor:"#ffffff",textColor:"#333333",fontFamily:"inherit",borderRadius:4,borderColor:"transparent",badgeBgColor:"#ff4c00",badgeTextColor:"#ffffff",widgetWidth:350,zIndex:100,messageTitleColor:"#7a7a7a",timeTextColor:"#c4c4c4",emptyInboxTitle:"You're all caught up",emptyInboxTitleColor:"#333333",emptyInboxText:"There are no new messages. Stay tuned!",emptyInboxTextColor:"#7a7a7a",emptyInboxIconUrl:"https://pushon.pushwoosh.com/images/icon-empty-inbox.png",arrowBorderColor:"rgba(0,0,0,.1)"},mt=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/;function ft(t){let e="fixed"===window.getComputedStyle(t).position;return!e&&t.parentElement&&(e=ft(t.parentElement)),e}const xt=({imageUrl:t,title:e,message:i,sendDate:s})=>`\n<div class="pw-inbox_item-inner">\n <div class="pw-inbox_icon">\n <img src="${t}" alt="${e||i}" class="pw-inbox_message-image">\n </div>\n <div class="pw-inbox_content">\n ${e?`<div class="pw-inbox_item-title">\n ${e}\n </div>`:null}\n <div class="pw-inbox_item-body">\n ${i}\n </div>\n <div class="pw-inbox_item-time">\n ${function(t){const e=new Date(t),i=e.getHours()+e.getTimezoneOffset()/60;e.setHours(i);const s=(new Date).getTime()-e.getTime();if(s<=6e4)return"Just now";if(s<36e5&&s>0)return`${Math.floor(s/6e4)} minutes ago`;if(s<864e5&&s>0)return`${Math.floor(s/36e5)} hours ago`;return`${e.getDate()} ${gt[e.getMonth()]} ${e.getFullYear()}, ${e.getHours()}:${`0${e.getMinutes().toString()}`.slice(-2)}`}(s)}\n </div>\n </div>\n</div>\n<span class="pw-inbox_item-remove"></span>`;class vt{constructor(t){this.pw=t,this.config={...wt,arrowBorderColor:this.pw.inboxWidgetConfig.borderColor&&"transparent"!==this.pw.inboxWidgetConfig.borderColor?this.pw.inboxWidgetConfig.borderColor:"rgba(0,0,0,.1)",...this.pw.inboxWidgetConfig},this.updateInbox=this.updateInbox.bind(this),this.markVisibleItemsAsRead=this.markVisibleItemsAsRead.bind(this),this.onWidgetClickHandler=this.onWidgetClickHandler.bind(this),this.onTriggerClickHandler=this.onTriggerClickHandler.bind(this),this.onWindowScrollHandler=this.onWindowScrollHandler.bind(this),this.toggle=this.toggle.bind(this);try{this.initTrigger(),this.updateInbox(),this.addListeners()}catch(t){console.warn(t)}}toggle(t){(void 0===t?!this.isOpened:t)?this.openWidget():this.closeWidget()}initTrigger(){if(!this.pw.pwinbox)throw new Error("Web inbox is not allowed.");const t=document.getElementById(this.config.triggerId);if(!t)throw new Error("Inbox trigger element doesn't exist. You must set triggerId in inboxWidget config. See the documentation.");this.trigger=t,this.trigger.classList.add("pw-inbox-trigger"),this.defaultMargin=12,this.messagesElements={},this.messages=[],this.readItems=[],this.updateCounter(0),this.isOpened=!1,this.renderWidget(),this.isFixed=ft(this.trigger)}renderWidget(){this.widget=document.createElement("div"),this.widget.id="pwInboxWidget",this.widget.className="pw-inbox-widget",this.widget.classList.toggle("pw-open",this.isOpened),this.widgetParent=document.querySelector(this.config.appendTo)||document.body,this.widgetParent.appendChild(this.widget),this.widgetParent.appendChild(this.getStyle()),this.renderWidgetInner()}getStyle(){const t=document.createElement("style");return t.innerHTML=this.configureStyle(".pw-inbox-trigger {\n position: relative;\n cursor: pointer;\n}\n\n.pw-inbox-trigger:after {\n content: attr(data-pw-count);\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n background: var(--badgeBgColor);\n border-radius: 8px;\n color: var(--badgeTextColor);\n font-size: 10px;\n font-weight: normal;\n line-height: 16px;\n width: 16px;\n padding: 0 2px;\n box-sizing: border-box;\n text-align: center;\n}\n\n.pw-inbox-trigger.pw-empty:after {\n display: none;\n}\n\n.pw-inbox-widget * {\n position: static;\n box-sizing: border-box;\n font-size: 1em;\n outline: none;\n font-family: var(--fontFamily);\n}\n.pw-inbox-widget {\n font-size: 14px;\n position: absolute;\n top: 0;\n left: -1000px;\n background: var(--bgColor);\n border: solid 1px var(--borderColor);\n border-radius: var(--borderRadius);\n width: var(--widgetWidth);\n box-shadow: 0 1px 4px 0 rgba(0,0,0,.25);\n z-index: var(--zIndex);\n opacity: 0;\n transition: opacity .6s ease;\n transition-delay: 100ms;\n}\n.pw-inbox-widget.pw-open {\n opacity: 1;\n transition-delay: 0ms;\n}\n.pw-inbox-widget.pw-inbox-widget--inset {\n top: auto;\n left: auto;\n display: none;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-open {\n display: block;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-bottom {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-top {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-right {\n left: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-left {\n right: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--empty {\n max-height: none;\n}\n.pw-inbox-widget .pw-inbox__arrow {\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget .pw-inbox__arrow:before {\n content: \"\";\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget.pw-top {\n margin-top: -12px;\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow {\n border-top-color: var(--arrowBorderColor);\n bottom: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow:before {\n border-top-color: var(--bgColor);\n top: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-bottom {\n margin-top: 12px;\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow {\n border-bottom-color: var(--arrowBorderColor);\n top: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow:before {\n border-bottom-color: var(--bgColor);\n bottom: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-left {\n margin-left: -12px;\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow {\n border-left-color: var(--arrowBorderColor);\n right: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow:before {\n border-left-color: var(--bgColor);\n left: -11px;\n top: -10px;\n}\n.pw-inbox-widget.pw-right {\n margin-left: 12px;\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow {\n border-right-color: var(--arrowBorderColor);\n left: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow:before {\n border-right-color: var(--bgColor);\n right: -11px;\n top: -10px;\n}\n.pw-inbox_inner {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.pw-inbox_title {\n color: var(--textColor);\n margin: 0;\n padding: 28px 32px 12px;\n font-size: 24px;\n font-weight: 500;\n line-height: 1.1;\n text-align: left;\n flex: 0 0 66px;\n}\n.pw-inbox_list {\n overflow-x: hidden;\n overflow-y: auto;\n min-width: 200px;\n max-height: 300px;\n padding: 0;\n margin: 0;\n list-style: none;\n position: relative;\n flex: 1 1 auto;\n}\n\n.pw-inbox_item {\n position: relative;\n padding: 8px 32px;\n margin: 0;\n text-align: left;\n}\n.pw-inbox_item-inner {\n display: flex;\n cursor: pointer;\n}\n.pw-inbox_icon {\n flex: 0 0 40px;\n}\n.pw-inbox_message-image {\n width: 28px;\n}\n.pw-inbox_content {\n flex: 0 1 100%;\n}\n.pw-inbox_item-title {\n color: var(--messageTitleColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-body {\n color: var(--textColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-time {\n color: var(--timeTextColor);\n font-size: 12px;\n line-height: 17px;\n}\n.pw-inbox_item-remove {\n position: absolute;\n z-index: 2;\n top: 8px;\n right: 8px;\n display: none;\n width: 10px;\n height: 10px;\n background: transparent url('https://cdn.pushwoosh.com/webpush/img/iconClose.svg') 50% no-repeat;\n cursor: pointer;\n}\n.pw-inbox_item:hover .pw-inbox_item-remove {\n display: block;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-title {\n color: var(--textColor);\n font-weight: 700;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-body {\n font-weight: 700;\n}\n\n.pw-inbox_list--empty {\n padding: 50px 16px;\n text-align: center;\n max-height: 100%;\n overflow: auto;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-icon {\n text-align: center;\n margin-bottom: 30px;\n}\n.pw-inbox_list--empty .pw-inbox_list-icon img {\n max-width: 100%;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-title {\n font-size: 28px;\n line-height: 36px;\n color: var(--emptyInboxTitleColor);\n margin-bottom: 20px;\n}\n\n.pw-inbox_list--empty .ipw-inbox_list-body {\n font-size: 14px;\n line-height: 18px;\n color: var(--emptyInboxTextColor);\n}\n"),t}configureStyle(t){let e=t.toString();return bt.forEach((t=>{const i=new RegExp(`var\\(--${t.name}\\)`,"ig"),s=this.getStyleFormatter(t);e=e.replace(i,s)})),e}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(e=this.config[t.name].toString())||mt.test(e)?e:"#333";default:return"none"}var e}renderWidgetInner(){if(this.messages.length>0)this.widget.classList.remove("pw-inbox-widget--empty"),this.widget.innerHTML=`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_inner">\n <div class="pw-inbox_title">\n ${this.config.title}\n </div>\n <ul class="pw-inbox_list">\n\n </ul>\n</div>`,this.renderMessages();else{this.widget.classList.add("pw-inbox-widget--empty");const{emptyInboxTitle:t,emptyInboxText:e,emptyInboxIconUrl:i}=this.config;this.widget.innerHTML=((t,e,i)=>`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_list--empty">\n <div class="pw-inbox_list-icon">\n <img src="${t}" alt="${e}">\n </div>\n <div class="pw-inbox_list-title">\n ${e}\n </div>\n <div class="ipw-inbox_list-body">\n ${i}\n </div>\n</div>`)(i,t,e)}}renderMessages(){this.list=this.widget.querySelector(".pw-inbox_list")||document.createElement("ul"),this.messages.forEach((t=>{const e=document.createElement("li");e.className="pw-inbox_item",e.classList.toggle("pw-new",!t.isRead),e.classList.toggle("pw-unread",!t.isActionPerformed),e.setAttribute("data-pw-inbox-message-id",t.code),e.innerHTML=xt(t),this.list.appendChild(e),this.messagesElements[t.code]=e}))}updateCounter(t){this.count=t,this.trigger.setAttribute("data-pw-count",`${this.count}`),this.trigger.classList.toggle("pw-empty",0===this.count)}updateInboxMessages(t){this.messages=t.sort((({sendDate:t},{sendDate:e})=>function(t,e){const i=new Date(t),s=i.getHours()+i.getTimezoneOffset()/60,n=new Date(e),a=n.getHours()+n.getTimezoneOffset()/60;return i.setHours(s),n.setHours(a),n.getTime()-i.getTime()}(t,e))),this.renderWidgetInner()}openWidget(){this.isOpened=!0,this.widget.classList.add("pw-open"),document.addEventListener("click",this.onWidgetClickHandler),window.addEventListener("scroll",this.onWindowScrollHandler),window.addEventListener("resize",this.onWindowScrollHandler),this.markVisibleItemsAsRead(),this.messages.length>0&&this.list.addEventListener("scroll",this.markVisibleItemsAsRead),this.positionWidget()}closeWidget(){this.isOpened=!1,document.removeEventListener("click",this.onWidgetClickHandler),document.removeEventListener("click",this.onWindowScrollHandler),window.removeEventListener("resize",this.onWindowScrollHandler),this.updateReadStatus(),this.messages.length>0&&this.list.removeEventListener("scroll",this.markVisibleItemsAsRead),this.widget.classList.remove("pw-open","pw-top","pw-bottom","pw-right","pw-left"),this.widget.removeAttribute("style")}positionWidget(){this.isOpened&&(this.widgetParent===document.body?this.defaultPlaceWidget():this.customPlaceWidget())}customPlaceWidget(){const{position:t}=this.config;this.widgetParent.style.position="relative",this.widget.classList.add("pw-inbox-widget--inset"),this.widget.classList.add(`pw-${t}`)}defaultPlaceWidget(){const t=this.pw.inboxWidgetConfig.position?this.config.position:this.getDefaultPosition(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const i=Math.max(document.documentElement.clientWidth,window.innerWidth||0),s=Math.max(document.documentElement.clientHeight,window.innerHeight||0);switch(e.width+2*this.defaultMargin>i&&(this.widget.style.width=i-2*this.defaultMargin+"px"),e.height+24>s&&(this.widget.style.height=s-2*this.defaultMargin+"px"),t){case"top":this.alignWidgetTop();break;case"right":this.alignWidgetRight();break;case"left":this.alignWidgetLeft();break;case"bottom":this.alignWidgetBottom()}}alignWidgetTop(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const i=Math.max(document.documentElement.clientWidth,window.innerWidth||0),s=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-top");let n=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const a=n<pageXOffset,o=n+e.width>pageXOffset+i;a&&(n=pageXOffset+this.defaultMargin),o&&(n=pageXOffset+i-e.width-this.defaultMargin);const r=pageYOffset+t.top-e.height;this.alignWidgetElement(n,r),s.style.left=t.left+Math.floor(t.width/2)-n+"px";const c=this.widget.getBoundingClientRect().top;if(c<0){const t=this.widget.getBoundingClientRect().height+c-this.defaultMargin,e=this.widget.getBoundingClientRect().top-c+this.defaultMargin;this.widget.style.height=`${t}px`,this.widget.style.top=`${e}px`}}alignWidgetRight(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const i=Math.max(document.documentElement.clientWidth,window.innerWidth||0),s=Math.max(document.documentElement.clientHeight,window.innerHeight||0),n=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-right");let a=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const o=a<pageYOffset,r=pageYOffset+s<a+e.height;o&&(a=pageYOffset+this.defaultMargin),r&&(a=pageYOffset+s-e.height-this.defaultMargin);const c=pageXOffset+t.left+t.width;this.alignWidgetElement(c,a),n.style.top=t.top+Math.floor(t.height/2)-a+"px";const p=i-this.widget.getBoundingClientRect().right;if(p<this.defaultMargin){const t=this.widget.getBoundingClientRect().width+p-this.defaultMargin;this.widget.style.width=`${t}px`}}alignWidgetLeft(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),s=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-left");let n=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const a=n<pageYOffset,o=pageYOffset+i<n+e.height;a&&(n=pageYOffset+this.defaultMargin),o&&(n=pageYOffset+i-e.height-this.defaultMargin);const r=pageXOffset+t.left-e.width;this.alignWidgetElement(r,n),s.style.top=t.top+Math.floor(t.height/2)-n+"px";const c=this.widget.getBoundingClientRect().left;if(c<0){const t=this.widget.getBoundingClientRect().width+c-this.defaultMargin,e=this.widget.getBoundingClientRect().left-c;this.widget.style.width=`${t}px`,this.widget.style.left=`${e}px`}}alignWidgetBottom(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const i=Math.max(document.documentElement.clientWidth,window.innerWidth||0),s=Math.max(document.documentElement.clientHeight,window.innerHeight||0),n=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-bottom");let a=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const o=a<pageXOffset,r=a+e.width>pageXOffset+i;o&&(a=pageXOffset+this.defaultMargin),r&&(a=pageXOffset+i-e.width-12);const c=pageYOffset+t.top+t.height;this.alignWidgetElement(a,c),n.style.left=t.left+Math.floor(t.width/2)-a+"px";const p=s-this.widget.getBoundingClientRect().bottom;if(p<this.defaultMargin){const t=this.widget.getBoundingClientRect().height+p-this.defaultMargin;this.widget.style.height=`${t}px`}}alignWidgetElement(t,e){this.widget.style.left=`${t}px`,this.widget.style.top=`${e}px`}getDefaultPosition(){const{left:t,top:e,width:i,height:s}=this.trigger.getBoundingClientRect();if(!document.documentElement)return"";const n={right:t,bottom:e,left:Math.max(document.documentElement.clientWidth,window.innerWidth||0)-(t+i),top:Math.max(document.documentElement.clientHeight,window.innerHeight||0)-(e+s)},a=Math.min(t,e,n.left,n.top);let o="bottom";return Object.keys(n).forEach((t=>{n[t]===a&&(o=t)})),o}addListeners(){this.trigger.addEventListener("click",this.onTriggerClickHandler),this.pw.push(["onPutNewMessageToInboxStore",()=>{this.updateInbox()}]),this.pw.push(["onUpdateInboxMessages",()=>{this.updateInbox()}])}markVisibleItemsAsRead(){if(0===this.messages.length)return;const t=this.list.clientHeight+this.list.scrollTop-50;Object.keys(this.messagesElements).forEach((e=>{if(!this.messagesElements[e]||this.messagesElements[e].offsetTop>t)return;const i=this.messages.find((t=>t.code===e));!i||i.isRead||this.readItems.indexOf(e)+1||this.readItems.push(e)}))}updateReadStatus(){this.pw.pwinbox.readMessagesWithCodes(this.readItems).then(this.updateInbox)}updateInbox(){this.pw.pwinbox.loadMessages().then((t=>{this.updateInboxMessages(t)})),this.pw.pwinbox.unreadMessagesCount().then((t=>{this.updateCounter(t)}))}performMessageAction(t){this.pw.pwinbox.performActionForMessageWithCode(t).then((()=>{this.updateInbox()}))}removeMessages(t){t.forEach((t=>{this.readItems=this.readItems.slice(this.readItems.indexOf(t),1)})),this.pw.pwinbox.deleteMessagesWithCodes(t).then((()=>{this.updateInbox()}))}onTriggerClickHandler(t){t.stopPropagation(),t.target&&this.toggle()}onWidgetClickHandler(t){if(!t.target)return;const e=t.target.closest(".pw-inbox_item");if(!e)return void this.toggle();const i=e.getAttribute("data-pw-inbox-message-id");if(!i)return;t.target.closest(".pw-inbox_item-remove")?this.removeMessages([i]):this.performMessageAction(i)}onWindowScrollHandler(){this.isFixed&&this.isOpened?this.toggle():this.positionWidget()}}const yt="bottomRight",_t="bottomLeft",Ct="topRight",kt="topLeft",St={position:_t,bgColor:"#12AE7E",bellColor:"white",bellStrokeColor:"#08754f",bellButtonBorder:"1px solid #379676",shadow:"0px 0px 6px rgba(0, 0, 0, 0.75)",size:"48px",indent:"20px",zIndex:"999999",tooltipText:{successSubscribe:"You are successfully subscribed!",needSubscribe:"Get notifications about important news!",blockSubscribe:"Click to see how to get notifications",alreadySubscribed:"You are already subscribed"}};class Et{static getBellPosition(t,e){let i;switch(t){case yt:i={top:"auto",left:"auto",bottom:e,right:e};break;case _t:i={top:"auto",left:e,bottom:e,right:"auto"};break;case kt:i={top:e,left:e,bottom:"auto",right:"auto"};break;case Ct:i={top:e,left:"auto",bottom:"auto",right:e};break;default:i={top:"auto",left:"auto",bottom:e,right:e}}return i}static getTooltipPosition(t,e){let i,s;const n=parseInt(e)+12+"px";switch(t){case yt:i={right:n},s="right";break;case _t:case kt:i={left:n},s="left";break;default:i={right:n},s="right"}return[i,s]}static getPopoverPosition(t,e){let i,s;const n=parseInt(e)+15+"px";switch(t){case yt:i={bottom:n,right:"0",left:"auto",top:"auto"},s="bottom";break;case _t:i={bottom:n,left:"0",right:"auto",top:"auto"},s="bottom";break;case kt:i={top:n,left:"0",right:"auto",bottom:"auto"},s="top";break;case Ct:i={top:n,right:"0",left:"auto",bottom:"auto"},s="top";break;default:i={bottom:n,right:"0",left:"auto",top:"auto"},s="bottom"}return[i,s]}static getPopoverArrowPosition(t,e){let i;switch(t){case yt:i="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;case _t:i="\n.pushwoosh-subscribe-widget__popover__bottom:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case kt:i="\n.pushwoosh-subscribe-widget__popover__top:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case Ct:i="\n.pushwoosh-subscribe-widget__popover__top:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;default:i="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px")}return i}}class Tt{constructor(t){if(this.pw=t,!dt.isAvailableNotifications)return void console.warn("Browser does not support push notifications");this.clickBell=this.clickBell.bind(this),this.onSubscribeEvent=this.onSubscribeEvent.bind(this),this.onUnsubscribeEvent=this.onUnsubscribeEvent.bind(this),this.onPermissionDeniedEvent=this.onPermissionDeniedEvent.bind(this),this.clickOutOfPopover=this.clickOutOfPopover.bind(this);const e=Object.assign(St.tooltipText,t.subscribeWidgetConfig.tooltipText);this.config=Object.assign({},St,t.subscribeWidgetConfig),this.config.tooltipText=e,t.isSubscribed().then((t=>{t||this.render()}))}addStylesToElement(t,e){Object.keys(t).forEach((i=>{e.style[i]=t[i]}))}createContainer(){const t=document.createElement("div");t.id="pushwooshBellWidget",t.className="pushwoosh-subscribe-widget";const e=Et.getBellPosition(this.config.position,this.config.indent),i=Object.assign({zIndex:this.config.zIndex},e);return this.addStylesToElement(i,t),t}createStyle(){const t=document.createElement("style");return t.innerHTML='/* Widget */\n.pushwoosh-subscribe-widget {\n position: fixed;\n display: block;\n transform: translate3d(0, 0, 0);\n}\n\n.pushwoosh-subscribe-widget__subscribed {\n display: none;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button {\n border-radius: 50%;\n cursor: pointer;\n font-size: 0;\n text-align: center;\n transform: scale(0.9) translate3d(0, 0, 0);\n transition: transform .3s ease-in-out;\n position: relative;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button:hover {\n transform: scale(1);\n}\n\n/* Tooltip */\n.pushwoosh-subscribe-widget__tooltip {\n position: absolute;\n height: 48px;\n max-width: 300px;\n min-width: 200px;\n padding: 5px 7px;\n background-color: #3b444b;\n color: #ffffff;\n text-align: center;\n vertical-align: middle;\n box-sizing: border-box;\n line-height: 38px;\n font-size: 0;\n font-weight: normal;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .3s,\n opacity .3s ease-in;\n top: 50%;\n transform: translate(0, -50%);\n box-shadow: 1px 1px 5px 0 rgba(0,0,0,0.5);\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after,\n.pushwoosh-subscribe-widget__tooltip__left:after {\n content: "";\n top: 50%;\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n background: #3b444b;\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after {\n left: calc(100% - 7px);\n border-top: 5px solid #3b444b;\n border-left: 5px solid #3b444b;\n border-right: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__tooltip__left:after {\n left: -7px;\n border-top: 5px solid #3b444b;\n border-right: 5px solid #3b444b;\n border-left: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: -2px -2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__bell-button:hover + .pushwoosh-subscribe-widget__tooltip,\n.pushwoosh-subscribe-widget__tooltip.pushwoosh-subscribe-widget__tooltip__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__tooltip-content {\n display: inline-block;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1.4;\n white-space: nowrap;\n overflow: hidden;\n padding-right: 5px;\n text-overflow: ellipsis;\n max-width: 100%;\n}\n\n/* Popover */\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover {\n position: absolute;\n right: auto;\n box-shadow: 1px 1px 5px 0 rgba(0, 0, 0, 0.5);\n box-sizing: border-box;\n background: #9ca8b1;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .5s,\n opacity .5s ease-in;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after,\n.pushwoosh-subscribe-widget__popover__top:after {\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-right: 8px solid transparent;\n border-left: 8px solid #9ca8b1;\n background: #9ca8b1;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after {\n border-bottom: 8px solid #9ca8b1;\n border-top: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: -2px 2px 1px 0 rgba(0, 0, 0, 0.25);\n bottom: -16px;\n}\n\n.pushwoosh-subscribe-widget__popover__top:after {\n top: 0;\n border-top: 8px solid #9ca8b1;\n border-bottom: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: 1px -1px 1px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__popover-content-wrapper {\n overflow: auto;\n max-width: 100%;\n}\n\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n display: flex;\n flex-direction: column;\n padding: 14px;\n box-sizing: border-box;\n float: left;\n min-width: 100%;\n align-items: center;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n display: block;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-bottom: 14px;\n}\n\n@media (max-width: 767px) and (orientation: portrait) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: column;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 0;\n margin-bottom: 14px;\n }\n}\n@media (max-width: 767px) and (orientation: landscape) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: row;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 14px;\n margin-bottom: 0;\n }\n}\n',t}createBell(){const{config:t}=this;let e;var i,s;return t.buttonImage?(e=document.createElement("img"),e.src=t.buttonImage):(e=document.createElement("div"),this.addStylesToElement({backgroundColor:t.bgColor,boxShadow:t.shadow,lineHeight:t.size,border:t.bellButtonBorder},e),e.innerHTML=(i=t.bellColor,s=t.bellStrokeColor,`<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg\n xmlns:dc="http://purl.org/dc/elements/1.1/"\n xmlns:cc="http://creativecommons.org/ns#"\n xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n version="1.1"\n id="Capa_1"\n x="0px"\n y="0px"\n viewBox="0 0 346.013 346.013"\n style="enable-background:new 0 0 346.013 346.013;width: 80%; height: auto; vertical-align: middle;"\n xml:space="preserve"\n inkscape:version="0.91 r13725"\n sodipodi:docname="alarm_white.svg"><metadata\n id="metadata51"><rdf:RDF><cc:Work\n rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type\n rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs\n id="defs49" /><sodipodi:namedview\n borderopacity="1"\n objecttolerance="10"\n gridtolerance="10"\n guidetolerance="10"\n inkscape:pageopacity="0"\n inkscape:pageshadow="2"\n inkscape:window-width="1618"\n inkscape:window-height="828"\n id="namedview47"\n showgrid="false"\n inkscape:zoom="0.6820553"\n inkscape:cx="173.0065"\n inkscape:cy="173.0065"\n inkscape:window-x="0"\n inkscape:window-y="0"\n inkscape:window-maximized="0"\n inkscape:current-layer="g3" /><g\n id="g3"><path\n d="m 256.76227,220.19006 c -1.77513,-2.69766 -3.45154,-5.24564 -3.98966,-7.46382 -0.042,-0.17861 -0.0911,-0.36128 -0.16237,-0.61436 -2.28354,-7.67647 0.69147,-24.43921 2.46886,-34.45124 0.26788,-1.50394 0.52274,-2.94197 0.75286,-4.29035 0.0232,-0.13675 0.044,-0.27211 0.0724,-0.48006 1.95582,-15.28051 2.58811,-37.91956 -5.51044,-58.99147 -5.6032,-14.57978 -14.45978,-25.82612 -26.3559,-33.48393 1.26598,-9.812938 -4.85967,-19.343691 -14.66682,-22.0511 -9.80715,-2.70741 -19.95724,2.33226 -23.90298,11.405413 -14.1382,0.467533 -27.51111,5.577097 -39.80114,15.219267 -17.76129,13.9298 -28.83431,33.68757 -34.99389,47.80757 l -0.0479,0.11335 c -0.0512,0.12175 -0.0998,0.24114 -0.13249,0.32962 -0.49733,1.28292 -1.01552,2.64514 -1.55689,4.07255 -3.61311,9.51043 -9.66004,25.42824 -15.611995,30.89342 -0.106524,0.10027 -0.208228,0.20187 -0.362362,0.35435 -1.636243,1.66563 -4.382941,2.99463 -7.288979,4.40101 -7.145531,3.45301 -22.013613,10.64166 -17.206389,31.67844 0.929154,4.07105 4.008437,7.29057 8.033861,8.40185 l 167.570804,46.2604 c 4.02253,1.11048 8.31521,-0.0729 11.2052,-3.08958 14.91617,-15.58874 5.84693,-29.38668 1.48625,-36.02133 z"\n id="path5"\n inkscape:connector-curvature="0"\n vector-effect="non-scaling-stroke"\n style="fill:${i}; stroke: ${s}; stroke-width: 1; " /><path\n vector-effect="non-scaling-stroke"\n d="m 174.26737,259.72378 -38.76399,-10.70137 c -1.59243,-0.43962 -3.28183,-0.15596 -4.63548,0.7754 -2.53909,1.7494 -2.84182,4.93159 -3.02304,6.83188 l -0.0151,0.15247 c -1.22819,12.67106 6.79854,24.33046 19.08688,27.72284 12.51583,3.45518 25.8324,-2.91586 30.9681,-14.80385 l 0.0935,-0.19205 c 0.52305,-1.06418 1.74613,-3.55554 0.50882,-6.31116 -0.44302,-0.98439 -1.5794,-2.74529 -4.21964,-3.47416 z"\n id="path7"\n inkscape:connector-curvature="0"\n style="fill:${i}; stroke: ${s}; stroke-width: 1;" /></g><g\n id="g17" /><g\n id="g19" /><g\n id="g21" /><g\n id="g23" /><g\n id="g25" /><g\n id="g27" /><g\n id="g29" /><g\n id="g31" /><g\n id="g33" /><g\n id="g35" /><g\n id="g37" /><g\n id="g39" /><g\n id="g41" /><g\n id="g43" /><g\n id="g45" /></svg>`)),this.addStylesToElement({width:t.size,height:t.size},e),e.className="pushwoosh-subscribe-widget__bell-button",e}async createTooltip(){const t=document.createElement("div"),[e,i]=Et.getTooltipPosition(this.config.position,this.config.size);return t.className=`pushwoosh-subscribe-widget__tooltip pushwoosh-subscribe-widget__tooltip__${i}`,this.addStylesToElement(e,t),t.appendChild(await this.createTooltipContent()),t}async createTooltipContent(){const t=document.createElement("div");return t.innerText=await this.tooltipTextFactory(),t.className="pushwoosh-subscribe-widget__tooltip-content",t}async tooltipTextFactory(){const t=await this.pw.driver.getPermission(),{tooltipText:e}=this.config,i=await G.get("MANUAL_UNSUBSCRIBE");switch(t){case o:return i?e.needSubscribe:e.alreadySubscribed;case r:return e.needSubscribe;case a:return e.blockSubscribe;default:return e.needSubscribe}}createPopover(){const t=document.createElement("div"),e=document.createElement("div"),[i,s]=Et.getPopoverPosition(this.config.position,this.config.size);e.className=`pushwoosh-subscribe-widget__popover pushwoosh-subscribe-widget__popover__${s}`,t.className="pushwoosh-subscribe-widget__popover-content-wrapper",this.style.innerHTML+=Et.getPopoverArrowPosition(this.config.position,this.config.size);const n=Object.assign({maxWidth:`calc(100vw - ${this.config.indent} - ${this.config.indent})`},i);return this.addStylesToElement(n,e),t.appendChild(this.createPopoverContent()),e.appendChild(t),e}getBrowserName(){let t;return t=dt.isOpera?"opera":11===dt.platform&&navigator.userAgent.match(/Android/i)?"mobileChrome":12===dt.platform?"firefox":10===dt.platform?"safari":150===dt.platform?"edge":"chrome",t}createPopoverContent(){const{config:t}=this,e=document.createElement("div");e.className="pushwoosh-subscribe-widget__popover-content";const i=this.getBrowserName(),s=t.contentImages&&t.contentImages[i];if(s){const t=document.createElement("img");t.src=s,e.appendChild(t)}else{const t={opera:"opera",mobileChrome:"mobile_chrome",firefox:"FF",safari:"safari"}[i]||"chrome";[{src:this.getImageSrc(t),width:500,height:130},{src:this.getImageSrc(`${t}_unlock`),width:500,height:230}].forEach((t=>{const i=document.createElement("img");Object.assign(i,t),e.appendChild(i)}))}return e}getImageSrc(t){return`https://cdn.pushwoosh.com/webpush/img/${t}.jpg`}async render(){this.widget=this.createContainer(),this.style=this.createStyle();const t=this.createBell();this.tooltip=await this.createTooltip(),this.popover=await this.createPopover(),this.widget.appendChild(this.style),this.widget.appendChild(t),this.widget.appendChild(this.tooltip),this.widget.appendChild(this.popover),document.body.appendChild(this.widget),this.pw.push(["onSubscribe",this.onSubscribeEvent]),this.pw.push(["onUnsubscribe",this.onUnsubscribeEvent]),this.pw.push(["onPermissionDenied",this.onPermissionDeniedEvent]),this.addEventListeners()}addEventListeners(){this.widget.addEventListener("click",this.clickBell),window.addEventListener("click",this.clickOutOfPopover)}toggleHelpPopover(){this.popover.classList.toggle("pushwoosh-subscribe-widget__popover__visible")}async clickBell(){switch(this.pw.driver.getPermission()){case o:case r:await this.pw.subscribe();break;case a:this.toggleHelpPopover();break;default:console.warn("Unknown browser notification permission")}}async onSubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=this.config.tooltipText.successSubscribe,this.tooltip.classList.add("pushwoosh-subscribe-widget__tooltip__visible"),setTimeout((async()=>{this.tooltip.classList.remove("pushwoosh-subscribe-widget__tooltip__visible"),t.innerText=await this.tooltipTextFactory(),this.widget.classList.add("pushwoosh-subscribe-widget__subscribed")}),2e3))}async onPermissionDeniedEvent(){this.addEventListeners();const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}clickOutOfPopover(t){this.popover.classList.contains("pushwoosh-subscribe-widget__popover__visible")&&!t.target.classList.contains("pushwoosh-subscribe-widget__popover")&&null===t.target.closest(".pushwoosh-subscribe-widget__popover")&&!t.target.classList.contains("pushwoosh-subscribe-widget__bell-button")&&null===t.target.closest(".pushwoosh-subscribe-widget__bell-button")&&this.popover.classList.remove("pushwoosh-subscribe-widget__popover__visible")}async onUnsubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}}const Pt={text:"Don’t miss out on our news and updates! Enable push notifications",askLaterButtonText:"Not now",confirmSubscriptionButtonText:"Subscribe",delay:5,retryOffset:604800,overlay:!1,position:"top",mobileViewMargin:"0",bgColor:"#fff",borderColor:"transparent",boxShadow:"0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)",textColor:"#000",textSize:"inherit",textWeight:"normal",fontFamily:"inherit",subscribeBtnBgColor:"#4285f4",subscribeBtnTextColor:"#fff",subscribeBtnTextWeight:"normal",subscribeBtnBorderColor:"transparent",subscribeBtnBorderRadius:"2px",askLaterBtnBgColor:"transparent",askLaterBtnTextColor:"#000",askLaterBtnTextWeight:"normal",askLaterBtnBorderColor:"transparent",askLaterBtnBorderRadius:"2px",theme:"material",viewport:"html"},It=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/,Mt=[{name:"mobileViewMargin",type:"string"},{name:"mobileViewPosition",type:"string"},{name:"mobileViewTransition",type:"string"},{name:"bgColor",type:"color"},{name:"borderColor",type:"color"},{name:"boxShadow",type:"string"},{name:"textColor",type:"color"},{name:"textSize",type:"string"},{name:"textWeight",type:"string"},{name:"fontFamily",type:"string"},{name:"subscribeBtnBgColor",type:"color"},{name:"subscribeBtnTextColor",type:"color"},{name:"subscribeBtnTextWeight",type:"string"},{name:"subscribeBtnBorderColor",type:"color"},{name:"subscribeBtnBorderRadius",type:"string"},{name:"askLaterBtnBgColor",type:"color"},{name:"askLaterBtnTextColor",type:"color"},{name:"askLaterBtnTextWeight",type:"string"},{name:"askLaterBtnBorderColor",type:"color"},{name:"askLaterBtnBorderRadius",type:"string"}];class Bt{constructor(t){this.pw=t;const{mobileViewMargin:e=""}=t.subscribePopupConfig||{};this.config={...Pt,...this.pw.subscribePopupConfig,mobileViewTransition:e?"none":"bottom .4s ease-out",mobileViewPosition:e?"auto!important":"auto"},this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async initPopup(){const t=await this.pw.isSubscribed(),e=await this.pw.data.getStatusManualUnsubscribed();if(t||e)return;const i=await this.pw.driver.getPermission();if("granted"===i||"denied"===i)return;this.renderPopup(),this.appendStyles();const s=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),n=s?parseInt(s):0,a=(new Date).getTime();n+1e3*this.config.retryOffset<a&&!this.config.manualToggle&&setTimeout((()=>{this.toggle(!0)}),1e3*this.config.delay)}toggle(t){("boolean"==typeof t?t:!this.isShown)?(this.showPopup(),this.pw.eventBus.dispatchEvent("subscribe-popup-show",{})):(this.closePopup(),this.pw.eventBus.dispatchEvent("subscribe-popup-hide",{}))}showPopup(){this.isShown=!0,this.popup.classList.add("pw-show"),document.body.classList.add("pw-popup-opened");const t=new CustomEvent("showPopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:e,viewport:i,position:s}=this.config;if("topbar"===e&&"top"===s){const t=document.querySelector(i)||document.createElement("div"),e=window.getComputedStyle(t).marginTop||"0";t.style.transition="margin-top .3s ease-out",t.style.marginTop=`${parseInt(e)+this.popup.getBoundingClientRect().height}px`}}closePopup(){this.isShown=!1,this.popup.classList.remove("pw-show"),document.body.classList.remove("pw-popup-opened");const t=new CustomEvent("hidePopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);const e=(new Date).getTime().toString();localStorage.setItem("LAST_OPEN_SUBSCRIPTION_POPUP",e);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:i,viewport:s,position:n}=this.config;if("topbar"===i&&"top"===n){const t=document.querySelector(s)||document.createElement("div"),e=window.getComputedStyle(t).marginTop||"0";t.style.marginTop=parseInt(e)-this.popup.getBoundingClientRect().height+"px"}}renderPopup(){this.popup=document.createElement("div"),this.popup.id="pwSubscribePopup";const{text:t,askLaterButtonText:e,confirmSubscriptionButtonText:i,iconUrl:s,iconAlt:n,position:a,overlay:o,theme:r}=this.config;this.popup.className=`pw-subscribe-popup pw-position-${a} pw-subscribe-popup-${r}`,this.popup.classList.toggle("pw-subscribe-popup__overlay",o),this.popup.innerHTML=(({iconUrl:t,iconAlt:e,text:i,askLaterButtonText:s,confirmSubscriptionButtonText:n})=>`<div class="pw-subscription-popup-inner">\n <div class="pw-subscription-popup-content">\n ${t?`<div class="pw-subscription-popup-icon"><img src="${t}" alt="${e||"Subscribe"}"></div>`:""}\n <div class="pw-subscription-popup-text">\n ${i}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${s}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${n}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:e,confirmSubscriptionButtonText:i,iconUrl:s,iconAlt:n}),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=this.configureStyle(".pw-subscribe-popup {\n position: fixed;\n left: 50%;\n transform: translateX(-50%);\n justify-content: center;\n z-index: 1000000;\n display: flex;\n transition: all .4s ease-out;\n}\n\n.pw-subscribe-popup.pw-position-top {\n top: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-top.pw-show {\n top: 0;\n}\n\n.pw-subscribe-popup.pw-position-bottom {\n bottom: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-bottom.pw-show {\n bottom: 0;\n}\n\n.pw-subscribe-popup.pw-position-center {\n display: flex;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n justify-content: center;\n align-items: center;\n\n transform: none;\n}\n\n.pw-subscribe-popup__overlay {\n background: rgba(0,0,0,.4);\n z-index: 1000000;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-subscribe-popup__overlay) {\n pointer-events: none;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-show) {\n display: none;\n}\n\n\n.pw-subscribe-popup__overlay.pw-position-top {\n align-items: flex-start;\n}\n\n.pw-subscribe-popup__overlay.pw-position-bottom {\n align-items: flex-end;\n}\n\n.pw-subscribe-popup__overlay.pw-position-center {\n align-items: center;\n}\n\n.pw-subscription-popup-inner {\n max-width: 400px;\n font-size: var(--textSize);\n color: var(--textColor);\n font-weight: var(--textWeight);\n font-family: var(--fontFamily);\n border-style: solid;\n border-width: 1px;\n border-color: var(--borderColor);\n background: var(--bgColor);\n box-shadow: var(--boxShadow);\n pointer-events: auto;\n}\n\n.pw-subscription-popup-content {\n padding: 16px 16px 4px;\n display: flex;\n justify-content: stretch;\n}\n\n.pw-subscription-popup-icon {\n flex: 0 0 50px;\n margin-right: 12px;\n padding-top: 4px;\n}\n\n.pw-subscription-popup-icon img {\n max-width: 60px;\n max-height: 60px;\n}\n\n.pw-subscription-popup-text {\n flex: 1 1 300px;\n}\n\n.pw-subscription-popup-controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: center;\n padding: 8px 16px 16px;\n}\n\nbutton.pw-subscribe-popup-button {\n border: solid 1px var(--askLaterBtnBorderColor);\n border-radius: var(--askLaterBtnBorderRadius);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--askLaterBtnTextWeight);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--askLaterBtnTextColor);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--askLaterBtnBgColor);\n margin: 4px 8px;\n}\nbutton.pw-subscribe-popup-button:hover {\n background: rgba(0,0,0,.04);\n}\nbutton.pw-subscribe-popup-button:active {\n background: rgba(0,0,0,.12);\n}\n\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active {\n color: var(--subscribeBtnTextColor);\n background: var(--subscribeBtnBgColor);\n border-radius: var(--subscribeBtnBorderRadius);\n border: solid 1px var(--subscribeBtnBorderColor);\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n font-weight: var(--subscribeBtnTextWeight);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:hover {\n box-shadow: 0 3px 3px 0 rgba(0,0,0,0.14),\n 0 1px 7px 0 rgba(0,0,0,0.12),\n 0 3px 1px -1px rgba(0,0,0,0.2);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:active {\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n}\n\n@media screen and (min-width: 541px) {\n\n .pw-subscribe-popup-topbar {\n width: 100%;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n display: flex;\n flex-direction: row;\n padding: 2px 40px;\n justify-content: center;\n align-items: center;\n flex-wrap: nowrap;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-content {\n padding: 0;\n justify-content: flex-start;\n align-items: center;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-icon img {\n max-width: 28px;\n max-height: 28px;\n }\n\n .pw-subscribe-popup-topbar button.pw-subscribe-popup-button {\n height: 32px;\n line-height: 32px;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-controls {\n padding: 0 0 0 16px;\n align-items: center;\n }\n}\n@media screen and (max-width: 540px) {\n .pw-subscribe-popup,\n .pw-subscribe-popup.pw-position-top,\n .pw-subscribe-popup.pw-position-center,\n .pw-subscribe-popup.pw-position-bottom {\n top: var(--mobileViewPosition);\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: var(--mobileViewTransition);\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-subscribe-popup__overlay {\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-show {\n bottom: var(--mobileViewMargin);\n }\n\n .pw-subscribe-popup__overlay .pw-subscription-popup-inner {\n align-items: flex-end;\n justify-content: stretch;\n }\n\n .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n }\n}\n"),document.body.appendChild(t)}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(e=this.config[t.name].toString())||It.test(e)?e:"#333";default:return"none"}var e}configureStyle(t){let e=t.toString();return Mt.forEach((t=>{const i=new RegExp(`var\\(--${t.name}\\)`,"ig"),s=this.getStyleFormatter(t);e=e.replace(i,s)})),e}addListeners(){const t=this.popup.querySelector('button[name="pwAskLater"]')||document.createElement("button"),e=this.popup.querySelector('button[name="pwSubscribe"]')||document.createElement("button");t.addEventListener("click",this.onAskLaterClick),e.addEventListener("click",this.onSubscribeClick)}onAskLaterClick(){this.toggle(!1),this.pw.eventBus.dispatchEvent("subscribe-popup-decline",{})}onSubscribeClick(){this.toggle(!1),this.pw.eventBus.dispatchEvent("subscribe-popup-accept",{}),this.pw.subscribe()}}return document.addEventListener("pushwoosh.initialized",(t=>{if(t.detail.pw.subscribeWidgetConfig.enable&&new Tt(t.detail.pw),t.detail.pw.subscribePopupConfig&&t.detail.pw.subscribePopupConfig.enable){const e=new Bt(t.detail.pw);e.initPopup().then((()=>{t.detail.pw.subscribePopup=e}))}t.detail.pw.pwinbox&&t.detail.pw.inboxWidgetConfig.enable&&(t.detail.pw.pwinboxWidget=new vt(t.detail.pw))})),e})()));
2
- //# sourceMappingURL=index.js.map