1(function(){const ALLOWED_CHARACTERS=/[^A-Z0-9&.â¥]/g;function createGuid(){return window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/x/g,()=>Math.floor(Math.random()*16).toString(16))}class ProductMonogramDrawer extends HTMLElement{constructor(){super(),this.handleDocumentClick=this.handleDocumentClick.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.syncSubmitState=this.syncSubmitState.bind(this),this.close=this.close.bind(this)}connectedCallback(){this.cartForm=this.closest("cart-form"),this.productCard=this.closest("product-card"),this.input=this.querySelector("[data-monogram-input]"),this.colorNameOutput=this.querySelector("[data-monogram-color-name]"),this.consent=this.querySelector("[data-monogram-consent]"),this.submitButton=this.querySelector("[data-monogram-submit]"),this.swatches=Array.from(this.querySelectorAll("[data-monogram-color]")),this.maxCharacters=parseInt(this.dataset.maxCharacters,10)||3,this.monogramVariantId=this.dataset.monogramVariantId||"",document.addEventListener("click",this.handleDocumentClick),this.querySelectorAll("[data-monogram-close]").forEach(el=>el.addEventListener("click",this.close)),this.input&&this.input.addEventListener("input",()=>{this.sanitiseInput(),this.syncSubmitState()}),this.consent&&this.consent.addEventListener("change",this.syncSubmitState),this.swatches.forEach(swatch=>swatch.addEventListener("click",()=>this.selectColor(swatch))),this.submitButton&&this.submitButton.addEventListener("click",()=>this.addToCart()),this.swatches.length===1&&this.selectColor(this.swatches[0]),this.syncSubmitState()}disconnectedCallback(){document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("keydown",this.handleKeydown),this.classList.contains("open")&&this.releasePageScroll()}handleDocumentClick(event){event.target.closest("[data-monogram-trigger]")&&(event.preventDefault(),this.open())}handleKeydown(event){event.key==="Escape"&&this.close()}sanitiseInput(){const cleaned=this.input.value.toUpperCase().replace(ALLOWED_CHARACTERS,"").slice(0,this.maxCharacters);cleaned!==this.input.value&&(this.input.value=cleaned)}selectColor(swatch){this.swatches.forEach(el=>el.setAttribute("aria-current",el===swatch?"true":"false")),this.colorNameOutput&&(this.colorNameOutput.textContent=swatch.dataset.monogramColorName||""),this.syncSubmitState()}selectedSwatch(){return this.swatches.find(el=>el.getAttribute("aria-current")==="true")}getCharacters(){return Array.from(this.input?this.input.value:"").join(",")}isComplete(){return!!(this.input&&this.input.value.length>0&&this.selectedSwatch()&&this.consent&&this.consent.checked)}syncSubmitState(){this.submitButton&&(this.submitButton.disabled=!this.isComplete())}async addToCart(){if(!this.isComplete()||!this.cartForm||!this.productCard)return;const swatch=this.selectedSwatch(),garment=this.productCard.getItemData(),properties={Characters:this.getCharacters(),Color:swatch.dataset.monogramColorName,_color:swatch.dataset.monogramColor,_guid:createGuid()},items=[{...garment,properties}];this.monogramVariantId&&items.push({id:this.monogramVariantId,quantity:garment.quantity,properties}),items.forEach(item=>this.cartForm.formDataAPI.updateItems(item)),this.close();try{await this.cartForm.reqCart()}finally{this.monogramVariantId&&this.cartForm.formDataAPI.deleteItem(this.monogramVariantId),this.productCard.UpdateFormData(),this.reset()}}reset(){this.input&&(this.input.value=""),this.consent&&(this.consent.checked=!1),this.syncSubmitState()}lockPageScroll(){document.body.classList.add("!overflow-hidden"),window.lenis&&window.lenis.stop()}releasePageScroll(){document.body.classList.remove("!overflow-hidden"),window.lenis&&window.lenis.start()}open(){this.classList.add("open"),document.addEventListener("keydown",this.handleKeydown),this.lockPageScroll(),requestAnimationFrame(()=>{this.input&&this.input.focus({preventScroll:!0})})}close(){this.classList.contains("open")&&(this.classList.remove("open"),document.removeEventListener("keydown",this.handleKeydown),this.releasePageScroll())}}customElements.get("product-monogram-drawer")||customElements.define("product-monogram-drawer",ProductMonogramDrawer)})(); 2//# sourceMappingURL=/cdn/shop/t/587/assets/product-monogram.js.map?v=104876531200491946231786729586
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.