PageSourceSearch

https://grybezpradu.eu/application/assets/storefront/chunk-inpost_pay_v2_initializer.rvD1lYD.js

js grybezpradu.eu collected 2026-10-10 01:10:43 UTC 8,534 bytes, 10 lines download raw bytes

1import{b as T,bl as O,aN as g,aO as A,B as M,J as f,aP as y,bQ as k,bq as R,R as B,Q as V,A as U,M as N,N as z,cg as D,aa as F,D as K,H as L,p as $,e as G,r as H,C as x}from"./storefrontApp.CsApItsi.min.js";import{S as w}from"./chunk-storefront_settings_constants.DIF02Gz.js";import{P as Y}from"./chunk-product_variants_validator.3TFbf28.js";import{B as W,e as q,m}from"./chunk-vendor-rxjs.Dp7kflo.js";import{a as S,I as Q,B as j}from"./chunk-inpost_pay_button_constants.RkLheTG.js";import{f as J,w as X,r as Z,$ as P,e as v,t as tt}from"./chunk-vendor-lit.NvY0u02.js";import{S as it}from"./chunk-storefront_base_lit_element.lX23Jvc.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-phoenix.cdKS79L.js";const et={service:"inpostPayService"},b={buttonsVisibilityChanged:"inpostPayButtonsVisibilityChanged"},I={basketProductChanged:"basketProductChanged",orderCreated:"orderCreated"},C={sandbox:"https://sandbox-inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js",production:"https://inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js"};class st extends T{constructor({featureSystemApi:t,pageManagerApi:i,inpostPayHttpApi:r,settingsApi:s,messageStorageApi:p,basketGiftCardsApi:c,flashMessengerApi:l}){super(),this.moduleName=et.service,this.#n=new W(!0),this._initInpostWidget=async()=>{const e=this.#e.getInpostPayWidgetSettings();if(!e)return;const n=await this._getBindingApiKey();if(!n&&this.#e.isFeatureEnabled("dev_gift_cards"))return;const o={merchantClientId:e.merchantClientId,basketBindingApiKey:n,unboundWidgetClicked:async a=>this._addToCart(a),handleBasketEvent:async a=>{switch(a){case I.basketProductChanged:this.#s=await this.getApi(A.api),this.#s&&this.#s.refreshBasket();break;case I.orderCreated:this._redirectToBasketDoneOnOrderComplete();break}return!0}},h=window.InPostPayWidget.init(o);new O(()=>{h.refresh();const a=this.#r?.get().map(_=>_.id);a&&this._isAnyInpostShippingAvailable(a)})},this._getBindingApiKey=async(e=!1)=>{const{data:n}=await this.#t.getBindingApiKey().response;if(n._flash_messenger&&this.#e.isFeatureEnabled("dev_gift_cards")){e&&this.#d.parseAndAddFlashMessages(n._flash_messenger);return}return n.basket_binding_api_key},this._validateBasketBinding=async()=>{const e=await this._getBindingApiKey(!0);if(!e)throw new Error("UNDELIVERABLE_PRODUCT");return e},this._addToCart=async e=>{if(!e)return this.#e.isFeatureEnabled("dev_gift_cards")?await this._validateBasketBinding():this._getBindingApiKey();if(!await new Y().isEveryVariantOptionSelected(Number(e)))throw new Error("UNDELIVERABLE_PRODUCT");if(!this.isFeatureRegistered(g.feature))return await this.#i.registerDynamic(g.feature),this._addToCart(e);this.#s=await this.getApi(A.api),this.#e.isFeatureEnabled("dev_gift_cards")&&(await this.#s.refreshBasket(),(this.#a?.getGiftCards().length||0)>0&&await this._validateBasketBinding());const o=document.querySelector(`${M.component}[product-id="${e}"]`);if(!o)throw new Error("BUY_BUTTON_NOT_FOUND");const h=await this.#s?.addItem({variantId:o.variantId,quantity:o.quantity,variantOptions:o.variantOptions,basketTrackingParams:o.basketTrackingParams,isExchangedWithLoyaltyPoints:!1,showAddedModal:!1,bundleItems:o.bundleItems});if(h?.shippings){const a=h.shippings.map(_=>_.id);this._isAnyInpostShippingAvailable(a)}if(!this.#n.value)throw new Error("UNDELIVERABLE_PRODUCT");return this._getBindingApiKey()},this._redirectToBasketDoneOnOrderComplete=async()=>{try{const n=(await this.#t.getOrderComplete().response).data;return n&&n.action==="redirect"&&(this.eventBus.emit(new f(y.orderPlaced)),this.#o.visit(n.redirect)),n}catch(e){console.error(e)}},this.#i=t,this.#o=i,this.#t=r,this.#e=s,this.#p=p,this.#a=c,this.#d=l,this._setupEvents(),this._setupSubscriptions(),this._createIziPayScript().then(async()=>{this._initInpostWidget()})}#t;#i;#o;#e;#p;#a;#d;#s;#r;#h;#n;_setupEvents(){const t=this.#p.getChannelMessages(y.initialized);t.length>0&&t.forEach(()=>this._synchronizeBaskets()),this.eventBus.on(y.initialized,async()=>this._synchronizeBaskets())}_setupSubscriptions(){this._selectShouldShowButtons$().subscribe(t=>{this._toggleIziButtons(t)})}_selectShouldShowButtons$(){return this.#a?q([this.#n,this.#a.selectHasAppliedGiftCards$(
1)]).pipe(m(([t,i])=>t&&!i)):this.#n.asObservable()}_showIziButtons(){Array.from(document.getElementsByTagName("inpost-izi-button")).forEach(i=>i.removeAttribute("hidden"))}_hideIziButtons(){Array.from(document.getElementsByTagName("inpost-izi-button")).forEach(i=>i.setAttribute("hidden",""))}_toggleIziButtons(t){this.#e.isFeatureEnabled("dev_inpost_pay_button")?this.eventBus.emit(new f(b.buttonsVisibilityChanged,t)):t?this._showIziButtons():this._hideIziButtons()}async _synchronizeBaskets(){this.#s=await this.getApi(A.api),this.#r=await this.getApi(k.api),this.#h=await this.getApi("basketProductsApi"),this.#r.select$().pipe(m(t=>t.map(i=>i.id))).subscribe(t=>this._isAnyInpostShippingAvailable(t))}_isAnyInpostShippingAvailable(t){if((this.#h?.getBasketCount()??0)===0){this.#n.next(!0);return}const r=t.some(s=>this.#e.getInpostPayWidgetSettings()?.mappedShippingMethodsIds.includes(s));this.#n.next(r)}async _createIziPayScript(){const i=this.#e.getInpostPayWidgetSettings()?.isSandbox==="1"?C.sandbox:C.production;await R.create("iziPay",i)}}class nt{getBindingApiKey(){return"/webapi/front/inpost/binding"}getOrderComplete(){return"/webapi/front/inpost/order-complete"}}class at{#t=new nt;#i;constructor(t){this.#i=t}getOrderComplete(){const t={url:this.#t.getOrderComplete(),method:B.get};return this.#i.fetch(t)}getBindingApiKey(){const t={url:this.#t.getBindingApiKey(),method:B.post};return this.#i.fetch(t)}}const rt="inpost-pay-buttons-visibility-changed-handler";class ot extends T{constructor(t){super(),this.moduleName=rt,this.#t=this.queryBus.executeSync(new V(U.getApiSync,N)),this.#i=t,this._handlePastPageLoads(),this.eventBus.on(b.buttonsVisibilityChanged,t)}#t;#i;_handlePastPageLoads(){const t=this.#t.getChannelMessages(b.buttonsVisibilityChanged);t.length>0&&t.forEach(i=>this.#i(i))}}var pt=Object.defineProperty,E=(d,t,i,r)=>{for(var s=void 0,p=d.length-1,c;p>=0;p--)(c=d[p])&&(s=c(t,i,s)||s);return s&&pt(t,i,s),s};class u extends it{constructor(){super(...arguments),this.bindingPlace=S.BASKET_SUMMARY,this._storefrontSettingsApi=null,this._isButtonVisible=!0}static{this.moduleName=Q}connectedCallback(){super.connectedCallback(),this._storefrontSettingsApi=this.getApiSync(w.api),this._inpostPayButtonsVisibilityChangedHandler||(this._inpostPayButtonsVisibilityChangedHandler=new ot(({body:t})=>{t!==void 0&&(this._isButtonVisible=t)}))}_shouldRenderButton(){const t=this._storefrontSettingsApi?.getInpostPayWidgetSettings();if(!t)return!1;const{merchantClientId:i,showOnProductPage:r,showInBasket:s}=t;if(!i)return!1;switch(this.bindingPlace){case S.PRODUCT_CARD:return r==="1";case S.BASKET_SUMMARY:return s==="1";default:return!1}}_getButtonVariation(){const t=this._storefrontSettingsApi?.getInpostPayWidgetSettings();if(!t)return"primary";const i=t.buttonVariant==="secondary"?"secondary":"primary",r=t.isDarkMode?"dark":"",s=t.frameStyle||"";return`${i} ${r} ${s}`.trim()}render(){return P`
2            ${J(this._shouldRenderButton(),()=>P`<inpost-izi-button
3                    data-v2
4                    data-product-id="${Z(this.productId)}"
5                    variation="${this._getButtonVariation()}"
6                    binding_place="${this.bindingPlace}"
7                    ?hidden=${!this._isButtonVisible}
8                >
9                </inpost-izi-button>`,()=>X)}
10        `}}E([v({type:String,attribute:"binding-place"})],u.prototype,"bindingPlace");E([v({type:String,attribute:"data-product-id"})],u.prototype,"productId");E([tt()],u.prototype,"_isButtonVisible");class bt extends z{static{this.featureName=D.feature}async init(){const t=this.getApiSync(F),i=await this.getApi(K.api),r=this.getApiSync(L),s=this.getApiSync($),p=await this.getApi(w.api),c=this.getApiSync(N),l=this.getApiSync(G.api);let e;p.isFeatureEnabled("dev_gift_cards")&&(this.globalCoresContainersRegistry.hasFeatureBeenRegistered(g.feature)||await t.registerDynamic(g.feature),e=this.getApiSync(j.api));const n=new at(r),o=new st({featureSystemApi:t,pageManagerApi:i,inpostPayHttpApi:n,storeFactoryApi:s,settingsApi:p,messageStorageApi:c,basketGiftCardsApi:e,flashMessengerApi:l}),h=[{type:H.service,instance:[o]}];return p.isFeatureEnabled("dev_inpost_pay_button")&&h.push({type:x,instance:[u]}),{cores:h}}}export{bt as InpostPayV2Initializer};

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.