web-push-notifications 3.90.1 → 3.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/models/InboxCell.d.ts +2 -17
- package/npm.js +1 -1
- package/npm.js.map +1 -1
- package/package.json +2 -2
- package/service-worker.js +1 -1
- package/service-worker.js.map +1 -1
- package/widget-inbox.js +1 -1
- package/widget-inbox.js.map +1 -1
- package/widgets/Inbox/InboxWidget.d.ts +0 -8
- package/widgets/Inbox/constants.d.ts +0 -3
- package/widgets/Inbox/helpers.d.ts +0 -2
- package/widgets/Inbox/inbox_widget.types.d.ts +4 -32
- package/widgets/Inbox/renderer.d.ts +10 -0
- package/widgets/Inbox/__tests__/widgetTemplates.test.d.ts +0 -1
- package/widgets/Inbox/widgetTemplates.d.ts +0 -4
package/widget-inbox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(this,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let e={};t.r(e),t.d(e,{PWInboxWidget:()=>_});const n=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"],i="pw-inbox",o=[{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"},{name:"unreadDotColor",type:"color"},{name:"avatarBgColor",type:"color"},{name:"avatarTextColor",type:"color"},{name:"avatarSize",type:"size"},{name:"mediaRadius",type:"size"},{name:"slideCaptionColor",type:"color"},{name:"slideScrimColor",type:"color"},{name:"pagerDotActiveColor",type:"color"},{name:"pagerDotColor",type:"color"}],s=["badgeBgColor","badgeTextColor"],r=o.filter(t=>-1!==s.indexOf(t.name)),a={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/static/icon-empty-inbox.png",arrowBorderColor:"rgba(0,0,0,.1)",legacyClassicCell:!1,unreadDotColor:"#00a2ff",avatarBgColor:"#c4c8cc",avatarTextColor:"#4b5057",avatarSize:52,mediaRadius:8,slideCaptionColor:"#ffffff",slideScrimColor:"rgba(0,0,0,.45)",pagerDotActiveColor:"#00a2ff",pagerDotColor:"#ebf0f5"};function l(t){let e="fixed"===window.getComputedStyle(t).position;return!e&&t.parentElement&&(e=l(t.parentElement)),e}const d={"&":"&","<":"<",">":">",'"':""","'":"'"},p=/[&<>"']/g,g=RegExp(p.source);function c(t){return t&&g.test(t)?t.replace(p,t=>d[t]):t}const w=({title:t,message:e,sendDate:i,isRead:o})=>`\n<div class="pw-inbox_content">\n <div class="pw-inbox_item-title">\n ${c(t)}${o?"":'<span class="pw-inbox_unread-dot"></span>'}\n </div>\n <div class="pw-inbox_item-body">\n ${c(e)}\n </div>\n <div class="pw-inbox_item-time">\n ${c(function(t){const e=new Date(t),i=(new Date).getTime()-e.getTime();if(i<=6e4)return"Just now";if(i<36e5&&i>0)return`${Math.floor(i/6e4)} minutes ago`;if(i<864e5&&i>0)return`${Math.floor(i/36e5)} hours ago`;return`${e.getDate()} ${n[e.getMonth()]} ${e.getFullYear()}, ${e.getHours()}:${`0${e.getMinutes().toString()}`.slice(-2)}`}(i))}\n </div>\n</div>`,h=(t,e)=>`\n<div class="pw-inbox_media">\n <img src="${c(t)}" alt="${c(e)}" class="pw-inbox_hero">\n</div>`,b=(t,e=0)=>{const{layout:n,heroUrl:i,carousel:o,title:s,message:r}=t,a=s||r;let l;switch(n){case"banner":l=h(i,a);break;case"captioned":l=`${h(i,a)}${w(t)}`;break;case"carousel":l=`${((t,e,n)=>{const i=t[e],o=i.caption?`<span class="pw-inbox_slide-caption">${c(i.caption)}</span>`:"",s=t.length>1?`<div class="pw-inbox_pager">${t.map((t,n)=>`<button type="button" class="pw-inbox_dot${n===e?" pw-active":""}" data-pw-slide="${n}"></button>`).join("")}</div>`:"";return`\n<div class="pw-inbox_media">\n <div class="pw-inbox_slide" data-pw-slide-link="${c(i.link)}">\n <img src="${c(i.imageUrl)}" alt="${c(i.caption||n)}" class="pw-inbox_hero">\n ${o}\n </div>\n ${s}\n</div>`})(o,Math.min(e,o.length-1),a)}${w(t)}`;break;default:l=`<div class="pw-inbox_icon">${(({iconUrl:t,title:e,message:n})=>t?`<img src="${c(t)}" alt="${c(e||n)}" class="pw-inbox_message-image">`:`<span class="pw-inbox_icon-initial">${c(function(t,e){return(t||e||"?").trim().charAt(0).toUpperCase()||"?"}(e,n))}</span>`)(t)}</div>${w(t)}`}return`\n<div class="pw-inbox_item-inner pw-inbox_item--${c(n)}">\n ${l}\n</div>\n<span class="pw-inbox_item-remove"></span>`},x="#333",m=/[;{}]/;let f=null;function u(t,e){switch(t){case"size":{const t=Number(e??0);return Number.isFinite(t)?`${t}px`:null}case"number":{const t=parseFloat(String(e));return Number.isFinite(t)?String(t):null}case"color":{const t=String(e);return function(t){return m.test(t)?x:(f||(f=document.createElement("div")),f.style.color="",f.style.color=t,f.style.color?t:x)}(t)===t?t:null}default:return String(e).trim()||null}}function y(t,e,n,i){n.forEach(({name:n,type:o})=>{const s=u(o,i[n]);null!==s&&t.style.setProperty(function(t,e){return`--${t}-${e}`}(e,n),s)})}const v=/^(?:javascript|vbscript|data|blob|file):/i;function C(t){return t.split("").filter(t=>t.charCodeAt(0)>32&&127!==t.charCodeAt(0)).join("")}class _{constructor(t){this.lastSyncAt=0,this.pw=t;const e=this.pw.initParams.inboxWidget;this.config={...a,arrowBorderColor:e.borderColor&&"transparent"!==e.borderColor?e.borderColor:"rgba(0,0,0,.1)",...this.pw.initParams.inboxWidget},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)}async run(){this.initTrigger(),this.updateInbox(),this.addListeners()}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.lastSyncAt=Date.now(),this.defaultMargin=12,this.messagesElements={},this.activeSlides={},this.messages=[],this.readItems=[],this.updateCounter(0),this.isOpened=!1,this.renderWidget(),this.isFixed=l(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.widget.classList.toggle("pw-inbox-widget--legacy-cell",this.config.legacyClassicCell),this.widgetParent=document.querySelector(this.config.appendTo)||document.body,this.widgetParent.appendChild(this.widget),this.widgetParent.appendChild(this.getStyle()),this.applyStyleVariables(),this.renderWidgetInner()}getStyle(){const t=document.createElement("style");return t.innerHTML=".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(--pw-inbox-badgeBgColor, #ff4c00);\n border-radius: 8px;\n color: var(--pw-inbox-badgeTextColor, #ffffff);\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(--pw-inbox-fontFamily, inherit);\n}\n.pw-inbox-widget {\n font-size: 14px;\n position: absolute;\n top: 0;\n left: -1000px;\n background: var(--pw-inbox-bgColor, #ffffff);\n border: solid 1px var(--pw-inbox-borderColor, transparent);\n border-radius: var(--pw-inbox-borderRadius, 4px);\n width: var(--pw-inbox-widgetWidth, 350px);\n box-shadow: 0 1px 4px 0 rgba(0,0,0,.25);\n z-index: var(--pw-inbox-zIndex, 100);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-textColor, #333333);\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 auto;\n width: var(--pw-inbox-avatarSize, 52px);\n height: var(--pw-inbox-avatarSize, 52px);\n margin-right: 14px;\n overflow: hidden;\n border-radius: var(--pw-inbox-mediaRadius, 8px);\n background: var(--pw-inbox-avatarBgColor, #c4c8cc);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pw-inbox_message-image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n}\n.pw-inbox_icon-initial {\n color: var(--pw-inbox-avatarTextColor, #4b5057);\n font-size: 22px;\n line-height: 1;\n font-weight: 700;\n}\n.pw-inbox_content {\n flex: 1 1 auto;\n min-width: 0;\n}\n.pw-inbox_item-title {\n color: var(--pw-inbox-messageTitleColor, #7a7a7a);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n display: flex;\n align-items: center;\n gap: 6px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.pw-inbox_unread-dot {\n flex: 0 0 auto;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--pw-inbox-unreadDotColor, #00a2ff);\n}\n.pw-inbox_item-body {\n color: var(--pw-inbox-textColor, #333333);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.pw-inbox_item-time {\n color: var(--pw-inbox-timeTextColor, #c4c4c4);\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(--pw-inbox-textColor, #333333);\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(--pw-inbox-emptyInboxTitleColor, #333333);\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(--pw-inbox-emptyInboxTextColor, #7a7a7a);\n}\n\n/* Cell layouts: banner, captioned and carousel stack their media above the\n texts, so the flex row of the classic cell becomes a column. */\n.pw-inbox_item--banner,\n.pw-inbox_item--captioned,\n.pw-inbox_item--carousel {\n flex-direction: column;\n gap: 12px;\n}\n\n.pw-inbox_media {\n position: relative;\n width: 100%;\n}\n.pw-inbox_hero {\n display: block;\n width: 100%;\n max-width: 100%;\n aspect-ratio: 2 / 1;\n object-fit: cover;\n border-radius: var(--pw-inbox-mediaRadius, 8px);\n}\n\n.pw-inbox_slide {\n position: relative;\n display: block;\n cursor: pointer;\n}\n.pw-inbox_slide-caption {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n padding: 14px 10px 6px;\n color: var(--pw-inbox-slideCaptionColor, #ffffff);\n font-size: 14px;\n line-height: 20px;\n border-radius: 0 0 var(--pw-inbox-mediaRadius, 8px) var(--pw-inbox-mediaRadius, 8px);\n background: linear-gradient(transparent, var(--pw-inbox-slideScrimColor, rgba(0,0,0,.45)));\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n\n.pw-inbox_pager {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n}\n.pw-inbox_dot {\n width: 6px;\n height: 6px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: var(--pw-inbox-pagerDotColor, #ebf0f5);\n cursor: pointer;\n}\n.pw-inbox_dot.pw-active {\n background: var(--pw-inbox-pagerDotActiveColor, #00a2ff);\n}\n\n/* `legacyClassicCell` restores the pre-3.75 classic cell. Scoped to classic on\n purpose: the three new layouts have no older look to go back to. */\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_icon {\n display: block;\n flex: 0 0 40px;\n width: auto;\n height: auto;\n margin-right: 0;\n border-radius: 0;\n background: none;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_message-image {\n width: 28px;\n height: auto;\n object-fit: fill;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_content {\n flex: 0 1 100%;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_item-title {\n display: block;\n overflow: visible;\n text-overflow: clip;\n white-space: normal;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_unread-dot {\n display: none;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_item-body {\n display: block;\n overflow: visible;\n}\n".toString(),t}applyStyleVariables(){y(this.widget,i,o,this.config),y(this.trigger,i,r,this.config)}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:n}=this.config;this.widget.innerHTML=((t,e,n)=>`\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 ${n}\n </div>\n</div>`)(n,t,e)}}renderMessages(){this.list=this.widget.querySelector(".pw-inbox_list")||document.createElement("ul"),this.messagesElements={},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=b(t,this.activeSlides[t.code]||0),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})=>{return n=t,new Date(e).getTime()-new Date(n).getTime();var n}),this.renderWidgetInner()}openWidget(){this.isOpened=!0,this.widget.classList.add("pw-open"),this.syncMessages(),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),window.removeEventListener("scroll",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.initParams.inboxWidget.position?this.config.position:this.getDefaultPosition(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);switch(e.width+2*this.defaultMargin>n&&(this.widget.style.width=n-2*this.defaultMargin+"px"),e.height+24>i&&(this.widget.style.height=i-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 n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-top");let o=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const s=o<pageXOffset,r=o+e.width>pageXOffset+n;s&&(o=pageXOffset+this.defaultMargin),r&&(o=pageXOffset+n-e.width-this.defaultMargin);const a=pageYOffset+t.top-e.height;this.alignWidgetElement(o,a),i.style.left=t.left+Math.floor(t.width/2)-o+"px";const l=this.widget.getBoundingClientRect().top;if(l<0){const t=this.widget.getBoundingClientRect().height+l-this.defaultMargin,e=this.widget.getBoundingClientRect().top-l+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 n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-right");let s=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const r=s<pageYOffset,a=pageYOffset+i<s+e.height;r&&(s=pageYOffset+this.defaultMargin),a&&(s=pageYOffset+i-e.height-this.defaultMargin);const l=pageXOffset+t.left+t.width;this.alignWidgetElement(l,s),o.style.top=t.top+Math.floor(t.height/2)-s+"px";const d=n-this.widget.getBoundingClientRect().right;if(d<this.defaultMargin){const t=this.widget.getBoundingClientRect().width+d-this.defaultMargin;this.widget.style.width=`${t}px`}}alignWidgetLeft(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-left");let o=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const s=o<pageYOffset,r=pageYOffset+n<o+e.height;s&&(o=pageYOffset+this.defaultMargin),r&&(o=pageYOffset+n-e.height-this.defaultMargin);const a=pageXOffset+t.left-e.width;this.alignWidgetElement(a,o),i.style.top=t.top+Math.floor(t.height/2)-o+"px";const l=this.widget.getBoundingClientRect().left;if(l<0){const t=this.widget.getBoundingClientRect().width+l-this.defaultMargin,e=this.widget.getBoundingClientRect().left-l;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 n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-bottom");let s=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const r=s<pageXOffset,a=s+e.width>pageXOffset+n;r&&(s=pageXOffset+this.defaultMargin),a&&(s=pageXOffset+n-e.width-12);const l=pageYOffset+t.top+t.height;this.alignWidgetElement(s,l),o.style.left=t.left+Math.floor(t.width/2)-s+"px";const d=i-this.widget.getBoundingClientRect().bottom;if(d<this.defaultMargin){const t=this.widget.getBoundingClientRect().height+d-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:n,height:i}=this.trigger.getBoundingClientRect();if(!document.documentElement)return"";const o={right:t,bottom:e,left:Math.max(document.documentElement.clientWidth,window.innerWidth||0)-(t+n),top:Math.max(document.documentElement.clientHeight,window.innerHeight||0)-(e+i)},s=Math.min(t,e,o.left,o.top);let r="bottom";return Object.keys(o).forEach(t=>{o[t]===s&&(r=t)}),r}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 n=this.messages.find(t=>t.code===e);!n||n.isRead||this.readItems.indexOf(e)+1||this.readItems.push(e)})}updateReadStatus(){const t=this.readItems;this.readItems=[],this.pw.pwinbox.readMessagesWithCodes(t).then(this.updateInbox)}syncMessages(){Date.now()-this.lastSyncAt<3e4||(this.lastSyncAt=Date.now(),this.pw.pwinbox.syncMessages().catch(t=>{console.error("Pushwoosh: cannot refresh the inbox on open",t)}))}updateInbox(){this.pw.pwinbox.loadMessages().then(t=>{this.updateInboxMessages(t)}),this.pw.pwinbox.unreadMessagesCount().then(t=>{this.updateCounter(t)})}performMessageAction(t){const e=this.messages.find(e=>e.code===t);e&&e.webPopupCode&&this.toggle(!1),this.pw.pwinbox.performActionForMessageWithCode(t).then(()=>{this.updateInbox()})}removeMessages(t){this.readItems=this.readItems.filter(e=>-1===t.indexOf(e)),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 n=e.getAttribute("data-pw-inbox-message-id");if(!n)return;if(t.target.closest(".pw-inbox_item-remove"))return void this.removeMessages([n]);const i=t.target.closest(".pw-inbox_dot");if(i)return void this.showSlide(n,parseInt(i.getAttribute("data-pw-slide")||"0",10));const o=t.target.closest(".pw-inbox_slide"),s=o&&o.getAttribute("data-pw-slide-link");var r;s&&(r=s)&&!v.test(C(r))?document.location.href=s:this.performMessageAction(n)}showSlide(t,e){this.activeSlides[t]=e;const n=this.messagesElements[t],i=this.messages.find(e=>e.code===t);n&&i&&(n.innerHTML=b(i,e))}onWindowScrollHandler(){this.isFixed&&this.isOpened?this.toggle():this.positionWidget()}}return e})());
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,()=>(()=>{"use strict";const e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{PWInboxWidget:()=>xt});const n=["classic","captioned","banner","carousel"],i="pw-inbox",o=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"],r=[{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"},{name:"unreadDotColor",type:"color"},{name:"avatarBgColor",type:"color"},{name:"avatarTextColor",type:"color"},{name:"avatarSize",type:"size"},{name:"mediaRadius",type:"size"},{name:"slideCaptionColor",type:"color"},{name:"slideScrimColor",type:"color"},{name:"pagerDotActiveColor",type:"color"},{name:"pagerDotColor",type:"color"}],l={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/static/icon-empty-inbox.png",arrowBorderColor:"rgba(0,0,0,.1)",legacyClassicCell:!1,unreadDotColor:"#00a2ff",avatarBgColor:"#c4c8cc",avatarTextColor:"#4b5057",avatarSize:52,mediaRadius:8,slideCaptionColor:"#ffffff",slideScrimColor:"rgba(0,0,0,.45)",pagerDotActiveColor:"#00a2ff",pagerDotColor:"#ebf0f5"};const s=6e4,a=36e5,c=/[;{}]/;function p(e){return(Array.isArray(e)?e:[]).filter(e=>!!e&&!!e.imageUrl).slice(0,5)}function _(e){return e.bannerUrl||e.iconUrl||""}function d(e){const t=!!e.title,i=!!e.body,o=_(e);let r=e.layoutType;switch(n.includes(r)||(r=e.bannerUrl&&!t?"banner":e.bannerUrl&&t&&i?"captioned":"classic"),r){case"banner":return o?"banner":"classic";case"captioned":return o&&t&&i?"captioned":"classic";case"carousel":return t&&i&&p(e.carousel).length>0?"carousel":"classic";default:return"classic"}}function u(e){return(e.title||e.body||"?").trim().charAt(0).toUpperCase()||"?"}function h(e,t=Date.now()){const n=new Date(e),i=t-n.getTime();if(i<=s)return"Just now";if(i<a)return`${Math.floor(i/s)} minutes ago`;if(i<864e5)return`${Math.floor(i/a)} hours ago`;const r=`0${n.getMinutes()}`.slice(-2);return`${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}, ${n.getHours()}:${r}`}function f(e){const t={};return r.forEach(({name:n,type:o})=>{const r=function(e,t){switch(e){case"size":{if(null==t||""===t)return null;const e=Number(t);return Number.isFinite(e)?`${e}px`:null}case"number":{const e=parseFloat(String(t));return Number.isFinite(e)?String(e):null}default:{const e=String(t??"").trim();return e&&!c.test(e)?e:null}}}(o,e[n]);null!==r&&(t[`--${i}-${n}`]=r)}),t}const g=i,w=[...r],m=["badgeBgColor","badgeTextColor"],b=w.filter(e=>-1!==m.indexOf(e.name)),x={enable:!1,triggerId:"pwInbox",position:"bottom",appendTo:"body",...l};function v(e){let t="fixed"===window.getComputedStyle(e).position;return!t&&e.parentElement&&(t=v(e.parentElement)),t}var y,C,k,M,S,W,E,P,N,R,I,T,O,A,H={},L=[],B=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,U=Array.isArray;function D(e,t){for(var n in t)e[n]=t[n];return e}function z(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function $(e,t,n){var i,o,r,l={};for(r in t)"key"==r?i=t[r]:"ref"==r?o=t[r]:l[r]=t[r];if(arguments.length>2&&(l.children=arguments.length>3?y.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===l[r]&&(l[r]=e.defaultProps[r]);return F(e,l,i,o,null)}function F(e,t,n,i,o){var r={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++k,__i:-1,__u:0};return null==o&&null!=C.vnode&&C.vnode(r),r}function j(e){return e.children}function Y(e,t){this.props=e,this.context=t}function X(e,t){if(null==t)return e.__?X(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?X(e):null}function V(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],o=[],r=D({},t);r.__v=t.__v+1,C.vnode&&C.vnode(r),re(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??X(t),!!(32&t.__u),o),r.__v=t.__v,r.__.__k[r.__i]=r,se(i,r,o),t.__e=t.__=null,r.__e!=n&&q(r)}}function q(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),q(e)}function J(e){(!e.__d&&(e.__d=!0)&&M.push(e)&&!Z.__r++||S!=C.debounceRendering)&&((S=C.debounceRendering)||W)(Z)}function Z(){try{for(var e,t=1;M.length;)M.length>t&&M.sort(E),e=M.shift(),t=M.length,V(e)}finally{M.length=Z.__r=0}}function G(e,t,n,i,o,r,l,s,a,c,p){var _,d,u,h,f,g,w=i&&i.__k||L,m=t.length;for(a=K(n,t,w,a,m),_=0;_<m;_++)null!=(u=n.__k[_])&&(d=-1!=u.__i&&w[u.__i]||H,u.__i=_,g=re(e,u,d,o,r,l,s,a,c,p),h=u.__e,u.ref&&d.ref!=u.ref&&(d.ref&&pe(d.ref,null,u),p.push(u.ref,u.__c||h,u)),null==f&&null!=h&&(f=h),4&u.__u?(a=Q(u,a,e),d.__e&&(d.__e=null)):"function"==typeof u.type&&void 0!==g?a=g:h&&(a=h.nextSibling),u.__u&=-7);return n.__e=f,a}function K(e,t,n,i,o){var r,l,s,a,c,p=n.length,_=p,d=0;for(e.__k=new Array(o),r=0;r<o;r++)null!=(l=t[r])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[r]=F(null,l,null,null,null):U(l)?l=e.__k[r]=F(j,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[r]=F(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[r]=l,a=r+d,l.__=e,l.__b=e.__b+1,s=null,-1!=(c=l.__i=te(l,n,a,_))&&(_--,(s=n[c])&&(s.__u|=2)),null==s||null==s.__v?(-1==c&&(o>p?d--:o<p&&d++),"function"!=typeof l.type&&(l.__u|=4)):c!=a&&(c==a-1?d--:c==a+1?d++:(c>a?d--:d++,l.__u|=4))):e.__k[r]=null;if(_)for(r=0;r<p;r++)null!=(s=n[r])&&!(2&s.__u)&&(s.__e==i&&(i=X(s)),_e(s,s));return i}function Q(e,t,n){var i,o;if("function"==typeof e.type){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=Q(i[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=X(e)),t=n.insertBefore(e.__e,t||null));do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function ee(e,t){return t=t||[],null==e||"boolean"==typeof e||(U(e)?e.some(function(e){ee(e,t)}):t.push(e)),t}function te(e,t,n,i){var o,r,l,s=e.key,a=e.type,c=t[n],p=null!=c&&!(2&c.__u);if(null===c&&null==s||p&&s==c.key&&a==c.type)return n;if(i>(p?1:0))for(o=n-1,r=n+1;o>=0||r<t.length;)if(null!=(c=t[l=o>=0?o--:r++])&&!(2&c.__u)&&s==c.key&&a==c.type)return l;return-1}function ne(e,t,n){"-"==t[0]?e.setProperty(t,n??""):e[t]=null==n?"":"number"!=typeof n||B.test(t)?n:n+"px"}function ie(e,t,n,i,o){var r,l;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||ne(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||ne(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(I,"$1")),l=t.toLowerCase(),t=l in e||"onFocusOut"==t||"onFocusIn"==t?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?i?n[R]=i[R]:(n[R]=T,e.addEventListener(t,r?A:O,r)):e.removeEventListener(t,r?A:O,r);else{if("http://www.w3.org/2000/svg"==o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=n??"";break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function oe(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t[N])t[N]=T++;else if(t[N]<n[R])return;return n(C.event?C.event(t):t)}}}function re(e,t,n,i,o,r,l,s,a,c){var p,_,d,u,h,f,g,w,m,b,x,v,y,k,M,S,W=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(a=!!(32&n.__u),r=[s=t.__e=n.__e]),(p=C.__b)&&p(t);e:if("function"==typeof W){_=l.length;try{if(m=t.props,b=W.prototype&&W.prototype.render,x=(p=W.contextType)&&i[p.__c],v=p?x?x.props.value:p.__:i,n.__c?w=(d=t.__c=n.__c).__=d.__E:(b?t.__c=d=new W(m,v):(t.__c=d=new Y(m,v),d.constructor=W,d.render=de),x&&x.sub(d),d.state||(d.state={}),d.__n=i,u=d.__d=!0,d.__h=[],d._sb=[]),b&&null==d.__s&&(d.__s=d.state),b&&null!=W.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=D({},d.__s)),D(d.__s,W.getDerivedStateFromProps(m,d.__s))),h=d.props,f=d.state,d.__v=t,u)b&&null==W.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),b&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(b&&null==W.getDerivedStateFromProps&&m!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(m,v),t.__v==n.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(m,d.__s,v)){t.__v!=n.__v&&(d.props=m,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),L.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&l.push(d),s=X(n);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(m,d.__s,v),b&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,f,g)})}if(d.context=v,d.props=m,d.__P=e,d.__e=!1,y=C.__r,k=0,b)d.state=d.__s,d.__d=!1,y&&y(t),p=d.render(d.props,d.state,d.context),L.push.apply(d.__h,d._sb),d._sb=[];else do{d.__d=!1,y&&y(t),p=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++k<25);d.state=d.__s,null!=d.getChildContext&&(i=D(D({},i),d.getChildContext())),b&&!u&&null!=d.getSnapshotBeforeUpdate&&(g=d.getSnapshotBeforeUpdate(h,f)),M=null!=p&&p.type===j&&null==p.key?ae(p.props.children):p,s=G(e,U(M)?M:[M],t,n,i,o,r,l,s,a,c),d.base=t.__e,t.__u&=-161,d.__h.length&&l.push(d),w&&(d.__E=d.__=null)}catch(e){if(l.length=_,t.__v=null,a||null!=r){if(e.then){for(t.__u|=a?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;null!=r&&(r[r.indexOf(s)]=null),t.__e=s}else if(null!=r)for(S=r.length;S--;)z(r[S])}else t.__e=n.__e;null==t.__k&&(t.__k=n.__k||[]),e.then||le(t),C.__e(e,t,n)}}else null==r&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ce(n.__e,t,n,i,o,r,l,a,c);return(p=C.diffed)&&p(t),128&t.__u?void 0:s}function le(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(le))}function se(e,t,n){for(var i=0;i<n.length;i++)pe(n[i],n[++i],n[++i]);C.__c&&C.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){C.__e(e,t.__v)}})}function ae(e){return"object"!=typeof e||null==e||e.__b>0?e:U(e)?e.map(ae):void 0!==e.constructor?null:D({},e)}function ce(e,t,n,i,o,r,l,s,a){var c,p,_,d,u,h,f,g=n.props||H,w=t.props,m=t.type;if("svg"==m?o="http://www.w3.org/2000/svg":"math"==m?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;c<r.length;c++)if((u=r[c])&&"setAttribute"in u==!!m&&(m?u.localName==m:3==u.nodeType)){e=u,r[c]=null;break}if(null==e){if(null==m)return document.createTextNode(w);e=document.createElementNS(o,m,w.is&&w),s&&(C.__m&&C.__m(t,r),s=!1),r=null}if(null==m)g===w||s&&e.data==w||(e.data=w);else{if(r="textarea"==m&&null!=w.defaultValue?null:r&&y.call(e.childNodes),!s&&null!=r)for(g={},c=0;c<e.attributes.length;c++)g[(u=e.attributes[c]).name]=u.value;for(c in g)u=g[c],"dangerouslySetInnerHTML"==c?_=u:"children"==c||c in w||"value"==c&&"defaultValue"in w||"checked"==c&&"defaultChecked"in w||ie(e,c,null,u,o);for(c in w)u=w[c],"children"==c?d=u:"dangerouslySetInnerHTML"==c?p=u:"value"==c?h=u:"checked"==c?f=u:s&&"function"!=typeof u||g[c]===u||ie(e,c,u,g[c],o);if(p)s||_&&(p.__html==_.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(_&&(e.innerHTML=""),G("template"==t.type?e.content:e,U(d)?d:[d],t,n,i,"foreignObject"==m?"http://www.w3.org/1999/xhtml":o,r,l,r?r[0]:n.__k&&X(n,0),s,a),null!=r)for(c=r.length;c--;)z(r[c]);s&&"textarea"!=m||(c="value","progress"==m&&null==h?e.removeAttribute("value"):null!=h&&(h!==e[c]||"progress"==m&&!h||"option"==m&&h!=g[c])&&ie(e,c,h,g[c],o),c="checked",null!=f&&f!=e[c]&&ie(e,c,f,g[c],o))}return e}function pe(e,t,n){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){C.__e(e,n)}}function _e(e,t,n){var i,o;if(C.unmount&&C.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||pe(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){C.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(o=0;o<i.length;o++)i[o]&&_e(i[o],t,n||"function"!=typeof e.type);n||z(e.__e),e.__c=e.__=e.__e=void 0}function de(e,t,n){return this.constructor(e,n)}function ue(e,t,n){var i,o,r,l;t==document&&(t=document.documentElement),C.__&&C.__(e,t),o=(i="function"==typeof n)?null:n&&n.__k||t.__k,r=[],l=[],re(t,e=(!i&&n||t).__k=$(j,null,[e]),o||H,H,t.namespaceURI,!i&&n?[n]:o?null:t.firstChild?y.call(t.childNodes):null,r,!i&&n?n:o?o.__e:t.firstChild,i,l),se(r,e,l),e.props.children=null}y=L.slice,C={__e:function(e,t,n,i){for(var o,r,l;t=t.__;)if((o=t.__c)&&!o.__)try{if((r=o.constructor)&&null!=r.getDerivedStateFromError&&(o.setState(r.getDerivedStateFromError(e)),l=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,i||{}),l=o.__d),l)return o.__E=o}catch(t){e=t}throw e}},k=0,Y.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=D({},this.state),"function"==typeof e&&(e=e(D({},n),this.props)),e&&D(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),J(this))},Y.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),J(this))},Y.prototype.render=j,M=[],W="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,E=function(e,t){return e.__v.__b-t.__v.__b},Z.__r=0,P=Math.random().toString(8),N="__d"+P,R="__a"+P,I=/(PointerCapture)$|Capture$/i,T=0,O=oe(!1),A=oe(!0);var he=0;Array.isArray;function fe(e,t,n,i,o,r){t||(t={});var l,s,a=t;if("ref"in a)for(s in a={},t)"ref"==s?l=t[s]:a[s]=t[s];var c={type:e,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--he,__i:-1,__u:0,__source:o,__self:r};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===a[s]&&(a[s]=l[s]);return C.vnode&&C.vnode(c),c}var ge,we,me,be,xe=0,ve=[],ye=C,Ce=ye.__b,ke=ye.__r,Me=ye.diffed,Se=ye.__c,We=ye.unmount,Ee=ye.__;function Pe(e,t){ye.__h&&ye.__h(we,e,xe||t),xe=0;var n=we.__H||(we.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ne(e){return xe=1,function(e,t,n){var i=Pe(ge++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):He(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=we,!we.__f)){var o=function(e,t,n){if(!i.__c.__H)return!0;var o=!1,l=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){o=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(l=!0)}}),r){var s=r.call(this,e,t,n);return o?s||l:s}return!o||l};we.__f=!0;var r=we.shouldComponentUpdate,l=we.componentWillUpdate;we.componentWillUpdate=function(e,t,n){if(this.__e){var i=r;r=void 0,o(e,t,n),r=i}l&&l.call(this,e,t,n)},we.shouldComponentUpdate=o}return i.__N||i.__}(He,e)}function Re(){for(var e;e=ve.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Oe),t.__h.some(Ae),t.__h=[]}catch(n){t.__h=[],ye.__e(n,e.__v)}}}ye.__b=function(e){we=null,Ce&&Ce(e)},ye.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ee&&Ee(e,t)},ye.__r=function(e){ke&&ke(e),ge=0;var t=(we=e.__c).__H;t&&(me===we?(t.__h=[],we.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Oe),t.__h.some(Ae),t.__h=[],ge=0)),me=we},ye.diffed=function(e){Me&&Me(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==ve.push(t)&&be===ye.requestAnimationFrame||((be=ye.requestAnimationFrame)||Te)(Re)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),me=we=null},ye.__c=function(e,t){t.some(function(e){try{e.__h.some(Oe),e.__h=e.__h.filter(function(e){return!e.__||Ae(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],ye.__e(n,e.__v)}}),Se&&Se(e,t)},ye.unmount=function(e){We&&We(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Oe(e)}catch(e){t=e}}),n.__H=void 0,t&&ye.__e(t,n.__v))};var Ie="function"==typeof requestAnimationFrame;function Te(e){var t,n=function(){clearTimeout(i),Ie&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);Ie&&(t=requestAnimationFrame(n))}function Oe(e){var t=we,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),we=t}function Ae(e){var t=we;e.__c=e.__(),we=t}function He(e,t){return"function"==typeof t?t(e):t}function Le(e,t){for(var n in t)e[n]=t[n];return e}function Be(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var i in t)if("__source"!==i&&e[i]!==t[i])return!0;return!1}function Ue(e,t){this.props=e,this.context=t}(Ue.prototype=new Y).isPureReactComponent=!0,Ue.prototype.shouldComponentUpdate=function(e,t){return Be(this.props,e)||Be(this.state,t)};var De=C.__b;C.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),De&&De(e)};"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var ze=C.__e;C.__e=function(e,t,n,i){if(e.then)for(var o,r=t;r=r.__;)if((o=r.__c)&&o.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k||[]),o.__c(e,t);ze(e,t,n,i)};var $e=C.unmount;function Fe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=Le({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Fe(e,t,n)})),e}function je(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return je(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Ye(){this.__u=0,this.o=null,this.__b=null}function Xe(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Ve(){this.i=null,this.l=null}C.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),$e&&$e(e)},(Ye.prototype=new Y).__c=function(e,t){var n=t.__c,i=this;null==i.o&&(i.o=[]),i.o.push(n);var o=Xe(i.__v),r=!1,l=function(){r||i.__z||(r=!0,n.__R=null,o?o(a):a())};n.__R=l;var s=n.__P;n.__P=null;var a=function(){if(! --i.__u){if(i.state.__a){var e=i.state.__a;i.__v.__k[0]=je(e,e.__c.__P,e.__c.__O)}var t;for(i.setState({__a:i.__b=null});t=i.o.pop();)t.__P=s,t.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(l,l)},Ye.prototype.componentWillUnmount=function(){this.o=[]},Ye.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=Fe(this.__b,n,i.__O=i.__P)}this.__b=null}var o=t.__a&&$(j,null,e.fallback);return o&&(o.__u&=-33),[$(j,null,t.__a?null:e.children),o]};var qe=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(Ve.prototype=new Y).__a=function(e){var t=this,n=Xe(t.__v),i=t.l.get(e);return i[0]++,function(o){var r=function(){t.props.revealOrder?(i.push(o),qe(t,e,i)):o()};n?n(r):r()}},Ve.prototype.render=function(e){this.i=null,this.l=new Map;var t=ee(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Ve.prototype.componentDidUpdate=Ve.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){qe(e,n,t)})};var Je="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Ze=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Ge=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ke=/[A-Z0-9]/g,Qe="undefined"!=typeof document,et=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};Y.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Y.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var tt=C.event;C.event=function(e){return tt&&(e=tt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var nt={configurable:!0,get:function(){return this.class}},it=C.vnode;C.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,i={},o=-1==n.indexOf("-");for(var r in t){var l=t[r];if(!("value"===r&&"defaultValue"in t&&null==l||Qe&&"children"===r&&"noscript"===n||"class"===r||"className"===r)){var s=r.toLowerCase();"defaultValue"===r&&"value"in t&&null==t.value?r="value":"download"===r&&!0===l?l="":"translate"===s&&"no"===l?l=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?r="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||et(t.type)?"onfocus"===s?r="onfocusin":"onblur"===s?r="onfocusout":Ge.test(r)&&(r=s):s=r="oninput":o&&Ze.test(r)?r=r.replace(Ke,"-$&").toLowerCase():null===l&&(l=void 0),"oninput"===s&&i[r=s]&&(r="oninputCapture"),i[r]=l}}"select"==n&&(i.multiple&&Array.isArray(i.value)&&(i.value=ee(t.children).forEach(function(e){e.props.selected=-1!=i.value.indexOf(e.props.value)})),null!=i.defaultValue&&(i.value=ee(t.children).forEach(function(e){e.props.selected=i.multiple?-1!=i.defaultValue.indexOf(e.props.value):i.defaultValue==e.props.value}))),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,"className",nt)):t.className&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=Je,it&&it(e)};var ot=C.__r;C.__r=function(e){ot&&ot(e),e.__c};var rt=C.diffed;C.diffed=function(e){rt&&rt(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};function lt(e){return t=>{t.stopPropagation(),e?.()}}function st({slides:e,alt:t,onSlideLinkClick:n}){const[i,o]=Ne(0),r=Math.min(i,e.length-1),l=e[r];return fe("div",{className:"pw-inbox_media",children:[fe("div",{className:"pw-inbox_slide",onClick:l.link?lt(()=>n?.(l.link)):void 0,children:[fe("img",{alt:l.caption||t,className:"pw-inbox_hero",src:l.imageUrl}),!!l.caption&&fe("span",{className:"pw-inbox_slide-caption",children:l.caption})]}),e.length>1&&fe("div",{className:"pw-inbox_pager",children:e.map((e,t)=>fe("button",{className:t===r?"pw-inbox_dot pw-active":"pw-inbox_dot",onClick:lt(()=>o(t)),type:"button"},t))})]})}function at({url:e,alt:t,placeholder:n}){return fe("div",{className:"pw-inbox_media",children:n?fe("div",{className:"pw-inbox_hero pw-inbox_hero--placeholder"}):fe("img",{alt:t,className:"pw-inbox_hero",src:e})})}function ct(e){const{content:t,layout:n,title:i,body:o,timeLabel:r,isRead:l,isActionPerformed:s,code:a,placeholder:c,onClick:d,onRemove:h,onSlideLinkClick:f}=e,g=t.title||t.body||"",w=fe("div",{className:"pw-inbox_content",children:[fe("div",{className:"pw-inbox_item-title",children:[i,!l&&fe("span",{className:"pw-inbox_unread-dot"})]}),fe("div",{className:"pw-inbox_item-body",children:o}),fe("div",{className:"pw-inbox_item-time",children:r})]});let m,b;"carousel"!==n||c?"classic"!==n&&(m=fe(at,{alt:g,placeholder:c,url:_(t)})):m=fe(st,{alt:g,onSlideLinkClick:f,slides:p(t.carousel)}),b=fe("div",c?{className:"pw-inbox_icon pw-inbox_icon--placeholder"}:{className:"pw-inbox_icon",children:t.iconUrl?fe("img",{alt:g,className:"pw-inbox_message-image",src:t.iconUrl}):fe("span",{className:"pw-inbox_icon-initial",children:u(t)})});return fe("li",{className:["pw-inbox_item",!l&&"pw-new",!s&&"pw-unread"].filter(Boolean).join(" "),"data-pw-inbox-message-id":a,onClick:d,children:[fe("div",{className:`pw-inbox_item-inner pw-inbox_item--${n}`,children:["classic"===n?b:m,"banner"!==n&&w]}),fe("span",{className:"pw-inbox_item-remove",onClick:lt(h)})]})}function pt({messages:e,appearance:t,now:n,onMessageClick:i,onMessageRemove:o,onSlideLinkClick:r}){return 0===e.length?fe("div",{className:"pw-inbox_list--empty",children:[fe("div",{className:"pw-inbox_list-icon",children:fe("img",{alt:t.emptyInboxTitle,src:t.emptyInboxIconUrl})}),fe("div",{className:"pw-inbox_list-title",children:t.emptyInboxTitle}),fe("div",{className:"ipw-inbox_list-body",children:t.emptyInboxText})]}):fe("div",{className:"pw-inbox_inner",children:[fe("div",{className:"pw-inbox_title",children:t.title}),fe("ul",{className:"pw-inbox_list",children:e.map(e=>fe(ct,{body:e.body,code:e.code,content:e,isActionPerformed:e.isActionPerformed,isRead:e.isRead,layout:d(e),onClick:()=>i?.(e.code),onRemove:()=>o?.(e.code),onSlideLinkClick:t=>r?.(e.code,t),timeLabel:h(e.sendDate,n),title:e.title},e.code))})]})}function _t(e){const{mode:t,messages:n,now:i,onMessageClick:o,onMessageRemove:r,onSlideLinkClick:s}=e,a=function(e){const{borderColor:t}=e||{};return{...l,arrowBorderColor:t&&"transparent"!==t?t:l.arrowBorderColor,...e}}(e.appearance),c=fe(j,{children:[fe("style",{children:"\n.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(--pw-inbox-badgeBgColor, #ff4c00);\n border-radius: 8px;\n color: var(--pw-inbox-badgeTextColor, #ffffff);\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(--pw-inbox-fontFamily, inherit);\n}\n.pw-inbox-widget {\n font-size: 14px;\n position: absolute;\n top: 0;\n left: -1000px;\n background: var(--pw-inbox-bgColor, #ffffff);\n border: solid 1px var(--pw-inbox-borderColor, transparent);\n border-radius: var(--pw-inbox-borderRadius, 4px);\n width: var(--pw-inbox-widgetWidth, 350px);\n box-shadow: 0 1px 4px 0 rgba(0,0,0,.25);\n z-index: var(--pw-inbox-zIndex, 100);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-arrowBorderColor, rgba(0,0,0,.1));\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(--pw-inbox-bgColor, #ffffff);\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(--pw-inbox-textColor, #333333);\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 auto;\n width: var(--pw-inbox-avatarSize, 52px);\n height: var(--pw-inbox-avatarSize, 52px);\n margin-right: 14px;\n overflow: hidden;\n border-radius: var(--pw-inbox-mediaRadius, 8px);\n background: var(--pw-inbox-avatarBgColor, #c4c8cc);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pw-inbox_message-image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n}\n.pw-inbox_icon-initial {\n color: var(--pw-inbox-avatarTextColor, #4b5057);\n font-size: 22px;\n line-height: 1;\n font-weight: 700;\n}\n.pw-inbox_content {\n flex: 1 1 auto;\n min-width: 0;\n}\n.pw-inbox_item-title {\n color: var(--pw-inbox-messageTitleColor, #7a7a7a);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n display: flex;\n align-items: center;\n gap: 6px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.pw-inbox_unread-dot {\n flex: 0 0 auto;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--pw-inbox-unreadDotColor, #00a2ff);\n}\n.pw-inbox_item-body {\n color: var(--pw-inbox-textColor, #333333);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.pw-inbox_item-time {\n color: var(--pw-inbox-timeTextColor, #c4c4c4);\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(--pw-inbox-textColor, #333333);\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(--pw-inbox-emptyInboxTitleColor, #333333);\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(--pw-inbox-emptyInboxTextColor, #7a7a7a);\n}\n\n/* Cell layouts: banner, captioned and carousel stack their media above the\n texts, so the flex row of the classic cell becomes a column. */\n.pw-inbox_item--banner,\n.pw-inbox_item--captioned,\n.pw-inbox_item--carousel {\n flex-direction: column;\n gap: 12px;\n}\n\n.pw-inbox_media {\n position: relative;\n width: 100%;\n}\n.pw-inbox_hero {\n display: block;\n width: 100%;\n max-width: 100%;\n aspect-ratio: 2 / 1;\n object-fit: cover;\n border-radius: var(--pw-inbox-mediaRadius, 8px);\n}\n\n.pw-inbox_slide {\n position: relative;\n display: block;\n cursor: pointer;\n}\n.pw-inbox_slide-caption {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n padding: 14px 10px 6px;\n color: var(--pw-inbox-slideCaptionColor, #ffffff);\n font-size: 14px;\n line-height: 20px;\n border-radius: 0 0 var(--pw-inbox-mediaRadius, 8px) var(--pw-inbox-mediaRadius, 8px);\n background: linear-gradient(transparent, var(--pw-inbox-slideScrimColor, rgba(0,0,0,.45)));\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n\n.pw-inbox_pager {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n}\n.pw-inbox_dot {\n width: 6px;\n height: 6px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: var(--pw-inbox-pagerDotColor, #ebf0f5);\n cursor: pointer;\n}\n.pw-inbox_dot.pw-active {\n background: var(--pw-inbox-pagerDotActiveColor, #00a2ff);\n}\n\n/* `legacyClassicCell` restores the pre-3.75 classic cell. Scoped to classic on\n purpose: the three new layouts have no older look to go back to. */\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_icon {\n display: block;\n flex: 0 0 40px;\n width: auto;\n height: auto;\n margin-right: 0;\n border-radius: 0;\n background: none;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_message-image {\n width: 28px;\n height: auto;\n object-fit: fill;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_content {\n flex: 0 1 100%;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_item-title {\n display: block;\n overflow: visible;\n text-overflow: clip;\n white-space: normal;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_unread-dot {\n display: none;\n}\n.pw-inbox-widget--legacy-cell .pw-inbox_item--classic .pw-inbox_item-body {\n display: block;\n overflow: visible;\n}\n\n.pw-inbox-widget.pw-inbox-widget--preview {\n position: relative;\n top: auto;\n left: auto;\n max-width: 100%;\n opacity: 1;\n transition: none;\n}\n.pw-inbox-widget--preview .pw-inbox__arrow {\n display: none;\n}\n.pw-inbox-widget--cell .pw-inbox_item {\n padding: 16px;\n}\n.pw-inbox_icon--placeholder {\n border: 1px dashed #00a2ff;\n background: #80b7ff33;\n}\n.pw-inbox_hero--placeholder {\n border: 1px dashed #00a2ff;\n background: #80b7ff33;\n}\n"}),fe("div",{className:"pw-inbox__arrow"}),fe(pt,{appearance:a,messages:n,now:i,onMessageClick:o,onMessageRemove:r,onSlideLinkClick:s})]});if("live"===t)return c;const p=function(e,t){return{className:["pw-inbox-widget pw-inbox-widget--preview",t,e.legacyClassicCell&&"pw-inbox-widget--legacy-cell"].filter(Boolean).join(" "),style:f(e)}}(a,0===n.length?"pw-inbox-widget--empty":void 0);return fe("div",{className:p.className,style:p.style,children:c})}const dt=e=>({code:e.code,title:e.title,body:e.message,iconUrl:e.iconUrl,bannerUrl:e.heroUrl,layoutType:e.layout,carousel:e.carousel,sendDate:e.sendDate,isRead:e.isRead,isActionPerformed:e.isActionPerformed}),ut="#333",ht=/[;{}]/;let ft=null;function gt(e,t){switch(e){case"size":{const e=Number(t??0);return Number.isFinite(e)?`${e}px`:null}case"number":{const e=parseFloat(String(t));return Number.isFinite(e)?String(e):null}case"color":{const e=String(t);return function(e){return ht.test(e)?ut:(ft||(ft=document.createElement("div")),ft.style.color="",ft.style.color=e,ft.style.color?e:ut)}(e)===e?e:null}default:return String(t).trim()||null}}function wt(e,t,n,i){n.forEach(({name:n,type:o})=>{const r=gt(o,i[n]);null!==r&&e.style.setProperty(function(e,t){return`--${e}-${t}`}(t,n),r)})}const mt=/^(?:javascript|vbscript|data|blob|file):/i;function bt(e){return e.split("").filter(e=>e.charCodeAt(0)>32&&127!==e.charCodeAt(0)).join("")}class xt{constructor(e){this.lastSyncAt=0,this.pw=e;const t=this.pw.initParams.inboxWidget;this.config={...x,arrowBorderColor:t.borderColor&&"transparent"!==t.borderColor?t.borderColor:"rgba(0,0,0,.1)",...this.pw.initParams.inboxWidget},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)}async run(){this.initTrigger(),this.updateInbox(),this.addListeners()}toggle(e){(void 0===e?!this.isOpened:e)?this.openWidget():this.closeWidget()}initTrigger(){if(!this.pw.pwinbox)throw new Error("Web inbox is not allowed.");const e=document.getElementById(this.config.triggerId);if(!e)throw new Error("Inbox trigger element doesn't exist. You must set triggerId in inboxWidget config. See the documentation.");this.trigger=e,this.trigger.classList.add("pw-inbox-trigger"),this.lastSyncAt=Date.now(),this.defaultMargin=12,this.messagesElements={},this.messages=[],this.readItems=[],this.updateCounter(0),this.isOpened=!1,this.renderWidget(),this.isFixed=v(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.widget.classList.toggle("pw-inbox-widget--legacy-cell",this.config.legacyClassicCell),this.widgetParent=document.querySelector(this.config.appendTo)||document.body,this.widgetParent.appendChild(this.widget),this.applyStyleVariables(),this.renderWidgetInner()}applyStyleVariables(){wt(this.widget,g,w,this.config),wt(this.trigger,g,b,this.config)}renderWidgetInner(){var e,t,n,i;this.widget.classList.toggle("pw-inbox-widget--empty",0===this.messages.length),e=this.widget,t=this.messages,n=this.config,i={onMessageClick:e=>this.performMessageAction(e),onMessageRemove:e=>this.removeMessages([e]),onSlideLinkClick:(e,t)=>{var n;(n=t)&&!mt.test(bt(n))?document.location.href=t:this.performMessageAction(e)}},ue(fe(_t,{mode:"live",messages:t.map(dt),appearance:n,onMessageClick:i.onMessageClick,onMessageRemove:i.onMessageRemove,onSlideLinkClick:i.onSlideLinkClick}),e),this.list=this.widget.querySelector(".pw-inbox_list")||document.createElement("ul"),this.messagesElements={},this.widget.querySelectorAll("[data-pw-inbox-message-id]").forEach(e=>{this.messagesElements[e.getAttribute("data-pw-inbox-message-id")||""]=e})}updateCounter(e){this.count=e,this.trigger.setAttribute("data-pw-count",`${this.count}`),this.trigger.classList.toggle("pw-empty",0===this.count)}updateInboxMessages(e){this.messages=e.sort(({sendDate:e},{sendDate:t})=>{return n=e,new Date(t).getTime()-new Date(n).getTime();var n}),this.renderWidgetInner()}openWidget(){this.isOpened=!0,this.widget.classList.add("pw-open"),this.syncMessages(),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),window.removeEventListener("scroll",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:e}=this.config;this.widgetParent.style.position="relative",this.widget.classList.add("pw-inbox-widget--inset"),this.widget.classList.add(`pw-${e}`)}defaultPlaceWidget(){const e=this.pw.initParams.inboxWidget.position?this.config.position:this.getDefaultPosition(),t=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);switch(t.width+2*this.defaultMargin>n&&(this.widget.style.width=n-2*this.defaultMargin+"px"),t.height+24>i&&(this.widget.style.height=i-2*this.defaultMargin+"px"),e){case"top":this.alignWidgetTop();break;case"right":this.alignWidgetRight();break;case"left":this.alignWidgetLeft();break;case"bottom":this.alignWidgetBottom()}}alignWidgetTop(){const e=this.trigger.getBoundingClientRect(),t=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-top");let o=pageXOffset+e.left+Math.floor(e.width/2)-Math.floor(t.width/2);const r=o<pageXOffset,l=o+t.width>pageXOffset+n;r&&(o=pageXOffset+this.defaultMargin),l&&(o=pageXOffset+n-t.width-this.defaultMargin);const s=pageYOffset+e.top-t.height;this.alignWidgetElement(o,s),i.style.left=e.left+Math.floor(e.width/2)-o+"px";const a=this.widget.getBoundingClientRect().top;if(a<0){const e=this.widget.getBoundingClientRect().height+a-this.defaultMargin,t=this.widget.getBoundingClientRect().top-a+this.defaultMargin;this.widget.style.height=`${e}px`,this.widget.style.top=`${t}px`}}alignWidgetRight(){const e=this.trigger.getBoundingClientRect(),t=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-right");let r=pageYOffset+e.top+Math.floor(e.height/2)-Math.floor(t.height/2);const l=r<pageYOffset,s=pageYOffset+i<r+t.height;l&&(r=pageYOffset+this.defaultMargin),s&&(r=pageYOffset+i-t.height-this.defaultMargin);const a=pageXOffset+e.left+e.width;this.alignWidgetElement(a,r),o.style.top=e.top+Math.floor(e.height/2)-r+"px";const c=n-this.widget.getBoundingClientRect().right;if(c<this.defaultMargin){const e=this.widget.getBoundingClientRect().width+c-this.defaultMargin;this.widget.style.width=`${e}px`}}alignWidgetLeft(){const e=this.trigger.getBoundingClientRect(),t=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-left");let o=pageYOffset+e.top+Math.floor(e.height/2)-Math.floor(t.height/2);const r=o<pageYOffset,l=pageYOffset+n<o+t.height;r&&(o=pageYOffset+this.defaultMargin),l&&(o=pageYOffset+n-t.height-this.defaultMargin);const s=pageXOffset+e.left-t.width;this.alignWidgetElement(s,o),i.style.top=e.top+Math.floor(e.height/2)-o+"px";const a=this.widget.getBoundingClientRect().left;if(a<0){const e=this.widget.getBoundingClientRect().width+a-this.defaultMargin,t=this.widget.getBoundingClientRect().left-a;this.widget.style.width=`${e}px`,this.widget.style.left=`${t}px`}}alignWidgetBottom(){const e=this.trigger.getBoundingClientRect(),t=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-bottom");let r=pageXOffset+e.left+Math.floor(e.width/2)-Math.floor(t.width/2);const l=r<pageXOffset,s=r+t.width>pageXOffset+n;l&&(r=pageXOffset+this.defaultMargin),s&&(r=pageXOffset+n-t.width-12);const a=pageYOffset+e.top+e.height;this.alignWidgetElement(r,a),o.style.left=e.left+Math.floor(e.width/2)-r+"px";const c=i-this.widget.getBoundingClientRect().bottom;if(c<this.defaultMargin){const e=this.widget.getBoundingClientRect().height+c-this.defaultMargin;this.widget.style.height=`${e}px`}}alignWidgetElement(e,t){this.widget.style.left=`${e}px`,this.widget.style.top=`${t}px`}getDefaultPosition(){const{left:e,top:t,width:n,height:i}=this.trigger.getBoundingClientRect();if(!document.documentElement)return"";const o={right:e,bottom:t,left:Math.max(document.documentElement.clientWidth,window.innerWidth||0)-(e+n),top:Math.max(document.documentElement.clientHeight,window.innerHeight||0)-(t+i)},r=Math.min(e,t,o.left,o.top);let l="bottom";return Object.keys(o).forEach(e=>{o[e]===r&&(l=e)}),l}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 e=this.list.clientHeight+this.list.scrollTop-50;Object.keys(this.messagesElements).forEach(t=>{if(!this.messagesElements[t]||this.messagesElements[t].offsetTop>e)return;const n=this.messages.find(e=>e.code===t);!n||n.isRead||this.readItems.indexOf(t)+1||this.readItems.push(t)})}updateReadStatus(){const e=this.readItems;this.readItems=[],this.pw.pwinbox.readMessagesWithCodes(e).then(this.updateInbox)}syncMessages(){Date.now()-this.lastSyncAt<3e4||(this.lastSyncAt=Date.now(),this.pw.pwinbox.syncMessages().catch(e=>{console.error("Pushwoosh: cannot refresh the inbox on open",e)}))}updateInbox(){this.pw.pwinbox.loadMessages().then(e=>{this.updateInboxMessages(e)}),this.pw.pwinbox.unreadMessagesCount().then(e=>{this.updateCounter(e)})}performMessageAction(e){const t=this.messages.find(t=>t.code===e);t&&t.webPopupCode&&this.toggle(!1),this.pw.pwinbox.performActionForMessageWithCode(e).then(()=>{this.updateInbox()})}removeMessages(e){this.readItems=this.readItems.filter(t=>-1===e.indexOf(t)),this.pw.pwinbox.deleteMessagesWithCodes(e).then(()=>{this.updateInbox()})}onTriggerClickHandler(e){e.stopPropagation(),e.target&&this.toggle()}onWidgetClickHandler(e){e.target&&(e.target.closest(".pw-inbox_item")||this.toggle())}onWindowScrollHandler(){this.isFixed&&this.isOpened?this.toggle():this.positionWidget()}}return t})());
|
|
2
2
|
//# sourceMappingURL=widget-inbox.js.map
|