PageSourceSearch

https://www.kosmos.de/cdn/shop/t/7/assets/custom.js?v=171591269748554765661790854206

js kosmos.de collected 2026-10-02 02:32:40 UTC 43,959 bytes, 2 lines download raw bytes

1class BBNotificationManager{constructor(){this.container=null}getContainer(){return this.container||(this.container=document.createElement("div"),this.container.className="bb-notification-container",this.container.setAttribute("role","region"),this.container.setAttribute("aria-label","Notifications"),document.body.insertBefore(this.container,document.body.firstChild)),this.container}show(options={}){const{text="",linkText="",link="",duration=5e3,showCloseButton=!0}=options,notification=document.createElement("div");notification.className="bb-notification",notification.setAttribute("role","alert"),notification.setAttribute("aria-live","polite");let html="";text&&(html+=`<p class="bb-notification__text">${text}</p>`),(linkText&&link||showCloseButton)&&(html+='<div class="bb-notification__actions">',linkText&&link&&(html+=`<a href="${link}" class="bb-notification__link">${linkText}</a>`),showCloseButton&&(html+='<button type="button" class="bb-notification__close" aria-label="Close notification"><svg width="24" height="24" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.319 3.94506C22.095 3.95035 21.8823 4.04402 21.7272 4.20561L13.5651 12.3677L5.40302 4.20561C5.32398 4.12422 5.22942 4.05952 5.12493 4.01533C5.02044 3.97115 4.90815 3.94838 4.7947 3.94837C4.62595 3.94841 4.46106 3.9988 4.32111 4.09308C4.18117 4.18736 4.07253 4.32125 4.00911 4.47762C3.94568 4.63399 3.93035 4.80573 3.96508 4.97086C3.9998 5.13599 4.08301 5.28701 4.20404 5.40459L12.3661 13.5667L4.20404 21.7288C4.12267 21.8069 4.0577 21.9005 4.01295 22.004C3.96819 22.1076 3.94455 22.219 3.9434 22.3318C3.94226 22.4446 3.96363 22.5565 4.00627 22.661C4.04891 22.7654 4.11196 22.8603 4.19173 22.9401C4.27149 23.0198 4.36638 23.0829 4.47082 23.1255C4.57526 23.1682 4.68716 23.1895 4.79996 23.1884C4.91276 23.1872 5.0242 23.1636 5.12776 23.1188C5.23131 23.0741 5.32489 23.0091 5.40302 22.9277L13.5651 14.7657L21.7272 22.9277C21.8053 23.0091 21.8989 23.0741 22.0025 23.1188C22.106 23.1636 22.2175 23.1872 22.3303 23.1884C22.4431 23.1895 22.555 23.1682 22.6594 23.1255C22.7638 23.0829 22.8587 23.0198 22.9385 22.9401C23.0183 22.8603 23.0813 22.7654 23.1239 22.661C23.1666 22.5565 23.188 22.4446 23.1868 22.3318C23.1857 22.219 23.162 22.1076 23.1173 22.004C23.0725 21.9005 23.0075 21.8069 22.9262 21.7288L14.7641 13.5667L22.9262 5.40459C23.0495 5.28624 23.1341 5.13341 23.1691 4.96611C23.204 4.79882 23.1876 4.62487 23.1219 4.46708C23.0563 4.30929 22.9445 4.17501 22.8012 4.08186C22.6579 3.98871 22.4898 3.94102 22.319 3.94506Z" fill="white"/></svg></button>'),html+="</div>"),notification.innerHTML=html;let progressBar=null;duration>0&&(progressBar=document.createElement("div"),progressBar.className="bb-notification__progress",notification.appendChild(progressBar)),this.getContainer().appendChild(notification),requestAnimationFrame(()=>{requestAnimationFrame(()=>{notification.classList.add("bb-notification--visible"),progressBar&&duration>0&&(progressBar.style.transitionDuration=`${duration}ms`,progressBar.style.transform="scaleX(0)")})});let timeout=null;function close(){timeout&&clearTimeout(timeout),notification.classList.remove("bb-notification--visible"),setTimeout(()=>notification.remove(),200)}return showCloseButton&&notification.querySelector(".bb-notification__close")?.addEventListener("click",close),duration>0&&(timeout=setTimeout(close,duration)),{close}}}class CdpSessionManager{static SESSION_KEY="cdp::session_id";static POLL_INTERVAL=200;static POLL_TIMEOUT=5e3;constructor(){this.cachedPromise=null}getFromCookie(){const match=document.cookie.match(/(^|; )_shopify_y=([^;]*)/);return match?decodeURIComponent(match[2]):null}get(){return this.cachedPromise?this.cachedPromise:(this.cachedPromise=new Promise(resolve=>{const immediate=localStorage.getItem(CdpSessionManager.SESSION_KEY);if(immediate){resolve(immediate);return}let elapsed=0;const poll=setInterval(()=>{const value=localStorage.getItem(CdpSessionManager.SESSION_KEY);if(value){clearInterval(poll),resolve(value);return}if(elapsed+=CdpSessionManager.POLL_INTERVAL,elapsed>=CdpSessionManager.POLL_TIMEOUT){clearInterval(poll);const cookieId=this.getFromCookie();cookieId||console.error("CdpSession: sessionId not resolved"),resolve(cookieId)}},CdpSessionManager.POLL_INTERVAL)}
1),this.cachedPromise)}reset(){this.cachedPromise=null}}const CdpSession=new CdpSessionManager;class BBWishlistManager{static ATTRIBUTE_KEY="_bb_wishlist";static DEBOUNCE_MS=300;static WISHLIST_ENDPOINT="/a/kosmos/wishlist";static CDP_METAFIELD_KEY="cdp--wishlist";constructor(){this.entries=[],this.initialized=!1,this.initPromise=null,this.readyPromise=null,this.cdpLoaded=!1,this.sessionMissing=!1,this.debounceTimer=null}static parseRaw(raw){return raw?raw.split(",").filter(Boolean).map(entry=>{const sep=entry.indexOf(":");return sep===-1?{handle:entry,productId:null}:{handle:entry.slice(0,sep),productId:entry.slice(sep+1)||null}}):[]}static serialize(entries){return entries.map(e=>e.productId?`${e.handle}:${e.productId}`:e.handle).join(",")}static VALID_FORMAT=/^([a-z0-9]([a-z0-9-]*[a-z0-9])?:\d+)(,[a-z0-9]([a-z0-9-]*[a-z0-9])?:\d+)*$/;static isValidFormat(raw){return!raw||BBWishlistManager.VALID_FORMAT.test(raw)}handles(){return this.entries.map(e=>e.handle)}fetchFromCdp(){return CdpSession.get().then(sessionId=>{if(this.sessionMissing=!sessionId,!sessionId)return null;const params=new URLSearchParams({product_fragment:"handle,id",sid:sessionId});return fetch(`${BBWishlistManager.WISHLIST_ENDPOINT}?${params}`).then(r=>r.ok?r.json():null).then(data=>!data||!Array.isArray(data.value)?null:data.value.map(item=>{const handle=item.shopifyProduct?.handle||null,rawId=item.shopifyProduct?.id??null,productId=rawId!=null?String(rawId).replace(/\D/g,""):null;return{handle,productId}}).filter(e=>e.handle&&e.productId))}).catch(()=>null)}init(){return this.initPromise?this.initPromise:(this.initPromise=Promise.all([fetch(`${Shopify.routes.root}cart.js`).then(r=>r.json()),this.fetchFromCdp()]).then(([cart,cdpEntries])=>{const raw=cart.attributes?.[BBWishlistManager.ATTRIBUTE_KEY]||"",formatValid=BBWishlistManager.isValidFormat(raw),cartEntries=formatValid?BBWishlistManager.parseRaw(raw).filter(e=>e.productId):[];return this.initialized=!0,this.cdpLoaded=cdpEntries!==null,cdpEntries!==null?(this.entries=cdpEntries,BBWishlistManager.serialize(cartEntries)!==BBWishlistManager.serialize(cdpEntries)&&this.writeCart(cdpEntries)):formatValid?this.entries=cartEntries:(this.entries=[],this.writeCart([])),this.dispatch(),this.handles()}).catch(()=>(this.entries=[],this.initialized=!0,this.cdpLoaded=!1,this.handles())),this.initPromise)}ready(){return this.readyPromise?this.readyPromise:(this.readyPromise=this.init().then(()=>{if(this.sessionMissing)return CdpSession.reset(),this.initPromise=null,this.init()}),this.readyPromise)}writeCart(entries){const value=BBWishlistManager.serialize(entries);return fetch(`${Shopify.routes.root}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{[BBWishlistManager.ATTRIBUTE_KEY]:value}})}).catch(()=>{})}save(){this.writeCart(this.entries),this.cdpLoaded&&this.syncToCdp()}syncToCdp(){CdpSession.get().then(sessionId=>{if(!sessionId)return;const value=this.entries.filter(e=>e.productId).map(e=>({shopify_product_id:e.productId})),params=new URLSearchParams({sid:sessionId});fetch(`${BBWishlistManager.WISHLIST_ENDPOINT}?${params}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value})}).catch(()=>{})}).catch(()=>{})}dispatch(){document.dispatchEvent(new CustomEvent("wishlist:change",{detail:{handles:this.handles()}}))}debouncedSave(){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this.save(),BBWishlistManager.DEBOUNCE_MS)}get(){return[...this.entries]}has(handle){return this.entries.some(e=>e.handle===handle)}async add(handle,productId){await this.ready(),!(!handle||this.has(handle))&&(this.entries.push({handle,productId:productId||null}),this.dispatch(),this.debouncedSave())}async remove(handle){await this.ready();const idx=this.entries.findIndex(e=>e.handle===handle);idx!==-1&&(this.entries.splice(idx,1),this.dispatch(),this.debouncedSave())}async toggle(handle,productId){return await this.ready(),this.has(handle)?(await this.remove(handle),!1):(await this.add(handle,productId),!0)}async set(newEntries){await this.ready(),this.entries=[...newEntries],this.dispatch(),this.debouncedSave()}}const BBNotification=new BBNotificationManager,BBWishlist=new BBWishlistManager;class BBWishlistConsentManager{static DRAWER_ID="wishlist-consent-drawer";static UC_SERVICES=["Shopify Analytics","Shopify Marketing"];constructor(){this.ready=new Promise(resolve=>{window.Shopify?.customerPrivacy?.setTrackingConsent?resolve():window.Shopify.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],()=>resolve())})}hasConsented(){const cp=window.Shopify?.customerPrivacy;return cp?cp.analyticsProcessingAllowed()&&cp.marketingAllowed():!1}grantConsent(){const cp=window.Shopify?.customerPrivacy;cp?.setTrackingConsent&&cp.setTrackingConsent({analytics:!0,marketing:!0},()=>{}),this.grantUsercentricsConsent()}async grantUsercentricsConsent(){try{const uc=await BBWishlistConsentManager.usercentricsReady(),{services}=await uc.getConsentDetails(),updates=Object.entries(services).filter(([,service])=>BBWishlistConsentManager.UC_SERVICES.includes(service.name)).map(([id])=>({id,consent:!0}));if(!updates.length)return;await uc.updateServicesConsents(updates),await uc.saveConsents()}catch{}}static async usercentricsReady(){const uc=window.__ucCmp;return(!uc||!await uc.isInitialized())&&await new Promise(resolve=>window.addEventListener("UC_UI_INITIALIZED",resolve,{once:!0})),await new Promise(resolve=>setTimeout(resolve)),window.__ucCmp}requestConsent(){return new Promise(resolve=>{const drawer=document.getElementById(BBWishlistConsentManager.DRAWER_ID);if(!drawer){resolve(!1);return}const ac=new AbortController;drawer.querySelectorAll("[data-wishlist-consent]").forEach(btn=>{btn.addEventListener("click",e=>{const accepted=e.currentTarget.dataset.wishlistConsent==="accept";drawer.hide(),ac.abort(),accepted&&this.grantConsent(),resolve(accepted)},{signal:ac.signal})}),drawer.show()})}async gate(){return await this.ready,this.hasConsented()?!0:this.requestConsent()}}const BBWishlistConsent=new BBWishlistConsentManager;class BBWishlistButton extends HTMLElement{constructor(){super(),this._onClick=this._onClick.bind(this),this._onWishlistChange=this._onWishlistChange.bind(this)}
1connectedCallback(){BBWishlist.init(),this.addEventListener("click",this._onClick),document.addEventListener("wishlist:change",this._onWishlistChange)}disconnectedCallback(){this.removeEventListener("click",this._onClick),document.removeEventListener("wishlist:change",this._onWishlistChange)}_onClick(e){e.preventDefault(),e.stopPropagation();const handle=this.getAttribute("handle");handle&&BBWishlistConsent.gate().then(async allowed=>{if(!allowed)return;const productId=this.getAttribute("product-id")||null;if(await BBWishlist.toggle(handle,productId)){const text=this.getAttribute("notification-text");text&&document.dispatchEvent(new CustomEvent("wishlist:added",{detail:{text}}))}})}_onWishlistChange(e){this.dataset.active=e.detail.handles.includes(this.getAttribute("handle")).toString()}}customElements.get("bb-wishlist-button")||customElements.define("bb-wishlist-button",BBWishlistButton);class CollectionTabsPanel extends HTMLElement{connectedCallback(){this._resizeObserver=new ResizeObserver(()=>{if(!this.hidden){const scrollCarousel=this.querySelector("scroll-carousel");if(scrollCarousel){const isScrollable=scrollCarousel.scrollWidth>scrollCarousel.clientWidth;scrollCarousel.classList.toggle("is-scrollable",isScrollable)}}}),this._resizeObserver.observe(this)}disconnectedCallback(){this._resizeObserver?.disconnect()}}customElements.get("collection-tabs-panel")||customElements.define("collection-tabs-panel",CollectionTabsPanel);class CollectionWorlds extends HTMLElement{connectedCallback(){this._carousels=this.querySelectorAll("scroll-carousel[color-worlds]"),this._handleChange=this._handleChange.bind(this),this._handleTabClick=this._handleTabClick.bind(this),this._carousels.forEach(carousel=>{carousel.addEventListener("carousel:change",this._handleChange),carousel.addEventListener("carousel:settle",this._handleChange)}),this.addEventListener("click",this._handleTabClick),requestAnimationFrame(()=>{const firstCarousel=this._carousels[0];firstCarousel&&this._applyColors(firstCarousel,0)})}disconnectedCallback(){this._carousels?.forEach(carousel=>{carousel.removeEventListener("carousel:change",this._handleChange),carousel.removeEventListener("carousel:settle",this._handleChange)}),this.removeEventListener("click",this._handleTabClick)}_handleTabClick(e){if(!e.target.closest('[role="tab"]'))return;const panelId=e.target.closest('[role="tab"]').getAttribute("controlled-panel"),carousel=document.getElementById(panelId)?.querySelector("scroll-carousel[color-worlds]");if(carousel&&carousel.offsetParent!==null)this._applyColors(carousel,0);else if(carousel){const observer=new IntersectionObserver(entries=>{entries[0].isIntersecting&&(this._applyColors(carousel,0),observer.disconnect())});observer.observe(carousel)}}_handleChange(e){this._applyColors(e.currentTarget,e.detail?.index??0)}_applyColors(carousel,index){const item=carousel.querySelectorAll(".collection-card")[index];item&&(this.style.setProperty("--world-text-color",item.dataset.worldTextColor||""),this.style.setProperty("--world-title-color",item.dataset.worldTitleColor||""),this.style.setProperty("--world-section-bg",item.dataset.worldSectionBg||""),this.style.setProperty("--world-section-bg-gradient",item.dataset.worldSectionBgGradient||""),this.style.setProperty("--world-tab-bg-active",item.dataset.worldTabBgActive||""),this.style.setProperty("--world-tab-text-active",item.dataset.worldTabTextActive||""),this.style.setProperty("--world-tab-bg-inactive",item.dataset.worldTabBgInactive||""),this.style.setProperty("--world-tab-text-inactive",item.dataset.worldTabTextInactive||""),this.style.setProperty("--world-tab-border-active",item.dataset.worldTabBorderActive||""),this.style.setProperty("--world-tab-border-inactive",item.dataset.worldTabBorderInactive||""))}}customElements.get("collection-worlds")||customElements.define("collection-worlds",CollectionWorlds);class BBMobileSearchCollapse{constructor(header){this.header=header,this.mode=header.dataset.mobileSearchCollapse||"scroll",this.toggleButton=header.querySelector(".bb-mobile-search-toggle"),this.searchInput=header.querySelector('bb-inline-search input[name="q"]'),this.scrollPaused=!1,this.resumeTimer=null,window.addEventListener("scroll",()=>this.handleScroll(),{passive:!0}),this.toggleButton?.addEventListener("click",()=>this.handleToggleClick()),this.searchInput?.addEventListener("keydown",event=>this.handleKeydown(event)),this.mode!=="manual"&&this.handleScroll()}handleScroll(){this.scrollPaused||(window.scrollY>105?this.header.classList.add("header--search-hidden"):window.scrollY<5&&this.mode==="scroll"&&this.header.classList.remove("header--search-hidden"))}handleToggleClick(){this.header.classList.remove("header--search-hidden"),this.searchInput?.focus({preventScroll:!0}),this.scrollPaused=!0,clearTimeout(this.resumeTimer),this.resumeTimer=setTimeout(()=>{this.scrollPaused=!1},400)}handleKeydown(event){event.key==="Escape"&&(this.searchInput.blur(),(window.scrollY>105||this.mode==="manual")&&this.header.classList.add("header--search-hidden"))}}document.addEventListener("DOMContentLoaded",()=>{const header=document.querySelector("store-header[data-mobile-search-collapse]");header&&new BBMobileSearchCollapse(header)});class BBInlineSearch extends HTMLElement{constructor(){super(),this.isMenuOpen=!1,this.searchInput=null,this.megaMenu=null,this.searchSubmit=null,this.form=null,this.predictiveSearch=null,this.mutationObserver=null,this.handleInputChange=this.handleInputChange.bind(this),this.handleInputFocus=this.handleInputFocus.bind(this),this.handleMegaMenuClick=this.handleMegaMenuClick.bind(this),this.handleSearchSubmit=this.handleSearchSubmit.bind(this),this.handleClickOutside=this.handleClickOutside.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleHeaderTransparency=this.handleHeaderTransparency.bind(this)}connectedCallback(){this.findElements(),!(!this.searchInput||!this.megaMenu)&&this.setupEventListeners()}disconnectedCallback(){this.removeEventListeners(),this.cleanupObserver()}findElements(){this.searchInput=this.querySelector('input[name="q"]'),this.megaMenu=this.querySelector("#bb-inline-search-mega-menu"),this.searchSubmit=this.querySelector("[data-search-submit]"),this.inputCloseButton=this.querySelector("[data-inline-search-input-close]"),this.form=this.querySelector("form"),this.predictiveSearch=this.querySelector("predictive-search")}setupEventListeners(){this.searchInput.addEventListener("input",this.handleInputChange),this.searchInput.addEventListener("focus",this.handleInputFocus),this.searchInput.addEventListener("keydown",this.handleKeydown),this.megaMenu.addEventListener("click",this.handleMegaMenuClick),this.searchSubmit&&this.searchSubmit.addEventListener("click",this.handleSearchSubmit),this.inputCloseButton&&this.inputCloseButton.addEventListener("click",e=>{e.preventDefault(),this.searchInput.value="",this.closeMegaMenu()}),this.setupPredictiveSearchObserver()}setupPredictiveSearchObserver(){this.predictiveSearch&&(this.mutationObserver=new MutationObserver(()=>{this.handlePredictiveSearchChange()}),this.mutationObserver.observe(this.predictiveSearch,{childList:!0,subtree:!0}))}cleanupObserver(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}removeEventListeners(){this.searchInput&&(this.searchInput.removeEventListener("input",this.handleInputChange),this.searchInput.removeEventListener("focus",this.handleInputFocus),this.searchInput.removeEventListener("keydown",this.handleKeydown)),this.megaMenu&&this.megaMenu.removeEventListener("click",this.handleMegaMenuClick),this.searchSubmit&&this.searchSubmit.removeEventListener("click",this.handleSearchSubmit),document.removeEventListener("click",this.handleClickOutside)}handleInputChange(){const inputValue=this.searchInput.value.trim();this.hasAttribute("data-enable-idle-state")?(inputValue.length>0||this.isMenuOpen)&&this.openMegaMenu():this.toggleMegaMenu(inputValue.length>0)}handleInputFocus(){const inputValue=this.searchInput.value.trim();(this.hasAttribute("data-enable-idle-state")||inputValue.length>0)&&this.openMegaMenu()}handleMegaMenuClick(event){event.stopPropagation()}handleSearchSubmit(event){event.preventDefault();const searchValue=this.searchInput.value.trim();this.form&&searchValue!==""&&this.form.submit()}handlePredictiveSearchChange(){this.searchInput.value.trim().length>0&&this.predictiveSearch&&this.predictiveSearch.querySelector('[slot="results"]')&&this.openMegaMenu()}handleClickOutside(event){this.contains(event.target)||this.closeMegaMenu()}
1handleKeydown(event){event.key==="Escape"&&this.isMenuOpen&&(this.closeMegaMenu(),this.searchInput.blur())}toggleMegaMenu(shouldOpen){shouldOpen?this.openMegaMenu():this.closeMegaMenu()}openMegaMenu(){this.isMenuOpen||(this.isMenuOpen=!0,this.megaMenu.classList.add("is-open"),this.megaMenu.setAttribute("open",""),this.inputCloseButton&&(this.inputCloseButton.hidden=!1),document.addEventListener("click",this.handleClickOutside),this.triggerPredictiveSearch(),this.handleHeaderTransparency())}closeMegaMenu(){this.isMenuOpen&&(this.isMenuOpen=!1,this.megaMenu.classList.remove("is-open"),this.megaMenu.removeAttribute("open"),this.inputCloseButton&&(this.inputCloseButton.hidden=!0),document.removeEventListener("click",this.handleClickOutside),this.handleHeaderTransparency())}triggerPredictiveSearch(){if(this.predictiveSearch&&this.searchInput){const event=new Event("input",{bubbles:!0});this.searchInput.dispatchEvent(event)}}handleHeaderTransparency(){const header=document.querySelector("store-header");header&&typeof header._checkTransparency=="function"&&header._checkTransparency()}}customElements.define("bb-inline-search",BBInlineSearch);class BBWishlistLink extends HTMLElement{constructor(){super(),this._onWishlistAdded=this._onWishlistAdded.bind(this),this._onWishlistChange=this._onWishlistChange.bind(this),this._onLinkClick=this._onLinkClick.bind(this),this._animating=!1}connectedCallback(){this._overlay=this.querySelector(".bb-wishlist-link-overlay"),this._overlayText=this.querySelector(".bb-wishlist-link-overlay__text-inner"),this._countBubble=this.querySelector("[data-wishlist-count]"),this._countText=this._countBubble?.querySelector('[aria-hidden="true"]'),document.addEventListener("wishlist:added",this._onWishlistAdded),document.addEventListener("wishlist:change",this._onWishlistChange),this.addEventListener("click",this._onLinkClick)}disconnectedCallback(){document.removeEventListener("wishlist:added",this._onWishlistAdded),document.removeEventListener("wishlist:change",this._onWishlistChange),this.removeEventListener("click",this._onLinkClick)}_onLinkClick(e){!BBWishlistConsent.isEnabled()||BBWishlistConsent.hasConsented()||(e.preventDefault(),e.stopPropagation(),BBWishlistConsent.gate().then(allowed=>{if(!allowed)return;const link=this.querySelector("a[href]");link&&(window.location.href=link.href)}))}_onWishlistChange(e){const count=e.detail?.handles?.length||0;this._countText&&(this._countText.textContent=count),!this._animating&&this._countBubble&&this._countBubble.classList.toggle("opacity-0",count===0)}_onWishlistAdded(e){if(this._animating||!this._overlay)return;this._animating=!0;const text=e.detail?.text||"";this._overlayText&&(this._overlayText.textContent=text),this._countBubble&&this._countBubble.classList.add("opacity-0");const overlay=this._overlay;overlay.classList.remove("is-animating"),overlay.offsetWidth,overlay.classList.add("is-animating"),overlay.addEventListener("animationend",()=>{overlay.classList.remove("is-animating"),this._animating=!1,this._countBubble&&+(this._countText?.textContent||0)>0&&this._countBubble.classList.remove("opacity-0")},{once:!0})}}customElements.get("bb-wishlist-link")||customElements.define("bb-wishlist-link",BBWishlistLink);class BBExpandable extends HTMLElement{connectedCallback(){this._toggleBtn=this.querySelector("[data-expandable-toggle]"),this._expandBtn=this.querySelector("[data-expandable-button]"),this._collapseBtn=this.querySelector("[data-collapsable-button]"),this._items=this.querySelectorAll("[data-expandable-item]"),!(!this._toggleBtn&&!this._expandBtn&&!this._collapseBtn||!this._items.length)&&(this._toggle=this._toggle.bind(this),this._syncAria=this._syncAria.bind(this),this._syncAria(),this._toggleBtn?.addEventListener("click",this._toggle),this._expandBtn?.addEventListener("click",this._toggle),this._collapseBtn?.addEventListener("click",this._toggle))}disconnectedCallback(){this._toggleBtn?.removeEventListener("click",this._toggle),this._expandBtn?.removeEventListener("click",this._toggle),this._collapseBtn?.removeEventListener("click",this._toggle)}
1_toggle(){this.dataset.expanded=this.dataset.expanded==="true"?"false":"true",this._syncAria()}_syncAria(){this._toggleBtn&&this._toggleBtn.setAttribute("aria-expanded",this.dataset.expanded==="true"?"true":"false")}}customElements.get("bb-expandable")||customElements.define("bb-expandable",BBExpandable);const updateMobileNextButton=gallery=>{const carousel=gallery.querySelector("media-carousel"),nextBtn=gallery.querySelector(".product-gallery__next");if(!carousel||!nextBtn)return;const isAtEnd=carousel.selectedIndexAmongVisible>=carousel.visibleItems.length-1;nextBtn.toggleAttribute("hidden",isAtEnd)};document.addEventListener("carousel:change",e=>{const gallery=e.target.closest("product-gallery");gallery&&updateMobileNextButton(gallery)}),document.addEventListener("carousel:settle",e=>{const gallery=e.target.closest("product-gallery");gallery&&updateMobileNextButton(gallery)});class BBWishlistShareButton extends HTMLElement{constructor(){super(),this._onClick=this._onClick.bind(this)}connectedCallback(){this.addEventListener("click",this._onClick)}disconnectedCallback(){this.removeEventListener("click",this._onClick)}
1_onClick(e){e.preventDefault(),BBWishlist.init().then(handles=>{if(!handles.length)return;const entries=BBWishlist.get(),url=new URL(window.location.href);url.search="",url.hash="",url.searchParams.set("wishlist",BBWishlistManager.serialize(entries));const shareUrl=url.toString();navigator.share?navigator.share({url:shareUrl}).catch(()=>{this._copyFallback(shareUrl)}):this._copyFallback(shareUrl)})}_copyFallback(url){navigator.clipboard.writeText(url).catch(()=>{})}}customElements.get("bb-wishlist-share-button")||customElements.define("bb-wishlist-share-button",BBWishlistShareButton),(function(){const wl=new URLSearchParams(window.location.search).get("wishlist");if(!wl)return;const entries=BBWishlistManager.parseRaw(wl);if(!entries.length)return;const value=BBWishlistManager.serialize(entries);fetch(`${Shopify.routes.root}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{_bb_wishlist:value}})}).then(()=>{BBWishlist.entries=entries,BBWishlist.initialized=!0,BBWishlist.syncToCdp();const url=new URL(window.location.href);url.searchParams.delete("wishlist"),window.location.replace(url.toString())}).catch(()=>{const url=new URL(window.location.href);url.searchParams.delete("wishlist"),window.location.replace(url.toString())})})(),(function(){if(typeof WebHaptics>"u")return;const haptics=new WebHaptics;document.addEventListener("submit",e=>{(e.target.matches('[is="product-form"]')||e.target.action?.includes("/cart/add"))&&haptics.trigger("success")},!0),document.addEventListener("wishlist:added",()=>{haptics.trigger([{duration:40}])})})();class BBVideoEndImage extends HTMLElement{connectedCallback(){this.slide=this.closest(".slideshow__slide"),this.slide&&(this.handleEnded=this.handleEnded.bind(this),this.slide.querySelectorAll("video-media video").forEach(video=>{video.addEventListener("ended",this.handleEnded)}))}disconnectedCallback(){this.slide?.querySelectorAll("video-media video").forEach(video=>{video.removeEventListener("ended",this.handleEnded)})}handleEnded(){this.slide?.classList.add("slideshow__slide--video-ended")}}customElements.get("bb-video-end-image")||customElements.define("bb-video-end-image",BBVideoEndImage);class BBErsatzteilSearch extends HTMLElement{constructor(){super(),this._onInput=this._onInput.bind(this),this._onClear=this._onClear.bind(this),this._onScanClick=this._onScanClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._scanLoop=this._scanLoop.bind(this),this._runSearch=this._runSearch.bind(this)}connectedCallback(){if(this._input=this.querySelector('input[name="q"]'),this._clearBtn=this.querySelector("[data-ersatzteil-search-clear]"),this._scanBtn=this.querySelector("[data-ersatzteil-search-scan]"),this._resultsRegion=this.querySelector("[data-ersatzteil-search-results]"),this._loadingRegion=this.querySelector("[data-ersatzteil-search-loading]"),this._debounceTimer=null,this._controller=null,!!this._input){if(this._input.addEventListener("input",this._onInput),this._clearBtn&&this._clearBtn.addEventListener("click",this._onClear),this._scanBtn){const scannerId=this.dataset.scannerId;this._modal=scannerId?document.getElementById(scannerId):null,this._modal?(this._modal.parentElement!==document.body&&document.body.appendChild(this._modal),this._video=this._modal.querySelector("[data-ersatzteil-scanner-video]"),this._loader=this._modal.querySelector("[data-ersatzteil-scanner-loader]"),this._errorEl=this._modal.querySelector("[data-ersatzteil-scanner-error]"),this._hintEl=this._modal.querySelector("[data-ersatzteil-scanner-hint]"),this._closeBtn=this._modal.querySelector("[data-ersatzteil-scanner-close]"),this._scanBtn.addEventListener("click",this._onScanClick),this._closeBtn&&this._closeBtn.addEventListener("click",this._onCloseClick)):this._scanBtn.hidden=!0}this._syncControlVisibility()}}disconnectedCallback(){this._input&&this._input.removeEventListener("input",this._onInput),this._clearBtn&&this._clearBtn.removeEventListener("click",this._onClear),this._scanBtn&&this._scanBtn.removeEventListener("click",this._onScanClick),this._closeBtn&&this._closeBtn.removeEventListener("click",this._onCloseClick),this._hideModal(),this._stopScan(),this._abortFetch(),this._debounceTimer&&clearTimeout(this._debounceTimer)}_onInput(){this._syncControlVisibility(),this._scheduleSearch()}_onClear(){this._input.value="",this._input.focus(),this._syncControlVisibility(),this._scheduleSearch()}_scheduleSearch(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(this._runSearch,250)}_abortFetch(){this._controller&&(this._controller.abort(),this._controller=null)}async _runSearch(){if(!this._resultsRegion)return;const term=this._input.value.trim();if(this._abortFetch(),!term){await this._showPanel("idle");return}await this._showPanel("loading"),this._controller=new AbortController;const url=`${Shopify.routes.root}search?view=ersatzteile&type=product&options[unavailable_products]=last&q=${encodeURIComponent(term)}&section_id=ersatzteile-search-results`;try{const res=await fetch(url,{signal:this._controller.signal});if(!res.ok)throw new Error(`HTTP ${res.status}`);const html=await res.text();await this._showPanel("results",html)}
1catch(err){if(err.name==="AbortError")return;await this._showPanel("results","")}finally{this._controller=null}}async _showPanel(panel,html){if(this._activePanel===panel&&panel!=="results")return;const current=this._visibleRegion();if(current)try{await current.animate({opacity:[1,0]},{duration:100,easing:"ease"}).finished}catch{}this._loadingRegion&&(this._loadingRegion.hidden=panel!=="loading"),this._resultsRegion&&(panel==="results"?(this._resultsRegion.innerHTML=html??"",this._resultsRegion.hidden=!1):panel==="idle"?(this._resultsRegion.innerHTML="",this._resultsRegion.hidden=!0):this._resultsRegion.hidden=!0),this._activePanel=panel;const next=this._visibleRegion();if(next)try{await next.animate({opacity:[0,1],transform:["translateY(5px)","translateY(0)"]},{duration:100,easing:"ease"}).finished}catch{}}_visibleRegion(){return this._activePanel==="loading"?this._loadingRegion:this._activePanel==="results"?this._resultsRegion:null}_syncControlVisibility(){const hasValue=this._input.value.trim().length>0;this._clearBtn&&(this._clearBtn.hidden=!hasValue),this._scanBtn&&(this._scanBtn.hidden=hasValue)}_onScanClick(){this._showModal()}_onCloseClick(){this._hideModal()}_onEscapeKey(e){e.key==="Escape"&&this._hideModal()}_showModal(){this._modal&&(this._modal.setAttribute("data-open",""),document.addEventListener("keydown",this._onEscapeKey),document.documentElement.classList.add("lock"),this._startScan())}_hideModal(){this._modal&&(this._modal.removeAttribute("data-open"),document.removeEventListener("keydown",this._onEscapeKey),document.documentElement.classList.remove("lock"),this._stopScan())}async _startScan(){this._setError(""),this._setLoaderVisible(!0);try{this._DetectorCtor=await this._loadDetector()}catch{this._setLoaderVisible(!1),this._setError(this._getText("unsupported"));return}if(!this._DetectorCtor){this._setLoaderVisible(!1),this._setError(this._getText("unsupported"));return}try{this._stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1})}catch{this._setLoaderVisible(!1),this._setError(this._getText("camera_error"));return}if(!this._video)return;this._video.srcObject=this._stream;try{await this._video.play()}catch{}const formats=(this.dataset.barcodeFormats||"").split(",").map(s=>s.trim()).filter(Boolean);try{this._detector=new this._DetectorCtor(formats.length?{formats}:void 0)}catch{this._detector=new this._DetectorCtor}this._setLoaderVisible(!1),this._scanning=!0,this._scanLoop()}_stopScan(){this._scanning=!1,this._scanTimer&&(clearTimeout(this._scanTimer),this._scanTimer=null),this._stream&&(this._stream.getTracks().forEach(t=>t.stop()),this._stream=null),this._video&&(this._video.pause(),this._video.srcObject=null),this._detector=null}async _scanLoop(){if(!(!this._scanning||!this._detector||!this._video)){if(this._video.readyState<2){this._scanTimer=setTimeout(this._scanLoop,120);return}try{const results=await this._detector.detect(this._video);if(results&&results.length>0){const value=(results[0].rawValue||"").trim();if(value){this._handleDetected(value);return}}}catch{}this._scanning&&(this._scanTimer=setTimeout(this._scanLoop,200))}}_handleDetected(value){this._hideModal(),this._input&&(this._input.value=value,this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.focus(),this._syncControlVisibility())}_setError(message){this._errorEl&&(this._errorEl.textContent=message||"",this._errorEl.hidden=!message)}_setLoaderVisible(visible){this._loader&&(this._loader.hidden=!visible)}_getText(key){const tpl=this._modal?.querySelector(`template[data-ersatzteil-scanner-text="${key}"]`);return tpl?tpl.innerHTML.trim():""}async _loadDetector(){if("BarcodeDetector"in window)try{const supported=await window.BarcodeDetector.getSupportedFormats();if(supported&&supported.length>0)return window.BarcodeDetector}catch{}const ns=window.BarcodeDetectionAPI;if(ns?.BarcodeDetector)return this._configurePolyfill(ns),ns.BarcodeDetector;const src=this.dataset.polyfillSrc;if(!src)return null;BBErsatzteilSearch._polyfillPromise||(BBErsatzteilSearch._polyfillPromise=new Promise((resolve,reject)=>{const script=document.createElement("script");script.src=src,script.async=!0,script.onload=()=>resolve(),script.onerror=()=>reject(new Error("Failed to load barcode polyfill")),document.head.appendChild(script)})),await BBErsatzteilSearch._polyfillPromise;const loaded=window.BarcodeDetectionAPI;return loaded?.BarcodeDetector?(this._configurePolyfill(loaded),loaded.BarcodeDetector):null}_configurePolyfill(ns){if(BBErsatzteilSearch._polyfillConfigured||typeof ns.setZXingModuleOverrides!="function")return;const wasmSrc=this.dataset.wasmSrc;wasmSrc&&(ns.setZXingModuleOverrides({locateFile:path=>path&&path.endsWith(".wasm")?wasmSrc:path}),BBErsatzteilSearch._polyfillConfigured=!0)}}customElements.get("bb-ersatzteil-search")||customElements.define("bb-ersatzteil-search",BBErsatzteilSearch);class BBBackInStockManager{static DRAWER_ID="back-in-stock-drawer";constructor(){this._bound=!1,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this._bind(),{once:!0}):this._bind()}drawer(){return document.getElementById(BBBackInStockManager.DRAWER_ID)}_bind(){if(this._bound)return;const drawer=this.drawer();drawer&&(this._bound=!0,drawer.addEventListener("click",e=>{e.target.closest("[data-back-in-stock-close]")&&drawer.hide()}),drawer.addEventListener("dialog:after-hide",()=>{const url=new URL(window.location.href);
1url.searchParams.has("customer_posted")&&(url.searchParams.delete("customer_posted"),window.history.replaceState({},"",url.toString()))}))}show(){const drawer=this.drawer();!drawer||typeof drawer.show!="function"||(this._bind(),drawer.show(),requestAnimationFrame(()=>{drawer.querySelector('input[type="email"]')?.focus()}))}}const BBBackInStock=new BBBackInStockManager;class BBBackInStockButton extends HTMLElement{constructor(){super(),this._onClick=this._onClick.bind(this)}connectedCallback(){this.addEventListener("click",this._onClick)}disconnectedCallback(){this.removeEventListener("click",this._onClick)}_onClick(e){e.preventDefault(),e.stopPropagation(),BBBackInStock.show()}}customElements.get("bb-back-in-stock-button")||customElements.define("bb-back-in-stock-button",BBBackInStockButton);class BBFilterRange extends HTMLElement{connectedCallback(){this._ac=new AbortController;const{signal}=this._ac;this.rangeMin=this.querySelector("[data-range-min]"),this.rangeMax=this.querySelector("[data-range-max]"),this.numberMin=this.querySelector("[data-number-min]"),this.numberMax=this.querySelector("[data-number-max]"),this.group=this.querySelector(".range-group"),!(!this.rangeMin||!this.rangeMax||!this.group)&&(this.axisMin=parseFloat(this.dataset.axisMin),this.axisMax=parseFloat(this.dataset.axisMax),this.vonInputs=Array.from(this.querySelectorAll("[data-von-input]")),this.bisInputs=Array.from(this.querySelectorAll("[data-bis-input]")),this._restorePosition(),this._updateFill(),this.numberMin.addEventListener("focus",()=>this.numberMin.select(),{signal}),this.numberMax.addEventListener("focus",()=>this.numberMax.select(),{signal}),this.rangeMin.addEventListener("input",()=>this._onRangeInput("min"),{signal}),this.rangeMax.addEventListener("input",()=>this._onRangeInput("max"),{signal}),this.rangeMin.addEventListener("change",event=>{event.stopPropagation(),this._commit()},{signal}),this.rangeMax.addEventListener("change",event=>{event.stopPropagation(),this._commit()},{signal}),this.numberMin.addEventListener("change",()=>this._onNumberChange("min"),{signal}),this.numberMax.addEventListener("change",()=>this._onNumberChange("max"),{signal}))}disconnectedCallback(){this._ac?.abort()}_onRangeInput(which){const lo=parseFloat(this.rangeMin.value),hi=parseFloat(this.rangeMax.value);which==="min"&&(this.rangeMin.value=Math.min(lo,hi-1)),which==="max"&&(this.rangeMax.value=Math.max(hi,lo+1)),this.numberMin.value=this.rangeMin.value,this.numberMax.value=this.rangeMax.value,this._updateFill()}_onNumberChange(which){const input=which==="min"?this.numberMin:this.numberMax;let value=parseInt(input.value,10);isNaN(value)&&(value=which==="min"?this.axisMin:this.axisMax),which==="min"?this.rangeMin.value=value:this.rangeMax.value=value,this._commit()}_clamp(){let lo=parseFloat(this.rangeMin.value),hi=parseFloat(this.rangeMax.value);if(isNaN(lo)&&(lo=this.axisMin),isNaN(hi)&&(hi=this.axisMax),lo=Math.max(this.axisMin,Math.min(lo,this.axisMax)),hi=Math.max(this.axisMin,Math.min(hi,this.axisMax)),lo>hi){const swap=lo;lo=hi,hi=swap}return this.rangeMin.value=lo,this.rangeMax.value=hi,this.numberMin.value=lo,this.numberMax.value=hi,{lo,hi}}_updateFill(){const span=this.axisMax-this.axisMin||1,lo=parseFloat(this.rangeMin.value),hi=parseFloat(this.rangeMax.value);this.group.style.setProperty("--range-min",`${(lo-this.axisMin)/span*100}%`),this.group.style.setProperty("--range-max",`${(hi-this.axisMin)/span*100}%`)}_storageKey(){const von=this.vonInputs[0]?this.vonInputs[0].name:"",bis=this.bisInputs[0]?this.bisInputs[0].name:"";return`bb-range:${location.pathname}:${von}:${bis}`}_checkedSignature(){const von=this.vonInputs.filter(input=>input.checked).map(input=>input.value).sort(),bis=this.bisInputs.filter(input=>input.checked).map(input=>input.value).sort();return`${von.join(",")}|${bis.join(",")}`}_restorePosition(){let stored=null;try{stored=JSON.parse(sessionStorage.getItem(this._storageKey()))}catch{return}if(!stored||typeof stored.lo!="number"||typeof stored.hi!="number")return;if(stored.sig!==this._checkedSignature()){try{sessionStorage.removeItem(this._storageKey())}catch{}return}const lo=Math.max(this.axisMin,Math.min(stored.lo,this.axisMax)),hi=Math.max(this.axisMin,Math.min(stored.hi,this.axisMax));this.rangeMin.value=lo,this.rangeMax.value=hi,this.numberMin.value=lo,this.numberMax.value=hi}_commit(){const{lo,hi}=this._clamp();this._updateFill();
1const upperUnbounded=hi>=this.axisMax,lowerUnbounded=lo<=this.axisMin,fullRange=upperUnbounded&&lowerUnbounded;this.vonInputs.forEach(input=>{const value=parseFloat(input.value);input.checked=!upperUnbounded&&!isNaN(value)&&value<=hi}),this.bisInputs.forEach(input=>{const value=parseFloat(input.value);input.checked=!lowerUnbounded&&!isNaN(value)&&value>=lo});try{fullRange?sessionStorage.removeItem(this._storageKey()):sessionStorage.setItem(this._storageKey(),JSON.stringify({lo,hi,sig:this._checkedSignature()}))}catch{}this.dispatchEvent(new Event("change",{bubbles:!0}))}}customElements.get("bb-filter-range")||customElements.define("bb-filter-range",BBFilterRange);class BBRangeClear extends HTMLButtonElement{constructor(){super(),this._onClick=this._onClick.bind(this)}connectedCallback(){this.addEventListener("click",this._onClick)}disconnectedCallback(){this.removeEventListener("click",this._onClick)}_onClick(event){event.preventDefault();const section=this.closest(".shopify-section");if(!section)return;const sectionId=section.id.replace("shopify-section-",""),url=new URL(window.location.href);(this.dataset.params||"").split(",").forEach(param=>{const key=param.trim();key&&url.searchParams.delete(key)}),url.searchParams.delete("page"),url.searchParams.set("section_id",sectionId),this.dispatchEvent(new CustomEvent("facet:update",{bubbles:!0,detail:{url}}))}}customElements.get("bb-range-clear")||customElements.define("bb-range-clear",BBRangeClear,{extends:"button"});class BBDiscountPopup extends customElements.get("dialog-element"){connectedCallback(){super.connectedCallback(),this._overlay=this.querySelector("[data-overlay]"),this._overlay?.addEventListener("click",this._onOverlayClick,{signal:this._abortController.signal}),this._codeInput=this.querySelector("[data-code-input]"),this._copyButton=this.querySelector("[data-copy-button]"),this._codeInput&&this._copyButton&&this._codeInput.addEventListener("click",this._onCodeClick,{signal:this._abortController.signal}),(this.debugMode||this.shouldAppearAutomatically)&&(this._timer=setTimeout(()=>this.show(),this.apparitionDelay))}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._timer)}_onOverlayClick=()=>this.hide();_onCodeClick=()=>{this._codeInput.select?.(),this._copyButton.click()};get initialFocus(){return!1}get shouldLock(){return!0}get apparitionDelay(){return parseInt(this.getAttribute("apparition-delay")||0,10)*1e3}get debugMode(){return this.hasAttribute("debug-mode")}get storageKey(){return"theme:discount-popup-appeared"}get shouldAppearAutomatically(){return!(this.hasAttribute("only-once")&&localStorage.getItem(this.storageKey)==="true")}attributeChangedCallback(name,oldValue,newValue){super.attributeChangedCallback(name,oldValue,newValue),name==="open"&&this.open&&!this.debugMode&&localStorage.setItem(this.storageKey,"true")}}customElements.get("bb-discount-popup")||customElements.define("bb-discount-popup",BBDiscountPopup);class BBRatingTooltip extends HTMLElement{connectedCallback(){this._abortController=new AbortController;const{signal}=this._abortController;document.addEventListener("keydown",event=>{event.key==="Escape"&&this.matches(":hover, :focus-within")&&this.setAttribute("data-dismissed","")},{signal}),this.addEventListener("pointerenter",()=>this._updatePosition(),{signal}),this.addEventListener("focusin",()=>this._updatePosition(),{signal}),this.addEventListener("pointerleave",()=>this.removeAttribute("data-dismissed"),{signal}),this.addEventListener("focusout",()=>this.removeAttribute("data-dismissed"),{signal})}disconnectedCallback(){this._abortController.abort()}_updatePosition(){const panel=this.querySelector(".rating-tooltip__panel");if(!panel)return;const rect=this.getBoundingClientRect(),probe=document.createElement("div");probe.style.cssText="position:absolute;visibility:hidden;height:var(--sticky-area-height, 0px);",document.body.appendChild(probe);const stickyAreaHeight=probe.offsetHeight;probe.remove();const neededSpace=panel.offsetHeight+16,spaceBelow=window.innerHeight-rect.bottom,spaceAbove=rect.top-stickyAreaHeight;this.removeAttribute("data-position"),spaceBelow<neededSpace&&spaceAbove>neededSpace&&this.setAttribute("data-position","above")}}customElements.get("bb-rating-tooltip")||customElements.define("bb-rating-tooltip",BBRatingTooltip);
2//# sourceMappingURL=/cdn/shop/t/7/assets/custom.js.map?v=171591269748554765661790854206

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.