1import{b as l,c as n}from"./chunk-CZRSL6NU.js";import{l as o}from"./chunk-VJGBCIFP.js";import"./chunk-XCPXRTXT.js";import"./chunk-XJLSI5BW.js";import"./chunk-ZOYOJ6FT.js";import"./chunk-6KHOHYTW.js";var i=class{constructor(e){this.element=e,this.init()}init(){if(this.expectModal())if(this.element.parentNode.nodeName==="MAIN"){this.modalId=this.element.getAttribute("data-modalId"),this.modalContainer=this.element.querySelector("lcl-modal-container"),this.receiptModalContainer=this.element.querySelector("#receipt-modal-container"),this.fallbackReceiptButton=this.element.querySelector(".fallback-receipt-button"),this.closeModalListener();let t="/api/get-receipt"+l(n({articleUrl:this._articleUrl,articleId:this._articleId}));fetch(t).then(async a=>{if(a.status===200)return await a.text()}).then(async a=>{if(a){this.receiptModalContainer.innerHTML="";let r=document.createRange().createContextualFragment(a);this.receiptModalContainer.appendChild(r),this.openModal()}else this._showFallbackReceipt(),this.openModal()}).catch(()=>{this._showFallbackReceipt(),this.openModal()})}else this._moveModalToMain()}_showFallbackReceipt(){this.element.classList.add("receipt-modal--fallback-receipt")}_removeFallbackReceipt(){this.element.classList.remove("receipt-modal--fallback-receipt")}closeModalListener(){document.addEventListener(`lcl-modal:close:${this.modalId}`,()=>{this.sendTapetEvent(),this.removeKvittoQueryParam()}),this.fallbackReceiptButton&&this.fallbackReceiptButton.addEventListener("click",()=>{this.removeKvittoQueryParam(),this.modalContainer.closeModal()}),window.addEventListener("tapet-event",e=>{e.detail.event==="Tapet Paywall Close"&&this.modalContainer.closeModal(0)})}openModal(){setTimeout(()=>{document.dispatchEvent(new CustomEvent(`lcl-modal:open:${this.modalId}`))})}sendTapetEvent(){let e=this.element.querySelector(".tapet-paywall-receipt .tapet-button:not([href])");e&&e.click()}removeKvittoQueryParam(){let e=new URL(window.location.href),t=new URLSearchParams(e.search);t.delete("kvitto"),e.search=t.toString(),window.history.replaceState({},document.title,e.href)}expectModal(){return this.element.dataset.blockNativeApp==="true"?!o:!0}_moveModalToMain(){let e=document.querySelector("main");e&&e.appendChild(this.element)}};export{i as default}; 2//# sourceMappingURL=receipt-modal-module-XYWD4LBD.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.