PageSourceSearch

https://vesper.pl/modules/inpostizi/views/js/front/v2.0095364c2f27022ee4c0.js

js vesper.pl collected 2026-10-02 06:31:53 UTC 7,047 bytes, 1 lines download raw bytes

1!function(){"use strict";var t=()=>{const t={merchantClientId:"",basketBindingApiKey:void 0,unboundWidgetClicked:void 0,handleBasketEvent:()=>!1,apiBaseUrl:void 0,webView:!1,language:"pl"};return{setMerchantClientId:e=>{t.merchantClientId=e},setBasketBindingApiKey:e=>{t.basketBindingApiKey=e},setUnboundWidgetClicked:e=>{t.unboundWidgetClicked=e},setHandleBasketEvent:e=>{t.handleBasketEvent=e},setApiBaseUrl:e=>{t.apiBaseUrl=e},setWebView:e=>{t.webView=e},setLanguage:e=>{t.language=e},build:()=>{const e={};for(const r in t)"undefined"!==t[r]&&(e[r]=t[r]);return e}}};var e={orderConfirmationUrl:"inpost/v2/izi/merchant/order/confirmation-url",bindingKey:"inpost/v2/izi/merchant/basket/binding-key",widgetGet:"inpost/v2/izi/merchant/widget/get"};var r=t=>{const e=new URL(t),r=(t,r)=>{e.searchParams.set(t,r)};return{getURL:()=>e.toString(),addParam:r,addParams:t=>{Object.keys(t).forEach(e=>{r(e,t[e])})}}};var n=(t,e,n=null,o={})=>{const{addParam:i,addParams:a,getURL:s}=r(t),d={method:e,headers:{"Content-Type":"application/json",...o}};null!==n&&(d.body=JSON.stringify(n));return{getResponse:()=>{const t=d,e=s();return fetch(e,t)},setParams:t=>{a(t)},setParam:(t,e)=>{i(t,e)}}};const o=window.inpostizi_backend_ajax_url,i=window.inpostizi_cart_controller_url;var a=(t,e,i=null,a={})=>{const{addParam:s,getURL:d}=r(o);return s("path",t),n(d(),e,i,a)};var s=async()=>{const{bindingKey:t}=e,{getResponse:r}=a(t,"GET"),n=await r();if(!n.ok&&404!==n.status)throw new Error("Error while fetching binding key");if(404!==n.status)return n.json()};class d extends Error{constructor(t,e){super(t,e),this.name="WidgetError",this.code=t}}var c=d;var u=(t=!1)=>!1===t&&null!==window.inpostizi_binding_api_key?window.inpostizi_binding_api_key:!1!==t||window.inpostizi_fetch_binding_key?new Promise((t,e)=>{s().then(e=>{t(e)}).catch(t=>{e(new c("BINDING_KEY_FETCH_FAILED",{cause:t}))})}):void 0;const p={productPageForm:"#add-to-cart-or-refresh",inpostIziButton:"inpost-izi-button",inpostIziProductButtonWrapper:".js-inpost-izi-product-btn-wrapper",inpostIziAddToCartAlert:".js-inpost-izi-add-to-cart-alert"};var l=()=>void 0!==window.inpost_izi_selectors_map?{...p,...window.inpost_izi_selectors_map}:p;var w=(t,e="success",r="")=>{const n=document.createElement("div");return n.classList.add("alert",`alert-${e}`,"w-100"),"string"==typeof r?n.classList.add(r):Array.isArray(r)&&r.forEach(t=>{n.classList.add(t)}),n.textContent=t,n};var h=t=>{const{inpostIziProductButtonWrapper:e,inpostIziAddToCartAlert:r}=l(),n=w(t.message,"danger",r.replace(".","")),o=document.querySelector(e);if(o){const t=o.querySelector(r);t&&t.remove(),o.prepend(n)}};var g=class extends c{constructor(t){super("UNDELIVERABLE_PRODUCT",t),this.name="UndeliverableProductError"}};var f=async t=>{const{getResponse:e,setParams:r}=n(prestashop.urls.pages.cart,"POST",null,{"X-Requested-With":"XMLHttpRequest","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"});r(t);const o=await e(),i=await o.json();if(i?.hasError&&i?.errors&&Array.isArray(i.errors)){const t=new Error(i.errors.join("\n"));throw setTimeout(()=>{h(t)}),new g({cause:t})}try{prestashop.emit("updateCart",{reason:{idProduct:i.id_product,idProductAttribute:i.id_product_attribute,idCustomization:i.id_customization,cart:i.cart,linkAction:"inpostizi-widget-bind"},resp:i})}catch(t){console.error("updateCart listener failed",t)}return u()};const m=(t=!1)=>new Promise((e,r)=>{const n=u(t);n instanceof Promise?n.then(t=>{e(t)}).catch(t=>{r(t)}):e(n)});var v=t=>new Promise((e,r)=>{if(!t)return void m(!0).then(t=>{e(t)}).catch(t=>{r(t)});const{productPageForm:n}=l(),o=document.querySelector(n);if(!o)return void r(new c("PRODUCT_FORM_NOT_FOUND"));const{group:i,...a}=(t=>{const e=new FormData(t),r={},n=[];for(const[t,o]of e.entries())0===t.indexOf("group")?n.push({key:t,value:encodeURIComponent(o)}):r[t]=o;return r.group=n,r})(o),s={add:1,action:"update",ajax:1,...a};i.forEach(t=>{s[t.key]=t.value}),f(s).then(()=>{m(!0).then(t=>{e(t)}).catch(t=>{r(t)})}).catch(t=>{r(t instanceof c?t:new c("ADD_TO_CART_FAILED",{cause:t}))})});var y=t=>(new DOMParser).parseFromString(t,"text/html").body.children[0];var _=async(t,r,n=null)=>{const o=((t,r,n=null)=>{const{widgetGet:o}=e;return null!==n?`${o}/${t}/${r}/${n}`:`${o}/${t}/${r}`})(t,r,n),{getResponse:i}=a(o,"GET");return i()};var k=async(t,e,r)=>{const n=await _(t,e,r);
1if(!n.ok)throw new Error(`Failed to fetch widget for hook ${t}, product ${e}, attribute ${r}`);const{content:o}=await n.json();return y(o)};const b=(t,e)=>{const r=y(t);return r?r.matches?.(e)?r:r.querySelector?.(e):null};var E=(t,e)=>{for(const r of Object.values(t))if("string"==typeof r&&""!==r){const t=b(r,e);if(t)return t}return null};var P=async t=>{const{id_product_attribute:e=0}=t,r=l().inpostIziProductButtonWrapper,n=document.querySelectorAll(`${r}[data-hook]`);if(0===n.length)return;const o=(t=>{const e=new Map;for(const r of t){const t=r.dataset.hook;e.has(t)||e.set(t,[]),e.get(t).push(r)}return e})(n);await Promise.all(Array.from(o.entries()).map(([n,o])=>(async(t,e,r,n,o)=>{const i=`${n}[data-hook="${t}"]`;let a=E(r,i);if(!a){const{idProduct:r}=e[0].dataset;if(!r)throw new Error(`No data-id-product attribute found for block ${i}`);a=await k(t,parseInt(r,10),parseInt(o,10))}e.forEach((t,e)=>{const r=0===e?a:a.cloneNode(!0);t.replaceWith(r)})})(n,o,t,r,e)))};var z=async()=>{const{orderConfirmationUrl:t}=e,{getResponse:r}=a(t,"GET"),n=await r();if(!n.ok)throw new Error("NOK");return n.json()};var C=async()=>{const{addParam:t,getURL:e}=r(i);t("token",window.prestashop.static_token);const{getResponse:o}=n(e(),"GET"),a=await o();if(!a.ok)throw new Error("Could not fetch cart data");return a.json()};const A=async()=>{try{return await C()}catch(t){return{cart:window.prestashop.cart}}};var I=async t=>{if("basketProductChanged"===t||"basketDeleted"===t)prestashop.emit("updateCart",{reason:{linkAction:"refresh"},resp:await A()});else if("orderCreated"===t)try{window.location.href=await z()}catch(t){return!1}return!0};let B;var R=()=>({init:t=>{B=window.InPostPayWidget.init(t)},refresh:()=>{if(void 0===B)throw new Error("Widget is not initialized yet, use init() method first");"function"!=typeof B.rerender?B.refresh():B.rerender()}});var U=()=>({init:()=>{const{init:e,refresh:r}=R(),{setMerchantClientId:n,setBasketBindingApiKey:o,setUnboundWidgetClicked:i,setHandleBasketEvent:a,setLanguage:s,build:d}=t();void 0!==window.prestashop.language.iso_code&&s(window.prestashop.language.iso_code),n(window.inpostizi_merchant_client_id),o(u()),i(v),a(I),e(d()),window.prestashop.on("updatedCart",()=>r()),window.prestashop.on("updatedProduct",async t=>{if(void 0===t.is_quick_view||!t.is_quick_view){try{await P(t)}catch(t){console.error(t)}r()}})}});window.prestashop??={},window.prestashop.inpostizi??={},window.prestashop.inpostizi.widget??=R(),"function"!=typeof window.handleInpostIziButtons&&(window.handleInpostIziButtons=window.prestashop.inpostizi.widget.refresh),document.addEventListener("DOMContentLoaded",()=>{const{init:t}=U();t()})}();

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.