(()=>{const e={checkInterval:null,maxAttempts:120,currentAttempt:0,intervalTime:1e3,isChecking:!1},t=()=>{const e=document.getElementById("simplyin-blik-status-modal");return{paymentProcessing:e.dataset.paymentProcessing,paymentPending:e.dataset.paymentPending,paymentSuccess:e.dataset.paymentSuccess,paymentRejected:e.dataset.paymentRejected,paymentTimeout:e.dataset.paymentTimeout,statusCheckError:e.dataset.statusCheckError,networkError:e.dataset.networkError,mainMessageProcessing:e.dataset.mainMessageProcessing,mainMessagePending:e.dataset.mainMessagePending,mainMessageSuccess:e.dataset.mainMessageSuccess,mainMessageError:e.dataset.mainMessageError,mainMessageTimeout:e.dataset.mainMessageTimeout}},s=(e,s)=>{const r=t();switch(e){case"SUCCESS":n();break;case"FAILURE":i(s||r.paymentRejected);break;case"PENDING":a(r.paymentPending,"pending");break;case"CHECK_BANK_APP":a(r.acceptPaymentMessage,"processing");break;default:a(r.paymentProcessing,"processing")}},a=(e,s)=>{const a=document.getElementById("blik-status-message"),n=document.querySelector(".simplyin-blik-main-message"),i=document.getElementById("simplyin-blik-status-modal"),r=t(),c={success:r.mainMessageSuccess,error:r.mainMessageError,pending:r.mainMessagePending,processing:r.mainMessageProcessing,timeout:r.mainMessageTimeout};(e=>{const t=document.querySelector(".simplyin-blik-icon svg");if(!t)return;const s={success:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="#4CAF50"></path>',error:'<circle cx="12" cy="12" r="10" fill="#f44336"></circle><path d="M15 9l-6 6m0-6l6 6" stroke="white" stroke-width="2" stroke-linecap="round"></path>',pending:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" fill="#FF9800"></path>',processing:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" fill="#2196F3"></path><circle cx="12" cy="12" r="3" fill="#2196F3" opacity="0.3"><animate attributeName="opacity" values="0.3;1;0.3" dur="1.5s" repeatCount="indefinite"></animate></circle>',timeout:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" fill="#f44336"></path>'};t.innerHTML=s[e]||s.processing})(s),a&&(a.textContent=e),n&&(n.textContent=c[s]||c.processing),i&&(i.classList.remove("simplyin-blik-success","simplyin-blik-error","simplyin-blik-pending","simplyin-blik-processing","simplyin-blik-timeout"),"success"===s?i.classList.add("simplyin-blik-success"):"error"===s?i.classList.add("simplyin-blik-error"):"pending"===s?i.classList.add("simplyin-blik-pending"):"processing"===s?i.classList.add("simplyin-blik-processing"):"timeout"===s&&i.classList.add("simplyin-blik-timeout"))},n=()=>{const e=t();m(),c(),a(e.paymentSuccess,"success")},i=e=>{m(),c(),a(e,"error")},r=()=>{const e=t();m(),c(),a(e.paymentTimeout,"timeout")},c=()=>{const e=document.getElementById("blik-loader");e&&e.classList.add("hidden")},m=()=>{e.checkInterval&&(clearInterval(e.checkInterval),e.checkInterval=null)};window.addEventListener("load",(()=>{window.simplyInStatus&&(e.checkInterval&&clearInterval(e.checkInterval),e.currentAttempt=0,e.isChecking=!1,e.checkInterval=setInterval((()=>{(async()=>{if(!e.isChecking)if(e.currentAttempt++,e.isChecking=!0,e.currentAttempt>e.maxAttempts)r();else try{const e={action:"true"===document.getElementById("simplyin-blik-status-modal").dataset.isCardPayment?"simplyin_get_card_payment_status":"simplyin_get_blik_payment_status",ajax_token:window.simplyInStatus.nonce,order_id:window.simplyInStatus.orderId},a=await fetch(window.simplyInStatus.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(e)});if(!a.ok){const e=t(),{customer_error_message:s}=await a.json();return void i(s||e.paymentRejected)}const{payment_status:n,customer_error_message:r}=await a.json();if(n)s(n,r);else{const e=t();console.error(e.statusCheckError,data.data)}}catch(e){const s=t();console.error(s.networkError,e)}finally{e.isChecking=!1}})()}),e.intervalTime))}))})();