PageSourceSearch

https://www.bonprix.at/bff_resources/marketing-parameters-CXp5wvUq.js

js bonprix.at collected 2026-10-07 23:25:59 UTC 9,576 bytes, 2 lines download raw bytes

1import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./message-broker-DRci_Yxm.js";import{t as n}from"./messages-BBXpSxxD.js";import{t as r}from"./logger-DB0jBlfJ.js";import{t as i}from"./js.cookie-LuQ0sRX_.js";import{t as a}from"./fetch-with-csrf-BhX0S57R.js";import{t as o}from"./url-CuOZUmTE.js";import{t as s}from"./jsh-module-DkUSoj5t.js";import{t as c}from"./react-DVplv7_D.js";import{t as l}from"./client-msFgu0UU.js";import{t as u}from"./jsx-runtime-B74pBk57.js";var d=e(c(),1),f=l(),p=`/ajax/marketing-parameters/`,m=3,h=850,g=class{constructor(){this.attemptCount=0,this.maxAttempts=m,this.retryInterval=h,this.intervalId=null,this.pendingPromise=null,this.latestResult=null,this.isFetching=!1}resetAttempts(){this.attemptCount=0}hasReachedMaxAttempts(){return this.attemptCount>=this.maxAttempts}stopPolling(){this.intervalId&&=(clearInterval(this.intervalId),null)}async fetchOptimusData({pageType:e,traceId:t}){this.attemptCount+=1;let n=new URLSearchParams({bffPageType:e,traceId:t}),i=`${o.toAbsolute(p)}?${n.toString()}`;try{let e=await a(i,{method:`GET`,headers:{"Content-Type":`application/json`}});return e.ok?await e.json():(r.debug(`Optimus API returned non-OK response`,{status:e.status}),null)}catch(e){return r.debug(`Unable to fetch Optimus parameters (attempt ${this.attemptCount}/${this.maxAttempts})`,e),null}}async fetchWithRetry({onFetch:e,onMaxAttemptsReached:t=null}){if(!this.isFetching){if(this.hasReachedMaxAttempts()){this.stopPolling(),r.debug(`Max attempts reached for fetching Optimus parameters`),t&&t();return}this.isFetching=!0;try{await e()&&this.stopPolling()}finally{this.isFetching=!1}}}startPolling({onFetch:e,onMaxAttemptsReached:t=null}){this.stopPolling(),this.fetchWithRetry({onFetch:e,onMaxAttemptsReached:t}),this.intervalId=setInterval(()=>{this.fetchWithRetry({onFetch:e,onMaxAttemptsReached:t})},this.retryInterval)}hasPendingRequest(){return!!this.pendingPromise}getLatestResultOrPromise({pageType:e,traceId:t}){return this.pendingPromise?this.pendingPromise:this.latestResult?Promise.resolve(this.latestResult):this.request({pageType:e,traceId:t})}request({pageType:e,traceId:t}){return this.pendingPromise?this.pendingPromise:(this.resetAttempts(),this.pendingPromise=new Promise(n=>{let r=e=>{this.stopPolling(),this.pendingPromise=null,this.latestResult=e??null,n(e??null)};this.startPolling({onFetch:async()=>{let n=await this.fetchOptimusData({pageType:e,traceId:t});return n?(r(n),!0):!1},onMaxAttemptsReached:()=>{r(null)}})}),this.pendingPromise)}},_={ANALYTICS:`_con_analytics`,PERSONAL:`_con_personal`,MARKETING:`_con_marketing`,GDPR_ATT:`gdpr_att`},v={ADVERTISEMENT:_.MARKETING,PERFORMANCE:_.ANALYTICS,PERSONALIZATION:_.PERSONAL},y=365,b=class e{static updateConsentCookiesFromCategories(e){if(e)for(let[t,n]of Object.entries(v))i.set(n,e[t]===1?`1`:`0`,{path:`/`,expires:y})}static hasAny3rdPartyConsent(e){return e?e.ADVERTISEMENT!==0||e.PERFORMANCE!==0||e.PERSONALIZATION!==0:!1}static has3rdPartyConsent(){if(typeof window.hc_consent?.getCategoriesConsents==`function`){let t=window.hc_consent.getCategoriesConsents();return e.hasAny3rdPartyConsent(t)}return e.hasAnyConsentCategoryOptin()}static hasAnyConsentCategoryOptin(){return[i.get(_.ANALYTICS),i.get(_.PERSONAL),i.get(_.MARKETING)].some(e=>e===`1`)}static resetConsentCookies(){i.remove(_.ANALYTICS),i.remove(_.PERSONAL),i.remove(_.MARKETING)}static getGdprAttCookie(){return i.get(_.GDPR_ATT)}},x=class{static isApp(e){return RegExp(`^bonprix( mobile)? App `,`i`).test(e)}static isAndroidApp(e){return e.toLowerCase().includes(`android`)&&this.isApp(e)}static isIOsApp(e){return(e.toLowerCase().includes(`ipad`)||e.toLowerCase().includes(`iphone`)||e.toLowerCase().includes(`ios`))&&this.isApp(e)}static getAppVersion(e){if(!this.isApp(e))return null;let t=e.match(/^bonprix( mobile)? App ([\d.]+) /i);return t?t[2]:null}static compareVersions(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0}static appVersionSupportsCookieBanner(e,t){if(!t||!this.isApp(e))return!1;let n=this.getAppVersion(e);return n?this.compareVersions(n,t)>=0:!1}},S={ALLOWED:`ALLOWED`,DECLINED:`DECLINED`},C=`1.38`,w=class{static isIOsApp(e=window.navigator.userAgent){return x.isIOsApp(e)}static getAppPermissionStatus(e=window.navigator.userAgent){let t=b.getGdprAttCookie();return t===void 0?x.appVersionSupportsCookieBanner(e,C)?S.ALLOWED:S.DECLINED:t===`1`?S.ALLOWED:S.DECLINED}static isAttPermissionAllowed(e=window.navigator.userAgent){return this.getAppPermissionStatus(e)===S.ALLOWED}static checkAttPermissionAndResetIfNeeded(e=window.navigator.userAgent){if(this.isIOsApp(e)){let t=this.isAttPermissionAllowed(e);return t||b.resetConsentCookies(),t}return!0}},T=class{static pushTrackingEvent(e=null){let t=e??window.owaParams;t&&(window.hc_tm=window.hc_tm??[],window.hc_tm.push({e:`track`,p:t}))}static sendAddToCartEvent({eventId:e,price:t,owaParams:n}){let r=n??window.owaParams;if(!r)return!1;let i={...r,page_type:`add_to_cart`,product_quantity:1,eventId:e,product_price:t};return this.pushTrackingEvent(i),!0}static sendAddToWishlistEvent({eventId:e,owaParams:t}){let n=t??window.owaParams;if(!n)return!1;let r={...n,page_type:`add_to_wishlist`,product_quantity:1,eventId:e};return this.pushTrackingEvent(r),!0}static subscribeToEvents(e,t){let n=[e.subscribe(t.CART.ITEM_ADD_SUCCESS,({eventId:e,price:t})=>{this.sendAddToCartEvent({eventId:e,price:t})}),e.subscribe(t.WISHLIST.ITEM_ADDED,({eventId:e})=>{this.sendAddToWishlistEvent({eventId:e})})];return()=>
1{n.forEach(t=>e.unsubscribe(t))}}},E=`hurra-init`,D=class e{static loadScript({hurraInstanceId:t,hurraScriptUrl:n,attOptInStatus:i,onLoad:a,onError:o}){if(!t)return r.warn(`Cannot load Hurra script: missing hurraInstanceId`),!1;if(document.getElementById(E))return r.debug(`Hurra script already loaded`),!1;let s=document.createElement(`script`);s.id=E,s.async=!0,s.type=`text/javascript`;let c=e.resolveBaseUrl(n),l=new window.URL(c);return l.pathname=`${l.pathname.replace(/\/+$/,``)}/oti.js`,l.searchParams.set(`cid`,t),l.searchParams.set(`skip_track`,`1`),b.getGdprAttCookie()===void 0&&i===!1&&(l.searchParams.set(`nt`,`1`),l.searchParams.set(`gdpr_att`,`0`)),s.src=l.toString(),s.onload=()=>a?.(),s.onerror=e=>o?.(e),document.body.appendChild(s),!0}static resolveBaseUrl(e){let t=(e||o.toAbsolute(`hc_scripts`)).trim();return new window.URL(t,window.location.origin).toString().replace(/\/+$/,``)}static loadWithRetry({hurraInstanceId:t,hurraScriptUrl:n,attOptInStatus:i,maxAttempts:a=3,retryDelayMs:o=1e3}){let s=0;return new Promise(c=>{let l=()=>{s+=1,e.loadScript({hurraInstanceId:t,hurraScriptUrl:n,attOptInStatus:i,onLoad:()=>c(!0),onError:e=>{r.error(`Failed to load Hurra script (attempt ${s}/${a})`,e);let t=document.getElementById(E);t&&t.remove(),s<a?(r.info(`Retrying Hurra script load in 1 second...`),setTimeout(l,o)):(r.warn(`Max retry attempts reached for Hurra script. Continuing with fallback parameters only.`),c(!1))}})||c(!0)};l()})}},O=class{static updateWindowOwaParams(e=null,t=null){let n=e?{...e}:{page_type:window.tracking?.owaPageType??void 0,uid:window.tracking?.uid??void 0,device_type:window.tracking?.deviceType??`d`,eventId:window.tracking?.pageViewId};window.owaParams=n,t&&(window.owaParams.eventId=t)}
1static getWindowOwaParams(){return window.owaParams??null}},k=function(e){return e[e.DECLINED=0]=`DECLINED`,e[e.ACCEPTED=1]=`ACCEPTED`,e[e.MIXED=2]=`MIXED`,e}({}),A=`FP_NITRO`,j=`ADVERTISEMENT`,M=`m1510`;function N(e){e?.detail?.vendors?.[j]?.[M]!==k.ACCEPTED&&(document.cookie=`${A}=; Max-Age=0; path=/`)}function P({pageType:e,hurraScriptUrl:i,traceId:a}){let[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)(!1),f=(0,d.useRef)(new g),p=(0,d.useRef)(!1),m=(0,d.useCallback)(()=>{O.updateWindowOwaParams(null,a);let e=window.tracking?.hurraInstanceId??``;return s(e),e},[a]),h=(0,d.useCallback)(e=>{if(!e||p.current)return;p.current=!0;let t=w.checkAttPermissionAndResetIfNeeded();D.loadWithRetry({hurraInstanceId:e,hurraScriptUrl:i,attOptInStatus:t,maxAttempts:3,retryDelayMs:1e3}).then(e=>{l(!0),e||r.warn(`Hurra script unavailable after retries. Continuing with fallback parameters only.`)})},[i]),_=(0,d.useCallback)(()=>{try{if(window.hc_tm===void 0){r.warn(`Hurra tracking system not available. Event push skipped.`);return}T.pushTrackingEvent(window.owaParams)}catch(e){r.error(`Failed to push tracking event to Hurra`,e)}},[]),v=(0,d.useCallback)(async()=>{let t=await f.current.getLatestResultOrPromise({pageType:e,traceId:a});return t&&(O.updateWindowOwaParams(t.parameters,a),s(t.hurraInstanceId)),t??null},[e,a]),y=(0,d.useCallback)(async e=>{let t=e.detail?.categories;t&&(b.updateConsentCookiesFromCategories(t),N(e),b.hasAny3rdPartyConsent(t)&&(await v(),_()))},[_,v,a]);return(0,d.useEffect)(()=>{let e=m();h(e)},[m,h]),(0,d.useEffect)(()=>{c&&!u.current&&(async()=>{(f.current.hasPendingRequest()||b.has3rdPartyConsent())&&await v(),u.current||=(_(),!0)})()},[c,a,_,v]),(0,d.useEffect)(()=>(document.addEventListener(`consent::change`,y),()=>{document.removeEventListener(`consent::change`,y)}),[y]),(0,d.useEffect)(()=>{let e=T.subscribeToEvents(t,n);return()=>{e()}},[]),(0,d.useEffect)(()=>()=>{f.current.stopPolling()},[]),null}var F=u(),{moduleScope:I,config:L}=s(`consent/marketing-parameters`);(0,f.createRoot)(I).render((0,F.jsx)(P,{pageType:L.pageType,hurraScriptUrl:L.hurraScriptUrl,traceId:L.hurraTraceId}));
2//# sourceMappingURL=marketing-parameters-CXp5wvUq.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.