@liquidcommerce/elements-sdk 2.6.0-beta.35 → 2.6.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- (function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t="undefined"!=typeof globalThis?globalThis:t||self,e(t.LiquidCommerceElementsCheckout={}))})(this,function(exports){"use strict";class SDKError extends Error{constructor(t,e=![]){super(t),this.name="SDKError",this.isSdk=!![],this.reThrow=e,Error.captureStackTrace&&Error.captureStackTrace(this,SDKError),Object.setPrototypeOf(this,SDKError.prototype)}}function isSDKError(t,e){if((null==t?void 0:t.isSdk)===!![])return t instanceof SDKError&&t.reThrow?![]:!![];if(!t||"object"!=typeof t)return e?isSDKSource(e):![];const n=String((null==t?void 0:t.message)||""),r=/liquidcommerce\s+elements/i.test(n),s=String((null==t?void 0:t.stack)||""),a=(null==t?void 0:t.source)||e||"",c=[/@[/\\](?:core|modules|constants|enums|interfaces|utils|static)[/\\]/,/[./]*[/\\](?:core|modules|constants|enums|interfaces|utils|static)[/\\]/,/node_modules[/\\]@liquidcommerce[/\\]elements-sdk[/\\]/i,/elements-sdk[/\\](?:src[/\\])?(?:core|modules)[/\\]/i,/chunk-[a-z0-9]+.*elements/i],l=[/\bElements\b(?!\w)/,/\bElementsBuilder\b/,/\bLiquidCommerceElements\b/,/BaseComponent/,/Elements(?:Base)?Client/,/(?:Auth|Store|Command|ApiClient|Telemetry|FingerPrint|GoogleTagManager|ClientConfig|ThemeProvider|ComponentFactory|PubSub|SingletonManager|DebugPanel)Service/,/(?:Cart|Product|Checkout|Address|ProductList|UI|Common)Commands/,/(?:Product|Cart|Checkout|Address|ProductList).*Component/],d=[/(?:service|commands|component)\.(?:ts|js)/,/auto-initialize\/(?:main|checkout)\.(?:ts|js)/,/elements-(?:base-|builder-)?client\.(?:ts|js)/],h=[/elements-sdk[/\\]/i,/modules[/\\](?:cart|product|checkout|address|product-list|theme-provider|ui-components)[/\\]/,/core[/\\](?:auth|store|command|api-client|telemetry|fingerprint|google-tag-manager|client|component-factory|pubsub|singleton-manager|debug-panel)[/\\]/,/@liquidcommerce[/\\]elements-sdk/i],p=isSDKSource(a),m=c.some(t=>t.test(s)),f=l.some(t=>t.test(s)),g=d.some(t=>t.test(s)),v=h.some(t=>t.test(s));return r||p||m||f||g||v}function isSDKSource(t){if(!t||"string"!=typeof t)return![];const e=[/\/elements\.js$/i,/\/index\.esm\.js$/i,/@liquidcommerce\/elements-sdk/i,/node_modules[/\\]@liquidcommerce[/\\]elements-sdk/i,/@liquidcommerce[/\\]elements-sdk[/\\]/i,/\/elements-sdk[/\\]/i,/elements-sdk[/\\]src/i,/elements[-.]?[a-z0-9]*\.js$/i,/chunk.*elements/i,/elements.*chunk/i,/\?.*elements\.js/i,/#.*elements\.js/i];return e.some(e=>e.test(t))}class SingletonManager{static getInstances(){return"builder"===SingletonManager.currentContext?(SingletonManager.builderClientInstances||(SingletonManager.builderClientInstances=new Map),SingletonManager.builderClientInstances):(SingletonManager.regularClientInstances||(SingletonManager.regularClientInstances=new Map),SingletonManager.regularClientInstances)}constructor(){}static setContext({isBuilder:t}){SingletonManager.currentContext=t?"builder":"regular"}static setClientConstructor(t){SingletonManager.clientConstructor=t}static getClientConstructor(){return SingletonManager.clientConstructor}static getClassInstance(t,e){const n=SingletonManager.getInstances();n.has(t)||n.set(t,e());const r=n.get(t);if(!r)throw new SDKError("ElementsSdk: Instance for class "+t+" could not be created.");return r}static async getClient(t){const e=[t.apiKey,t.env,t.isBuilder,t.debugMode].join("_"),n="LiquidCommerceElementsClient_"+e,r=SingletonManager.getInstances();if(r.has(n))return r.get(n);if(!SingletonManager.clientConstructor)throw new SDKError("LiquidCommerce Elements: Client constructor is not set.");const s=new SingletonManager.clientConstructor(t);return await s.prepare(),r.set(n,s),s}}SingletonManager.clientConstructor=null,SingletonManager.regularClientInstances=null,SingletonManager.builderClientInstances=null,SingletonManager.currentContext="regular";class LoggerService{constructor(t){this.prefix="LiquidCommerce Elements",this.colors={debug:"#9CA3AF",log:"#60A5FA",info:"#22D3EE",warn:"#FB923C",error:"#F87171",prefix:"#C084FC"},this.enableLogging=![],this.telemetryService=null,this.context=t}static getInstance(t){return SingletonManager.getClassInstance("LoggerService_"+t,()=>new LoggerService(t))}setEnableLogging(t){this.enableLogging=t}setTelemetryService(t){this.telemetryService=t}getPrefix(t){if(!this.enableLogging)return[];const e=(new Date).toISOString().slice(11,23);return["%c["+e+"%c "+this.prefix+"%c "+this.context+"%c]","color: "+this.colors[t],"color: "+this.colors.prefix+"; font-weight: bold","color: "+this.colors[t],"color: "+this.colors[t]]}debug(t,e){if(this.sendToTelemetry("debug",t,void 0,e),!this.enableLogging)return;const[n,...r]=this.getPrefix("debug");void 0!==e?console.debug(n,...r,t,e):console.debug(n,...r,t)}info(t,e){if(!this.enableLogging)return;const[n,...r]=this.getPrefix("info");void 0!==e?console.info(n,...r,t,e):console.info(n,...r,t)}warn(t,e){if(this.sendToTelemetry("warn",t,void 0,e),!this.enableLogging)return;const[n,...r]=this.getPrefix("warn");void 0!==e?console.warn(n,...r,t,e):console.warn(n,...r,t)}error(t,e){const n=e instanceof Error;let r=n?e:void 0,s=!n&&e?e:void 0;if(s&&s.error instanceof Error){r=s.error;const{error:t,...e}=s;s=Object.keys(e).length>0?e:void 0}if(this.sendToTelemetry("error",t,r,s),!this.enableLogging)return;const[a,...c]=this.getPrefix("error");if(console.group(a+" "+t,...c),r){console.log("Type:",r.name||"Error"),console.log("Message:",r.message),r.stack&&console.log("Stack:",r.stack),r.cause&&console.log("Caused by:",r.cause);const t=Object.keys(r).filter(t=>!["name","message","stack","cause"].includes(t));if(t.length>0){const e={};for(const n of t)e[n]=r[n];console.log("Additional:",e)}}s&&Object.keys(s).length>0&&console.log("Context:",s),console.groupEnd()}sendToTelemetry(t,e,n,r){if(this.telemetryService&&this.telemetryService.isEnabled())try{this.telemetryService.captureEvent(t,e,{context:this.context,error:n,data:r})}catch(s){}}}class LoggerFactory{static getInstances(){return LoggerFactory.instances||(LoggerFactory.instances=new Map),LoggerFactory.instances}static get(t){const e=this.getInstances();if(!e.has(t)){const n=LoggerService.getInstance(t);n.setEnableLogging(this.enableLoggingGlobally),this.telemetryService&&n.setTelemetryService(this.telemetryService),e.set(t,n)}return e.get(t)}static setEnableLogging(t){this.enableLoggingGlobally=t;const e=this.getInstances();for(const[,n]of e)n.setEnableLogging(t)}static setTelemetryService(t){this.telemetryService=t;const e=this.getInstances();for(const[,n]of e)n.setTelemetryService(t)}}LoggerFactory.instances=null,LoggerFactory.enableLoggingGlobally=![],LoggerFactory.telemetryService=null;class ApiClientService{constructor(){this.client=null,this.logger=LoggerFactory.get("ApiClient")}static getInstance(){return SingletonManager.getClassInstance("ApiClientService",()=>new ApiClientService)}async setClient(t){this.client=t}async setPersistedStore(t,e){try{if(!t)return this.logger.error("User device ID is required to set persisted store"),void 0;if(!e||0===Object.keys(e).length)return this.logger.error("No data provided to set persisted store"),void 0;await this.client.post("/configs/store/"+t,{body:e})}catch(n){this.logger.error("Error setting persisted store",n)}}async getPersistedStore(t){try{if(!t)return this.logger.error("User device ID is required to get persisted store"),null;const e=await this.client.get("/configs/store/"+t);return e.data}catch(e){return this.logger.error("Error fetching persisted store",e),null}}async deletePersistedStore(t){try{if(!t)return this.logger.error("User device ID is required to delete persisted store"),void 0;await this.client.post("/configs/store/"+t+"/delete")}catch(e){this.logger.error("Error deleting persisted store",e)}}async getAddressSuggestions(t){try{if(!t||0===t.trim().length)return this.logger.error("Input is required to fetch address suggestions"),[];const e=await this.client.post("/address/autocomplete",{body:{input:t}});return e.data}catch(e){return this.logger.error("Error fetching address suggestions",e),[]}}async getAddressDetails(t){try{if(!t||0===t.trim().length)throw this.logger.error("Address ID is required to fetch address details"),new SDKError("Address ID is required to fetch address details");const e=await this.client.post("/address/details",{body:{id:t}});return e.data}catch(e){throw this.logger.error("Error fetching address details",e),new SDKError("Failed to fetch address details: "+(null==e?void 0:e.message))}}async getProductsData(t,e){try{if(0===t.length)return this.logger.error("No product identifiers provided"),null;const n={identifiers:t,location:e},r=await this.client.post("/product/availability",{body:n});return r.data}catch(n){return this.logger.error("Error fetching product data",n),null}}async catalogSearch(t){try{const e=await this.client.post("/product/search",{body:t});return e.data}catch(e){return this.logger.error("Error fetching catalog search data",e),{products:[],retailers:{},navigation:{currentPage:1,totalPages:0,totalCount:0,filters:[]}}}}async getCartData(t){try{const e=await this.client.post("/cart/get",{body:{id:t||void 0}});return e.data}catch(e){throw this.logger.error("Error fetching cart data",e),new SDKError("Failed to fetch cart data: "+e.message)}}async updateCart(t){try{const e=await this.client.post("/cart/update",{body:t});return e.data}catch(e){throw this.logger.error("Error updating cart",e),new SDKError("Failed to update cart: "+(null==e?void 0:e.message))}}async prepareCheckout(t){try{const e=await this.client.post("/checkout/prepare",{body:t});return e.data}catch(e){throw this.logger.error("Error fetching prepare checkout data",e),new SDKError("Failed to fetch prepare checkout data: "+(null==e?void 0:e.message))}}async updateCheckoutItems(t){try{const e=await this.client.post("/checkout/items",{body:t});return e.data}catch(e){throw this.logger.error("Error updating checkout items",e),new SDKError("Failed to update checkout items: "+(null==e?void 0:e.message))}}async getPaymentSession(t){try{const e=await this.client.post("/checkout/payment/session",{body:{cartId:t}});return e.data}catch(e){throw this.logger.error("Error fetching payment session",e),new SDKError("Failed to get payment session: "+(null==e?void 0:e.message))}}async confirmPaymentSession(t){try{const e=await this.client.post("/checkout/payment/confirm",{body:t});return e.data}catch(e){throw this.logger.error("Error confirming payment session",e),new SDKError("Failed to confirm payment session: "+(null==e?void 0:e.message))}}async checkoutComplete(t){try{const e=await this.client.post("/checkout/complete",{body:{token:t}});return e.data}catch(e){if(this.logger.error("Error completing checkout",e),null==e?void 0:e.error)throw new SDKError("Failed to complete checkout: "+(null==e?void 0:e.message));throw e}}}class HttpClientService{constructor(){this.logger=LoggerFactory.get("HttpClient"),this.defaultShouldRetry=(t,e)=>t||e&&e.status>=500&&e.status<600?!![]:![],this.xhrFetch=(t,e)=>new Promise((n,r)=>{const s=new XMLHttpRequest;s.open(e.method||"GET",t);for(const[t,a]of Object.entries(e.headers))s.setRequestHeader(t,a);s.onload=()=>{const t={ok:s.status>=200&&s.status<300,status:s.status,statusText:s.statusText,headers:s.getAllResponseHeaders().split("\r\n").reduce((t,e)=>{const[n,r]=e.split(": ");return n&&r&&(t[n]=r),t},{}),t:s.responseText,json:()=>Promise.resolve(JSON.parse(s.responseText)),text:()=>Promise.resolve(s.responseText)};n(t)},s.onerror=()=>{r(new TypeError("Network request failed"))},s.ontimeout=()=>{r(new TypeError("Network request timed out"))},s.timeout=3e4,s.send(e.body)}),this.fetchImpl=this.getFetchImplementation()}async request(t){var e,n,r;const{url:s,options:a,retryConfig:c}=t,l=null!==(e=null==c?void 0:c.maxRetries)&&void 0!==e?e:3,d=null!==(n=null==c?void 0:c.retryDelay)&&void 0!==n?n:1e3,h=null!==(r=null==c?void 0:c.shouldRetry)&&void 0!==r?r:this.defaultShouldRetry;let p;const m=Date.now();for(let g=0;g<=l;g++){let t=Date.now();try{t=Date.now();const e=await this.fetchImpl(s,a),n=Date.now()-t;if(e.ok)return e;if(await this.logFailedResponse(s,a,e,n,g,l),g<l&&h(null,e)){await this.delay(d*2**g);continue}return e}catch(f){const e=Date.now()-t;if(p=f,this.logNetworkError(s,a,f,e,g,l),g<l&&h(f,void 0)){await this.delay(d*2**g);continue}throw this.enhanceError(f,s,a,Date.now()-m)}}throw this.enhanceError(p,s,a,Date.now()-m)}async logFailedResponse(t,e,n,r,s,a){const c=s<a;let l,d;try{n.t||(n.t=await n.text());try{l=JSON.parse(n.t)}catch(h){l=n.t}}catch(p){l="[Unable to read response body]"}if(e.body)try{d=JSON.parse(e.body)}catch(m){d=e.body}this.logger.error("HTTP request failed",{method:e.method,url:t,status:n.status,statusText:n.statusText,duration:r+"ms",attempt:s+1+"/"+(a+1),willRetry:c,requestHeaders:e.headers,requestBody:d,responseHeaders:n.headers,responseBody:l})}logNetworkError(t,e,n,r,s,a){var c;const l=s<a;this.logger.error("Network request failed",{method:e.method,url:t,error:n,errorType:(null===(c=null==n?void 0:n.constructor)||void 0===c?void 0:c.name)||typeof n,duration:r+"ms",attempt:s+1+"/"+(a+1),willRetry:l,possibleCauses:this.diagnosePossibleCauses(n)})}diagnosePossibleCauses(t){var e,n,r,s,a;const c=[];return((null===(e=null==t?void 0:t.message)||void 0===e?void 0:e.includes("timeout"))||(null===(n=null==t?void 0:t.message)||void 0===n?void 0:n.includes("timed out")))&&c.push("Request timeout - server took too long to respond"),((null===(r=null==t?void 0:t.message)||void 0===r?void 0:r.includes("Failed to fetch"))||(null===(s=null==t?void 0:t.message)||void 0===s?void 0:s.includes("Network request failed")))&&(c.push("Network connectivity issue"),c.push("CORS policy blocking the request"),c.push("Server is not responding"),c.push("Request was blocked by browser or firewall")),(null===(a=null==t?void 0:t.message)||void 0===a?void 0:a.includes("aborted"))&&c.push("Request was aborted"),0===c.length&&c.push("Unknown network error"),c}enhanceError(t,e,n,r){const s=new Error((null==t?void 0:t.message)||"Network request failed - no response from server");return s.url=e,s.method=n.method,s.totalDuration=r+"ms",s.isNetworkError=!![],s.originalError=t,s.possibleCauses=this.diagnosePossibleCauses(t),s}delay(t){return new Promise(e=>setTimeout(e,t))}getFetchImplementation(){return"undefined"!=typeof fetch?this.fetchAdapter(fetch):"undefined"!=typeof global&&global.fetch?this.fetchAdapter(global.fetch):window.fetch?this.fetchAdapter(window.fetch):this.xhrFetch}fetchAdapter(t){return async(e,n)=>{var r;const s=await t(e,n);let a;if("function"==typeof(null===(r=s.headers)||void 0===r?void 0:r.entries))a=Object.fromEntries(s.headers.entries());else{a={};for(const[t,e]of s.headers)a[t]=e}const c={ok:s.ok,status:s.status,statusText:s.statusText,headers:a,json:async()=>(c.t||(c.t=await s.text()),JSON.parse(c.t)),text:async()=>(c.t||(c.t=await s.text()),c.t)};return c}}}const t={DEVELOPMENT:"development",STAGING:"staging",PRODUCTION:"production"},e={CLIENT_READY:"client_ready",ADDRESS_UPDATED:"address_updated",ADDRESS_CLEARED:"address_cleared",ADDRESS_FAILED:"address_failed",PRODUCT_LOADED:"product_loaded",PRODUCT_QUANTITY_INCREASE:"product_quantity_increase",PRODUCT_QUANTITY_DECREASE:"product_quantity_decrease",PRODUCT_ADD_TO_CART:"product_add_to_cart",PRODUCT_SIZE_CHANGED:"product_size_changed",PRODUCT_FULFILLMENT_TYPE_CHANGED:"product_fulfillment_type_changed",PRODUCT_FULFILLMENT_CHANGED:"product_fulfillment_changed",CART_LOADED:"cart_loaded",CART_CLOSED:"cart_closed",CART_OPENED:"cart_opened",CART_UPDATED:"cart_updated",CART_FAILED:"cart_failed",CART_RESET:"cart_reset",CART_ITEM_ADDED:"cart_item_added",CART_ITEM_REMOVED:"cart_item_removed",CART_ITEM_QUANTITY_INCREASE:"cart_item_quantity_increase",CART_ITEM_QUANTITY_DECREASE:"cart_item_quantity_decrease",CART_ITEM_ENGRAVING_UPDATED:"cart_item_engraving_updated",CART_PROMO_CODE_APPLIED:"cart_promo_code_applied",CART_PROMO_CODE_REMOVED:"cart_promo_code_removed",CART_PROMO_CODE_FAILED:"cart_promo_code_failed",CART_PRODUCT_ADD_SUCCESS:"cart_product_add_success",CART_PRODUCT_ADD_FAILED:"cart_product_add_failed",INTERNAL_CART_TO_CHECKOUT:"internal_cart_to_checkout",CHECKOUT_LOADED:"checkout_loaded",CHECKOUT_OPENED:"checkout_opened",CHECKOUT_CLOSED:"checkout_closed",CHECKOUT_FAILED:"checkout_failed",CHECKOUT_IS_GIFT_TOGGLED:"checkout_is_gift_toggled",CHECKOUT_BILLING_SAME_AS_SHIPPING_TOGGLED:"checkout_billing_same_as_shipping_toggled",CHECKOUT_MARKETING_PREFERENCES_TOGGLED:"checkout_marketing_preferences_toggled",CHECKOUT_CUSTOMER_INFORMATION_UPDATED:"checkout_customer_information_updated",CHECKOUT_GIFT_INFORMATION_UPDATED:"checkout_gift_information_updated",CHECKOUT_BILLING_INFORMATION_UPDATED:"checkout_billing_information_updated",CHECKOUT_ITEM_REMOVED:"checkout_item_removed",CHECKOUT_ITEM_QUANTITY_INCREASE:"checkout_item_quantity_increase",CHECKOUT_ITEM_QUANTITY_DECREASE:"checkout_item_quantity_decrease",CHECKOUT_ITEM_ENGRAVING_UPDATED:"checkout_item_engraving_updated",CHECKOUT_TIP_UPDATED:"checkout_tip_updated",CHECKOUT_SUBMIT_STARTED:"checkout_submit_started",CHECKOUT_SUBMIT_COMPLETED:"checkout_submit_completed",CHECKOUT_SUBMIT_FAILED:"checkout_submit_failed",CHECKOUT_PROMO_CODE_APPLIED:"checkout_promo_code_applied",CHECKOUT_PROMO_CODE_REMOVED:"checkout_promo_code_removed",CHECKOUT_PROMO_CODE_FAILED:"checkout_promo_code_failed",CHECKOUT_GIFT_CARD_APPLIED:"checkout_gift_card_applied",CHECKOUT_GIFT_CARD_REMOVED:"checkout_gift_card_removed",CHECKOUT_GIFT_CARD_FAILED:"checkout_gift_card_failed",CHECKOUT_PRODUCT_ADD_SUCCESS:"checkout_product_add_success",CHECKOUT_PRODUCT_ADD_FAILED:"checkout_product_add_failed"},n={CUSTOMER:"customer",GIFT:"gift",BILLING:"billing"},r={DRAWER:"drawer",INPUT:"input",ENGRAVING_FORM:"engraving-form",ENGRAVING_VIEW:"engraving-view",BUTTONS_CART_OPEN:"buttons-cart-open",POWERED_BY:"powered-by",LCE_ELEMENT:"lce-element",PURCHASE_MIN_ALERT:"purchase-min-alert",ALERT:"alert",PROMO_CODE_TICKER:"promo-code-ticker",MODAL:"modal",ADDRESS:"address",ADDRESS_INPUT:"address-input",ADDRESS_DISPLAY:"address-display",PRODUCT:"product",PRODUCT_IMAGE_CAROUSEL:"product-image-carousel",PRODUCT_OPTIONS:"product-options",PRODUCT_INTERACTIONS:"product-interactions",PRODUCT_DESCRIPTION:"product-description",PRODUCT_RETAILERS:"product-retailers",PRODUCT_RETAILERS_CAROUSEL:"product-retailers-carousel",PRODUCT_RETAILERS_POPUP:"product-retailers-popup",PRODUCT_RETAILERS_POPUP_LIST:"product-retailers-popup-list",PRODUCT_PRICE:"product-price",PRODUCT_ADD_TO_CART_SECTION:"product-add-to-cart-section",PRODUCT_DRAWER:"product-drawer",PRODUCT_LOADING:"product-loading",PRODUCT_LIST:"product-list",PRODUCT_LIST_CARD:"product-list-card",PRODUCT_LIST_FILTERS:"product-list-filters",PRODUCT_LIST_SEARCH:"product-list-search",PRODUCT_LIST_CARD_LOADING:"product-list-card-loading",PRODUCT_LIST_RETAILERS:"product-list-retailers",PRODUCT_LIST_ENGRAVING_FORM:"product-list-engraving-form",CART:"cart",CART_RETAILER:"cart-retailer",CART_ITEM:"cart-item",CART_FOOTER:"cart-footer",CART_ITEM_QUANTITY_PRICE:"cart-item-quantity-price",CART_RETAILER_SUBTOTAL:"cart-retailer-subtotal",CART_PROMO_CODE:"cart-promo-code",CART_HEADER:"cart-header",CART_BODY:"cart-body",CART_FULFILLMENT:"cart-fulfillment",CHECKOUT:"checkout",CHECKOUT_INFORMATION:"checkout-information",CHECKOUT_STRIPE_HANDLER:"checkout-stripe-handler",CHECKOUT_STRIPE_FORM:"checkout-stripe-form",CHECKOUT_PAYMENT:"checkout-payment",CHECKOUT_PAYMENT_SUMMARY:"checkout-payment-summary",CHECKOUT_BILLING:"checkout-billing",CHECKOUT_ORDER_SUMMARY:"checkout-order-summary",CHECKOUT_PROMO_CODE:"checkout-promo-code",CHECKOUT_GIFT_CARDS:"checkout-gift-cards",CHECKOUT_AMOUNTS:"checkout-amounts",CHECKOUT_ITEMS:"checkout-items",CHECKOUT_COMPLETED:"checkout-completed",CHECKOUT_DELIVER_TO:"checkout-deliver-to",CHECKOUT_DELIVER_TO_SUMMARY:"checkout-deliver-to-summary",CHECKOUT_BUYER:"checkout-buyer",CHECKOUT_BUYER_SUMMARY:"checkout-buyer-summary",CHECKOUT_TIPS:"checkout-tips",CHECKOUT_PC_GC:"checkout-pc-gc",CHECKOUT_ITEM:"checkout-item",CHECKOUT_ITEM_QUANTITY:"checkout-item-quantity",CHECKOUT_PLACE_ORDER_BUTTON:"checkout-place-order-button",CHECKOUT_HEADER:"checkout-header",CHECKOUT_PRESALE_COUNTDOWN:"checkout-presale-countdown",CHECKOUT_PRESALE_EXPIRED:"checkout-presale-expired",CHECKOUT_SEND_AS_GIFT:"checkout-send-as-gift"},s={ON_DEMAND:"onDemand",SHIPPING:"shipping"},a={NONE:"none",CONSOLE:"console",PANEL:"panel"},c={GENERIC:"generic",PROMO_CODE:"promo-code",GIFT_CARD:"gift-card"},l={SUCCESS:"success",WARNING:"warning",ERROR:"error"},d={[t.DEVELOPMENT]:"https://dev-elements.liquidcommerce.us",[t.STAGING]:"https://staging-elements.liquidcommerce.us",[t.PRODUCTION]:"https://elements.liquidcommerce.us"},h={ENGRAVING:"engraving",PRESALE:"presale",FULFILLMENT:"fulfillment",PRICE:"price",BRANDS:"brands",CATEGORIES:"categories",FLAVOR:"flavor",REGION:"region",VARIETY:"variety",VINTAGE:"vintage",COUNTRY:"country",APPELLATION:"appellation",MATERIALS:"materials",SIZES:"sizes"},p={DRAWER_WRAPPER:2147483640,DRAWER_CONTENT:5952,DRAWER_BACKDROP:5951,LOADING_INDICATOR:5730,PROGRESS_BAR:5560,CHECKOUT_HEADER:5920,INDEPENDENT_BUTTON:5910,TOGGLE_SLIDER:5150,FORM_CONTROLS:5130,SKELETON_WAVE:5040,MODAL:2147483640},m="lce",f={id:"",formattedAddress:"",address:{one:"",two:"",city:"",state:"",zip:"",country:""},coordinates:{latitude:0,longitude:0}},g={id:"",brand:"",category:"",catPath:"",classification:"",type:"",subType:"",salsifyGrouping:"",name:"",description:"",htmlDescription:"",images:[],region:"",country:"",material:"",abv:"",proof:"",age:"",color:"",flavor:"",variety:"",appellation:"",vintage:"",tastingNotes:"",noAvailabilityPrice:0,identifier:"",sizes:{},quantity:1,selectedSizeId:null,selectedFulfillmentType:s.SHIPPING,selectedFulfillmentId:null,selectedFulfillment:null,productHasAvailability:![],fulfillmentHasAvailability:![],drawer:{isOpen:![],contentConfig:null},loading:![],updating:![],rerender:![],error:null},v={id:"",subtotal:0,itemsQuantity:0,items:{},fulfillments:{},retailers:{},promoCode:null,events:[],loading:![],error:null,rerender:![],shouldReset:![]},y={token:"",cartId:"",loading:![],updating:![],error:null,presale:null,isGift:![],marketingPreferences:{canEmail:![],canSms:![]},customerForm:{data:{firstName:"",lastName:"",email:"",phone:"",birthDate:"",company:""},isEditing:!![],isValid:![],isSaving:![]},giftRecipientForm:{data:{firstName:"",lastName:"",email:"",phone:"",message:""},isEditing:!![],isValid:![],isSaving:![]},paymentForm:{paymentSession:null,paymentMethod:null,data:null,billingSameAsShipping:!![],isEditing:!![],isValid:![],isSaving:![]},shippingAddress:{formattedAddress:"",address:{one:"",two:"",city:"",state:"",zip:"",country:""},coordinates:{latitude:0,longitude:0}},promoCode:null,giftCards:[],orderNumber:null,itemsQuantity:0,items:{},fulfillments:{},retailers:{},amounts:{total:0,subtotal:0,shipping:0,discounts:0,delivery:0,engraving:0,giftCards:0,tip:0,service:0,platform:0,tax:0},rerender:![],tipSelection:10,deliveryInstructions:"",giftCardError:null,promoCodeError:null,events:[]},b={drawer:{isOpen:![],contentConfig:null},modal:{isOpen:![],contentConfig:null}},x={checkout:{injection:null,returnUrl:null}},w={products:[],retailers:{},filters:[],pagination:{currentPage:0,totalPages:0,totalCount:0,hasMorePages:!![]},appliedFilters:{},searchTerm:"",gridConfig:void 0,userProducts:{},loading:![]},C={products:{},cart:v,address:f,checkout:y,ui:b,metadata:x,productsList:w};class ClientConfigService{constructor(){this.config=null}static getInstance(){return SingletonManager.getClassInstance("ClientConfigService",()=>new ClientConfigService)}initialize(t,e={}){this.validateInputs(t,e),this.config=Object.freeze(this.buildConfiguration(t,e))}getConfigs(){return{...this.config}}get(t){return this.config[t]}set(t,e){if(!this.config)throw new SDKError("Configuration service is not ready. Please initialize first.");this.config=Object.freeze({...this.config,[t]:e})}isDevelopment(){return this.get("env")===t.DEVELOPMENT}isStaging(){return this.get("env")===t.STAGING}isProduction(){return this.get("env")===t.PRODUCTION}isBuilder(){return this.get("isBuilder")}isDebuggingEnabled(){const t=this.get("debugMode");return t===a.CONSOLE||t===a.PANEL}isDebugPanelEnabled(){return this.get("debugMode")===a.PANEL}debuggingDisabled(){const t=this.get("debugMode");return t===a.NONE}hasCustomTheme(){return null!==this.get("customTheme")}isMobile(){return"mobile"===this.get("deviceType")}getProxyConfig(){return this.get("proxy")}validateInputs(e,n){if(!(null==e?void 0:e.trim()))throw new SDKError("API key is required. Please provide a valid API key.",!![]);if(n.env&&!Object.values(t).includes(n.env)&&(console.warn('[LiquidCommerce Elements] Invalid environment "'+n.env+'". Using default environment.'),n.env=void 0),void 0!==n.isBuilder&&"boolean"!=typeof n.isBuilder&&(console.warn("[LiquidCommerce Elements] isBuilder must be a boolean. Using default value."),n.isBuilder=void 0),void 0===n.debugMode||Object.values(a).includes(n.debugMode)||(console.warn('[LiquidCommerce Elements] Invalid debugMode "'+n.debugMode+'". Must be one of: '+Object.values(a).join(", ")+". Using default value."),n.debugMode=void 0),n.promoTicker&&"object"!=typeof n.promoTicker&&(console.warn("[LiquidCommerce Elements] promoTicker must be an object. Skipping promoTicker configuration."),n.promoTicker=void 0),n.checkout&&("object"!=typeof n.checkout?(console.warn("[LiquidCommerce Elements] checkout must be an object. Skipping checkout configuration."),n.checkout=void 0):n.checkout.pageUrl&&"string"==typeof n.checkout.pageUrl?n.checkout.pageUrl.trim()?n.checkout.pageUrl.includes("{id}")||console.warn('[LiquidCommerce Elements] checkout.pageUrl does not include "{id}" placeholder and will not include cart IDs.'):(console.warn("[LiquidCommerce Elements] checkout.pageUrl cannot be empty. Skipping checkout configuration."),n.checkout=void 0):(console.warn("[LiquidCommerce Elements] checkout.pageUrl is required and must be a string. Skipping checkout configuration."),n.checkout=void 0)),n.promoTicker)if(Array.isArray(n.promoTicker)){const t=n.promoTicker.filter((t,e)=>{if(!t.promoCode.trim())return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].promoCode is required and must be a non-empty string. Skipping this promo."),![];if(!Array.isArray(t.text)||0===t.text.length||!t.text.every(t=>"string"==typeof t&&t.trim()))return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].text is required and must be a non-empty array of strings. Skipping this promo."),![];if("string"!=typeof t.separator||!t.separator.trim())return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].separator is required and must be a non-empty string. Skipping this promo."),![];if(!t.activeFrom)return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].activeFrom is required. Skipping this promo."),![];const n="string"==typeof t.activeFrom?new Date(t.activeFrom):t.activeFrom;if(!(n instanceof Date)||Number.isNaN(n.getTime()))return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].activeFrom must be a valid Date object or ISO date string. Skipping this promo."),![];if(!t.activeUntil)return console.warn("[LiquidCommerce Elements] promoTicker["+e+"].activeUntil is required. Skipping this promo."),![];const r="string"==typeof t.activeUntil?new Date(t.activeUntil):t.activeUntil;return r instanceof Date&&!Number.isNaN(r.getTime())?n>=r?(console.warn("[LiquidCommerce Elements] promoTicker["+e+"].activeFrom must be earlier than activeUntil. Skipping this promo."),![]):!![]:(console.warn("[LiquidCommerce Elements] promoTicker["+e+"].activeUntil must be a valid Date object or ISO date string. Skipping this promo."),![])});n.promoTicker=t.length>0?t:void 0}else console.warn("[LiquidCommerce Elements] promoTicker must be an array. Skipping promoTicker configuration."),n.promoTicker=void 0;n.proxy&&("object"!=typeof n.proxy?(console.warn("[LiquidCommerce Elements] proxy must be an object. Skipping proxy configuration."),n.proxy=void 0):n.proxy.baseUrl&&"string"==typeof n.proxy.baseUrl?n.proxy.headers&&"object"!=typeof n.proxy.headers&&(console.warn("[LiquidCommerce Elements] proxy.headers must be an object. Skipping proxy configuration."),n.proxy=void 0):(console.warn("[LiquidCommerce Elements] proxy.baseUrl is required and must be a string. Skipping proxy configuration."),n.proxy=void 0))}buildConfiguration(e,n){var r,s,c,l;const h=n.env||t.PRODUCTION;let p=d[h];const f=h===t.PRODUCTION,g=n.isBuilder||![],v=m+(f?"":"_"+h)+(g?"builder":"");return(null===(r=n.development)||void 0===r?void 0:r.customApiUrl)&&(p=n.development.customApiUrl),{apiKey:e.trim(),env:h,isBuilder:g,debugMode:n.debugMode||a.NONE,baseUrl:p,partnerCode:void 0,partnerName:void 0,customTheme:n.customTheme||null,proxy:n.proxy||null,deviceType:this.detectDeviceType(),userDeviceId:void 0,localStorageKeyPrefix:v,isLocalStorageAvailable:void 0,version:void 0,clientPrepared:![],promoTicker:n.promoTicker||null,paymentMethodId:(null===(s=n.development)||void 0===s?void 0:s.paymentMethodId)||void 0,openShadowDom:f?![]:(null===(c=n.development)||void 0===c?void 0:c.openShadowDom)||![],hasCustomApiUrl:Boolean(null===(l=n.development)||void 0===l?void 0:l.customApiUrl),checkout:n.checkout||null}}detectDeviceType(){var t,e;if("undefined"==typeof navigator)return"desktop";const n=navigator.userAgent.toLowerCase(),r="ontouchstart"in window||navigator.maxTouchPoints>0,s=(null===(t=window.screen)||void 0===t?void 0:t.width)||0,a=(null===(e=window.screen)||void 0===e?void 0:e.height)||0,c=Math.max(s,a),l=[/ipad/,/android(?!.*mobile)/,/tablet/,/kindle/,/playbook/,/silk/,/gt-p\d{4}/,/nexus (7|9|10)/,/xoom/,/sch-i800/,/galaxy tab/,/surface/,/googletv/,/appletv/,/hbbtv/,/roku/,/smarttv/,/webtv/],d=[/android.*mobile/,/iphone/,/ipod/,/blackberry/,/opera mini/,/opera mobi/,/iemobile/,/mobile/,/webos/,/palm/,/symbian/,/nokia/,/fennec/,/maemo/,/windows phone/,/windows ce/,/htc/,/samsung.*mobile/,/lg.*mobile/,/motorola/,/sony.*mobile/,/watch/,/applewatch/,/wearos/,/tizen/];return l.some(t=>t.test(n))?"tablet":d.some(t=>t.test(n))||r&&c<768?"mobile":r&&c>=768&&c<=1200||r&&/macintosh/i.test(n)&&navigator.maxTouchPoints>1||/android/i.test(n)&&r&&c>=768||/windows nt/i.test(n)&&r&&c>=768?"tablet":(/automotive|carplay|android auto|car browser/i.test(n),"desktop")}}class AuthClientService{constructor(t){this.accessToken=null,this.tokenExpiration=null,this.authPromise=null,this.refreshPromise=null,this.shouldRetryNonAuth=(t,e)=>t?!![]:e&&this.isAuthError(e)?![]:e&&e.status>=500&&e.status<600,this.apiKey=t.apiKey,this.baseUrl=t.baseUrl,this.env=t.env,this.httpClient=new HttpClientService,this.logger=LoggerFactory.get("Auth"),this.clientConfig=ClientConfigService.getInstance()}static getInstance(t){return SingletonManager.getClassInstance("AuthService",()=>new AuthClientService(t))}async authenticateAndGetConfigs(){var t,e,n,r,s,a,c,l,d;try{this.logger.info("Authenticating and fetching configurations in single request");const h=await this.request("/auth/authenticate",{method:"GET"},!![]);return(null===(e=null===(t=null==h?void 0:h.data)||void 0===t?void 0:t.auth)||void 0===e?void 0:e.accessToken)&&(null===(r=null===(n=null==h?void 0:h.data)||void 0===n?void 0:n.auth)||void 0===r?void 0:r.expiration)?(null===(d=null==h?void 0:h.data)||void 0===d?void 0:d.configs)?(this.accessToken=h.data.auth.accessToken,this.tokenExpiration=h.data.auth.expiration-AuthClientService.TOKEN_EXPIRATION_BUFFER_MS,this.logger.info("Successfully authenticated and retrieved configurations"),{success:!![],configs:{...h.data.configs,productList:{theme:{backgroundColor:"#FFFFFF"},layout:{productCard:{style:"card",cornerRadius:"rounded",showPrice:!![],showSizeSelector:!![],showFulfillment:!![],showRetailerName:!![],showQuantityCounter:!![],enablePersonalization:!![],enableShippingFulfillment:!![],enableOnDemandFulfillment:!![],showCollections:![]}}}}}):(this.logger.error("Combined auth response missing configs data",{response:null==h?void 0:h.data}),{success:![]}):(this.logger.error("Combined auth response missing required auth fields",{hasToken:!!(null===(a=null===(s=null==h?void 0:h.data)||void 0===s?void 0:s.auth)||void 0===a?void 0:a.accessToken),hasExp:!!(null===(l=null===(c=null==h?void 0:h.data)||void 0===c?void 0:c.auth)||void 0===l?void 0:l.expiration),response:null==h?void 0:h.data}),{success:![]})}catch(h){return this.logger.error("Failed to authenticate and get configs from combined endpoint",{error:h,env:this.env,baseUrl:this.baseUrl,endpoint:"/auth"}),{success:![]}}}async authenticate(){if(this.authPromise)return this.authPromise;this.authPromise=this.performAuthentication();try{return await this.authPromise}finally{this.authPromise=null}}async refreshToken(){if(this.refreshPromise)return this.refreshPromise;this.refreshPromise=this.performTokenRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async get(t,e){return this.request(t,{method:"GET",headers:null==e?void 0:e.headers})}async post(t,e){return this.request(t,{method:"POST",body:null==e?void 0:e.body,headers:null==e?void 0:e.headers})}async performAuthentication(){var t,e,n,r;try{const s=await this.request("/auth",{method:"GET"},!![]);return(null===(t=null==s?void 0:s.data)||void 0===t?void 0:t.accessToken)&&(null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.expiration)?(this.accessToken=s.data.accessToken,this.tokenExpiration=s.data.expiration-AuthClientService.TOKEN_EXPIRATION_BUFFER_MS,!![]):(this.logger.error("Authentication response missing required fields",{hasToken:!!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.accessToken),hasExp:!!(null===(r=null==s?void 0:s.data)||void 0===r?void 0:r.expiration),response:null==s?void 0:s.data}),![])}catch(s){return this.logger.error("Failed to obtain access token from authentication endpoint",{error:s,env:this.env,baseUrl:this.baseUrl,endpoint:"/auth"}),![]}}async performTokenRefresh(){var t,e,n,r;try{this.logger.info("Attempting to refresh access token");const s=await this.request("/auth/refresh",{method:"POST"},![],!![]);return(null===(t=null==s?void 0:s.data)||void 0===t?void 0:t.accessToken)&&(null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.expiration)?(this.accessToken=s.data.accessToken,this.tokenExpiration=s.data.expiration-AuthClientService.TOKEN_EXPIRATION_BUFFER_MS,this.logger.info("Access token refreshed successfully"),!![]):(this.logger.error("Token refresh response missing required fields",{hasToken:!!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.accessToken),hasExp:!!(null===(r=null==s?void 0:s.data)||void 0===r?void 0:r.expiration),response:null==s?void 0:s.data}),![])}catch(s){return this.logger.warn("Failed to refresh access token, will fall back to full authentication",{error:s,status:null==s?void 0:s.status,endpoint:"/auth/refresh"}),![]}}async request(t,e,n=![],r=![]){if(!n&&!r&&(!this.accessToken||this.isTokenExpired())){let t=this.accessToken?await this.refreshToken():![];if(t||(this.logger.info("Token refresh failed or unavailable, attempting full authentication"),t=await this.authenticate()),!t)throw{status:401,message:"Authentication failed - unable to obtain valid access token",isAuthError:!![]}}const s=this.buildUrl(t),a=this.buildHeaders(e.headers,n),c=await this.httpClient.request({url:s,options:{method:e.method,headers:a,body:e.body?JSON.stringify(e.body):void 0},retryConfig:{maxRetries:AuthClientService.MAX_RETRIES,retryDelay:AuthClientService.RETRY_DELAY_MS,shouldRetry:this.shouldRetryNonAuth}});return c.ok?this.handleSuccessResponse(c,t,e.method):!this.isAuthError(c)||n||r?this.handleErrorResponse(c):this.handleAuthError(c,t,e)}async handleSuccessResponse(t,e,n){try{return await t.json()}catch(r){const s=await t.text().catch(()=>"Success");return this.logger.error("Response returned 2xx status but body is not valid JSON",{path:e,method:n,status:t.status,responsePreview:s.substring(0,1e3),error:r}),{message:s}}}async handleAuthError(t,e,n){this.logger.warn("Access token rejected with "+t.status+", attempting to obtain new token and retry request",{status:t.status,path:e,method:n.method});let r=await this.refreshToken();return r||(this.logger.info("Token refresh failed after auth error, attempting full authentication"),this.clearToken(),r=await this.authenticate()),r?this.request(e,n,![],!![]):(this.logger.error("Unable to obtain new access token after receiving auth error, request cannot be retried",{status:t.status,path:e,method:n.method}),this.handleErrorResponse(t))}async handleErrorResponse(t){let e;try{e=await t.json()}catch(n){const r=await t.text().catch(()=>"HTTP error status: "+t.status);e={message:r||"Unknown error"}}throw{...e,status:t.status,message:(null==e?void 0:e.message)||"Request failed"}}isTokenExpired(){return!this.tokenExpiration||Date.now()>=this.tokenExpiration}clearToken(){this.accessToken=null,this.tokenExpiration=null}buildUrl(t){const e=this.clientConfig.getProxyConfig();return new URL("api"+t,e?e.baseUrl:this.baseUrl).toString()}buildHeaders(t,e=![]){const n={"Content-Type":"application/json","X-Liquid-Api-Env":this.env,"X-Liquid-Api-Sdk":window.location.href,"X-Liquid-Sdk-Version":this.clientConfig.get("version")||"unknown","X-Liquid-Timestamp":Date.now().toString(),"X-Liquid-UD-ID":this.clientConfig.get("userDeviceId")||"unknown",...this.getProxyHeaders(),...t};return e?n["X-Liquid-Api-Key"]=this.apiKey:n.Authorization="Bearer "+this.accessToken,this.clientConfig.isBuilder()&&(n["X-Liquid-Api-Builder"]="true"),n}getProxyHeaders(){const t=this.clientConfig.getProxyConfig();return t?{"X-Liquid-Proxy":"true","X-Liquid-Proxy-Target":this.baseUrl,...t.headers}:{}}isAuthError(t){return 401===t.status||403===t.status}}AuthClientService.TOKEN_EXPIRATION_BUFFER_MS=6e5,AuthClientService.MAX_RETRIES=2,AuthClientService.RETRY_DELAY_MS=1e3;const _="@liquidcommerce/elements-sdk",E="LiquidCommerce Elements SDK",T="UNLICENSED",P="LiquidCommerce Team",D="2.6.0-beta.34",A="https://docs.liquidcommerce.co/elements-sdk",F={type:"git",url:"git+https://github.com/liquidcommerce/elements-sdk.git"},O={url:"https://github.com/liquidcommerce/elements-sdk/issues"},M="./dist/index.esm.js",L="./umd/elements.js",N="./dist/types/index.d.ts",z="pnpm@10.0.0",j={".":{types:"./dist/types/index.d.ts",import:"./dist/index.esm.js",browser:"./umd/elements.js",default:"./dist/index.esm.js"},"./checkout":{types:"./dist/types/index.checkout.d.ts",import:"./dist/index.checkout.esm.js",browser:"./umd/elements-checkout.js",default:"./dist/index.checkout.esm.js"},"./package.json":"./package.json"},B=["dist","umd","docs","README.md","LICENSE"],q={access:"public",registry:"https://registry.npmjs.org/"},U="module",V=["dist/index.esm.js","dist/index.checkout.esm.js","umd/elements.js","umd/elements-checkout.js","src/index.ts","src/index.umd.ts","src/index.checkout.ts","src/index.checkout.umd.ts"],G={build:"rollup -c","build:checkout":"rollup -c rollup.config.checkout.mjs","build:dev":"rollup -c --environment NODE_ENV:development",dev:"rollup -c -w","type-check":"tsc --noEmit",lint:"pnpm biome lint --write",format:"biome format --write",check:"pnpm biome check --write .",fl:"pnpm check && pnpm build && pnpm build:checkout",changelog:"conventional-changelog -p angular -i CHANGELOG.md -s",clean:"rm -rf dist umd node_modules && pnpm install && pnpm build && pnpm build:checkout",prepublishOnly:"pnpm run build","deprecate:old":'npm deprecate @liquidcommerceteam/elements-sdk@"*" "Package moved to @liquidcommerce/elements-sdk"',prepare:"husky"},H=["liquidcommerce","alcohol","beverage","alcohol tech","elements","custom web components","embeddable components","embeddable web components","embeddable commerce"],K={"@biomejs/biome":"2.3.11","@commitlint/cli":"^20.3.1","@commitlint/config-conventional":"^20.3.1","@rollup/plugin-alias":"^6.0.0","@rollup/plugin-commonjs":"^29.0.0","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^16.0.3","@rollup/plugin-replace":"^6.0.3","@rollup/plugin-terser":"^0.4.4","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","@semantic-release/npm":"^13.1.3","@semantic-release/release-notes-generator":"^14.1.0","@types/core-js":"^2.5.8","@types/node":"^25.0.10","conventional-changelog-cli":"^5.0.0",husky:"^9.1.7",process:"^0.11.10",rollup:"^4.56.0","rollup-obfuscator":"^4.1.1","rollup-plugin-typescript2":"^0.36.0","semantic-release":"^25.0.2","ts-node":"^10.9.2",typescript:"^5.9.3"},Y={node:">=22"},W={peerDependencyRules:{ignoreMissing:[]},onlyBuiltDependencies:["@biomejs/biome","javascript-obfuscator"],overrides:{"@conventional-changelog/git-client@<2.0.0":">=2.0.0"}},Q={name:_,description:E,license:T,author:P,version:D,homepage:A,repository:F,bugs:O,module:M,browser:L,types:N,packageManager:z,exports:j,files:B,publishConfig:q,type:U,sideEffects:V,scripts:G,keywords:H,devDependencies:K,engines:Y,pnpm:W};class GoogleTagManagerService{constructor(){this.enablePartnerGTM=![],this.enableLiquidCommerceGTM=![],this.isInitialized=![],this.isInitializing=![],this.currency="USD",this.eventQueue=[],this.logger=LoggerFactory.get("GoogleTagManager"),this.clientConfigService=ClientConfigService.getInstance()}static getInstance(){return SingletonManager.getClassInstance("GoogleTagManagerService",()=>new GoogleTagManagerService)}waitForDOMReady(){return new Promise(t=>{if("loading"!==document.readyState)return t(),void 0;document.addEventListener("DOMContentLoaded",()=>t())})}isGTMAlreadyLoaded(){return"function"==="object".gtag?!![]:Array.from(document.querySelectorAll('script[src*="googletagmanager.com/gtm.js"]')).length>0}isContainerLoaded(t){const e=Array.from(document.querySelectorAll('script[src*="googletagmanager.com/gtm.js"]'));return e.some(e=>{const n=e.src;return n.includes("id="+t)})}isContainerInitialized(t){return window.dataLayer&&Array.isArray(window.dataLayer)&&this.isContainerLoaded(t)?window.dataLayer.some(t=>t&&"object"==typeof t&&("gtm.start"in t||"gtm.js"===t.event)):![]}async loadGTMScript(t){try{if(this.isContainerInitialized(t))return{success:!![],usingExistingGTM:!![],message:"Container "+t+" already loaded"};if(this.isContainerLoaded(t)){const e=await this.waitForContainerInit(t,1e4);return e?{success:!![],usingExistingGTM:!![],message:"Container "+t+" initialized"}:this.checkFallbackGTM(t)}return await this.injectGTMScript(t),{success:!![],usingExistingGTM:![],message:"Container "+t+" loaded successfully"}}catch(e){return this.checkFallbackGTM(t)}}waitForContainerInit(t,e){return new Promise(n=>{let r;const s=setInterval(()=>{this.isContainerInitialized(t)&&(clearInterval(s),clearTimeout(r),n(!![]))},100);r=setTimeout(()=>{clearInterval(s),n(![])},e)})}injectGTMScript(t){return new Promise((e,n)=>{const r=document.createElement("script");r.src="https://www.googletagmanager.com/gtm.js?id="+t,r.async=!![],r.crossOrigin="anonymous";let s=![];const a=setTimeout(()=>{s||(s=!![],this.isContainerInitialized(t)?e():n(new Error("GTM script timeout")))},15e3);r.onload=()=>{s||setTimeout(()=>{s||(s=!![],clearTimeout(a),this.isContainerInitialized(t)||window.dataLayer&&Array.isArray(window.dataLayer)?e():n(new Error("GTM script loaded but failed to initialize")))},500)},r.onerror=()=>{setTimeout(()=>{s||(s=!![],clearTimeout(a),this.isContainerLoaded(t)&&this.isContainerInitialized(t)?e():n(new Error("GTM script failed to load")))},100)},document.head.appendChild(r)})}checkFallbackGTM(t){if(this.isGTMAlreadyLoaded()&&window.dataLayer&&Array.isArray(window.dataLayer)){if(this.partnerGTMId&&this.isContainerInitialized(this.partnerGTMId))return{success:!![],usingExistingGTM:!![],message:"Using partner GTM container"};const t=window.dataLayer.some(t=>t&&"object"==typeof t&&("gtm.start"in t||"gtm.js"===t.event));if(t)return{success:!![],usingExistingGTM:!![],message:"Using existing GTM container"}}return window.dataLayer&&Array.isArray(window.dataLayer)?{success:!![],usingExistingGTM:!![],message:"Using basic dataLayer for event tracking"}:{success:![],usingExistingGTM:![],message:"Failed to load container "+t+" and no fallback available"}}processEventQueue(){const t=Date.now(),e=this.eventQueue.filter(e=>t-e.timestamp<3e4);for(const r of e)try{const t={event:r.eventName,...r.eventData};window.dataLayer.push(t)}catch(n){this.logger.error("Error processing queued event "+r.methodName,n)}this.eventQueue=[],e.length>0&&this.logger.info("Processed "+e.length+" queued GTM events")}getSendToTargets(){const t=[];return this.enableLiquidCommerceGTM&&this.liquidCommerceGTMId&&this.isContainerInitialized(this.liquidCommerceGTMId)&&t.push(this.liquidCommerceGTMId),this.enablePartnerGTM&&this.partnerGTMId&&this.isContainerInitialized(this.partnerGTMId)&&t.push(this.partnerGTMId),t}async initialize(t){try{if(this.isInitialized)return Promise.resolve();if(this.isInitializing&&this.initializationPromise)return this.initializationPromise;if(0,this.clientConfigService.isBuilder())return;this.isInitializing=!![],this.initializationPromise=this.doInitialize(t),await this.initializationPromise}catch(e){this.isInitializing=![],this.initializationPromise=void 0,this.logger.error("GTM initialization failed",e)}}async doInitialize(t){if(!(null==t?void 0:t.partnerName)||!(null==t?void 0:t.liquidCommerceGTMId))return;if(!t.enableLiquidCommerceGTM&&!t.enablePartnerGTM)return this.isInitialized=!![],this.isInitializing=![],this.initializationPromise=void 0,void 0;await this.waitForDOMReady(),this.partnerName=t.partnerName,this.partnerCode=t.partnerCode,this.partnerGTMId=t.partnerGTMId,this.liquidCommerceGTMId=t.liquidCommerceGTMId,this.enablePartnerGTM=t.enablePartnerGTM,this.enableLiquidCommerceGTM=t.enableLiquidCommerceGTM,window.dataLayer||(window.dataLayer=[]),window.gtag||(window.gtag=(...t)=>window.dataLayer.push(t));const e=t.enableLiquidCommerceGTM?await this.loadGTMScript(t.liquidCommerceGTMId):{success:!![],message:"Using partner GTM only"};if(!e.success)throw this.isInitializing=![],this.initializationPromise=void 0,new SDKError("GTM initialization failed: "+e.message);this.isInitialized=!![],this.isInitializing=![],this.initializationPromise=void 0,this.logger.info(e.message),this.processEventQueue()}executeEvent(t,e,n){try{if(this.clientConfigService.isBuilder())return;const r=this.getSendToTargets(),s={...n,...r.length>0&&{send_to:r},tenant_name:this.partnerName,tenant_code:this.partnerCode,tenant_env:this.clientConfigService.get("env"),tenant_source:Q.description+" v"+Q.version};if(!this.isInitialized)return this.eventQueue.length>=100&&this.eventQueue.shift(),this.eventQueue.push({methodName:t,eventName:e,eventData:s,timestamp:Date.now()}),void 0;if(!window.dataLayer||!Array.isArray(window.dataLayer))return;const a={event:e,...s};window.dataLayer.push(a)}catch(r){this.logger.error("GTM "+t+" error",r)}}calculateValue(t){const e=t.reduce((t,e)=>t+(e.price||0)*(e.quantity||1),0);return Number.parseFloat(e.toFixed(2))}viewItem(t){this.executeEvent("viewItem","view_item",{currency:this.currency,value:this.calculateValue([t]),items:[t]})}viewItemList(t,e,n){this.executeEvent("viewItemList","view_item_list",{currency:this.currency,item_list_id:e,item_list_name:n,items:t})}selectItem(t,e,n){this.executeEvent("selectItem","select_item",{item_list_id:e,item_list_name:n,items:[t]})}addToCart(t){this.executeEvent("addToCart","add_to_cart",{currency:this.currency,value:this.calculateValue([t]),quantity:t.quantity||1,items:[t]})}viewCart(t){this.executeEvent("viewCart","view_cart",{currency:this.currency,value:this.calculateValue(t),items:t})}removeFromCart(t){this.executeEvent("removeFromCart","remove_from_cart",{currency:this.currency,value:this.calculateValue([t]),items:[t]})}beginCheckout(t,e){this.executeEvent("beginCheckout","begin_checkout",{currency:this.currency,value:this.calculateValue(t),coupon:e,items:t})}addShippingInfo(t,e){this.executeEvent("addShippingInfo","add_shipping_info",{currency:this.currency,value:this.calculateValue(t),coupon:e,items:t})}addPaymentInfo(t,e,n){this.executeEvent("addPaymentInfo","add_payment_info",{currency:this.currency,value:this.calculateValue(t),payment_type:e,coupon:n,items:t})}purchase(t){this.executeEvent("purchase","purchase",{transaction_id:t.transaction_id,value:t.value,currency:this.currency,tax:t.tax,shipping:t.shipping,coupon:t.coupon,items:t.items,subtotal:t.subtotal,total:t.total_before_discounts,discounts:t.discounts,gift_cards:t.gift_cards,net_total:t.net_total})}promoCodeAttempt(t){this.executeEvent("promoCodeAttempt","promo_code_attempt",{promo_code:t})}promoCodeApplied(t,e){this.executeEvent("promoCodeApplied","promo_code_applied",{promo_code:t,discount_amount:e})}promoCodeFailed(t,e){this.executeEvent("promoCodeFailed","promo_code_failed",{promo_code:t,reason:e})}giftCardAttempt(t){this.executeEvent("giftCardAttempt","gift_card_attempt",{gift_card_code:t})}giftCardApplied(t,e){this.executeEvent("giftCardApplied","gift_card_applied",{gift_card_code:t,applied_amount:e})}giftCardFailed(t,e){this.executeEvent("giftCardFailed","gift_card_failed",{gift_card_code:t,reason:e})}addressUpdated(t){this.executeEvent("addressUpdated","address_updated",{address_id:t.googlePlacesId,formatted_address:t.formattedAddress,address:t.address,coordinates:t.coordinates})}addressFailed(t){this.executeEvent("addressFailed","address_failed",{address_id:t.googlePlacesId,formatted_address:t.formattedAddress,address:t.address,address_error_message:t.error})}productNoAvailability(t){this.executeEvent("productNoAvailability","product_no_availability",{product_id:t.productId,product_name:t.productName,product_brand:t.productBrand,product_category:t.productCategory,product_category2:t.productCategory2,product_category3:t.productCategory3,product_type:t.productType,product_subtype:t.productSubtype,product_price:t.productPrice,upc:t.upc,grouping_id:t.groupingId,address:t.address,availability_reason:t.reason})}productSizeNoAvailability(t){this.executeEvent("productSizeNoAvailability","product_size_no_availability",{product_id:t.productId,product_name:t.productName,product_brand:t.productBrand,product_category:t.productCategory,product_category2:t.productCategory2,product_category3:t.productCategory3,product_type:t.productType,product_subtype:t.productSubtype,product_price:t.productPrice,size_id:t.sizeId,size_name:t.sizeName,upc:t.upc,grouping_id:t.groupingId,address:t.address,availability_reason:t.reason})}productFulfillmentNoAvailability(t){this.executeEvent("productFulfillmentNoAvailability","product_fulfillment_no_availability",{product_id:t.productId,product_name:t.productName,product_brand:t.productBrand,product_category:t.productCategory,product_category2:t.productCategory2,product_category3:t.productCategory3,product_type:t.productType,product_subtype:t.productSubtype,product_price:t.productPrice,size_id:t.sizeId,size_name:t.sizeName,fulfillment_type:t.fulfillmentType,upc:t.upc,grouping_id:t.groupingId,address:t.address,availability_reason:t.reason})}}class PubSubService{constructor(){this.clientReadyEvent=null,this.eventPrefix="lce",this.logger=LoggerFactory.get("PubSub"),this.setupClientReadyBuffering()}static getInstance(){return SingletonManager.getClassInstance("PubSubService",()=>new PubSubService)}publishAction(t,e){this.publishSpecific("actions."+t,e)}publishForm(t,e){this.publishSpecific("forms."+t,e)}publishSpecific(t,e){const[n,r]=t.includes(".")?t.split(".",2):["actions",t];let s=r.split("_")[0];["product","cart","address","checkout"].includes(s)||(s="other");const a=Date.now(),c={eventId:"evt_"+a+"_"+Math.random().toString(36).slice(2,9),namespace:n,event:r,originalEvent:t,actionNamespace:"actions"===n?s:void 0,timestamp:a},l={data:e,metadata:c};this.dispatchNativeEvents(t,l)}dispatchNativeEvents(t,e){const[n]=t.split(".",2);try{"actions.client_ready"===t&&(this.clientReadyEvent=e);const r=new CustomEvent(this.eventPrefix+":"+t,{detail:e,bubbles:!![],cancelable:!![]});window.dispatchEvent(r);const s=new CustomEvent(this.eventPrefix+":"+n,{detail:e,bubbles:!![],cancelable:!![]});window.dispatchEvent(s)}catch(r){this.logger.error("Error dispatching native events for "+t,r)}}setupClientReadyBuffering(){try{const t=window.addEventListener,e=this.eventPrefix+":actions.client_ready";window.addEventListener=(n,r,s)=>{if(n!==e)return t.call(window,n,r,s);if(!this.clientReadyEvent)return t.call(window,n,r,s);try{const t=new CustomEvent(e,{detail:this.clientReadyEvent,bubbles:!![],cancelable:!![]});"function"==typeof r?r(t):r&&"function"==typeof r.handleEvent&&r.handleEvent(t)}catch(a){this.logger.error("Error replaying CLIENT_READY event",a)}return t.call(window,n,r,s)}}catch(Q){this.logger.error("Error setting up CLIENT_READY buffering",Q)}}}class StoreService{constructor(){this.middleware=[],this.isLocalStorageAvailable=![],this.loggingMiddleware=({action:t,payload:e,next:n})=>{const r=performance.now();try{const s=n(),a=performance.now()-r;return this.logger.info("🏪 Store "+t+" ✓ "+a.toFixed(3)+"ms",e),s}catch(s){const n=performance.now()-r;throw this.logger.error("🏪 Store "+t+" ✗ "+n.toFixed(3)+"ms",{payload:e,error:s}),s}},this.performanceMiddleware=({action:t,next:e})=>{const n=performance.now(),r=e(),s=performance.now()-n;return s>16&&this.logger.warn('⚠️ Slow store operation "'+t+'": '+s.toFixed(2)+"ms"),r},this.state=C,this.listeners=new Map,this.logger=LoggerFactory.get("Store"),this.clientConfig=ClientConfigService.getInstance(),this.api=ApiClientService.getInstance(),this.setupMiddleware()}static getInstance(){return SingletonManager.getClassInstance("StoreService",()=>new StoreService)}async initialize({userDeviceId:t,isLocalStorageAvailable:e,persistedStore:n}){this.localStorageKey=this.clientConfig.get("localStorageKeyPrefix")+"_"+t,this.isLocalStorageAvailable=e,e?await this.loadPersistedState():n&&await this.loadFromDBPersistence(n),this.state={...this.state,metadata:x},this.logger.info("Store service initialized successfully",{userDeviceId:t,isLocalStorageAvailable:e,hasPersistedState:null!==n,localStorageKey:this.localStorageKey})}get(t){if(!t)return{...this.state};const e=t.split(".");let n=this.state;for(const r of e){if(null==n)return;n=n[r]}return void 0!==n?Array.isArray(n)?[...n]:"object"==typeof n&&null!==n?{...n}:n:void 0}set(t,e){return this.runWithMiddleware("set",{path:t,value:e},()=>{const n=this.get(t);return this.state=this.immutableSet(this.state,t,e),this.notifyListeners(t,e,n),this.isLocalStorageAvailable&&this.debouncedSave(),!![]})}update(t,e){const n=this.get(t),r=e(n);return this.set(t,r)}remove(t){return this.runWithMiddleware("remove",{path:t},()=>{const e=this.get(t);if(void 0===e)return this.logger.warn('No value found at path "'+t+'" to remove.'),![];const n=t.split(".");let r=this.state;const s=n.pop();for(const a of n){if(void 0===r[a])return this.logger.warn('Path "'+t+'" does not exist in the state.'),![];r=r[a]}if(Array.isArray(r))r=r.filter((t,e)=>e!==Number.parseInt(s,10));else{if("object"!=typeof r||null===r)return this.logger.warn('Cannot remove property "'+s+'" from non-object type at path "'+t+'".'),![];{const{[s]:t,...e}=r;r=e}}return this.state=this.immutableSet(this.state,n.join("."),r),this.notifyListeners(t,void 0,e),this.isLocalStorageAvailable&&this.debouncedSave(),!![]})}batch(t){return this.runWithMiddleware("batch",{updates:t},()=>{const e=[];if("function"==typeof t){const n=t(this.state);for(const[t,r]of Object.entries(n)){const n=this.get(t);e.push({path:t,oldValue:n,newValue:r,timestamp:Date.now()}),this.state=this.immutableSet(this.state,t,r)}}else for(const[n,r]of Object.entries(t)){const t=this.get(n);e.push({path:n,oldValue:t,newValue:r,timestamp:Date.now()}),this.state=this.immutableSet(this.state,n,r)}for(const{path:t,oldValue:n,newValue:r}of e)this.notifyListeners(t,r,n);return this.isLocalStorageAvailable&&this.debouncedSave(),!![]})}watch(t,e){const n=t;return this.listeners.has(n)||this.listeners.set(n,new Set),this.listeners.get(n).add(e),()=>{var t;null===(t=this.listeners.get(n))||void 0===t?void 0:t.delete(e)}}watchMany(t,e){const n=[];let r;const s=t.map(t=>this.watch(t,(s,a)=>{n.push({path:t,value:s,oldValue:a}),clearTimeout(r),r=setTimeout(()=>{n.length>0&&(e([...n]),n.length=0)},0)}));return()=>{for(const t of s)t()}}createProductInstance(t){const e="products."+t,n=this.get(e);return n?!![]:this.set(e,g)}removeProductInstance(t){const e=this.get("products"),{[t]:n,...r}=e;return this.set("products",r)}getProductInstances(){return this.get("products")}getState(){return{...this.state}}setupMiddleware(){this.middleware.push(this.loggingMiddleware),this.middleware.push(this.performanceMiddleware)}runWithMiddleware(t,e,n){let r=0;const X=()=>{if(r>=this.middleware.length)return n();const s=this.middleware[r++];return s({action:t,payload:e,state:this.getState(),next:X})};return X()}immutableSet(t,e,n){const r=e.split(".");if(1===r.length){if(Array.isArray(t)){const e=[...t];return e[r[0]]=n,e}return{...t,[r[0]]:n}}const[s,...a]=r,c=t[s],l=Array.isArray(c)?[]:{};if(Array.isArray(t)){const e=[...t];return e[s]=this.immutableSet(c||l,a.join("."),n),e}return{...t,[s]:this.immutableSet(c||l,a.join("."),n)}}notifyListeners(t,e,n){const r=this.listeners.get(t);if(r)for(const l of r)try{l(e,n)}catch(a){this.logger.error('Error in store listener for path "'+t+'"',a)}const s=t.split(".");for(let l=s.length-1;l>0;l--){const t=s.slice(0,l).join("."),e=this.listeners.get(t);if(e){const r=this.get(t),a=s.slice(l).join("."),d=this.immutableSet(r,a,n);for(const n of e)try{n(r,d)}catch(c){this.logger.error('Error in store listener for parent path "'+t+'"',c)}}}}debouncedSave(){this.saveTimeout&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>this.saveStore(),50)}forceSave(){this.saveTimeout&&(clearTimeout(this.saveTimeout),this.saveTimeout=void 0),this.saveStore()}async persist(){var t;const e=this.get("address.id")||"",n=this.get("cart.id");if(!e&&!n)return this.logger.info("No session data to persist (both IDs are empty), skipping"),void 0;if(this.isLocalStorageAvailable)return this.forceSave(),this.logger.info("Session data persisted to localStorage",{addressId:e,cartId:n}),void 0;try{const r=null!==(t=this.clientConfig.get("userDeviceId"))&&void 0!==t?t:"not_defined";await this.api.setPersistedStore(r,{p:e,c:n}),this.logger.info("Session data persisted to DB",{userDeviceId:r,addressId:e,cartId:n})}catch(r){this.logger.error("Failed to persist session data to DB",r)}}clearLocalStorage(){if(!this.isLocalStorageAvailable||!this.localStorageKey)return this.logger.info("localStorage not available or key not set, skipping clear"),void 0;try{localStorage.removeItem(this.localStorageKey),this.logger.info("localStorage entry completely removed",{key:this.localStorageKey})}catch(Q){this.logger.error("Failed to clear localStorage entry",Q)}}saveStore(){if(this.isLocalStorageAvailable&&this.localStorageKey)try{let t="";if(this.clientConfig.debuggingDisabled()){const e=this.get("address.id")||"",n=this.get("cart.id");(e||n)&&(t=e+":"+n)}else t=this.getState();t&&localStorage.setItem(this.localStorageKey,"string"!=typeof t?JSON.stringify(t):t)}catch(t){this.logger.error("Failed to persist store state",t)}}async loadPersistedState(){if(this.isLocalStorageAvailable&&this.localStorageKey)try{const e=localStorage.getItem(this.localStorageKey);if(!e)return;try{const t=JSON.parse(e);for(const[e,n]of Object.entries(t))this.set(e,n);return}catch(t){if(e.includes(":")){const[t,n]=e.split(":");if(void 0!==t){const e=await this.getAddressDataFromId(t);this.set("address",e)}return void 0!==n&&this.set("cart.id",n||""),void 0}this.logger.warn("Unrecognized localStorage format, skipping load",{saved:e})}}catch(e){this.logger.error("Failed to load persisted state",e),localStorage.removeItem(this.localStorageKey)}}async loadFromDBPersistence(t){try{if(void 0!==t.p){const e=await this.getAddressDataFromId(t.p);this.set("address",e)}void 0!==t.c&&this.set("cart.id",t.c||""),this.logger.info("Session data loaded from DB persistence",{addressId:t.p,cartId:t.c})}catch(e){this.logger.error("Failed to load session data from DB persistence",e)}}async getAddressDataFromId(t){if(!t||""===t.trim())return f;try{const e=await this.api.getAddressDetails(t);return e&&0!==Object.keys(e).length?{id:t,formattedAddress:e.formattedAddress,address:{one:e.address.one,two:e.address.two,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country||""},coordinates:{latitude:e.coordinates.latitude,longitude:e.coordinates.longitude}}:{...f,id:t}}catch(e){return{...f,id:t}}}}const Z=[r.PRODUCT,r.PRODUCT_IMAGE_CAROUSEL,r.PRODUCT_OPTIONS,r.PRODUCT_INTERACTIONS,r.PRODUCT_DESCRIPTION,r.PRODUCT_RETAILERS,r.PRODUCT_RETAILERS_CAROUSEL,r.PRODUCT_RETAILERS_POPUP,r.PRODUCT_RETAILERS_POPUP_LIST,r.PRODUCT_PRICE,r.PRODUCT_ADD_TO_CART_SECTION,r.PRODUCT_DRAWER,r.PRODUCT_LOADING,r.ENGRAVING_FORM,r.ENGRAVING_VIEW],J=[r.ADDRESS_INPUT,r.ADDRESS_DISPLAY],$=[r.CART,r.CART_RETAILER,r.CART_ITEM,r.CART_FOOTER,r.CART_ITEM_QUANTITY_PRICE,r.CART_RETAILER_SUBTOTAL,r.CART_PROMO_CODE,r.CART_HEADER,r.CART_BODY,r.CART_FULFILLMENT,r.BUTTONS_CART_OPEN],tt=[r.CHECKOUT,r.CHECKOUT_INFORMATION,r.CHECKOUT_STRIPE_HANDLER,r.CHECKOUT_STRIPE_FORM,r.CHECKOUT_PAYMENT,r.CHECKOUT_BILLING,r.CHECKOUT_ORDER_SUMMARY,r.CHECKOUT_PROMO_CODE,r.CHECKOUT_GIFT_CARDS,r.CHECKOUT_AMOUNTS,r.CHECKOUT_ITEMS,r.CHECKOUT_COMPLETED,r.CHECKOUT_DELIVER_TO,r.CHECKOUT_DELIVER_TO_SUMMARY,r.CHECKOUT_BUYER,r.CHECKOUT_TIPS,r.CHECKOUT_PC_GC,r.CHECKOUT_ITEM,r.CHECKOUT_ITEM_QUANTITY,r.CHECKOUT_PLACE_ORDER_BUTTON,r.CHECKOUT_HEADER,r.CHECKOUT_PRESALE_COUNTDOWN,r.CHECKOUT_PRESALE_EXPIRED,r.CHECKOUT_SEND_AS_GIFT],et=[r.PRODUCT_LIST,r.PRODUCT_LIST_CARD,r.PRODUCT_LIST_CARD_LOADING,r.PRODUCT_LIST_FILTERS,r.PRODUCT_LIST_SEARCH];class FontManagerService{constructor(){this.googleFontsUrl="",this.defaultFontFamilies=[{name:"Poppins",weights:[400,500,600,700]}],this.fontsLinkAttribute="data-lce-fonts"}loadGoogleFonts(t,e="swap"){if(!t||0===t.length)return;const n=[...this.defaultFontFamilies,...t],r=n.map(t=>{const e=encodeURIComponent(t.name);return"family="+e+":wght@"+t.weights.join(";")}).join("&"),s="display="+e;this.googleFontsUrl="https://fonts.googleapis.com/css2?"+r+"&"+s,this.injectGoogleFontsResourceHints(),this.injectGoogleFontsLink()}updateGoogleFonts(t,e="swap"){const n=document.querySelector("link["+this.fontsLinkAttribute+"]");this.loadGoogleFonts(t,e),n&&n.remove()}injectGoogleFontsResourceHints(){const t=document.querySelector('link[href="https://fonts.googleapis.com"][rel="preconnect"]'),e=document.querySelector('link[href="https://fonts.gstatic.com"][rel="preconnect"]');if(!t){const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.googleapis.com",document.head.appendChild(t)}if(!e){const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="",document.head.appendChild(t)}}injectGoogleFontsLink(){if(!this.googleFontsUrl)return;const t=document.createElement("link");t.rel="stylesheet",t.href=this.googleFontsUrl,t.setAttribute(this.fontsLinkAttribute,""),document.head.appendChild(t)}}const nt={"headingFont.name":"--heading-font-family","paragraphFont.name":"--paragraph-font-family",buttonCornerRadius:"--button-border-radius",cardCornerRadius:"--card-border-radius",primaryColor:"--primary-color",accentColor:"--accent-color",defaultTextColor:"--default-text-color",selectedTextColor:"--selected-text-color",linkTextColor:"--link-text-color",errorColor:"--error-color",warningColor:"--warning-color",successColor:"--success-color",drawerBackgroundColor:"--drawer-background-color"},it={backgroundColor:"--product-background-color"},ot={backgroundColor:"--cart-background-color"},rt={backgroundColor:"--address-background-color"},st={backgroundColor:"--checkout-background-color"},at={backgroundColor:"--product-list-background-color"},ct={global:nt,product:it,cart:ot,address:rt,checkout:st,productList:at};function getCSSVariableMapping(t){return ct[t]||{}}class CssVariableProcessorService{constructor(){this.opacityLevels=[{suffix:"30",value:.3},{suffix:"50",value:.5},{suffix:"70",value:.7},{suffix:"90",value:.9}],this.logger=LoggerFactory.get("CssVariableProcessor")}extractVariablesFromTheme(t,e){const n={},r=getCSSVariableMapping(e);for(const[s,a]of Object.entries(r)){const e=this.getValueByPath(t,s);void 0!==e&&this.isCSSValue(e)&&(n[a]=e,this.isColorVariable(a,e)&&this.generateOpacityVariants(n,a,e))}return n}extractVariablesFromPartialTheme(t,e){const n={},r=getCSSVariableMapping(e);for(const[s,a]of Object.entries(r))if(this.hasValueAtPath(t,s)){const e=this.getValueByPath(t,s);void 0!==e&&this.isCSSValue(e)&&(n[a]=e,this.isColorVariable(a,e)&&this.generateOpacityVariants(n,a,e))}return n}generateCSSVariablesString(t){return Object.entries(t).map(([t,e])=>" "+t+": "+e+";").join("\n")}updateCSSVariablesInStylesheet(t,e){if(0!==Object.keys(e).length)try{const n=this.findOrCreateRule(t);for(const[t,r]of Object.entries(e))n.style.setProperty(t,String(r))}catch(n){this.logger.warn("Failed to update CSS variables")}}getValueByPath(t,e){return e.split(".").reduce((t,e)=>t&&void 0!==t[e]?t[e]:void 0,t)}hasValueAtPath(t,e){const n=e.split(".");let r=t;for(const s of n){if(null==r||!(s in r))return![];r=r[s]}return!![]}findOrCreateRule(t){const e=":host";for(const r of Array.from(t.cssRules))if(r instanceof CSSStyleRule&&r.selectorText===e)return r;const n=t.insertRule(e+" {}");return t.cssRules[n]}isCSSValue(t){if("string"==typeof t){if(""===t.trim())return![];if(/^(#[0-9a-f]{3,8}|rgb|rgba|hsl|hsla|\d+px|\d+%|\d+rem|\d+em|auto|none|inherit|initial|unset|rounded|squared)/.test(t.toLowerCase()))return!![];if(/^[a-zA-Z0-9\s\-'"]+$/.test(t))return!![];if(/^[a-z-]+$/.test(t))return!![]}return"number"==typeof t}generateOpacityVariants(t,e,n){for(const r of this.opacityLevels){const s=e+"-"+r.suffix,a=this.addOpacityToHexColor(n,r.value);a&&(t[s]=a)}}isColorVariable(t,e){if("string"!=typeof e)return![];const n=t.toLowerCase().includes("color"),r=/^#[0-9a-f]{3,8}$/i.test(e);return n&&r}addOpacityToHexColor(t,e){if(!t.startsWith("#"))return null;let n=t.slice(1);if(3===n.length&&(n=n.split("").map(t=>t+t).join("")),6!==n.length)return null;const r=Math.round(255*e),s=r.toString(16).padStart(2,"0");return"#"+n+s}}class StyleRegistryService{constructor(){this.registry=new Map}static getInstance(){return StyleRegistryService.instance||(StyleRegistryService.instance=new StyleRegistryService),StyleRegistryService.instance}register(t,e,n=10){this.registry.has(t)||this.registry.set(t,[]);const r=this.registry.get(t),s=r.some(t=>t.getter===e);s||(r.push({getter:e,priority:n}),r.sort((t,e)=>t.priority-e.priority))}getStyleGetters(t){const e=this.registry.get(t);return e?e.map(t=>t.getter):[]}getStyles(t){const e=this.getStyleGetters(t);return e.map(t=>t())}hasStyles(t){const e=this.registry.get(t);return!!e&&e.length>0}getRegisteredTypes(){return Array.from(this.registry.keys())}clear(){this.registry.clear()}}const lt=StyleRegistryService.getInstance();class StylesheetGeneratorService{constructor(){this.cssProcessor=new CssVariableProcessorService,this.styleSheets=new Map}getStylesheet(t){return this.styleSheets.get(t)}generateSpecificStylesheet(t,e){const n=this.cssProcessor.extractVariablesFromTheme(e,t),r=this.cssProcessor.generateCSSVariablesString(n),s=lt.getStyles(t).join("\n\n"),a=0===r.length?"":":host { "+r+" }",c=("\n "+a+"\n\n "+s+"\n ").trim();this.createStylesheet(t,c)}createStylesheet(t,e){try{if(this.isCSSStyleSheetSupported()){const n=new CSSStyleSheet;n.replaceSync(e),this.styleSheets.set(t,n)}else this.styleSheets.set(t,e)}catch(Q){this.styleSheets.set(t,e)}}isCSSStyleSheetSupported(){try{if("undefined"==typeof CSSStyleSheet)return![];if("function"!=typeof CSSStyleSheet.prototype.replaceSync)return![];const t=new CSSStyleSheet;return t.replaceSync("/* test */"),!![]}catch(t){return![]}}updateVariablesInStylesheet(t,e,n){const r=this.styleSheets.get(t);if(r&&"string"!=typeof r){const t=this.cssProcessor.extractVariablesFromPartialTheme(e,n);this.cssProcessor.updateCSSVariablesInStylesheet(r,t)}}}class ThemeProviderService{constructor(){this.logger=LoggerFactory.get("ThemeProvider"),this.stylesheetGenerator=new StylesheetGeneratorService,this.fontManager=new FontManagerService}static getInstance(){return SingletonManager.getClassInstance("ThemeProviderService",()=>new ThemeProviderService)}async initialize(t){this.data=t,this.fontManager.loadGoogleFonts([this.data.global.theme.headingFont,this.data.global.theme.paragraphFont]),this.stylesheetGenerator.generateSpecificStylesheet("global",this.data.global.theme),this.stylesheetGenerator.generateSpecificStylesheet("ui",{}),this.stylesheetGenerator.generateSpecificStylesheet("product",this.data.product.theme),this.stylesheetGenerator.generateSpecificStylesheet("cart",this.data.cart.theme),this.stylesheetGenerator.generateSpecificStylesheet("checkout",this.data.checkout.theme),this.stylesheetGenerator.generateSpecificStylesheet("address",this.data.address.theme),this.stylesheetGenerator.generateSpecificStylesheet("product-list",this.data.productList.theme)}updateComponentGlobalConfigs(t){var e,n;const r=this.data.global.layout.showPoweredBy;this.data.global=this.deepMerge(this.getConfigs("global"),t),this.data.global.layout.showPoweredBy=r,((null===(e=t.theme)||void 0===e?void 0:e.headingFont)||(null===(n=t.theme)||void 0===n?void 0:n.paragraphFont))&&this.fontManager.updateGoogleFonts([this.data.global.theme.headingFont,this.data.global.theme.paragraphFont]),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("global",t.theme,"global")}updateProductComponent(t){this.data.product=this.deepMerge(this.getConfigs("product"),t),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("product",t.theme,"product")}updateAddressComponent(t){this.data.address=this.deepMerge(this.getConfigs("address"),t),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("address",t.theme,"address")}updateCartComponent(t){this.data.cart=this.deepMerge(this.getConfigs("cart"),t),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("cart",t.theme,"cart")}updateCheckoutComponent(t){this.data.checkout=this.deepMerge(this.getConfigs("checkout"),t),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("checkout",t.theme,"checkout")}updateProductListComponent(t){this.data.productList=this.deepMerge(this.getConfigs("productList"),t),t.theme&&this.stylesheetGenerator.updateVariablesInStylesheet("product-list",t.theme,"product-list")}getConfigs(t){return"all"===t?this.data:this.data[t]}getComponentConfig(t){return-1!==Z.indexOf(t)?this.getConfigs("product"):-1!==J.indexOf(t)?this.getConfigs("address"):-1!==$.indexOf(t)?this.getConfigs("cart"):-1!==tt.indexOf(t)?this.getConfigs("checkout"):-1!==et.indexOf(t)?this.getConfigs("productList"):void 0}getStylesheet(t){const e=this.getBaseStylesheets();if(t===r.DRAWER||t===r.MODAL){const t=[...e],n=this.stylesheetGenerator.getStylesheet("product"),r=this.stylesheetGenerator.getStylesheet("cart"),s=this.stylesheetGenerator.getStylesheet("checkout"),a=this.stylesheetGenerator.getStylesheet("address"),c=this.stylesheetGenerator.getStylesheet("product-list");return n&&t.push(n),r&&t.push(r),s&&t.push(s),a&&t.push(a),c&&t.push(c),t}let n;if(J.includes(t)||t===r.ADDRESS)n="address";else if(Z.includes(t)||t===r.PRODUCT)n="product";else if($.includes(t)||t===r.CART)n="cart";else if(tt.includes(t)||t===r.CHECKOUT)n="checkout";else{if(!et.includes(t)&&t!==r.PRODUCT_LIST)return this.logger.warn("No stylesheets found for component type: "+t+", returning base stylesheets only."),e;n="product-list"}const s=this.stylesheetGenerator.getStylesheet(n);return s?[...e,s]:e}getBaseStylesheets(){const t=[],e=this.stylesheetGenerator.getStylesheet("global"),n=this.stylesheetGenerator.getStylesheet("ui");return e&&t.push(e),n&&t.push(n),t}deepMerge(t,e){const n={...t};for(const r in e)null!==e[r]&&void 0!==e[r]&&("object"!=typeof e[r]||Array.isArray(e[r])||"object"!=typeof t[r]||Array.isArray(t[r])?n[r]=e[r]:n[r]=this.deepMerge(t[r],e[r]));return n}}class BaseCommand{constructor(){this.store=StoreService.getInstance(),this.api=ApiClientService.getInstance(),this.logger=LoggerFactory.get("BaseCommand"),this.pubSub=PubSubService.getInstance(),this.googleTagManager=GoogleTagManagerService.getInstance(),this.clientConfig=ClientConfigService.getInstance(),this.themeProvider=ThemeProviderService.getInstance()}getLocation(){const t=this.store.get("address");if(t.address.one&&t.coordinates.longitude&&t.coordinates.latitude)return{coordinates:t.coordinates,address:t.address}}}function centToDollar(t){return t/100}function formatCentToDollarText(t,e=!![]){const n=Math.floor(t/100),r=t%100;let s="$"+n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");return(e||r>0)&&(s+=".",s+=r<10?"0"+r:r.toString()),s}function htmlStringToElement(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}function formatISODateToMMDDYYYY(t){if(!t)return"";try{const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=(e.getMonth()+1).toString().padStart(2,"0"),r=e.getDate().toString().padStart(2,"0"),s=e.getFullYear().toString();return n+"/"+r+"/"+s}catch(e){return""}}function capitalizeFirstLetter(t){return t?t.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.substring(1)).join(" "):t}function splitCategoryPath(t){const e=(null==t?void 0:t.split(" > ").map(t=>capitalizeFirstLetter(t.trim())))||[];return{category:e[0]||"",category2:e[1]||"",category3:e[2]||""}}class CartCommands extends BaseCommand{constructor(){super(),this.store.watch("cart.shouldReset",async t=>{t===!![]&&await this.resetCart()})}static getInstance(){return SingletonManager.getClassInstance("CartCommands",()=>new CartCommands)}async updateItemQuantity(t,n){try{this.store.set("cart.items."+t+".updating",!![]);const r=this.store.get("cart.id"),s=this.store.get("cart.items."+t);if(!s)throw this.logger.error("Cart item not found: "+t+" - cannot update quantity by "+n),new SDKError("Item not found");const a=s.quantity+n;if(a<1)return this.removeItem(t,!![]);const c=this.buildItemUpdate(s,a),l=await this.api.updateCart({id:r,items:[c],location:this.getLocation()});this.syncItemsFromApiResponse(l,[t]),this.updateFulfillment(s.fulfillmentId,l),this.syncRetailersFromApiResponse(l),this.syncCartMetaFromApiResponse(l),this.pubSub.publishAction(n<0?e.CART_ITEM_QUANTITY_DECREASE:e.CART_ITEM_QUANTITY_INCREASE,{cartId:r,itemId:s.id,quantity:a,previousQuantity:s.quantity});const d=splitCategoryPath(s.catPath),h={item_id:s.liquidId,item_name:s.name,item_brand:s.brand,item_size:s.size,item_category:d.category,item_category2:d.category2,item_category3:d.category3,quantity:Math.abs(n),price:centToDollar(s.unitPrice||0),item_image:s.mainImage,upc:s.upc,grouping_id:s.salsifyGrouping,product_id:s.liquidId};n<0?this.googleTagManager.removeFromCart(h):n>0&&this.googleTagManager.addToCart(h)}catch(r){throw this.store.set("cart.items."+t+".error",r.message),this.logger.error("Failed to update item quantity",r),r}finally{this.store.set("cart.items."+t+".updating",![])}}async removeItem(t,n){try{if(this.clientConfig.isBuilder())return this.logger.warn("Remove item is not available in builder mode"),void 0;n||this.store.set("cart.items."+t+".updating",!![]);const r=this.store.get("cart.id"),s=this.store.get("cart.items."+t);if(!s)throw new SDKError("Item not found");const a=this.buildItemUpdate(s,0),c=await this.api.updateCart({id:r,items:[a],location:this.getLocation()}),l={itemId:s.id,fulfillmentId:s.fulfillmentId,retailerId:s.retailerId};this.syncItemsFromApiResponse(c,[]),this.cleanupAfterItemRemoval(l,c),this.syncCartMetaFromApiResponse(c),this.pubSub.publishAction(e.CART_ITEM_REMOVED,{cartId:r,itemId:s.id});const d=splitCategoryPath(s.catPath);this.googleTagManager.removeFromCart({item_id:s.liquidId,item_name:s.name,item_brand:s.brand,item_size:s.size,item_category:d.category,item_category2:d.category2,item_category3:d.category3,quantity:s.quantity,price:centToDollar(s.unitPrice||0),item_image:s.mainImage,upc:s.upc,grouping_id:s.salsifyGrouping,product_id:s.liquidId})}catch(r){throw this.store.set("cart.items."+t+".error",r.message),this.logger.error("Failed to remove item",r),r}}async updateItemEngraving(t,n){var r,s,a;try{const c=this.store.get("cart"),l=null===(r=c.items)||void 0===r?void 0:r[t];if(!l)throw new SDKError("Item not found");this.store.set("cart.items."+t+".updating",!![]);const d=this.getDetails(),h={id:l.id,fulfillmentId:l.fulfillmentId,partNumber:l.partNumber,quantity:l.quantity,engravingLines:n},p=await this.api.updateCart({id:c.id||"",items:[h],location:this.getLocation()});this.syncItemsFromApiResponse(p,[t]),this.syncRetailersFromApiResponse(p),this.syncCartMetaFromApiResponse(p);const m=this.getDetails();this.pubSub.publishAction(e.CART_ITEM_ENGRAVING_UPDATED,{cartId:m.cartId,itemId:l.id,engravingLines:n,previousEngravingLines:(null===(a=null===(s=l.attributes)||void 0===s?void 0:s.engraving)||void 0===a?void 0:a.lines)||[]}),this.pubSub.publishAction(e.CART_UPDATED,{previous:d,current:m})}catch(c){throw this.store.set("cart.items."+t+".error",c.message),this.logger.error("Failed to update item engraving",c),c}finally{this.store.set("cart.items."+t+".updating",![])}}async addItem(t){var n,r;try{this.store.set("cart.loading",!![]);const s=this.store.get("cart"),a=this.getDetails(),c=(null===(n=t.engravingLines)||void 0===n?void 0:n.filter(t=>""!==t.trim()))||[],l=c.length>0,d=Object.values(s.items||{}).find(e=>{var n,r,s,a,d;const h=e.fulfillmentId===t.fulfillmentId&&e.partNumber===t.partNumber;if(!h)return![];if(l){const t=(null===(r=null===(n=e.attributes)||void 0===n?void 0:n.engraving)||void 0===r?void 0:r.lines)||[];return c.join(",")===t.join(",")}return!(null===(d=null===(a=null===(s=e.attributes)||void 0===s?void 0:s.engraving)||void 0===a?void 0:a.lines)||void 0===d?void 0:d.length)}),h={fulfillmentId:t.fulfillmentId,partNumber:t.partNumber,quantity:d?t.quantity+d.quantity:t.quantity};l&&(h.engravingLines=c);const p=await this.api.updateCart({id:s.id||"",items:[h],location:this.getLocation()}),m=null===(r=Object.values(p.items))||void 0===r?void 0:r.find(t=>t.fulfillmentId===h.fulfillmentId&&t.partNumber===h.partNumber);if(!m)throw new SDKError("Added item not found in cart response");this.syncItemsFromApiResponse(p,[]);const f=this.store.get("cart.fulfillments."+t.fulfillmentId);f?this.updateFulfillment(t.fulfillmentId,p):this.addNewFulfillmentAndRetailer(t.fulfillmentId,p),this.syncRetailersFromApiResponse(p),this.syncCartMetaFromApiResponse(p);const g=this.getDetails();this.pubSub.publishAction(e.PRODUCT_ADD_TO_CART,{...t}),this.pubSub.publishAction(e.CART_ITEM_ADDED,{cartId:g.cartId,itemId:m.id,fulfillmentId:t.fulfillmentId,partNumber:t.partNumber,quantity:t.quantity,engravingLines:t.engravingLines}),this.pubSub.publishAction(e.CART_UPDATED,{previous:a,current:g});const v=splitCategoryPath(m.catPath);this.googleTagManager.addToCart({item_id:m.liquidId,item_name:m.name,item_brand:m.brand,item_size:m.size,item_category:v.category,item_category2:v.category2,item_category3:v.category3,quantity:m.quantity,price:centToDollar(m.unitPrice||0),item_image:m.mainImage,upc:m.upc,grouping_id:m.salsifyGrouping,product_id:m.liquidId})}catch(s){this.store.set("cart.error",s.message),this.logger.error("Failed to add item to cart",s)}finally{this.store.set("cart.loading",![])}}async handleGoToCheckout(){try{this.store.set("cart.loading",!![]);const t=this.store.get("cart"),n=this.clientConfig.get("checkout");if(n){this.trackBeginCheckout(t);const e=await this.api.prepareCheckout({cartId:t.id||""}),r=this.resolveCheckoutRedirectUrl(n.pageUrl,e.token);return window.location.assign(r),void 0}this.pubSub.publishAction(e.INTERNAL_CART_TO_CHECKOUT,{}),this.trackBeginCheckout(t)}catch(t){throw this.store.set("cart.error",t.message),this.logger.error("Failed to proceed to checkout",t),t}finally{this.store.set("cart.loading",![])}}trackBeginCheckout(t){var e;const n=(null===(e=t.promoCode)||void 0===e?void 0:e.code)||void 0;this.googleTagManager.beginCheckout([...Object.values(t.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}})],n)}resolveCheckoutRedirectUrl(t,e){return t.includes("{id}")?e?t.split("{id}").join(encodeURIComponent(e)):(this.logger.warn('Checkout redirect URL contains "{id}" placeholder but no checkout token was found. Removing placeholder.'),t.split("{id}").join("")):t}async applyPromoCode(t){var n,r,s,a,c;if(!(null==t?void 0:t.trim()))throw new SDKError("Promo code is required");const l=t.trim().toUpperCase();try{const t=this.store.get("cart.id");this.googleTagManager.promoCodeAttempt(l);const d=await this.api.updateCart({id:t,items:[],promoCode:l,location:this.getLocation()});this.store.batch({"cart.subtotal":d.subtotal,"cart.itemsQuantity":d.itemsQuantity,"cart.events":d.events});const h=(null===(r=null===(n=d.promoCode)||void 0===n?void 0:n.code)||void 0===r?void 0:r.toLowerCase())===l.toLowerCase();h?(this.store.set("cart.promoCode",{code:l,discount:(null===(s=d.promoCode)||void 0===s?void 0:s.discount)||0}),this.pubSub.publishAction(e.CART_PROMO_CODE_APPLIED,{cartId:t,discount:(null===(a=d.promoCode)||void 0===a?void 0:a.discount)||0,newSubtotal:d.subtotal||0}),this.googleTagManager.promoCodeApplied(l,(null===(c=d.promoCode)||void 0===c?void 0:c.discount)||0)):(this.store.set("cart.promoCode",null),this.pubSub.publishAction(e.CART_PROMO_CODE_FAILED,{cartId:t,error:"Promo code does not exist"}),this.googleTagManager.promoCodeFailed(l,'Code "'+l+'" does not exist'))}catch(d){const t=(null==d?void 0:d.message)||"Failed to apply promo code. Please try again.";this.store.set("cart.error",t);const n=this.store.get("cart.id");throw this.pubSub.publishAction(e.CART_PROMO_CODE_FAILED,{cartId:n,error:t}),this.googleTagManager.promoCodeFailed(l,t),this.logger.error("Failed to apply promo code",d),d}}async removePromoCode(){try{const t=this.store.get("cart.id"),n=await this.api.updateCart({id:t,items:[],promoCode:"",location:this.getLocation()});this.store.batch({"cart.subtotal":n.subtotal,"cart.itemsQuantity":n.itemsQuantity,"cart.promoCode":null}),this.pubSub.publishAction(e.CART_PROMO_CODE_REMOVED,{cartId:t,newSubtotal:n.subtotal||0}),this.googleTagManager.promoCodeApplied("",0)}catch(t){const n=(null==t?void 0:t.message)||"Failed to remove promo code. Please try again.";this.store.set("cart.error",n);const r=this.store.get("cart.promoCode"),s=this.store.get("cart.id");throw this.pubSub.publishAction(e.CART_PROMO_CODE_FAILED,{cartId:s,error:n}),(null==r?void 0:r.code)&&this.googleTagManager.promoCodeFailed(r.code,n),this.logger.error("Failed to remove promo code",t),t}}rerenderCart(){this.store.set("cart.rerender",!![])}async resetCart(){try{this.store.set("cart",{...v,rerender:!![]}),this.store.set("cart.loading",!![]);const t=this.store.get("cart"),n=await this.api.getCartData(t.id);this.syncCartState(n,!![]),n.id!==t.id&&await this.store.persist(),this.pubSub.publishAction(e.CART_RESET,!![])}catch(t){const n=(null==t?void 0:t.message)||"Failed to reset cart";this.store.set("cart.error",n);const r=this.store.get("cart.id");throw this.pubSub.publishAction(e.CART_FAILED,{cartId:r,message:n}),this.logger.error("Reset cart failed",t),t}finally{this.store.set("cart.loading",![])}}getDetails(){var t;const e=this.store.get("cart"),n=this.store.get("address"),r={};for(const s in e.items||{}){const t=e.items[s];r[s]={id:t.id,variantId:t.variantId,liquidId:t.liquidId,salsifyGrouping:t.salsifyGrouping,retailerId:t.retailerId,partNumber:t.partNumber,fulfillmentId:t.fulfillmentId,upc:t.upc,sku:t.sku,catPath:t.catPath,volume:t.volume,uom:t.uom,pack:t.pack,packDesc:t.packDesc,container:t.container,containerType:t.containerType,name:t.name,brand:t.brand,size:t.size,price:t.price,quantity:t.quantity,maxQuantity:t.maxQuantity,unitPrice:t.unitPrice,mainImage:t.mainImage,attributes:t.attributes}}return{cartId:e.id||"",promoCodeDiscount:(null===(t=e.promoCode)||void 0===t?void 0:t.discount)||null,subtotal:e.subtotal,itemCount:e.itemsQuantity,items:r,retailers:e.retailers||{},location:n.id?{placesId:n.id,formattedAddress:n.formattedAddress,address:n.address,coordinates:n.coordinates}:null}}buildItemUpdate(t,e){var n,r,s;const a={id:t.id,fulfillmentId:t.fulfillmentId,partNumber:t.partNumber,quantity:e},c=(null===(s=null===(r=null===(n=t.attributes)||void 0===n?void 0:n.engraving)||void 0===r?void 0:r.lines)||void 0===s?void 0:s.filter(t=>""!==t.trim()))||[];return c.length>0&&(a.engravingLines=c),a}syncItemsFromApiResponse(t,e=[]){const n=this.store.get("cart.items")||{},r=new Set(Object.keys(t.items));for(const a of Object.keys(n))r.has(a)||this.store.remove("cart.items."+a);const s={};for(const a of Object.values(t.items))0!==e.length&&!e.includes(a.id)&&n[a.id]||(s["cart.items."+a.id]=a);Object.keys(s).length>0&&this.store.batch(s)}syncCartMetaFromApiResponse(t){var e,n;const r={"cart.subtotal":t.subtotal,"cart.itemsQuantity":t.itemsQuantity,"cart.error":null,"cart.events":t.events},s=null===(e=null==t?void 0:t.promoCode)||void 0===e?void 0:e.code;if(s)r["cart.promoCode"]={code:s.toUpperCase(),discount:(null===(n=t.promoCode)||void 0===n?void 0:n.discount)||0};else{const t=this.store.get("cart.promoCode");(null==t?void 0:t.code)&&(r["cart.promoCode"]=null)}this.store.batch(r)}syncRetailersFromApiResponse(t){var e,n;const r=this.store.get("cart.retailers")||{},s=this.store.get("cart.fulfillments")||{},a=new Set(Object.keys(t.retailers)),c=new Set;for(const l of Object.values(t.retailers))if(l.fulfillments)for(const t of Object.keys(l.fulfillments))c.add(t);for(const l of Object.keys(r))a.has(l)||this.store.remove("cart.retailers."+l);for(const l of Object.keys(s))c.has(l)||this.store.remove("cart.fulfillments."+l);if((null===(e=Object.values(t.retailers))||void 0===e?void 0:e.length)>0){const e={};for(const r of Object.values(t.retailers))if(e["cart.retailers."+r.id]=r,(null===(n=Object.values(r.fulfillments))||void 0===n?void 0:n.length)>0)for(const t of Object.values(r.fulfillments))e["cart.fulfillments."+t.id]=t;this.store.batch(e)}}updateFulfillment(t,e){var n;const r=null===(n=Object.values(e.retailers))||void 0===n?void 0:n.find(e=>{var n;return null===(n=Object.keys(e.fulfillments))||void 0===n?void 0:n.some(e=>e===t)}),s=null==r?void 0:r.fulfillments[t];s&&r&&this.store.set("cart.fulfillments."+t,s)}addNewFulfillmentAndRetailer(t,e){var n;const r=null===(n=Object.values(e.retailers))||void 0===n?void 0:n.find(e=>{var n;return null===(n=Object.keys(e.fulfillments))||void 0===n?void 0:n.some(e=>e===t)}),s=null==r?void 0:r.fulfillments[t];if(s&&r){const e={["cart.fulfillments."+t]:s,["cart.retailers."+r.id]:r};this.store.batch(e)}}cleanupAfterItemRemoval(t,e){var n,r;const s=null===(n=Object.values(e.retailers))||void 0===n?void 0:n.some(e=>{var n;return null===(n=Object.keys(e.fulfillments))||void 0===n?void 0:n.some(e=>e===t.fulfillmentId)}),a=null===(r=Object.keys(e.retailers))||void 0===r?void 0:r.some(e=>e===t.retailerId);if(s){this.updateFulfillment(t.fulfillmentId,e);const n=e.retailers[t.retailerId];n&&this.store.set("cart.retailers."+t.retailerId,n)}else if(this.store.remove("cart.fulfillments."+t.fulfillmentId),a){const n=e.retailers[t.retailerId];n&&this.store.set("cart.retailers."+t.retailerId,n)}else this.store.remove("cart.retailers."+t.retailerId)}syncCartState(t,n=![]){var r,s,a,c,l;const d=this.store.get("cart");for(const e of Object.keys(d.items||{}))this.store.remove("cart.items."+e);for(const e of Object.keys(d.retailers||{}))this.store.remove("cart.retailers."+e);for(const e of Object.keys(d.fulfillments||{}))this.store.remove("cart.fulfillments."+e);const h={"cart.id":t.id,"cart.error":null,"cart.subtotal":t.subtotal,"cart.itemsQuantity":t.itemsQuantity,"cart.events":[],"cart.promoCode":(null===(r=t.promoCode)||void 0===r?void 0:r.code)?{...t.promoCode,error:null}:null};if((null===(s=Object.values(t.items))||void 0===s?void 0:s.length)>0)for(const e of Object.values(t.items))h["cart.items."+e.id]=e;if((null===(a=Object.values(t.retailers))||void 0===a?void 0:a.length)>0)for(const e of Object.values(t.retailers))if(h["cart.retailers."+e.id]=e,(null===(c=Object.values(e.fulfillments))||void 0===c?void 0:c.length)>0)for(const t of Object.values(e.fulfillments))h["cart.fulfillments."+t.id]=t;if((null===(l=t.events)||void 0===l?void 0:l.length)>0&&(h["cart.events"]=t.events),this.store.batch(h),n){const t=this.store.get("cart"),n=this.buildCartLoadedEventData(t);this.pubSub.publishAction(e.CART_LOADED,n)}}buildCartLoadedEventData(t){var e,n;const r=this.store.get("address"),s={};for(const a of Object.keys(t.items||{})){const e=t.items[a];s[a]={id:e.id,variantId:e.variantId,liquidId:e.liquidId,salsifyGrouping:e.salsifyGrouping,retailerId:e.retailerId,partNumber:e.partNumber,fulfillmentId:e.fulfillmentId,upc:e.upc,sku:e.sku,catPath:e.catPath,volume:e.volume,uom:e.uom,pack:e.pack,packDesc:e.packDesc,container:e.container,containerType:e.containerType,name:e.name,brand:e.brand,size:e.size,price:e.price,quantity:e.quantity,maxQuantity:e.maxQuantity,unitPrice:e.unitPrice,mainImage:e.mainImage,attributes:e.attributes}}return{cartId:t.id,promoCodeDiscount:null!==(n=null===(e=t.promoCode)||void 0===e?void 0:e.discount)&&void 0!==n?n:null,subtotal:t.subtotal,itemCount:t.itemsQuantity,items:s,retailers:t.retailers||{},location:(null==r?void 0:r.id)&&r.coordinates&&r.address?{placesId:r.id,formattedAddress:r.formattedAddress,address:r.address,coordinates:r.coordinates}:null}}}function componentError({componentType:t,message:e}){const n=document.createElement("div");n.className=t;const r=n.attachShadow({mode:"closed"}),s=document.createElement("style");s.textContent='\n div {\n padding: 10px;\n background-color: #f0f4f8;\n border-radius: 6px;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n\n h3 {\n margin: 0;\n font-size: 16px;\n font-weight: 600;\n color: #d63031;\n line-height: 1.4;\n margin-bottom: 5px;\n }\n\n p {\n margin: 0;\n font-size: 14px;\n font-weight: 400;\n color: #18181B;\n line-height: 1.5;\n max-width: 350px;\n }\n ';const a=document.createElement("div"),c=document.createElement("h3");c.textContent="Component </"+t+">";const l=document.createElement("p");return l.textContent=e,a.appendChild(s),a.appendChild(c),a.appendChild(l),r.appendChild(a),n}function productionComponentError({title:t,message:e,componentType:n}){const r=document.createElement("div");r.setAttribute("data-component-type",n);const s=r.attachShadow({mode:"closed"}),a=document.createElement("style");a.textContent="\n div {\n padding: 20px;\n background-color: #f0f4f8;\n border-radius: 8px;\n box-sizing: border-box;\n font-family: Poppins, sans-serif;\n max-width: 512px;\n display: block;\n }\n\n h2 {\n color: #18181B;\n margin: 0 0 8px 0;\n font-size: 18px;\n font-style: normal;\n font-weight: 600;\n line-height: 18px;\n text-transform: lowercase;\n }\n\n h2::first-letter {\n text-transform: uppercase;\n }\n\n p {\n color: #18181B;\n font-size: 14px;\n font-style: italic;\n font-weight: 400;\n line-height: 20px;\n margin: 0;\n }\n ";const c=document.createElement("div"),l=document.createElement("h2");l.textContent=t;const d=document.createElement("p");return d.textContent=e,c.appendChild(a),c.appendChild(l),c.appendChild(d),s.appendChild(c),r}class ComponentFactoryService{static get logger(){return ComponentFactoryService.i||(ComponentFactoryService.i=LoggerFactory.get("ComponentFactory")),ComponentFactoryService.i}static get clientConfig(){return ComponentFactoryService.o||(ComponentFactoryService.o=ClientConfigService.getInstance()),ComponentFactoryService.o}static getComponentRegistry(){return ComponentFactoryService.componentRegistry||(ComponentFactoryService.componentRegistry=new Map),ComponentFactoryService.componentRegistry}static registerComponent(t,e){ComponentFactoryService.getComponentRegistry().set(t,e)}static createElement(t){try{const e=ComponentFactoryService.getComponentRegistry().get(t.type);if(!e)throw new SDKError("Component type ["+t.type+"] is not registered");const n=ComponentFactoryService.getComponentTagName(t.type);window.customElements.get(n)||window.customElements.define(n,e);const s=document.createElement(n);if(s.initialize){const{type:e,useShadowDom:r,wrapInLceElement:a,...c}=t,l={type:e,tagName:n,useShadowDom:r&&a!==!![]};s.initialize({data:c,config:l})}if(t.wrapInLceElement){const e=ComponentFactoryService.getComponentRegistry().get(r.LCE_ELEMENT),n=ComponentFactoryService.getComponentTagName(r.LCE_ELEMENT);window.customElements.get(n)||window.customElements.define(n,e);const a=document.createElement(n);return a.initialize(t.type,s),a}return s}catch(e){return ComponentFactoryService.logger.error("Failed to create component </"+t.type+">",e),ComponentFactoryService.clientConfig.isProduction()?productionComponentError({title:t.type.replace(/-/g," ")+" is not available.",message:"We're sorry, this element is currently unavailable.",componentType:t.type}):componentError({componentType:t.type,message:(null==e?void 0:e.message)||e})}}static componentError({componentType:t,message:e}){return ComponentFactoryService.logger.error("Component type "+t+" failed to load: "+e),ComponentFactoryService.clientConfig.isProduction()?productionComponentError({title:t.replace(/-/g," ")+" is not available.",message:"We're sorry, this element is currently unavailable.",componentType:t}):componentError({componentType:t,message:e})}static getComponentTagName(t){const e={[r.DRAWER]:"drawer-lc",[r.INPUT]:"input-lc",[r.ENGRAVING_FORM]:"engraving-form-lc",[r.ENGRAVING_VIEW]:"engraving-view-lc",[r.BUTTONS_CART_OPEN]:"buttons-cart-open-lc",[r.POWERED_BY]:"powered-by-lc",[r.LCE_ELEMENT]:"lce-element",[r.PURCHASE_MIN_ALERT]:"purchase-min-alert-lc",[r.ALERT]:"alert-lc",[r.PROMO_CODE_TICKER]:"promo-code-ticker-lc",[r.MODAL]:"modal-lc",[r.ADDRESS]:"address-lc",[r.ADDRESS_INPUT]:"address-input-lc",[r.ADDRESS_DISPLAY]:"address-display-lc",[r.PRODUCT]:"product-lc",[r.PRODUCT_OPTIONS]:"product-options-lc",[r.PRODUCT_IMAGE_CAROUSEL]:"product-image-carousel-lc",[r.PRODUCT_INTERACTIONS]:"product-interactions-lc",[r.PRODUCT_DESCRIPTION]:"product-description-lc",[r.PRODUCT_ADD_TO_CART_SECTION]:"product-add-to-cart-section-lc",[r.PRODUCT_RETAILERS]:"product-retailers-lc",[r.PRODUCT_RETAILERS_CAROUSEL]:"product-retailers-carousel-lc",[r.PRODUCT_RETAILERS_POPUP]:"product-retailers-popup-lc",[r.PRODUCT_RETAILERS_POPUP_LIST]:"product-retailers-popup-list-lc",[r.PRODUCT_PRICE]:"product-price-lc",[r.PRODUCT_DRAWER]:"product-drawer-lc",[r.PRODUCT_LOADING]:"product-loading-lc",[r.PRODUCT_LIST]:"product-list-lc",[r.PRODUCT_LIST_CARD]:"product-list-card-lc",[r.PRODUCT_LIST_FILTERS]:"product-list-filters-lc",[r.PRODUCT_LIST_SEARCH]:"product-list-search-lc",[r.PRODUCT_LIST_CARD_LOADING]:"product-list-card-loading-lc",[r.PRODUCT_LIST_RETAILERS]:"product-list-retailers-lc",[r.PRODUCT_LIST_ENGRAVING_FORM]:"product-list-engraving-form-lc",[r.CART]:"cart-lc",[r.CART_RETAILER]:"cart-retailer-lc",[r.CART_ITEM]:"cart-item-lc",[r.CART_FOOTER]:"cart-footer-lc",[r.CART_ITEM_QUANTITY_PRICE]:"cart-item-quantity-price-lc",[r.CART_RETAILER_SUBTOTAL]:"cart-retailer-subtotal-lc",[r.CART_PROMO_CODE]:"cart-promo-code-lc",[r.CART_HEADER]:"cart-header-lc",[r.CART_BODY]:"cart-body-lc",[r.CART_FULFILLMENT]:"cart-fulfillment-lc",[r.CHECKOUT]:"checkout-lc",[r.CHECKOUT_INFORMATION]:"checkout-information-lc",[r.CHECKOUT_PAYMENT]:"checkout-payment-lc",[r.CHECKOUT_PAYMENT_SUMMARY]:"checkout-payment-summary-lc",[r.CHECKOUT_STRIPE_HANDLER]:"checkout-stripe-handler-lc",[r.CHECKOUT_STRIPE_FORM]:"checkout-stripe-form-lc",[r.CHECKOUT_BILLING]:"checkout-billing-lc",[r.CHECKOUT_ORDER_SUMMARY]:"checkout-order-summary-lc",[r.CHECKOUT_PROMO_CODE]:"checkout-promo-code-lc",[r.CHECKOUT_GIFT_CARDS]:"checkout-gift-cards-lc",[r.CHECKOUT_AMOUNTS]:"checkout-amounts-lc",[r.CHECKOUT_ITEMS]:"checkout-items-lc",[r.CHECKOUT_COMPLETED]:"checkout-completed-lc",[r.CHECKOUT_DELIVER_TO]:"checkout-deliver-to-lc",[r.CHECKOUT_DELIVER_TO_SUMMARY]:"checkout-deliver-to-summary-lc",[r.CHECKOUT_BUYER]:"checkout-buyer-lc",[r.CHECKOUT_BUYER_SUMMARY]:"checkout-buyer-summary-lc",[r.CHECKOUT_TIPS]:"checkout-tips-lc",[r.CHECKOUT_PC_GC]:"checkout-pc-gc-lc",[r.CHECKOUT_ITEM]:"checkout-item-lc",[r.CHECKOUT_ITEM_QUANTITY]:"checkout-item-quantity-lc",[r.CHECKOUT_PLACE_ORDER_BUTTON]:"checkout-place-order-button-lc",[r.CHECKOUT_HEADER]:"checkout-header-lc",[r.CHECKOUT_PRESALE_COUNTDOWN]:"checkout-presale-countdown-lc",[r.CHECKOUT_PRESALE_EXPIRED]:"checkout-presale-expired-lc",[r.CHECKOUT_SEND_AS_GIFT]:"checkout-send-as-gift-lc"};return e[t]||t.toLowerCase()+"-lc"}}ComponentFactoryService.i=null,ComponentFactoryService.o=null,ComponentFactoryService.componentRegistry=null;class UICommands extends BaseCommand{static getInstance(){return SingletonManager.getClassInstance("UICommands",()=>new UICommands)}openDrawer(t,n){const s={type:t,data:n||{}};this.store.set("ui.drawer",{isOpen:!![],contentConfig:s}),t===r.CART&&this.pubSub.publishAction(e.CART_OPENED,!![]),t===r.CHECKOUT&&this.pubSub.publishAction(e.CHECKOUT_OPENED,!![])}closeDrawer(){this.store.set("ui.drawer.isOpen",![]);const t=this.store.get("ui.drawer.contentConfig");(null==t?void 0:t.type)===r.CART&&this.pubSub.publishAction(e.CART_CLOSED,!![]),(null==t?void 0:t.type)===r.CHECKOUT&&this.pubSub.publishAction(e.CHECKOUT_CLOSED,!![])}openModal(t,e){const n={type:t,data:e||{}};this.store.set("ui.modal",{isOpen:!![],contentConfig:n})}closeModal(){this.store.set("ui.modal.isOpen",![]),this.store.set("ui.modal.contentConfig",null)}}function polyfillReplaceChildren(){"undefined"!=typeof Element&&"replaceChildren"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.replaceChildren=function(...t){for(;this.firstChild;)this.removeChild(this.firstChild);for(const e of t)"string"==typeof e?this.appendChild(document.createTextNode(e)):this.appendChild(e)})}function polyfillPrepend(){"undefined"!=typeof Element&&"prepend"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.prepend=function(...t){const e=document.createDocumentFragment();for(const n of t)"string"==typeof n?e.appendChild(document.createTextNode(n)):e.appendChild(n);this.insertBefore(e,this.firstChild)})}function polyfillRemove(){"undefined"!=typeof Element&&"remove"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)})}function polyfillReplaceWith(){"undefined"!=typeof Element&&"replaceWith"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.replaceWith=function(...t){const e=this.parentNode;if(!e)return;const n=document.createDocumentFragment();for(const r of t)"string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r);e.replaceChild(n,this)})}function polyfillBefore(){"undefined"!=typeof Element&&"before"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.before=function(...t){const e=this.parentNode;if(!e)return;const n=document.createDocumentFragment();for(const r of t)"string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r);e.insertBefore(n,this)})}function polyfillAfter(){"undefined"!=typeof Element&&"after"in Element.prototype||"undefined"!=typeof Element&&(Element.prototype.after=function(...t){const e=this.parentNode;if(!e)return;const n=document.createDocumentFragment();for(const r of t)"string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r);e.insertBefore(n,this.nextSibling)})}function polyfillObjectFromEntries(){"undefined"!=typeof Object&&"fromEntries"in Object||"undefined"!=typeof Object&&(Object.fromEntries=t=>{const e={};for(const[n,r]of t)e[n]=r;return e})}function initializeDOMPolyfills(){try{polyfillReplaceChildren(),polyfillPrepend(),polyfillRemove(),polyfillReplaceWith(),polyfillBefore(),polyfillAfter(),polyfillObjectFromEntries()}catch(Q){console.warn("DOM polyfills initialization failed:",Q)}}function safeReplaceChildren(t,...e){try{if("replaceChildren"in t&&"function"==typeof t.replaceChildren)t.replaceChildren(...e);else{for(;t.firstChild;)t.removeChild(t.firstChild);for(const n of e)"string"==typeof n?t.appendChild(document.createTextNode(n)):t.appendChild(n)}}catch(n){console.error("replaceChildren operation failed:",n),1===e.length&&"string"==typeof e[0]&&(t.innerHTML=e[0])}}class CheckoutCommands extends BaseCommand{constructor(){super(),this.uiCommands=UICommands.getInstance(),window.addEventListener("lce:actions."+e.INTERNAL_CART_TO_CHECKOUT,async()=>{this.store.set("metadata.checkout",x.checkout),await this.loadCheckout({}),this.uiCommands.openDrawer(r.CHECKOUT)}),window.addEventListener("lce:actions."+e.CART_RESET,()=>{this.store.set("checkout",{...y,rerender:!![]})})}static getInstance(){return SingletonManager.getClassInstance("CheckoutCommands",()=>new CheckoutCommands)}async addPresaleItem(t){try{const e={fulfillmentId:t.fulfillmentId,partNumber:t.partNumber,quantity:t.quantity,engravingLines:t.engravingLines},n=await this.api.updateCart({id:"",items:[e],location:this.getLocation()});await this.loadCheckout({cartId:n.id,isForPresale:!![]})}catch(e){throw this.store.set("checkout.error",e.message),this.logger.error("Failed to add presale item to checkout",e),e}}async loadCheckout(t){try{this.store.set("checkout.loading",!![]);const n=void 0!==t.cartId?t.cartId:this.store.get("cart.id");if(!t.checkoutId&&!n)return this.store.set("checkout.error","Checkout token or Cart ID is required"),void 0;const r=this.themeProvider.getConfigs("checkout"),s=await this.api.prepareCheckout({token:t.checkoutId||void 0,cartId:t.checkoutId?void 0:n,marketingPreferences:{canEmail:r.layout.emailOptIn.checked,canSms:r.layout.smsOptIn.checked}});if(t.isForPresale===!![]&&0===s.itemsQuantity)return this.showPresaleExpired("items_unavailable"),void 0;const a={"checkout.cartId":s.cartId,"checkout.isGift":s.isGift,"checkout.marketingPreferences":s.marketingPreferences,"checkout.customerForm":y.customerForm,"checkout.giftRecipientForm":y.giftRecipientForm,"checkout.paymentForm":y.paymentForm,"checkout.paymentForm.billingSameAsShipping":s.billingSameAsShipping,"checkout.shippingAddress":s.shippingAddress,"checkout.presale":s.presale,"checkout.giftRecipientForm.data":s.giftOptions,"checkout.updating":![],"checkout.itemsQuantity":s.itemsQuantity};this.store.batch(a),this.syncCheckoutState(s),this.pubSub.publishAction(e.CHECKOUT_LOADED,this.getDetails())}catch(n){this.store.set("checkout.error",n.message),this.pubSub.publishAction(e.CHECKOUT_FAILED,{message:n.message})}finally{this.store.set("checkout.loading",![])}}async toggleIsGift(t){const n=this.store.get("checkout.isGift"),r=null!=t?t:!n,s={firstName:"",lastName:"",email:"",phone:"",message:""};this.store.batch({"checkout.isGift":r,"checkout.customerForm.isEditing":!![],"checkout.giftRecipientForm.isEditing":!![],"checkout.giftRecipientForm.isValid":![],"checkout.giftRecipientForm.data":s});const a=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_IS_GIFT_TOGGLED,{cartId:a,isActive:r,previousIsActive:n})}async toggleBillingSameAsShipping(t){const n=this.store.get("checkout.paymentForm.billingSameAsShipping"),r=null!=t?t:!n;this.store.set("checkout.paymentForm.billingSameAsShipping",r);const s=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_BILLING_SAME_AS_SHIPPING_TOGGLED,{cartId:s,isActive:r,previousIsActive:n})}async toggleMarketingPreferences(t,n){const r=this.store.get("checkout.marketingPreferences."+t),s=null!=n?n:!r,a=this.store.get("checkout.marketingPreferences"),c=this.dataForCheckoutPrepare({marketingPreferences:{...a,[t]:s}}),l=await this.api.prepareCheckout(c);this.store.set("checkout.marketingPreferences",l.marketingPreferences);const d=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_MARKETING_PREFERENCES_TOGGLED,{cartId:d,fieldName:t,isActive:s,previousIsActive:r})}async getPaymentSession(){try{const t=this.store.get("cart.id"),e=await this.api.getPaymentSession(t);this.store.batch({"checkout.paymentForm.paymentSession":e,"checkout.paymentForm.paymentMethod":null})}catch(t){throw this.store.batch({"checkout.error":t.message,"checkout.loading":![]}),t}}async confirmPaymentSession(t,e){try{if(this.clientConfig.isDevelopment()&&this.clientConfig.get("paymentMethodId"))return{id:this.clientConfig.get("paymentMethodId"),card:{brand:"visa",last4:"1111",expMonth:"03",expYear:"35"}};const n=await this.api.confirmPaymentSession({confirmationTokenId:t,setupIntentId:e});return{id:n.id,card:{brand:n.card.brand,last4:n.card.last4,expMonth:n.card.expMonth,expYear:n.card.expYear}}}catch(n){return this.store.set("checkout.error","Failed to confirm payment method. Please try again."),null}}async applyPromoCode(t){try{this.googleTagManager.promoCodeAttempt(t);const n=this.dataForCheckoutPrepare({}),r=await this.api.prepareCheckout({...n,promoCode:t}),s=0!==r.amounts.discounts,a=r.events.some(t=>t.type===c.PROMO_CODE)?r.events[0]:null;if(!s){this.store.set("checkout.promoCodeError",a?a.message:'Code "'+t+'" does not exist');const n=this.store.get("checkout.cartId");return this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_FAILED,{cartId:n,error:(null==a?void 0:a.message)||'Code "'+t+'" does not exist'}),this.googleTagManager.promoCodeFailed(t,(null==a?void 0:a.message)||"not_applied"),void 0}const l=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_APPLIED,{cartId:l,discount:r.amounts.discounts,newTotal:r.amounts.total}),this.googleTagManager.promoCodeApplied(t,r.amounts.discounts),await this.refreshCheckout({response:r})}catch(n){const r=(null==n?void 0:n.message)||"Failed to apply promo code. Please try again.";this.store.set("checkout.error",r);const s=this.store.get("checkout.cartId");throw this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_FAILED,{cartId:s,error:r}),this.googleTagManager.promoCodeFailed(t,r),n}}async removePromoCode(){var t,n;try{const r=this.dataForCheckoutPrepare({}),s=(null===(n=null===(t=this.store.get("checkout"))||void 0===t?void 0:t.promoCode)||void 0===n?void 0:n.code)||"",a=await this.api.prepareCheckout({...r,promoCode:""});if(0!==a.amounts.discounts)return this.store.set("checkout.promoCodeError","Failed to remove promo code"),void 0;const c=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_REMOVED,{cartId:c,newTotal:a.amounts.total}),this.googleTagManager.promoCodeApplied(s,0),await this.refreshCheckout({response:a})}catch(r){const t=(null==r?void 0:r.message)||"Failed to remove promo code. Please try again.";this.store.set("checkout.error",t);const n=this.store.get("checkout.promoCode.code")||"",s=this.store.get("checkout.cartId");throw this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_FAILED,{cartId:s,error:t}),n&&this.googleTagManager.promoCodeFailed(n,t),r}}async clearPromoCodeError(){try{this.store.set("checkout.promoCodeError",null)}catch(Q){const e=Q.message||"Failed to clear promo code error. Please try again.";throw this.store.set("checkout.error",e),Q}}async applyGiftCard(t){const n=t.trim().toUpperCase();try{this.googleTagManager.giftCardAttempt(n);const t=this.dataForCheckoutPrepare({}),r=t.giftCards||[],s=await this.api.prepareCheckout({...t,giftCards:[...r,n]}),a=s.events.some(t=>t.type===c.GIFT_CARD&&t.level===l.ERROR)?s.events[0]:null;a&&this.store.set("checkout.giftCardError",a.message);const d=s.giftCards.find(t=>t.code.toLowerCase()===n.toLowerCase());if(!d){this.store.set("checkout.giftCardError","Gift card could not be applied");const t=this.store.get("checkout.cartId");return this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_FAILED,{cartId:t,error:(null==a?void 0:a.message)||"Gift card could not be applied"}),this.googleTagManager.giftCardFailed(n,(null==a?void 0:a.message)||"not_applied"),void 0}const h=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_APPLIED,{cartId:h,newTotal:s.amounts.total}),this.googleTagManager.giftCardApplied(n,d.applied),await this.refreshCheckout({response:s})}catch(r){const t=(null==r?void 0:r.message)||"Failed to apply gift card. Please try again.";this.store.set("checkout.error",t);const s=this.store.get("checkout.cartId");throw this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_FAILED,{cartId:s,error:t}),this.googleTagManager.giftCardFailed(n,t),r}}async removeGiftCard(t){var n;const r=t.trim().toUpperCase();try{const t=this.dataForCheckoutPrepare({}),s=(null===(n=t.giftCards)||void 0===n?void 0:n.filter(t=>t.toLowerCase()!==r.toLowerCase()))||[],a=await this.api.prepareCheckout({...t,giftCards:s}),c=a.giftCards.find(t=>t.code.toLowerCase()===r.toLowerCase());if(c)return this.store.set("checkout.giftCardError","Failed to remove gift card: "+r),void 0;const l=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_REMOVED,{cartId:l,newTotal:a.amounts.total}),this.googleTagManager.giftCardApplied(r,0),await this.refreshCheckout({response:a})}catch(s){const t=(null==s?void 0:s.message)||"Failed to remove gift card. Please try again.";this.store.set("checkout.error",t);const n=this.store.get("checkout.cartId");throw this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_FAILED,{cartId:n,error:t}),this.googleTagManager.giftCardFailed(r,t),s}}async clearGiftCardError(){try{this.store.set("checkout.giftCardError",null)}catch(Q){throw this.store.set("checkout.error",(null==Q?void 0:Q.message)||"Failed to clear gift card error. Please try again."),Q}}showPresaleExpired(t="time_expired"){this.store.set("checkout",{...y,rerender:![]});const e=this.store.get("metadata.checkout.injection");if(null==e?void 0:e.containerId){const n=document.getElementById(e.containerId);if(n){const e=ComponentFactoryService.createElement({type:r.CHECKOUT_PRESALE_EXPIRED,useShadowDom:!![],isIndependentComponent:!![],wrapInLceElement:!![],reason:t});safeReplaceChildren(n,e)}return}this.uiCommands.openDrawer(r.CHECKOUT_PRESALE_EXPIRED,{reason:t})}openCheckout(){const t=this.clientConfig.get("checkout");if(null==t?void 0:t.pageUrl){this.store.set("metadata.checkout.returnUrl",window.location.href);const e=this.store.get("checkout.token")||"",n=this.resolveCheckoutPageUrl(t.pageUrl,e);return window.location.assign(n),void 0}this.uiCommands.openDrawer(r.CHECKOUT)}getReturnUrl(){return this.store.get("metadata.checkout.returnUrl")}resolveCheckoutPageUrl(t,e){return t.includes("{id}")?e?t.split("{id}").join(encodeURIComponent(e)):(this.logger.warn('Checkout page URL contains "{id}" placeholder but no checkout token was found. Removing placeholder.'),t.split("{id}").join("")):t}rerenderCheckout(){this.store.set("checkout.rerender",!![])}async updateCheckoutItemQuantity(t,n){var r,s,a;try{this.store.set("checkout.items."+t+".updating",!![]);const c=this.store.get("checkout.cartId"),l=this.store.get("checkout.items."+t);if(!l)throw new SDKError("Item not found");const d=l.quantity,h=l.quantity+n;if(h<1)return this.removeItem(t,!![]);const p={id:l.cartItemId,fulfillmentId:l.fulfillmentId,partNumber:l.partNumber,quantity:h},m=(null===(a=null===(s=null===(r=l.attributes)||void 0===r?void 0:r.engraving)||void 0===s?void 0:s.lines)||void 0===a?void 0:a.filter(t=>""!==t.trim()))||[];m.length>0&&(p.engravingLines=m);const f=await this.api.updateCheckoutItems({cartId:c,items:[p],location:this.getLocation()});this.syncFromItemUpdate(f.cart,f.checkout),this.pubSub.publishAction(n>0?e.CHECKOUT_ITEM_QUANTITY_INCREASE:e.CHECKOUT_ITEM_QUANTITY_DECREASE,{cartId:c,cartItemId:l.cartItemId,quantity:h,previousQuantity:d});const g=splitCategoryPath(l.catPath),v={item_id:l.liquidId,item_name:l.name,item_brand:l.brand,item_size:l.size,item_category:g.category,item_category2:g.category2,item_category3:g.category3,quantity:Math.abs(n),price:centToDollar(l.unitPrice||0),item_image:l.mainImage,upc:l.upc,grouping_id:l.salsifyGrouping,product_id:l.liquidId};n<0?this.googleTagManager.removeFromCart(v):n>0&&this.googleTagManager.addToCart(v)}catch(c){throw this.store.set("checkout.items."+t+".error",c.message),c}finally{this.store.set("checkout.items."+t+".updating",![])}}async removeItemEngraving(t){var n,r,s;try{const a=this.store.get("checkout.items."+t);if(!a)throw new SDKError("Item not found in checkout");if(!(null===(n=a.attributes)||void 0===n?void 0:n.engraving))return this.logger.warn("No engraving found for checkout item",{productItemId:t}),void 0;const c=(null===(s=null===(r=a.attributes)||void 0===r?void 0:r.engraving)||void 0===s?void 0:s.lines)||[],l={id:a.cartItemId,fulfillmentId:a.fulfillmentId,partNumber:a.partNumber,quantity:a.quantity,engravingLines:[]},d=this.store.get("checkout.cartId"),h=await this.api.updateCheckoutItems({cartId:d,items:[l],location:this.getLocation()});this.syncFromItemUpdate(h.cart,h.checkout),this.pubSub.publishAction(e.CHECKOUT_ITEM_ENGRAVING_UPDATED,{cartId:d,cartItemId:a.cartItemId,engravingLines:[],previousEngravingLines:c})}catch(a){throw this.store.set("checkout.items."+t+".error",a.message),this.logger.error("Failed to remove engraving from checkout item",{productItemId:t,error:a}),a}}async removeItem(t,n){var r,s,a;try{if(this.clientConfig.isBuilder())return this.logger.warn("Remove item is not available in builder mode"),void 0;n||this.store.set("checkout.items."+t+".updating",!![]);const c=this.store.get("checkout.cartId"),l=this.store.get("checkout.items."+t);if(!l)throw new SDKError("Item not found");const d={id:l.cartItemId,fulfillmentId:l.fulfillmentId,partNumber:l.partNumber,quantity:0},h=(null===(a=null===(s=null===(r=l.attributes)||void 0===r?void 0:r.engraving)||void 0===s?void 0:s.lines)||void 0===a?void 0:a.filter(t=>""!==t.trim()))||[];h.length>0&&(d.engravingLines=h);const p=await this.api.updateCheckoutItems({cartId:c,items:[d],location:this.getLocation()});this.syncFromItemUpdate(p.cart,p.checkout),this.pubSub.publishAction(e.CHECKOUT_ITEM_REMOVED,{cartId:c,cartItemId:l.cartItemId})}catch(c){throw this.store.set("checkout.items."+t+".error",c.message),c}}async updateTips(t){try{this.store.set("checkout.updating",!![]),this.store.set("checkout.tipSelection",t);const n=this.store.get("checkout.fulfillments"),r=Object.values(n||{}).filter(t=>t.type===s.ON_DEMAND).map(t=>({fulfillmentId:t.id,tip:t.amounts.tip})),a=Object.values(n||{}).filter(t=>t.type===s.ON_DEMAND).map(e=>({fulfillmentId:e.id,tip:Math.round(e.amounts.subtotal*t/100)})),c=await this.api.prepareCheckout(this.dataForCheckoutPrepare({deliveryTips:a}));this.updateStoreFromCheckoutResponse(c);const l=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_TIP_UPDATED,{cartId:l,deliveryTips:a,previousDeliveryTips:r})}catch(n){throw this.store.set("checkout.error",(null==n?void 0:n.message)||"Failed to update tips. Please try again."),n}finally{this.store.set("checkout.updating",![])}}async updateFulfillmentTip(t,n){try{this.store.set("checkout.updating",!![]);const r=this.store.get("checkout.fulfillments"),a=Object.values(r||{}).filter(t=>t.type===s.ON_DEMAND).map(t=>({fulfillmentId:t.id,tip:t.amounts.tip})),c=Object.values(r||{}).filter(t=>t.type===s.ON_DEMAND).map(e=>({fulfillmentId:e.id,tip:e.id===t?n:e.amounts.tip})),l=await this.api.prepareCheckout(this.dataForCheckoutPrepare({deliveryTips:c}));this.updateStoreFromCheckoutResponse(l);const d=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_TIP_UPDATED,{cartId:d,deliveryTips:c,previousDeliveryTips:a})}catch(r){throw this.store.set("checkout.error",(null==r?void 0:r.message)||"Failed to update fulfillment tip. Please try again."),r}finally{this.store.set("checkout.updating",![])}}async removeFulfillmentTip(t){try{this.store.set("checkout.updating",!![]);const n=this.store.get("checkout.fulfillments"),r=Object.values(n||{}).filter(t=>t.type===s.ON_DEMAND).map(t=>({fulfillmentId:t.id,tip:t.amounts.tip})),a=Object.values(n||{}).filter(t=>t.type===s.ON_DEMAND).map(e=>({fulfillmentId:e.id,tip:e.id===t?0:e.amounts.tip})),c=await this.api.prepareCheckout(this.dataForCheckoutPrepare({deliveryTips:a}));this.updateStoreFromCheckoutResponse(c);const l=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_TIP_UPDATED,{cartId:l,deliveryTips:a,previousDeliveryTips:r})}catch(n){throw this.store.set("checkout.error",(null==n?void 0:n.message)||"Failed to remove fulfillment tip. Please try again."),n}finally{this.store.set("checkout.updating",![])}}async clearCheckoutError(){this.store.set("checkout.error",null)}async editCustomerForm(){this.store.set("checkout.customerForm.isEditing",!![])}async saveCustomerForm({shippingAddressTwo:t,deliveryInstructions:n,customerData:r}){var s;try{this.store.set("checkout.customerForm.isSaving",!![]);const a=this.store.get("checkout.customerForm.data"),c=this.store.get("checkout.isGift"),l=this.dataForCheckoutPrepare({shippingAddressTwo:t,deliveryInstructions:n||void 0,customer:{...a,...r},isGift:c}),d=await this.api.prepareCheckout(l);this.store.batch({"checkout.customerForm.data":d.customer,"checkout.customerForm.isEditing":![],"checkout.customerForm.isValid":!![],"checkout.shippingAddress":d.shippingAddress,"checkout.deliveryInstructions":n});const h=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_CUSTOMER_INFORMATION_UPDATED,{cartId:h});const p=this.store.get("checkout");this.googleTagManager.addShippingInfo([...Object.values(p.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}})],(null===(s=p.promoCode)||void 0===s?void 0:s.code)||void 0)}finally{this.store.set("checkout.customerForm.isSaving",![])}}async editGiftRecipientForm(){this.store.set("checkout.giftRecipientForm.isEditing",!![])}async saveGiftRecipientForm({shippingAddressTwo:t,deliveryInstructions:n,...r}){var s;try{this.store.set("checkout.giftRecipientForm.isSaving",!![]);const a=this.dataForCheckoutPrepare({shippingAddressTwo:t,deliveryInstructions:n||void 0,isGift:!![],giftRecipient:r}),c=await this.api.prepareCheckout(a);this.store.batch({"checkout.giftRecipientForm.data":c.giftOptions,"checkout.giftRecipientForm.isEditing":![],"checkout.giftRecipientForm.isValid":!![],"checkout.shippingAddress":c.shippingAddress,"checkout.deliveryInstructions":n});const l=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_GIFT_INFORMATION_UPDATED,{cartId:l});const d=this.store.get("checkout");this.googleTagManager.addShippingInfo([...Object.values(d.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}})],(null===(s=d.promoCode)||void 0===s?void 0:s.code)||void 0)}finally{this.store.set("checkout.giftRecipientForm.isSaving",![])}}async editPaymentForm(){this.store.set("checkout.paymentForm.isEditing",!![])}async savePaymentForm({billingFormData:t,paymentSession:n}){var r,s,a;try{this.store.set("checkout.paymentForm.isSaving",!![]);const c=this.store.get("checkout"),l={},d=this.clientConfig.isDevelopment()&&this.clientConfig.get("paymentMethodId");let h=null,p=null;if(d||n){const t=await this.confirmPaymentSession((null==n?void 0:n.confirmationTokenId)||"",(null==n?void 0:n.setupIntentId)||"");if(!t)throw new Error("Failed to confirm payment method");h=t.card,p=t.id}const m=this.dataForCheckoutPrepare({billingData:t,paymentMethodId:p||void 0}),f=await this.api.prepareCheckout(m);if(f.payment&&h&&(l["checkout.paymentForm.paymentMethod"]={id:f.payment,card:h}),t&&f.billingAddress){l["checkout.paymentForm.data"]={firstName:f.billingAddress.firstName||"",lastName:f.billingAddress.lastName||"",email:f.billingAddress.email||"",phone:f.billingAddress.phone||"",company:f.billingAddress.company||"",addressOne:f.billingAddress.one||"",addressTwo:f.billingAddress.two||"",city:f.billingAddress.city||"",state:f.billingAddress.state||"",zipCode:f.billingAddress.zip||""};const t=this.store.get("checkout.cartId");this.pubSub.publishAction(e.CHECKOUT_BILLING_INFORMATION_UPDATED,{cartId:t})}l["checkout.paymentForm.isEditing"]=![],l["checkout.paymentForm.isValid"]=!![],this.store.batch(l);const g=l["checkout.paymentForm.paymentMethod"]||(null===(r=c.paymentForm)||void 0===r?void 0:r.paymentMethod),v=(null===(s=null==g?void 0:g.card)||void 0===s?void 0:s.brand)?g.card.brand+" ****"+g.card.last4:"card";this.googleTagManager.addPaymentInfo(Object.values(c.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}}),v,(null===(a=c.promoCode)||void 0===a?void 0:a.code)||void 0)}catch(c){throw this.logger.error("Failed to save payment form",c),this.store.set("checkout.error",c.message),c}finally{this.store.set("checkout.paymentForm.isSaving",![])}}async checkoutComplete(){var t,n,s,a,c,l;try{this.store.set("checkout.loading",!![]),this.pubSub.publishAction(e.CHECKOUT_SUBMIT_STARTED,{started:!![]});const d=this.store.get("checkout"),{orderNumber:h}=await this.api.checkoutComplete(d.token);d.presale||this.store.set("cart.shouldReset",!![]);const p={orderNumber:h,orderTotal:d.amounts.total,cardLast4:(null===(s=null===(n=null===(t=null==d?void 0:d.paymentForm)||void 0===t?void 0:t.paymentMethod)||void 0===n?void 0:n.card)||void 0===s?void 0:s.last4)||"",customerEmail:d.customerForm.data.email,giftRecipientEmail:(null===(c=null===(a=null==d?void 0:d.giftRecipientForm)||void 0===a?void 0:a.data)||void 0===c?void 0:c.email)||null,checkoutToken:d.token,cartId:d.cartId},m=this.store.get("metadata.checkout.injection");if(null==m?void 0:m.containerId){const t=document.getElementById(m.containerId);if(t){const e=ComponentFactoryService.createElement({type:r.CHECKOUT_COMPLETED,useShadowDom:!![],isIndependentComponent:!![],wrapInLceElement:!![],...p});safeReplaceChildren(t,e)}}else this.uiCommands.openDrawer(r.CHECKOUT_COMPLETED,p);this.pubSub.publishAction(e.CHECKOUT_SUBMIT_COMPLETED,{orderNumber:h,orderTotal:d.amounts.total}),this.googleTagManager.purchase({transaction_id:h,tax:centToDollar(d.amounts.tax+d.amounts.service+d.amounts.platform),shipping:centToDollar(d.amounts.shipping||0),coupon:(null===(l=d.promoCode)||void 0===l?void 0:l.code)||void 0,items:[...Object.values(d.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}})],value:centToDollar(d.amounts.total),subtotal:centToDollar(d.amounts.subtotal),total_before_discounts:centToDollar(d.amounts.subtotal+d.amounts.tax+d.amounts.service+d.amounts.platform+d.amounts.shipping+d.amounts.delivery),discounts:centToDollar(d.amounts.discounts),gift_cards:centToDollar(d.amounts.giftCards||0),net_total:centToDollar(d.amounts.total)})}catch(d){const t=(null==d?void 0:d.message)||"Checkout complete failed";this.store.batch({"checkout.error":t}),this.pubSub.publishAction(e.CHECKOUT_SUBMIT_FAILED,{message:t})}finally{this.store.set("checkout.loading",![])}}updateStoreFromCheckoutResponse(t){const e={"checkout.amounts":t.amounts,"checkout.events":t.events,"checkout.error":null};if(t.retailers&&Object.values(t.retailers).length>0)for(const n of Object.values(t.retailers))for(const t of Object.values(n.fulfillments))e["checkout.fulfillments."+t.id]=t;this.store.batch(e)}syncFromItemUpdate(t,e){var n,r,s,a,c;try{this.store.set("checkout.updating",!![]);const l=this.store.get("cart");for(const t of Object.keys(l.items||{}))this.store.remove("cart.items."+t);for(const t of Object.keys(l.retailers||{}))this.store.remove("cart.retailers."+t);for(const t of Object.keys(l.fulfillments||{}))this.store.remove("cart.fulfillments."+t);const d={"cart.id":t.id,"cart.error":null,"cart.subtotal":t.subtotal,"cart.itemsQuantity":t.itemsQuantity,"cart.events":t.events||[],"cart.promoCode":(null===(n=t.promoCode)||void 0===n?void 0:n.code)?{...t.promoCode,error:null}:null};if((null===(r=Object.values(t.items))||void 0===r?void 0:r.length)>0)for(const e of Object.values(t.items))d["cart.items."+e.id]=e;if((null===(s=Object.values(t.retailers))||void 0===s?void 0:s.length)>0)for(const e of Object.values(t.retailers))if(d["cart.retailers."+e.id]=e,(null===(a=Object.values(e.fulfillments))||void 0===a?void 0:a.length)>0)for(const t of Object.values(e.fulfillments))d["cart.fulfillments."+t.id]=t;this.store.batch(d);const h={"checkout.token":e.token,"checkout.events":e.events,"checkout.amounts":e.amounts,"checkout.shippingAddress":e.shippingAddress,"checkout.itemsQuantity":e.itemsQuantity,"checkout.error":null,"checkout.promoCodeError":null,"checkout.giftCardError":null,"checkout.giftCards":e.giftCards.map(t=>({code:t.code,discount:t.applied})),"checkout.promoCode":(null===(c=null==e?void 0:e.promoCode)||void 0===c?void 0:c.code)?null==e?void 0:e.promoCode:null};if(Object.values(e.items).length>0){this.store.remove("checkout.items");for(const t of Object.values(e.items))h["checkout.items."+t.cartItemId]={...t,loading:![],updating:![],error:null}}if(e.retailers&&Object.values(e.retailers).length>0){this.store.remove("checkout.fulfillments"),this.store.remove("checkout.retailers");for(const t of Object.values(e.retailers)){h["checkout.retailers."+t.id]=t;for(const e of Object.values(t.fulfillments))h["checkout.fulfillments."+e.id]=e}}this.store.batch(h)}finally{this.store.set("checkout.updating",![])}}syncCheckoutState(t){var e;const n={"checkout.token":t.token,"checkout.events":t.events,"checkout.amounts":t.amounts,"checkout.shippingAddress":t.shippingAddress,"checkout.error":null,"checkout.promoCodeError":null,"checkout.giftCardError":null,"checkout.giftCards":t.giftCards.map(t=>({code:t.code,discount:t.applied})),"checkout.promoCode":(null===(e=null==t?void 0:t.promoCode)||void 0===e?void 0:e.code)?null==t?void 0:t.promoCode:null};if(Object.values(t.items).length>0){this.store.remove("checkout.items");for(const e of Object.values(t.items))n["checkout.items."+e.cartItemId]={...e,loading:![],updating:![],error:null}}if(t.retailers&&Object.values(t.retailers).length>0){this.store.remove("checkout.fulfillments"),this.store.remove("checkout.retailers");for(const e of Object.values(t.retailers)){n["checkout.retailers."+e.id]=e;for(const t of Object.values(e.fulfillments))n["checkout.fulfillments."+t.id]=t}}this.store.batch(n)}async refreshCheckout(t){var n;try{let e;if(this.store.set("checkout.updating",!![]),null==t?void 0:t.response)e=t.response;else{const r=null!==(n=null==t?void 0:t.cartId)&&void 0!==n?n:this.store.get("checkout.cartId");if(!r)return this.store.set("checkout.error","Cart ID is not provided"),void 0;const s=this.dataForCheckoutPrepare({});e=await this.api.prepareCheckout({...s,cartId:r})}this.syncCheckoutState(e)}catch(r){const t=(null==r?void 0:r.message)||"Failed to refresh checkout data. Please try again.";throw this.store.set("checkout.error",t),this.pubSub.publishAction(e.CHECKOUT_FAILED,{message:t}),r}finally{this.store.set("checkout.updating",![])}}dataForCheckoutPrepare({customer:t,giftRecipient:e,billingData:n,marketingPreferences:r,shippingAddressTwo:a,deliveryInstructions:c,deliveryTips:l,paymentMethodId:d,isGift:h}){var p,m,f,g,v,y,b,x,w,C,_,E,T,P,D,A,F,O,M,L,N,z,j;const B=this.store.get("checkout"),q=null!==(m=null===(p=B.paymentForm)||void 0===p?void 0:p.billingSameAsShipping)&&void 0!==m?m:!![],U=void 0!==h?h:B.isGift,V=e?!![]:null!==(g=null===(f=B.giftRecipientForm)||void 0===f?void 0:f.isValid)&&void 0!==g?g:![],G=U&&V,H={cartId:B.cartId,shippingAddressTwo:a,billingSameAsShipping:q,marketingPreferences:r||B.marketingPreferences,promoCode:(null===(v=B.promoCode)||void 0===v?void 0:v.code)||void 0,isGift:G,giftCards:(null===(y=null==B?void 0:B.giftCards)||void 0===y?void 0:y.map(t=>t.code))||[],deliveryTips:l||Object.values(B.fulfillments||{}).filter(t=>t.type===s.ON_DEMAND).map(t=>({fulfillmentId:t.id,tip:t.amounts.tip}))};d?H.payment=d:(null===(x=null===(b=B.paymentForm)||void 0===b?void 0:b.paymentMethod)||void 0===x?void 0:x.id)&&(H.payment=B.paymentForm.paymentMethod.id);const K=c||B.deliveryInstructions;if(K&&(H.deliveryInstructions=Object.values(B.items||{}).map(t=>({fulfillmentId:t.fulfillmentId,instructions:K}))),H.customer=t||((null===(C=null===(w=null==B?void 0:B.customerForm)||void 0===w?void 0:w.data)||void 0===C?void 0:C.email)?{firstName:null===(E=null===(_=B.customerForm)||void 0===_?void 0:_.data)||void 0===E?void 0:E.firstName,lastName:null===(P=null===(T=B.customerForm)||void 0===T?void 0:T.data)||void 0===P?void 0:P.lastName,email:null===(A=null===(D=B.customerForm)||void 0===D?void 0:D.data)||void 0===A?void 0:A.email,phone:null===(O=null===(F=B.customerForm)||void 0===F?void 0:F.data)||void 0===O?void 0:O.phone,birthDate:null===(L=null===(M=B.customerForm)||void 0===M?void 0:M.data)||void 0===L?void 0:L.birthDate,company:null===(z=null===(N=B.customerForm)||void 0===N?void 0:N.data)||void 0===z?void 0:z.company}:void 0),G){const t=e||(null===(j=B.giftRecipientForm)||void 0===j?void 0:j.data);t&&(H.giftOptions=t)}return q||(n?H.billingAddress={firstName:n.firstName,lastName:n.lastName,email:n.email,phone:n.phone,company:n.company,one:n.one,two:n.two,city:n.city,state:n.state,zip:n.zip}:B.paymentForm.data&&(H.billingAddress=B.paymentForm.data)),H}getDetails(){var t,e,n,r;const s=this.store.get("checkout"),a={};for(const c in s.items||{}){const t=s.items[c];a[c]={liquidId:t.liquidId,variantId:t.variantId,cartItemId:c,retailerId:t.retailerId,fulfillmentId:t.fulfillmentId,salsifyPid:t.salsifyPid,salsifyGrouping:t.salsifyGrouping,name:t.name,catPath:t.catPath,volume:t.volume,uom:t.uom,proof:t.proof,abv:t.abv,containerType:t.containerType,container:t.container,size:t.size,pack:t.pack,packDesc:t.packDesc,mainImage:t.mainImage,brand:t.brand,partNumber:t.partNumber,upc:t.upc,sku:t.sku,price:t.price,unitPrice:t.unitPrice,quantity:t.quantity,tax:t.tax,unitTax:t.unitTax,bottleDeposits:t.bottleDeposits,attributes:t.attributes}}return{cartId:s.cartId,isGift:s.isGift||![],billingSameAsShipping:(null===(t=s.paymentForm)||void 0===t?void 0:t.billingSameAsShipping)||!![],marketingPreferences:{canEmail:(null===(e=s.marketingPreferences)||void 0===e?void 0:e.canEmail)||![],canSms:(null===(n=s.marketingPreferences)||void 0===n?void 0:n.canSms)||![]},hasPromoCode:Boolean(null===(r=s.promoCode)||void 0===r?void 0:r.code),hasGiftCards:Array.isArray(s.giftCards)&&s.giftCards.length>0,amounts:s.amounts,itemCount:Object.values(a).reduce((t,e)=>t+(e.quantity||0),0),items:a}}}class ProductCommands extends BaseCommand{constructor(){super(),this.uiCommands=UICommands.getInstance(),this.cartCommands=CartCommands.getInstance(),this.checkoutCommands=CheckoutCommands.getInstance()}static getInstance(){return SingletonManager.getClassInstance("ProductCommands",()=>new ProductCommands)}async createProductInstance(t,e=![]){this.store.createProductInstance(t),e&&this.store.set("products."+t+".loading",!![])}async loadMultipleProducts(t){var e;if(!Array.isArray(t)||0===t.length)return this.logger.warn("No product IDs provided for loading multiple products."),void 0;this.store.batch(t.reduce((t,e)=>(t["products."+e+".loading"]=!![],t["products."+e+".error"]=null,t),{}));const n=await this.api.getProductsData(t,this.getLocation());if(!n||!n.products||0===n.products.length)return this.logger.warn("No product data found for the provided product IDs."),this.store.batch(t.reduce((t,e)=>(t["products."+e+".loading"]=![],t["products."+e+".error"]=!![],t),{})),void 0;const r=[];for(const a of n.products){const s=Object.values(a.sizes).filter(e=>t.some(t=>t===(e.upc||e.id||a.salsifyGrouping))),c=t.find(t=>s.some(e=>t===e.upc||t===e.id)||t===a.salsifyGrouping),l=c||(null===(e=null==s?void 0:s[0])||void 0===e?void 0:e.upc);await this.loadProduct(l,{products:[a],retailers:n.retailers}),r.push(l)}const s=t.filter(t=>-1===r.indexOf(t));this.store.batch(s.reduce((t,e)=>(t["products."+e+".loading"]=![],t["products."+e+".error"]="Product data not found",t),{}))}async loadProduct(t,n=null){var r,s;try{const a=this.store.get("products."+t);a.loading||this.store.set("products."+t+".loading",!![]);let c=null;if(n&&(c=n),n||(c=await this.api.getProductsData([t],this.getLocation())),!c||!(null===(r=null==c?void 0:c.products)||void 0===r?void 0:r[0]))return this.store.set("products."+t+".error","Product data not found"),void 0;const l=this.loadProductStoreUpdate(c);if(!l)return this.store.set("products."+t+".error","Failed to process product data"),void 0;this.store.set("products."+t,{...l,identifier:t}),this.pubSub.publishAction(e.PRODUCT_LOADED,this.productDataForEventFromStore(t));const d=c.products[0],h=l.sizes[l.selectedSizeId||""],p=Boolean(this.getLocation()),m=l.selectedFulfillment,f=p&&(null==m?void 0:m.variant.price)?m.variant.price:l.noAvailabilityPrice,g=splitCategoryPath(d.catPath);this.googleTagManager.viewItem({item_id:null==h?void 0:h.id,item_name:d.name,item_brand:d.brand,item_size:null==h?void 0:h.size,item_category:g.category,item_category2:g.category2,item_category3:g.category3,price:centToDollar(f),item_type:d.type,item_subtype:d.subType,item_image:(null==h?void 0:h.image)||(null===(s=d.images)||void 0===s?void 0:s[0]),upc:null==h?void 0:h.upc,grouping_id:d.salsifyGrouping,product_id:null==h?void 0:h.id})}catch(a){this.store.set("products."+t+".error",a.message),this.logger.error("Failed to load product data for ID "+t,a)}finally{this.store.set("products."+t+".loading",![])}}async selectSize(t,n){var r,a,c;const l=this.store.get("products."+t),d=l.sizes[n],h=Object.values(d.shippingFulfillments),p=Object.values(d.onDemandFulfillments),m=h.length>0,f=p.length>0,g=m||f;let v=l.selectedFulfillmentType,y=null,b=null;const x=v===s.SHIPPING?m:f;!x&&g&&(v=v===s.SHIPPING?s.ON_DEMAND:s.SHIPPING);const w=v===s.SHIPPING?h:p;w.length>0&&(y=w[0],b=y.id);const C=w.length>0,_=splitCategoryPath(l.catPath);this.googleTagManager.viewItem({item_id:null==d?void 0:d.id,item_name:l.name,item_brand:l.brand,item_size:null==d?void 0:d.size,item_category:_.category,item_category2:_.category2,item_category3:_.category3,price:centToDollar((null==y?void 0:y.variant.price)||l.noAvailabilityPrice),item_type:l.type,item_subtype:l.subType,item_image:(null==d?void 0:d.image)||(null===(r=l.images)||void 0===r?void 0:r[0]),upc:null==d?void 0:d.upc,grouping_id:l.salsifyGrouping,product_id:null==d?void 0:d.id}),g||this.googleTagManager.productSizeNoAvailability({productId:null==d?void 0:d.id,productName:l.name,productBrand:l.brand,productCategory:_.category,productCategory2:_.category2,productCategory3:_.category3,productType:l.type,productSubtype:l.subType,productPrice:l.noAvailabilityPrice,sizeId:n,sizeName:null==d?void 0:d.size,upc:null==d?void 0:d.upc,groupingId:l.salsifyGrouping,address:this.store.get("address.address"),reason:"No fulfillments available for this size"}),this.pubSub.publishAction(e.PRODUCT_SIZE_CHANGED,{identifier:t,selectedSizeId:n,selectedSize:(null===(a=l.sizes[n])||void 0===a?void 0:a.size)||"",previousSizeId:l.selectedSizeId||"",previousSize:(null===(c=l.sizes[l.selectedSizeId])||void 0===c?void 0:c.size)||""}),this.store.batch({["products."+t+".selectedSizeId"]:n,["products."+t+".productHasAvailability"]:g,["products."+t+".fulfillmentHasAvailability"]:C,["products."+t+".selectedFulfillmentType"]:v,["products."+t+".selectedFulfillment"]:y,["products."+t+".selectedFulfillmentId"]:b})}async selectFulfillment(t,n){var r;const a=this.store.get("products."+t),c=a.sizes[a.selectedSizeId],l=a.selectedFulfillmentType===s.SHIPPING?c.shippingFulfillments:c.onDemandFulfillments,d=l[n];this.pubSub.publishAction(e.PRODUCT_FULFILLMENT_CHANGED,{identifier:t,selectedFulfillmentId:n,selectedFulfillmentType:a.selectedFulfillmentType,previousFulfillmentId:a.selectedFulfillmentId||"",previousFulfillmentType:a.selectedFulfillmentType});const h=splitCategoryPath(a.catPath);this.googleTagManager.viewItem({item_id:null==c?void 0:c.id,item_name:a.name,item_brand:a.brand,item_size:null==c?void 0:c.size,item_category:h.category,item_category2:h.category2,item_category3:h.category3,price:centToDollar((null==d?void 0:d.variant.price)||a.noAvailabilityPrice),item_type:a.type,item_subtype:a.subType,item_image:(null==c?void 0:c.image)||(null===(r=a.images)||void 0===r?void 0:r[0]),upc:null==c?void 0:c.upc,grouping_id:a.salsifyGrouping,product_id:null==c?void 0:c.id}),this.store.batch({["products."+t+".selectedFulfillment"]:d,["products."+t+".selectedFulfillmentId"]:n,["products."+t+".quantity"]:1})}async updateQuantity(t,n){var r;const s=this.store.get("products."+t),a=s.quantity,c=a+n,l=1,d=(null===(r=null==s?void 0:s.selectedFulfillment)||void 0===r?void 0:r.variant.stock)||5,h=Math.max(l,Math.min(d,c));this.pubSub.publishAction(n<0?e.PRODUCT_QUANTITY_DECREASE:e.PRODUCT_QUANTITY_INCREASE,{identifier:t,quantity:h,previousQuantity:a}),this.store.set("products."+t+".quantity",h)}async changeFulfillmentType(t,n){var r,a;const c=this.store.get("products."+t),l=c.sizes[c.selectedSizeId],d=n===s.SHIPPING?l.shippingFulfillments:l.onDemandFulfillments,h=Object.values(d);if(0===h.length){const t=splitCategoryPath(c.catPath);return this.googleTagManager.productFulfillmentNoAvailability({productId:null==l?void 0:l.id,productName:c.name,productBrand:c.brand,productCategory:t.category,productCategory2:t.category2,productCategory3:t.category3,productType:c.type,productSubtype:c.subType,productPrice:c.noAvailabilityPrice,sizeId:null!==(r=c.selectedSizeId)&&void 0!==r?r:void 0,sizeName:null==l?void 0:l.size,fulfillmentType:n,upc:null==l?void 0:l.upc,groupingId:c.salsifyGrouping,address:this.store.get("address.address"),reason:"No "+n+" fulfillments available for selected size"}),void 0}const p=h[0]||null,m=(null==p?void 0:p.id)||null;this.pubSub.publishAction(e.PRODUCT_FULFILLMENT_TYPE_CHANGED,{identifier:t,selectedFulfillmentType:n,selectedFulfillmentId:m,previousFulfillmentType:c.selectedFulfillmentType,previousFulfillmentId:c.selectedFulfillmentId,fulfillmentHasAvailability:h.length>0});const f=splitCategoryPath(c.catPath);this.googleTagManager.viewItem({item_id:null==l?void 0:l.id,item_name:c.name,item_brand:c.brand,item_size:null==l?void 0:l.size,item_category:f.category,item_category2:f.category2,item_category3:f.category3,price:centToDollar((null==p?void 0:p.variant.price)||c.noAvailabilityPrice),item_type:c.type,item_subtype:c.subType,item_image:(null==l?void 0:l.image)||(null===(a=c.images)||void 0===a?void 0:a[0]),upc:null==l?void 0:l.upc,grouping_id:c.salsifyGrouping,product_id:null==l?void 0:l.id}),this.store.batch({["products."+t+".selectedFulfillmentType"]:n,["products."+t+".selectedFulfillment"]:p,["products."+t+".selectedFulfillmentId"]:m,["products."+t+".fulfillmentHasAvailability"]:h.length>0})}async removeProduct(t){this.store.removeProductInstance(t)}async openProductDrawer(t,e,n){const r={type:e,data:n||{}};this.store.batch({["products."+t+".drawer.isOpen"]:!![],["products."+t+".drawer.contentConfig"]:r})}async closeProductDrawer(t){this.store.set("products."+t+".drawer.isOpen",![])}async rerenderAllProducts(){const t=this.store.getProductInstances(),e=Object.keys(t);for(const n of e)this.store.set("products."+n+".rerender",!![])}async addToCart(t,e){try{this.store.set("products."+t+".updating",!![]),this.uiCommands.openDrawer(r.CART),await this.cartCommands.addItem(e),this.store.batch({["products."+t+".quantity"]:1,["products."+t+".updating"]:![]});const n=this.store.get("cart");this.googleTagManager.viewCart([...Object.values(n.items||{}).map(t=>{const e=splitCategoryPath(t.catPath);return{item_id:t.liquidId,item_name:t.name,item_brand:t.brand,item_size:t.size,item_category:e.category,item_category2:e.category2,item_category3:e.category3,quantity:t.quantity,price:centToDollar(t.unitPrice||0),item_image:t.mainImage,upc:t.upc,grouping_id:t.salsifyGrouping,product_id:t.liquidId}})])}catch(n){this.logger.error("Error adding to cart",n),this.store.set("products."+t+".updating",![])}}async addPresaleToCart(t,e){try{this.store.set("products."+t+".updating",!![]),await this.checkoutCommands.addPresaleItem(e),this.clientConfig.isBuilder()||this.checkoutCommands.openCheckout(),this.store.batch({["products."+t+".quantity"]:1,["products."+t+".updating"]:![]})}catch(n){this.logger.error("Error adding presale item to checkout",n),this.store.set("products."+t+".updating",![])}}productDataForEventFromStore(t){const e=this.store.get("products."+t);if(!e)throw new Error('Product store not found for identifier "'+t+'"');const fulfillmentEventData=t=>t?Object.entries(t).reduce((t,[e,n])=>(t[e]={...n},t),{}):{},n=Object.entries(e.sizes||{}).reduce((t,[e,n])=>{const{loading:r,error:s,shippingFulfillments:a,onDemandFulfillments:c,...l}=n;return t[e]={...l,shippingFulfillments:fulfillmentEventData(a),onDemandFulfillments:fulfillmentEventData(c)},t},{});return{identifier:t,selectedSizeId:e.selectedSizeId||null,selectedFulfillmentType:e.selectedFulfillmentType,selectedFulfillmentId:e.selectedFulfillmentId||null,productHasAvailability:Boolean(e.productHasAvailability),fulfillmentHasAvailability:Boolean(e.fulfillmentHasAvailability),id:e.id,name:e.name,brand:e.brand,catPath:e.catPath,category:e.category,classification:e.classification,type:e.type,subType:e.subType,salsifyGrouping:e.salsifyGrouping,description:e.description,htmlDescription:e.htmlDescription,tastingNotes:e.tastingNotes,images:e.images||[],region:e.region,country:e.country,material:e.material,abv:e.abv,proof:e.proof,age:e.age,color:e.color,flavor:e.flavor,variety:e.variety,appellation:e.appellation,vintage:e.vintage,noAvailabilityPrice:e.noAvailabilityPrice,sizes:n}}findFirstAvailableSize(t){const e=Object.values(t);for(const n of e){const t=n.shippingFulfillments||{},e=n.onDemandFulfillments||{},r=Object.values(t).length,s=Object.values(e).length;if(r+s>0)return n.id}return null}loadProductStoreUpdate({products:[t,...e],retailers:n}){var r,a,c,l,d;try{const e=this.themeProvider.getConfigs("product"),h={id:t.id,brand:t.brand,category:t.category,catPath:t.catPath,classification:t.classification,type:t.type,subType:t.subType,salsifyGrouping:t.salsifyGrouping,name:t.name,description:t.description,htmlDescription:t.htmlDescription,images:t.images,region:t.region,country:t.country,material:t.material,abv:t.abv,proof:t.proof,age:t.age,color:t.color,flavor:t.flavor,variety:t.variety,appellation:t.appellation,vintage:t.vintage,tastingNotes:t.tastingNotes,noAvailabilityPrice:t.noAvailabilityPrice,identifier:"",sizes:{},quantity:1,selectedSizeId:null,selectedFulfillmentType:e.layout.enableShippingFulfillment?s.SHIPPING:s.ON_DEMAND,selectedFulfillmentId:null,selectedFulfillment:null,productHasAvailability:![],fulfillmentHasAvailability:![],drawer:{isOpen:![],contentConfig:null},loading:![],updating:![],rerender:![],error:null};if(t.sizes&&Object.values(t.sizes).length>0)for(const{shippingVariants:r,onDemandVariants:s,...a}of Object.values(t.sizes)){h.sizes[a.id]={...a,shippingFulfillments:{},onDemandFulfillments:{},loading:![],error:null};for(const t of Object.values(r)){const e=n[t.retailerId];(null==e?void 0:e.shippingFulfillment)&&(h.sizes[a.id].shippingFulfillments[e.shippingFulfillment.id]={...e.shippingFulfillment,retailerName:e.name,retailerAddress:e.address,retailerAddressFormatted:e.addressFormatted,variant:t})}for(const t of Object.values(s)){const e=n[t.retailerId];(null==e?void 0:e.onDemandFulfillment)&&(h.sizes[a.id].onDemandFulfillments[e.onDemandFulfillment.id]={...e.onDemandFulfillment,retailerName:e.name,retailerAddress:e.address,retailerAddressFormatted:e.addressFormatted,variant:t})}}const p=Object.values(h.sizes),m=this.findFirstAvailableSize(h.sizes);h.selectedSizeId=m||(null===(r=p[0])||void 0===r?void 0:r.id)||"";const f=(null===(a=h.sizes[h.selectedSizeId])||void 0===a?void 0:a.shippingFulfillments)||{},g=(null===(c=h.sizes[h.selectedSizeId])||void 0===c?void 0:c.onDemandFulfillments)||{};h.productHasAvailability=Object.values(f).length+Object.values(g).length>0;const v=h.selectedFulfillmentType===s.SHIPPING?Object.values(f):Object.values(g);if(h.fulfillmentHasAvailability=v.length>0,h.selectedFulfillment=v[0]||null,h.selectedFulfillmentId=(null===(l=h.selectedFulfillment)||void 0===l?void 0:l.id)||null,!h.fulfillmentHasAvailability){const t=h.selectedFulfillmentType===s.SHIPPING?s.ON_DEMAND:s.SHIPPING,e=t===s.SHIPPING?Object.values(f):Object.values(g);e.length>0&&(h.selectedFulfillmentType=t,h.selectedFulfillment=e[0],h.selectedFulfillmentId=(null===(d=h.selectedFulfillment)||void 0===d?void 0:d.id)||null,h.fulfillmentHasAvailability=!![])}if(!h.productHasAvailability){const e=splitCategoryPath(t.catPath),n=h.sizes[h.selectedSizeId];this.googleTagManager.productNoAvailability({productId:null==n?void 0:n.id,productName:t.name,productBrand:t.brand,productCategory:e.category,productCategory2:e.category2,productCategory3:e.category3,productType:t.type,productSubtype:t.subType,productPrice:t.noAvailabilityPrice,upc:null==n?void 0:n.upc,groupingId:t.salsifyGrouping,address:this.store.get("address.address"),reason:"No fulfillments available for any size"})}return h}catch(h){throw this.logger.error("Product data processing error",h),h}}}class AddressCommands extends BaseCommand{constructor(){super(),this.productCommands=ProductCommands.getInstance(),this.cartCommands=CartCommands.getInstance()}static getInstance(){return SingletonManager.getClassInstance("AddressCommands",()=>new AddressCommands)}async searchAddresses(t){return!t||t.length<3?[]:await this.api.getAddressSuggestions(t)}async getAddressDetails(t){return await this.api.getAddressDetails(t)}async setSelectedAddress(t){try{this.store.batch({"address.id":t.id,"address.formattedAddress":t.formattedAddress,"address.address":t.address,"address.coordinates":t.coordinates});const e=this.store.get("products");await this.productCommands.loadMultipleProducts(Object.keys(e)),await this.cartCommands.resetCart(),await this.store.persist()}catch(n){throw this.googleTagManager.addressFailed({googlePlacesId:t.id,formattedAddress:t.formattedAddress,address:{one:t.address.one,two:t.address.two,city:t.address.city,state:t.address.state,zip:t.address.zip,country:t.address.country||""},error:(null==n?void 0:n.message)||"Failed to update downstream state after address change"}),this.pubSub.publishAction(e.ADDRESS_FAILED,{googlePlacesId:t.id,formattedAddress:t.formattedAddress,address:t.address,coordinates:t.coordinates,error:(null==n?void 0:n.message)||"Failed to update downstream state after address change"}),n}this.googleTagManager.addressUpdated({googlePlacesId:t.id,formattedAddress:t.formattedAddress,address:{one:t.address.one,two:t.address.two,city:t.address.city,state:t.address.state,zip:t.address.zip,country:t.address.country},coordinates:t.coordinates}),this.pubSub.publishAction(e.ADDRESS_UPDATED,{googlePlacesId:t.id,address:{one:t.address.one,two:t.address.two,city:t.address.city,state:t.address.state,zip:t.address.zip,country:t.address.country},coordinates:t.coordinates,formattedAddress:t.formattedAddress})}async setAddressManually(t,n){try{const e=this.buildFormattedAddressString(t),r={id:"",formattedAddress:e,address:t,coordinates:n};await this.setSelectedAddress(r)}catch(r){throw this.googleTagManager.addressFailed({googlePlacesId:"",formattedAddress:this.buildFormattedAddressString(t),address:{one:t.one,two:t.two,city:t.city,state:t.state,zip:t.zip,country:t.country},error:(null==r?void 0:r.message)||"Failed to set manual address"}),this.pubSub.publishAction(e.ADDRESS_FAILED,{googlePlacesId:"",formattedAddress:this.buildFormattedAddressString(t),address:t,coordinates:n,error:(null==r?void 0:r.message)||"Failed to set manual address"}),r}}async clearSelectedAddress(){this.store.set("address",f),this.pubSub.publishAction(e.ADDRESS_CLEARED,!![]),await this.cartCommands.resetCart();const t=this.clientConfig.get("userDeviceId");await this.api.deletePersistedStore(t),this.store.clearLocalStorage()}getDetails(){const t=this.store.get("address");return t.id?{id:t.id,formattedAddress:t.formattedAddress,address:t.address,coordinates:t.coordinates}:null}buildFormattedAddressString(t){var e,n,r,s,a,c;const l=[],d=[];(null===(e=t.one)||void 0===e?void 0:e.trim())&&d.push(t.one.trim()),(null===(n=t.two)||void 0===n?void 0:n.trim())&&d.push(t.two.trim()),d.length>0&&l.push(d.join(" ")),(null===(r=t.city)||void 0===r?void 0:r.trim())&&l.push(t.city.trim());const h=[];return(null===(s=t.state)||void 0===s?void 0:s.trim())&&h.push(t.state.trim()),(null===(a=t.zip)||void 0===a?void 0:a.trim())&&h.push(t.zip.trim()),h.length>0&&l.push(h.join(" ")),(null===(c=t.country)||void 0===c?void 0:c.trim())&&l.push(t.country.trim()),l.join(", ")}}const dt={BRANDS:"brands",FLAVOR:"flavor",FULFILLMENT:"fulfillment",REGION:"region",VARIETY:"variety",ENGRAVING:"engraving",PRICE:"price",PRESALE:"presale",CATEGORIES:"categories",SIZES:"sizes",APPELLATION:"appellation",COUNTRY:"country",VINTAGE:"vintage",MATERIALS:"materials"},ht={ALL:"all",SHIPPING:"shipping",ON_DEMAND:"onDemand"},ut={MIN:"0",MAX:"1000"},pt={YES:"YES",NO:"NO"};class ProductListCommands extends BaseCommand{constructor(){super(),this.FILTER_TYPE_MAP={[dt.BRANDS]:h.BRANDS,[dt.CATEGORIES]:h.CATEGORIES,[dt.FLAVOR]:h.FLAVOR,[dt.REGION]:h.REGION,[dt.VARIETY]:h.VARIETY,[dt.VINTAGE]:h.VINTAGE,[dt.COUNTRY]:h.COUNTRY,[dt.APPELLATION]:h.APPELLATION,[dt.MATERIALS]:h.MATERIALS,[dt.SIZES]:h.SIZES,[dt.PRESALE]:h.PRESALE,[dt.ENGRAVING]:h.ENGRAVING,[dt.FULFILLMENT]:h.FULFILLMENT},this.listeners=new Set,this.selectFulfillmentType=async(t,e)=>{var n;const r=this.getStoreState(),a=r.products.find(e=>(e.salsifyGrouping||e.id)===t),c=r.userProducts[t].selectedSizeId,l=a?Object.values(a.sizes).find(t=>t.id===c):void 0;if(!l)return;const d=e===s.SHIPPING?Object.values(l.shippingFulfillments):Object.values(l.onDemandFulfillments),h=d[0];if(!h)return;const p=h.variant,m=r.retailers,f=m[p.retailerId];if(!f)return;const g=e===s.SHIPPING?f.shippingFulfillment:f.onDemandFulfillment,v={...r.userProducts,[t]:{...r.userProducts[t],selectedFulfillmentType:e,selectedFulfillment:g?{...g,id:null!==(n=g.id)&&void 0!==n?n:"",retailerName:f.name,retailerAddress:f.address,retailerAddressFormatted:f.addressFormatted,variant:p,image:l.image}:null}};this.store.set("productsList.userProducts",v),this.notifyListeners()},this.selectFulfillment=async(t,e)=>{var n,r;const a=this.getStoreState(),c=a.products.find(e=>(e.salsifyGrouping||e.id)===t),l=a.userProducts[t].selectedSizeId,d=c?Object.values(c.sizes).find(t=>t.id===l):void 0;if(!d)return;const h=Object.values(d.shippingFulfillments||{}).find(t=>t.id===e),p=Object.values(d.onDemandFulfillments||{}).find(t=>t.id===e),m=h||p;if(!m)return;const f=h?s.SHIPPING:s.ON_DEMAND,g=null===(n=m.variant)||void 0===n?void 0:n.retailerId,v=g?a.retailers[g]:void 0;if(!v)return;const y=f===s.SHIPPING?v.shippingFulfillment:v.onDemandFulfillment,b={...a.userProducts,[t]:{...a.userProducts[t],selectedFulfillmentType:f,selectedFulfillment:y?{...y,id:null!==(r=y.id)&&void 0!==r?r:"",retailerName:v.name,retailerAddress:v.address,retailerAddressFormatted:v.addressFormatted,variant:m.variant,image:d.image}:null}};this.store.set("productsList.userProducts",b),this.notifyListeners()},this.selectSize=async(t,e)=>{var n;const r=this.getStoreState(),s=r.products.find(e=>(e.salsifyGrouping||e.id)===t);if(!s)return;const a=Object.values(s.sizes).find(t=>t.id===e);if(!a)return;const{fulfillment:c,fulfillmentType:l}=this.getFulfillmentForSize(a,r.userProducts[t].selectedFulfillmentType),d={...r.userProducts,[t]:{...r.userProducts[t],selectedSizeId:e,...l?{selectedFulfillmentType:l}:{},...c?{selectedFulfillment:c?{...c,image:null!==(n=c.image)&&void 0!==n?n:null}:null}:{}}};this.store.set("productsList.userProducts",d),this.notifyListeners()},this.updateQuantity=(t,e)=>{const n=this.getStoreState(),r={...n.userProducts,[t]:{...n.userProducts[t],selectedQuantity:e}};this.store.set("productsList.userProducts",r),this.notifyListeners()},this.uiCommands=UICommands.getInstance(),this.cartCommands=CartCommands.getInstance(),this.checkoutCommands=CheckoutCommands.getInstance()}static getInstance(){return SingletonManager.getClassInstance("ProductListCommands",()=>new ProductListCommands)}subscribe(t){this.listeners.add(t);const e=this.getStoreState();try{t(e)}catch(n){this.logger.error("Error in initial state listener call:",n)}return()=>{this.listeners.delete(t)}}getStoreState(){return this.store.get("productsList")}updateSearchTerm(t){this.store.set("productsList.searchTerm",t),this.notifyListeners()}setLoading(t){this.store.set("productsList.loading",t),this.notifyListeners()}notifyListeners(){const t=this.getStoreState();this.listeners.forEach(e=>{try{e(t)}catch(n){this.logger.error("Error in state listener:",n)}})}initializeProductFulfillment(t){const e=Object.values(t.sizes)[0];if(!e)return{sizeId:"",fulfillmentType:null,fulfillment:null};const n=e.id,r=Object.values(e.shippingFulfillments)[0];if(r)return{sizeId:n,fulfillmentType:"shipping",fulfillment:{...r,image:Object.values(t.sizes)[0].image}};const s=Object.values(e.onDemandFulfillments)[0];return s?{sizeId:n,fulfillmentType:"onDemand",fulfillment:{...s,image:t.sizes[0].image}}:{sizeId:n,fulfillmentType:null,fulfillment:null}}transformProductVariantsToFulfillments(t,e){return t.map(t=>this.transformSingleProduct(t,e))}transformSingleProduct(t,e){const n={...t,sizes:{}};if(!t.sizes||0===Object.values(t.sizes).length)return n;for(const[r,s]of Object.entries(t.sizes))n.sizes[r]=this.transformProductSize(s,e);return n}transformProductSize(t,e){const{shippingVariants:n,onDemandVariants:r,...s}=t,a={...s,shippingFulfillments:{},onDemandFulfillments:{},loading:![],error:null};return this.addShippingFulfillments(a,n,e),this.addOnDemandFulfillments(a,r,e),a}addShippingFulfillments(t,e,n){if(e)for(const r of Object.values(e)){const e=n[r.retailerId];(null==e?void 0:e.shippingFulfillment)&&(t.shippingFulfillments[e.shippingFulfillment.id]={...e.shippingFulfillment,retailerName:e.name,retailerAddress:e.address,retailerAddressFormatted:e.addressFormatted,variant:r})}}addOnDemandFulfillments(t,e,n){if(e)for(const r of Object.values(e)){const e=n[r.retailerId];(null==e?void 0:e.onDemandFulfillment)&&(t.onDemandFulfillments[e.onDemandFulfillment.id]={...e.onDemandFulfillment,retailerName:e.name,retailerAddress:e.address,retailerAddressFormatted:e.addressFormatted,variant:r})}}async loadInitialProducts(t,e,n,r,s){try{this.setLoading(!![]);const a=this.buildSearchParams(t,e,n,r,s),c=await this.getProductList(a),l=this.transformProductVariantsToFulfillments(c.products||[],c.retailers||{}),d={};l&&l.length>0&&l.forEach(t=>{var e;const n=t.salsifyGrouping||t.id||"",r=this.initializeProductFulfillment(t);d[n]={selectedSizeId:r.sizeId,selectedQuantity:1,selectedFulfillmentType:r.fulfillmentType||"shipping",selectedFulfillment:r.fulfillment?{...r.fulfillment,image:null!==(e=r.fulfillment.image)&&void 0!==e?e:null}:null,modal:{isOpen:![],contentConfig:null}}}),this.store.batch({"productsList.products":l,"productsList.retailers":c.retailers,"productsList.filters":c.navigation.filters,"productsList.pagination":this.updatePagination(c.navigation),"productsList.loading":![],"productsList.userProducts":d}),this.notifyListeners()}catch(a){throw this.logger.error("Error loading initial products:",a),this.store.batch({"productsList.products":[],"productsList.retailers":{},"productsList.filters":[],"productsList.pagination":{currentPage:0,totalPages:0,totalCount:0,hasMorePages:![]},"productsList.loading":![],"productsList.userProducts":{}}),this.notifyListeners(),a}}async loadMoreProducts(t,e,n,r){try{const s=this.getStoreState(),a=s.pagination;if(!a.hasMorePages)return;this.setLoading(!![]);const c=a.currentPage+1,l=this.buildSearchParams(c,t,e,n,r),d=await this.getProductList(l);if(d.products&&d.products.length>0){const t=s.products,e=s.retailers,n=s.userProducts,r=this.mergeRetailers(e,d.retailers||{}),a=this.transformProductVariantsToFulfillments(d.products,d.retailers||{}),c={...n};a.forEach(t=>{var e;const n=t.salsifyGrouping||t.id||"",r=this.initializeProductFulfillment(t);c[n]={selectedSizeId:r.sizeId,selectedQuantity:1,selectedFulfillmentType:r.fulfillmentType||"shipping",selectedFulfillment:r.fulfillment?{...r.fulfillment,image:null!==(e=r.fulfillment.image)&&void 0!==e?e:null}:null,modal:{isOpen:![],contentConfig:null}}}),this.store.batch({"productsList.products":[...t,...a],"productsList.retailers":r,"productsList.filters":d.navigation.filters,"productsList.pagination":this.updatePagination(d.navigation),"productsList.loading":![],"productsList.userProducts":c}),this.notifyListeners()}else this.store.batch({"productsList.pagination":{...a,hasMorePages:![]},"productsList.loading":![]}),this.notifyListeners()}catch(s){throw this.logger.error("Error loading more products:",s),this.setLoading(![]),s}}async getProductList(t){t.location=this.getLocation();const e=await this.api.catalogSearch(t);return e.products&&e.products.length>0&&this.trackViewItemList(e.products),e}syncFiltersFromComponent(t){const e={};for(const[n,r]of Object.entries(t))null!=r&&(Array.isArray(r)?e[n]=r:e[n]="object"==typeof r?[JSON.stringify(r)]:[String(r)]);this.store.set("productsList.appliedFilters",e),this.notifyListeners()}getSanitizedFilters(t,e){return e&&0!==e.length?t.filter(t=>{const n=this.FILTER_TYPE_MAP[t.type];return n&&e.includes(n)}):[]}buildSearchParams(t,e,n,r,s){const a={page:t,perPage:e,filters:this.buildFilters(r,s)};return n&&n.trim().length>0&&(a.search=n.trim()),a}buildFilters(t,e){const n=[];return this.addToggleFilters(n,t,e),this.addPriceFilter(n,t,e),this.addDynamicFilters(n,t,e),n}addToggleFilters(t,e,n){this.addEngravingFilter(t,e,n),this.addPresaleFilter(t,e,n),this.addFulfillmentFilter(t,e,n)}getBooleanFilterValue(t){return"boolean"==typeof t?t:Array.isArray(t)&&t.length>0?"true"===t[0]:"string"==typeof t?"true"===t:![]}addEngravingFilter(t,e,n){if(n.includes(h.ENGRAVING)){const n=this.getBooleanFilterValue(e[dt.ENGRAVING]);t.push({key:dt.ENGRAVING,values:[n?pt.YES:pt.NO]})}}addPresaleFilter(t,e,n){if(n.includes(h.PRESALE)){const n=this.getBooleanFilterValue(e[dt.PRESALE]);t.push({key:dt.PRESALE,values:[n?pt.YES:pt.NO]})}}addFulfillmentFilter(t,e,n){if(n.includes(h.FULFILLMENT)){const n=e[dt.FULFILLMENT],r=Array.isArray(n)?n[0]:n||ht.ALL,s=r===ht.ALL?[ht.ON_DEMAND,ht.SHIPPING]:[r];t.push({key:dt.FULFILLMENT,values:s})}}addPriceFilter(t,e,n){var r,s,a,c;n.includes(h.PRICE)&&t.push({key:dt.PRICE,values:{min:null!==(s=null===(r=e.price)||void 0===r?void 0:r.min)&&void 0!==s?s:ut.MIN,max:null!==(c=null===(a=e.price)||void 0===a?void 0:a.max)&&void 0!==c?c:ut.MAX}})}addDynamicFilters(t,e,n){const r=[dt.PRICE,dt.ENGRAVING,dt.PRESALE,dt.FULFILLMENT],s=Object.keys(e).filter(t=>!r.includes(t)),a=new Set;for(const l of s)t.push({key:l,values:e[l]}),a.add(l);const c=this.getFilterKeyToTypeMap();for(const l of n){const e=c[l];!e||a.has(e)||r.includes(e)||t.push({key:e,values:[]})}}setGridConfig(t,e){this.store.set("productsList.gridConfig",{rows:t,columns:e})}getItemsPerPage(){const t=this.getStoreState(),e=t.gridConfig;return e?e.rows*e.columns:16}updatePagination(t){var e,n,r,s,a;return t?{currentPage:null!==(e=t.currentPage)&&void 0!==e?e:0,totalPages:null!==(n=t.totalPages)&&void 0!==n?n:0,totalCount:null!==(r=t.totalCount)&&void 0!==r?r:0,hasMorePages:(null!==(s=t.currentPage)&&void 0!==s?s:0)<(null!==(a=t.totalPages)&&void 0!==a?a:1)-1}:{currentPage:0,totalPages:0,totalCount:0,hasMorePages:![]}}createInitialPagination(){return{currentPage:0,totalPages:0,totalCount:0,hasMorePages:!![]}}mergeRetailers(t,e){const n={...t};for(const[r,s]of Object.entries(e))n[r]||(n[r]=s);return n}extractProductCardData(t,e){const n=Object.values(t.sizes)[0];if(!n)return this.logger.warn("Product "+t.id+" has no sizes"),null;const r=Object.values(n.shippingFulfillments),s=Object.values(n.onDemandFulfillments),a=r[0],c=s[0],l=(null==a?void 0:a.variant)||(null==c?void 0:c.variant);if(!l)return this.logger.warn("Product "+t.id+" has no variants"),null;const d=e[l.retailerId];return d?{product:t,retailer:d}:(this.logger.warn("Retailer "+l.retailerId+" not found for product "+t.id),null)}getFilterKeyToTypeMap(){const t={};for(const[e,n]of Object.entries(this.FILTER_TYPE_MAP))t[n]=e;return t}async addToCart(t){try{this.uiCommands.openDrawer(r.CART),await this.cartCommands.addItem(t)}catch(e){throw this.logger.error("Error adding product to cart from product list",e),e}}async addPresaleToCart(t){try{await this.checkoutCommands.addPresaleItem(t),this.clientConfig.isBuilder()||this.checkoutCommands.openCheckout()}catch(e){throw this.logger.error("Error adding presale product to checkout from product list",e),e}}trackViewItemList(t){if(0!==t.length)try{const e=this.getStoreState(),n=this.transformProductVariantsToFulfillments(t,e.retailers),r=n.map((t,e)=>({...this.convertProductToBaseItem(t),index:e+1}));this.googleTagManager.viewItemList(r,"product_list","Product List")}catch(e){this.logger.error("Error tracking view_item_list event",e)}}trackSelectItem(t){try{const e=this.convertProductToBaseItem(t);this.googleTagManager.selectItem(e,"product_list","Product List")}catch(e){this.logger.error("Error tracking select_item event",e)}}convertProductToBaseItem(t){var e,n;const r=null===(e=t.sizes)||void 0===e?void 0:e[0],s=null==r?void 0:r.shippingFulfillments[Object.keys(r.shippingFulfillments)[0]],a=splitCategoryPath(t.catPath);return{item_id:null==r?void 0:r.id,item_name:t.name,item_brand:t.brand,item_size:null==r?void 0:r.size,item_category:a.category,item_category2:a.category2,item_category3:a.category3,price:(null==s?void 0:s.variant.price)?centToDollar(s.variant.price):t.noAvailabilityPrice?centToDollar(t.noAvailabilityPrice):void 0,item_type:t.type,item_subtype:t.subType,item_image:(null==r?void 0:r.image)||(null===(n=t.images)||void 0===n?void 0:n[0]),upc:null==r?void 0:r.upc,grouping_id:t.salsifyGrouping,product_id:null==r?void 0:r.id,item_list_id:"product_list",item_list_name:"Product List"}}openProductListModal(t,e,n){const r={type:e,data:n};this.store.batch({["productsList.userProducts."+t+".modal.isOpen"]:!![],["productsList.userProducts."+t+".modal.contentConfig"]:r}),this.notifyListeners()}closeProductListModal(t){this.store.batch({["productsList.userProducts."+t+".modal.isOpen"]:![],["productsList.userProducts."+t+".modal.contentConfig"]:null}),this.notifyListeners()}getFulfillmentForSize(t,e){const n=Object.values(t.shippingFulfillments||{}),r=Object.values(t.onDemandFulfillments||{}),a=n[0],c=r[0];return e===s.SHIPPING&&a?{fulfillment:{...a,image:t.image},fulfillmentType:s.SHIPPING}:e===s.ON_DEMAND&&c?{fulfillment:{...c,image:t.image},fulfillmentType:s.ON_DEMAND}:a?{fulfillment:{...a,image:t.image},fulfillmentType:s.SHIPPING}:c?{fulfillment:{...c,image:t.image},fulfillmentType:s.ON_DEMAND}:{fulfillment:null,fulfillmentType:null}}}class CommonCommands extends BaseCommand{static getInstance(){return SingletonManager.getClassInstance("CommonCommands",()=>new CommonCommands)}syncCartFromResponse(t,n=![]){var r,s,a,c,l;const d=this.store.get("cart");for(const e of Object.keys(d.items||{}))this.store.remove("cart.items."+e);for(const e of Object.keys(d.retailers||{}))this.store.remove("cart.retailers."+e);for(const e of Object.keys(d.fulfillments||{}))this.store.remove("cart.fulfillments."+e);const h={"cart.id":t.id,"cart.error":null,"cart.subtotal":t.subtotal,"cart.itemsQuantity":t.itemsQuantity,"cart.events":[],"cart.promoCode":(null===(r=t.promoCode)||void 0===r?void 0:r.code)?{...t.promoCode,error:null}:null};if((null===(s=Object.values(t.items))||void 0===s?void 0:s.length)>0)for(const e of Object.values(t.items))h["cart.items."+e.id]=e;if((null===(a=Object.values(t.retailers))||void 0===a?void 0:a.length)>0)for(const e of Object.values(t.retailers))if(h["cart.retailers."+e.id]=e,(null===(c=Object.values(e.fulfillments))||void 0===c?void 0:c.length)>0)for(const t of Object.values(e.fulfillments))h["cart.fulfillments."+t.id]=t;if((null===(l=t.events)||void 0===l?void 0:l.length)>0&&(h["cart.events"]=t.events),this.store.batch(h),n){const t=this.store.get("cart"),n=this.buildCartLoadedEventData(t);this.pubSub.publishAction(e.CART_LOADED,n)}}buildCartLoadedEventData(t){var e,n;const r=this.store.get("address"),s={};for(const a of Object.keys(t.items||{})){const e=t.items[a];s[a]={id:e.id,variantId:e.variantId,liquidId:e.liquidId,salsifyGrouping:e.salsifyGrouping,retailerId:e.retailerId,partNumber:e.partNumber,fulfillmentId:e.fulfillmentId,upc:e.upc,sku:e.sku,catPath:e.catPath,volume:e.volume,uom:e.uom,pack:e.pack,packDesc:e.packDesc,container:e.container,containerType:e.containerType,name:e.name,brand:e.brand,size:e.size,price:e.price,quantity:e.quantity,maxQuantity:e.maxQuantity,unitPrice:e.unitPrice,mainImage:e.mainImage,attributes:e.attributes}}return{cartId:t.id,promoCodeDiscount:null!==(n=null===(e=t.promoCode)||void 0===e?void 0:e.discount)&&void 0!==n?n:null,subtotal:t.subtotal,itemCount:t.itemsQuantity,items:s,retailers:t.retailers||{},location:(null==r?void 0:r.id)&&r.coordinates&&r.address?{placesId:r.id,formattedAddress:r.formattedAddress,address:r.address,coordinates:r.coordinates}:null}}async loadCart(){try{this.store.set("cart.loading",!![]);const t=this.store.get("cart"),e=await this.api.getCartData(t.id);this.syncCartFromResponse(e,!![]),e.id!==t.id&&await this.store.persist()}catch(t){const n=(null==t?void 0:t.message)||"Failed to load cart";this.store.set("cart.error",n);const r=this.store.get("cart.id");this.pubSub.publishAction(e.CART_FAILED,{cartId:r,message:n}),this.logger.error("Load cart failed",t)}finally{this.store.set("cart.loading",![])}}}class CommandService{constructor(){this.ui=UICommands.getInstance(),this.address=AddressCommands.getInstance(),this.product=ProductCommands.getInstance(),this.productList=ProductListCommands.getInstance(),this.cart=CartCommands.getInstance(),this.checkout=CheckoutCommands.getInstance(),this.common=CommonCommands.getInstance()}static getInstance(){return SingletonManager.getClassInstance("CommandService",()=>new CommandService)}}const mt="lce-checkout-stripe-slot",ft={firstName:"firstName",lastName:"lastName",email:"email",phone:"phone",birthDate:"birthDate",addressTwo:"addressTwo",company:"company"},gt={firstName:"firstName",lastName:"lastName",email:"email",phone:"phone",addressTwo:"addressTwo",message:"message"},vt={firstName:"firstName",lastName:"lastName",email:"email",phone:"phone",company:"company",addressOne:"addressOne",addressTwo:"addressTwo",city:"city",state:"state",zipCode:"zipCode"};class BaseActionService{constructor(t){this.store=StoreService.getInstance(),this.api=ApiClientService.getInstance(),this.pubSub=PubSubService.getInstance(),this.themeProvider=ThemeProviderService.getInstance(),this.logger=LoggerFactory.get(t)}getLocation(){const t=this.store.get("address");if(t.address.one&&t.coordinates.latitude&&t.coordinates.longitude)return{coordinates:t.coordinates,address:t.address}}}class ClientCheckoutActionService extends BaseActionService{constructor(){super("CheckoutAction"),this.allowedCustomerFields=new Set(Object.values(ft)),this.allowedBillingFields=new Set(Object.values(vt)),this.allowedGiftFields=new Set(Object.values(gt)),this.cartActionsAddProduct=null,this.command=CommandService.getInstance()}static getInstance(){return SingletonManager.getClassInstance("ClientCheckoutActionService",()=>new ClientCheckoutActionService)}setCartActionsAddProduct(t){this.cartActionsAddProduct=t}get actions(){return{openCheckout:this.openCheckout.bind(this),closeCheckout:this.closeCheckout.bind(this),toggleCheckout:this.toggleCheckout.bind(this),addProduct:this.addProduct.bind(this),applyPromoCode:this.applyPromoCode.bind(this),removePromoCode:this.removePromoCode.bind(this),applyGiftCard:this.applyGiftCard.bind(this),removeGiftCard:this.removeGiftCard.bind(this),toggleIsGift:this.toggleIsGift.bind(this),toggleBillingSameAsShipping:this.toggleBillingSameAsShipping.bind(this),toggleMarketingPreferences:this.toggleMarketingPreferences.bind(this),updateCustomerInfo:this.updateCustomerInfo.bind(this),updateBillingInfo:this.updateBillingInfo.bind(this),updateGiftInfo:this.updateGiftInfo.bind(this),getDetails:this.getDetails.bind(this)}}normalizeCheckoutFieldValue(t){return"string"==typeof t?t:null==t?"":String(t)}openCheckout(){this.command.ui.openDrawer(r.CHECKOUT)}closeCheckout(){this.command.ui.closeDrawer()}toggleCheckout(){const t=this.store.get("ui.drawer.isOpen");t?this.command.ui.closeDrawer():this.command.ui.openDrawer(r.CHECKOUT)}async addProduct(t,n){var a;try{if(!t||0===t.length)return this.logger.warn("No products provided to add to checkout"),void 0;n===!![]&&this.command.ui.openDrawer(r.CHECKOUT);const c=t.map(t=>t.identifier);if(this.cartActionsAddProduct)await this.cartActionsAddProduct(t);else for(const e of t){const t=this.getLocation();if(!t)throw new SDKError("Location is required to add products to checkout",!![]);const n=await this.api.getProductsData([e.identifier],t);if(!(null===(a=null==n?void 0:n.products)||void 0===a?void 0:a[0])){this.logger.warn("No product data found for identifier: "+e.identifier);continue}const r=n.products[0],c=Object.values(r.sizes)[0];if(!c)continue;const l=e.fulfillmentType===s.SHIPPING?c.shippingVariants:c.onDemandVariants,d=Object.values(l)[0];if(!d)continue;const h=e.fulfillmentType===s.ON_DEMAND?d.onDemandFulfillmentId:d.shippingFulfillmentId;await this.command.cart.addItem({fulfillmentId:h,partNumber:d.partNumber,quantity:e.quantity,identifier:e.identifier})}await this.command.checkout.loadCheckout({});const l=this.store.get("cart.id");this.pubSub.publishAction(e.CHECKOUT_PRODUCT_ADD_SUCCESS,{cartId:l,itemsAdded:t.length,identifiers:c}),this.logger.info("Products added to checkout successfully:",c)}catch(c){this.logger.error("Error adding products to checkout:",c);const n=this.store.get("cart.id");throw this.pubSub.publishAction(e.CHECKOUT_PRODUCT_ADD_FAILED,{cartId:n,identifiers:t.map(t=>t.identifier),error:c.message||"Failed to add products to checkout"}),c}}async applyPromoCode(t){var n;try{if(!t||""===t.trim())return this.logger.warn("Invalid promo code provided"),this.store.set("checkout.error","Invalid promo code provided"),void 0;const r=t.trim().toUpperCase(),s=this.themeProvider.getConfigs("global"),a=s.layout.allowPromoCodes;if(!a)return this.logger.warn("Promo codes are not allowed"),this.store.set("checkout.error","Promo codes are not allowed"),void 0;const c=this.store.get("checkout.promoCode");if(c&&c.code===r)return this.logger.info("Promo code is already applied"),void 0;await this.command.checkout.applyPromoCode(t);const l=this.store.get("checkout"),d=l.promoCode;this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_APPLIED,{cartId:l.cartId,discount:(null==d?void 0:d.discount)||0,newTotal:(null===(n=null==l?void 0:l.amounts)||void 0===n?void 0:n.total)||0}),this.logger.info("Checkout promo code applied successfully")}catch(r){this.logger.error("Failed to apply checkout promo code:",r);const t=this.store.get("checkout");throw this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_FAILED,{cartId:t.cartId,error:"Promo code could not be applied"}),r}}async removePromoCode(){var t;try{const n=this.themeProvider.getConfigs("global"),r=n.layout.allowPromoCodes;if(!r)return this.logger.warn("Promo codes are not allowed"),this.store.set("checkout.error","Promo codes are not allowed"),void 0;await this.command.checkout.removePromoCode();const s=this.store.get("checkout");this.pubSub.publishAction(e.CHECKOUT_PROMO_CODE_REMOVED,{cartId:s.cartId,newTotal:(null===(t=null==s?void 0:s.amounts)||void 0===t?void 0:t.total)||0}),this.logger.info("Checkout promo code removed successfully")}catch(n){throw this.logger.error("Failed to remove checkout promo code:",n),n}}async applyGiftCard(t){var n;try{const r=this.themeProvider.getConfigs("checkout"),s=r.layout.allowGiftCards;if(!s)return this.logger.warn("Gift cards are not allowed"),this.store.set("checkout.error","Gift cards are not allowed"),void 0;await this.command.checkout.applyGiftCard(t);const a=this.store.get("checkout");this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_APPLIED,{cartId:a.cartId,newTotal:(null===(n=null==a?void 0:a.amounts)||void 0===n?void 0:n.total)||0}),this.logger.info("Gift card applied successfully")}catch(r){this.logger.error("Failed to apply gift card:",r);const t=this.store.get("checkout");throw this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_FAILED,{cartId:t.cartId,error:"Gift card could not be applied"}),r}}async removeGiftCard(t){var n;try{const r=this.themeProvider.getConfigs("checkout"),s=r.layout.allowGiftCards;if(!s)return this.logger.warn("Gift cards are not allowed"),this.store.set("checkout.error","Gift cards are not allowed"),void 0;await this.command.checkout.removeGiftCard(t);const a=this.store.get("checkout");this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_REMOVED,{cartId:a.cartId,newTotal:(null===(n=null==a?void 0:a.amounts)||void 0===n?void 0:n.total)||0}),this.logger.info("Gift card removed successfully")}catch(r){this.logger.error("Failed to remove gift card:",r);const t=this.store.get("checkout");throw this.pubSub.publishAction(e.CHECKOUT_GIFT_CARD_FAILED,{cartId:t.cartId,error:"Gift card could not be removed"}),r}}async toggleIsGift(t){await this.command.checkout.toggleIsGift(t)}async toggleBillingSameAsShipping(t){await this.command.checkout.toggleBillingSameAsShipping(t)}async toggleMarketingPreferences(t,e){await this.command.checkout.toggleMarketingPreferences(t,e)}updateCustomerInfo(t){const e={};if(!t||"object"!=typeof t)return this.logger.warn("actions.checkout.updateCustomerInfo called without valid params"),void 0;for(const[n,r]of Object.entries(t)){if(!this.allowedCustomerFields.has(n))continue;const t=this.normalizeCheckoutFieldValue(r);n===ft.addressTwo?e["checkout.shippingAddress.address.two"]=t:e["checkout.customerForm.data."+n]=t}if(0===Object.keys(e).length)return this.logger.warn("actions.checkout.updateCustomerInfo called without supported fields"),void 0;this.store.batch(e)}updateBillingInfo(t){const e={};if(!t||"object"!=typeof t)return this.logger.warn("actions.checkout.updateBillingInfo called without valid params"),void 0;for(const[n,r]of Object.entries(t))this.allowedBillingFields.has(n)&&(e["checkout.paymentForm.data."+n]=this.normalizeCheckoutFieldValue(r));if(0===Object.keys(e).length)return this.logger.warn("actions.checkout.updateBillingInfo called without supported fields"),void 0;this.store.batch(e)}updateGiftInfo(t){const e={};if(!t||"object"!=typeof t)return this.logger.warn("actions.checkout.updateGiftInfo called without valid params"),void 0;for(const[n,r]of Object.entries(t)){if(!this.allowedGiftFields.has(n))continue;const t=this.normalizeCheckoutFieldValue(r);n===gt.addressTwo?e["checkout.shippingAddress.address.two"]=t:e["checkout.giftRecipientForm.data."+n]=t}if(0===Object.keys(e).length)return this.logger.warn("actions.checkout.updateGiftInfo called without supported fields"),void 0;this.store.batch(e)}getDetails(){return this.command.checkout.getDetails()}}const yt="\n :host {\n position: fixed;\n z-index: 2147483647;\n display: block;\n }\n\n .panel {\n position: relative;\n background: rgba(15, 23, 42, 0.95);\n backdrop-filter: blur(10px);\n border: 1px solid rgba(148, 163, 184, 0.2);\n border-radius: 12px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;\n font-size: 12px;\n color: #e2e8f0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n user-select: none;\n transition: all 0.2s ease;\n width: 100%;\n height: 100%;\n }\n\n .panel:hover {\n border-color: rgba(148, 163, 184, 0.4);\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);\n }\n\n .header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n border-bottom: 1px solid rgba(148, 163, 184, 0.2);\n background: rgba(30, 41, 59, 0.5);\n cursor: move;\n }\n\n .icon {\n font-size: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n }\n\n .title-container {\n display: flex;\n flex-direction: column;\n flex: 1;\n margin: 0 12px;\n }\n \n .title-container > *:not(:first-child) {\n margin-top: 2px;\n }\n\n .title {\n font-weight: 600;\n color: #f1f5f9;\n font-size: 13px;\n }\n\n\n .subtitle {\n font-size: 10px;\n color: #94a3b8;\n }\n\n .minimize {\n background: none;\n border: none;\n color: #94a3b8;\n font-size: 18px;\n cursor: pointer;\n padding: 4px;\n border-radius: 4px;\n transition: all 0.2s ease;\n line-height: 1;\n font-weight: bold;\n }\n\n .minimize:hover {\n background: rgba(148, 163, 184, 0.1);\n color: #cbd5e1;\n }\n\n .toggles {\n display: flex;\n padding: 8px 16px;\n border-bottom: 1px solid rgba(148, 163, 184, 0.2);\n background: rgba(30, 41, 59, 0.3);\n align-items: center;\n }\n\n .toggles > *:not(:last-child) {\n margin-right: 12px;\n }\n\n .toggle {\n display: flex;\n align-items: center;\n cursor: pointer;\n font-size: 11px;\n color: #cbd5e1;\n transition: color 0.2s ease;\n }\n \n .toggle > *:not(:last-child) {\n margin-right: 6px;\n }\n\n .toggle:hover {\n color: #f1f5f9;\n }\n\n .toggle input[type=\"checkbox\"] {\n width: 12px;\n height: 12px;\n accent-color: #3b82f6;\n cursor: pointer;\n }\n\n .clear-btn {\n background: none;\n border: none;\n color: #ef4444;\n font-size: 14px;\n padding: 0;\n cursor: pointer;\n transition: all 0.2s ease;\n margin-left: auto;\n min-width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .clear-btn:hover {\n transform: scale(1.1);\n color: #dc2626;\n }\n\n .logs {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n padding: 8px;\n background: rgba(15, 23, 42, 0.8);\n min-height: 0;\n max-height: 100%;\n }\n\n .log-entry {\n display: flex;\n align-items: flex-start;\n padding: 8px 12px;\n margin-bottom: 2px;\n border-radius: 6px;\n font-size: 11px;\n line-height: 1.4;\n transition: background-color 0.2s ease;\n user-select: text;\n }\n \n .log-entry > *:not(:last-child) {\n margin-right: 8px;\n }\n\n .log-entry:hover {\n background-color: rgba(148, 163, 184, 0.1);\n }\n\n /* Event type background colors */\n .log-entry.event {\n background: rgba(59, 130, 246, 0.1);\n }\n\n .log-entry.action {\n background: rgba(16, 185, 129, 0.1);\n }\n\n .log-entry.gtm {\n background: rgba(245, 158, 11, 0.1);\n }\n\n .log-entry.logger {\n background: rgba(139, 92, 246, 0.1);\n }\n\n\n .log-meta {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n min-width: 50px;\n }\n \n .log-meta > *:not(:first-child) {\n margin-top: 2px;\n }\n\n .log-type {\n font-weight: 600;\n font-size: 9px;\n padding: 2px 0;\n border-radius: 3px;\n white-space: nowrap;\n text-align: center;\n line-height: 1;\n font-weight: bold;\n letter-spacing: 0.5px;\n }\n\n .log-timestamp {\n color: #64748b;\n font-size: 9px;\n white-space: nowrap;\n line-height: 1;\n }\n\n .log-type.event {\n background: rgba(59, 130, 246, 0.2);\n color: #60a5fa;\n }\n\n .log-type.action {\n color: #34d399;\n }\n\n .log-type.gtm {\n color: #fbbf24;\n }\n\n .log-type.logger {\n color: #a78bfa;\n }\n\n .log-message {\n flex: 1;\n word-break: break-word;\n user-select: text;\n }\n\n .log-context {\n color: #94a3b8;\n font-size: 10px;\n margin-top: 2px;\n font-style: italic;\n }\n\n .log-data {\n background: rgba(30, 41, 59, 0.6);\n border: 1px solid rgba(148, 163, 184, 0.2);\n border-radius: 4px;\n padding: 8px;\n margin-top: 6px;\n font-size: 10px;\n color: #cbd5e1;\n max-height: 120px;\n overflow-y: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;\n user-select: text;\n }\n\n .log-data pre {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n }\n\n .resize-handle {\n position: absolute;\n bottom: 0;\n right: 0;\n width: 12px;\n height: 12px;\n background: linear-gradient(-45deg, transparent 30%, rgba(148, 163, 184, 0.3) 30%, rgba(148, 163, 184, 0.3) 70%, transparent 70%);\n cursor: nw-resize;\n border-radius: 0 0 12px 0;\n }\n\n .resize-handle:hover {\n background: linear-gradient(-45deg, transparent 30%, rgba(148, 163, 184, 0.7) 30%, rgba(148, 163, 184, 0.7) 70%, transparent 70%);\n transform: scale(1.1);\n }\n\n .resize-handle:active {\n background: linear-gradient(-45deg, transparent 30%, rgba(148, 163, 184, 0.9) 30%, rgba(148, 163, 184, 0.9) 70%, transparent 70%);\n }\n\n /* Scrollbar styling */\n .logs::-webkit-scrollbar {\n width: 6px;\n }\n\n .logs::-webkit-scrollbar-track {\n background: rgba(30, 41, 59, 0.3);\n border-radius: 3px;\n }\n\n .logs::-webkit-scrollbar-thumb {\n background: rgba(148, 163, 184, 0.3);\n border-radius: 3px;\n }\n\n .logs::-webkit-scrollbar-thumb:hover {\n background: rgba(148, 163, 184, 0.5);\n }\n\n .log-data::-webkit-scrollbar {\n width: 4px;\n }\n\n .log-data::-webkit-scrollbar-track {\n background: rgba(30, 41, 59, 0.3);\n border-radius: 2px;\n }\n\n .log-data::-webkit-scrollbar-thumb {\n background: rgba(148, 163, 184, 0.3);\n border-radius: 2px;\n }\n\n .log-data::-webkit-scrollbar-thumb:hover {\n background: rgba(148, 163, 184, 0.5);\n }\n\n /* Floating button styles */\n .floating-btn {\n position: absolute;\n top: 20px;\n left: 20px;\n width: 40px;\n height: 40px;\n background: rgba(15, 23, 42, 0.95);\n border: 1px solid rgba(148, 163, 184, 0.2);\n border-radius: 50%;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 18px;\n user-select: none;\n z-index: 1;\n }\n\n .floating-btn:hover {\n background: rgba(30, 41, 59, 0.95);\n border-color: rgba(148, 163, 184, 0.4);\n }\n\n /* Mobile Responsiveness */\n @media (max-width: 768px) {\n .panel {\n font-size: 11px;\n border-radius: 8px;\n }\n\n .header {\n padding: 8px 12px;\n }\n\n .title {\n font-size: 12px;\n }\n\n .subtitle {\n font-size: 9px;\n }\n\n .toggles {\n padding: 6px 12px;\n flex-wrap: wrap;\n }\n \n .toggles > *:not(:last-child) {\n margin-right: 8px;\n }\n\n .toggle {\n font-size: 10px;\n }\n\n .toggle input[type=\"checkbox\"] {\n width: 10px;\n height: 10px;\n }\n\n .logs {\n padding: 6px;\n }\n\n .log-entry {\n padding: 6px 8px;\n font-size: 10px;\n }\n\n .log-type {\n font-size: 8px;\n }\n\n .log-timestamp {\n font-size: 8px;\n }\n\n .log-data {\n font-size: 9px;\n padding: 6px;\n max-height: 80px;\n }\n\n .floating-btn {\n width: 36px;\n height: 36px;\n font-size: 16px;\n top: 15px;\n left: 15px;\n }\n }\n\n @media (max-width: 480px) {\n .panel {\n font-size: 10px;\n border-radius: 6px;\n }\n\n .header {\n padding: 6px 10px;\n }\n\n .title {\n font-size: 11px;\n }\n\n .subtitle {\n font-size: 8px;\n }\n\n .toggles {\n padding: 4px 10px;\n }\n \n .toggles > *:not(:first-child) {\n margin-right: 6px;\n }\n\n .toggle {\n font-size: 9px;\n }\n\n .logs {\n padding: 4px;\n }\n\n .log-entry {\n padding: 4px 6px;\n font-size: 9px;\n }\n \n .log-entry > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .log-meta {\n min-width: 40px;\n }\n\n .log-type {\n font-size: 7px;\n }\n\n .log-timestamp {\n font-size: 7px;\n }\n\n .log-data {\n font-size: 8px;\n padding: 4px;\n max-height: 60px;\n }\n\n .floating-btn {\n width: 32px;\n height: 32px;\n font-size: 14px;\n top: 10px;\n left: 10px;\n }\n }\n",bt="lce-debug-panel";class DebugPanelService{constructor(){this.panelElement=null,this.panelContainer=null,this.floatingButton=null,this.logContainer=null,this.logs=[],this.isVisible=![],this.showEvents=!![],this.showGtmEvents=!![],this.showLogs=![]}static getInstance(){return SingletonManager.getClassInstance("DebugPanelService",()=>new DebugPanelService)}initialize(){this.createPanel(),this.interceptLoggerService(),this.interceptPubSubEvents(),this.interceptGtmEvents()}toggleVisibility(){if(!this.panelElement)return this.createPanel(),void 0;this.isVisible=!this.isVisible,this.isVisible?this.showPanelContent():this.hidePanelContent()}destroy(){this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.panelContainer=null,this.floatingButton=null,this.logs=[],this.isVisible=![]}interceptLoggerService(){const t=LoggerFactory,e=t.instances;if(e)for(const[r,s]of e)this.interceptLoggerInstance(s,r);const n=LoggerFactory.get.bind(LoggerFactory);LoggerFactory.get=t=>{const e=n(t);return this.interceptLoggerInstance(e,t),e}}interceptLoggerInstance(t,e){if(t.l)return;const n=t.debug.bind(t),r=t.info.bind(t),s=t.warn.bind(t),a=t.error.bind(t),R=(t,n,r)=>({id:"logger_"+Date.now()+"_"+Math.random().toString(36).slice(2,9),timestamp:Date.now(),type:"logger",level:t,message:n,data:r,context:e});t.debug=(t,e)=>{n(t,e),this.addLogEntry(R("debug",t,e))},t.info=(t,e)=>{r(t,e),this.addLogEntry(R("info",t,e))},t.warn=(t,e)=>{s(t,e),this.addLogEntry(R("warn",t,e))},t.error=(t,e)=>{a(t,e),this.addLogEntry(R("error",t,e))},t.l=!![]}interceptPubSubEvents(){const t=PubSubService.getInstance(),e=t.publishAction.bind(t);t.publishAction=(t,n)=>{e(t,n),this.addLogEntry({id:"action_"+Date.now()+"_"+Math.random().toString(36).slice(2,9),timestamp:Date.now(),type:"event",level:"info",message:"Action: "+t,data:n,context:"PubSub"})};const n=t.publishForm.bind(t);t.publishForm=(t,e)=>{n(t,e),this.addLogEntry({id:"event_"+Date.now()+"_"+Math.random().toString(36).slice(2,9),timestamp:Date.now(),type:"event",level:"info",message:"Form Event: "+t,data:e,context:"PubSub"})}}interceptGtmEvents(){const t=GoogleTagManagerService.getInstance(),e=t.executeEvent.bind(t);t.executeEvent=(t,n,r)=>{e(t,n,r),this.addLogEntry({id:"gtm_"+Date.now()+"_"+Math.random().toString(36).slice(2,9),timestamp:Date.now(),type:"gtm",level:"info",message:"GTM Event: "+n,data:r,context:"GTM."+t})}}addLogEntry(t){this.logs.push(t),this.logs.length>100&&(this.logs=this.logs.slice(-100)),this.renderLogs()}renderLogs(){if(!this.logContainer)return;const t=this.logs.filter(t=>{switch(t.type){case"event":return this.showEvents;case"gtm":return this.showGtmEvents;case"logger":return this.showLogs;default:return!![]}});this.logContainer.innerHTML="",t.forEach(t=>{const e=this.createLogElement(t);this.logContainer.appendChild(e)}),this.logContainer.scrollTop=this.logContainer.scrollHeight}clearLogs(){this.logs=[],this.renderLogs()}createPanel(){const t=document.querySelector(bt);t&&t.remove(),this.panelElement=document.createElement(bt);const e=window.innerWidth<=768,n=window.innerWidth<=480;n?(this.panelElement.style.top="10px",this.panelElement.style.left="10px",this.panelElement.style.width="calc(100vw - 20px)",this.panelElement.style.height="40vh"):e?(this.panelElement.style.top="15px",this.panelElement.style.left="15px",this.panelElement.style.width="calc(100vw - 30px)",this.panelElement.style.height="40vh"):(this.panelElement.style.top="20px",this.panelElement.style.left="20px",this.panelElement.style.width="500px",this.panelElement.style.height="600px"),this.createPanelContent(),document.body.appendChild(this.panelElement),this.isVisible=!![]}createPanelContent(){if(!this.panelElement)return;const t=this.panelElement.attachShadow({mode:"closed"}),e=document.createElement("style");e.textContent=yt,t.appendChild(e),this.floatingButton=this.createFloatingButton(),t.appendChild(this.floatingButton),this.panelContainer=document.createElement("div"),this.panelContainer.className="panel";const n=this.createHeader();this.panelContainer.appendChild(n);const r=this.createToggles();this.panelContainer.appendChild(r),this.logContainer=document.createElement("div"),this.logContainer.className="logs",this.logContainer.title="Debug logs - scroll to see more",this.panelContainer.appendChild(this.logContainer);const s=this.createResizeHandle();this.panelContainer.appendChild(s),t.appendChild(this.panelContainer),this.setupShadowEventListeners(t)}createHeader(){const t=document.createElement("div");t.className="header",t.title="Drag to move panel";const e=document.createElement("div");e.className="icon",e.innerHTML="🔍",e.title="Elements Debug Console",e.style.cursor="help";const n=document.createElement("div");n.className="title-container";const r=document.createElement("div");r.className="title",r.textContent="Elements Debug Console";const s=document.createElement("div");s.className="subtitle",s.textContent="Live SDK logs, events & GTM tracking",n.appendChild(r),n.appendChild(s);const a=document.createElement("button");return a.className="minimize",a.innerHTML="−",a.title="Minimize debug panel",a.addEventListener("click",()=>this.toggleVisibility()),t.appendChild(e),t.appendChild(n),t.appendChild(a),t}createToggles(){const t=document.createElement("div");t.className="toggles";const e=[{key:"showLogs",label:"Logs",description:"SDK internal logs and debug messages",color:"#8b5cf6"},{key:"showEvents",label:"Events",description:"User actions and form interactions",color:"#10b981"},{key:"showGtmEvents",label:"GTM Events",description:"Google Tag Manager tracking events",color:"#f59e0b"}];e.forEach(({key:e,label:n,description:r,color:s})=>{const a=document.createElement("label");a.className="toggle",a.title=r;const c=document.createElement("input");c.type="checkbox",c.checked="showLogs"!==e,c.addEventListener("change",t=>{const n=t.target;"showEvents"===e&&(this.showEvents=n.checked),"showGtmEvents"===e&&(this.showGtmEvents=n.checked),"showLogs"===e&&(this.showLogs=n.checked),this.renderLogs()});const l=document.createElement("span");l.textContent=n,l.style.color=s,a.appendChild(c),a.appendChild(l),t.appendChild(a)});const n=document.createElement("button");return n.className="clear-btn",n.innerHTML="🗑️",n.title="Clear all logs",n.addEventListener("click",()=>this.clearLogs()),t.appendChild(n),t}createResizeHandle(){const t=document.createElement("div");t.className="resize-handle",t.title="Drag to resize panel",t.style.cursor="nw-resize";let e=![],n=0,r=0,s=0,a=0;t.addEventListener("mousedown",t=>{e=!![],n=t.clientX,r=t.clientY,s=Number.parseInt(this.panelElement.style.width,10)||500,a=Number.parseInt(this.panelElement.style.height,10)||300,document.addEventListener("mousemove",I),document.addEventListener("mouseup",u),t.preventDefault()});const I=t=>{if(!e||!this.panelElement)return;const c=t.clientX-n,l=t.clientY-r,d=window.innerWidth<=768,h=window.innerWidth<=480;let p,m,f,g;h?(p=280,m=window.innerWidth-20,f=200,g=.4*window.innerHeight):d?(p=300,m=window.innerWidth-30,f=200,g=.4*window.innerHeight):(p=300,m=800,f=200,g=600);const v=Math.max(p,Math.min(m,s+c)),y=Math.max(f,Math.min(g,a+l));this.panelElement.style.width=v+"px",this.panelElement.style.height=y+"px"},u=()=>{e=![],document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",u)};return t}setupShadowEventListeners(t){if(!this.panelElement)return;const e=t.querySelector(".header");if(e){let t=![],n=0,r=0,s=0,a=0;e.addEventListener("mousedown",e=>{if(e.target.classList.contains("minimize"))return;t=!![],n=e.clientX,r=e.clientY;const c=this.panelElement.getBoundingClientRect();s=c.left,a=c.top,document.addEventListener("mousemove",I),document.addEventListener("mouseup",u),e.preventDefault()});const I=e=>{if(!t||!this.panelElement)return;const c=e.clientX-n,l=e.clientY-r;this.panelElement.style.left=s+c+"px",this.panelElement.style.top=a+l+"px",this.panelElement.style.right="auto",this.panelElement.style.bottom="auto"},u=()=>{t=![],document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",u)}}}createFloatingButton(){const t=document.createElement("div");return t.className="floating-btn",t.innerHTML="⚙️",t.title="Open Elements Debug Console",t.style.display="none",t.addEventListener("click",()=>{this.toggleVisibility()}),t}showPanelContent(){this.panelContainer&&(this.panelContainer.style.display="flex"),this.floatingButton&&(this.floatingButton.style.display="none")}hidePanelContent(){this.panelContainer&&(this.panelContainer.style.display="none"),this.floatingButton&&(this.floatingButton.style.display="flex")}createLogElement(t){const e=document.createElement("div");e.className="log-entry "+t.type+" "+t.level;const n=new Date(t.timestamp).toLocaleTimeString();return e.innerHTML='\n <div class="log-meta">\n <div class="log-type '+t.type+'">'+t.type.toUpperCase()+'</div>\n <div class="log-timestamp">'+n+'</div>\n </div>\n <div class="log-message">\n '+this.escapeHtml(t.message)+"\n "+(t.context?'<div class="log-context">'+this.escapeHtml(t.context)+"</div>":"")+"\n "+(t.data?'<div class="log-data"><pre>'+this.formatJsonData(t.data)+"</pre></div>":"")+"\n </div>\n ",e}formatJsonData(t){try{return"object"==typeof t&&null!==t?JSON.stringify(t,null,2):String(t)}catch(e){return String(t)}}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}class FingerPrintService{constructor(){this.isLocalStorageAvailable=null,this.cachedFingerprint=null,this.clientConfig=ClientConfigService.getInstance()}static getInstance(){return SingletonManager.getClassInstance("FingerPrintService",()=>new FingerPrintService)}async getId(t){if(this.h()){const e=this.u(t);if(e)return this.m(t,e)}return this.cachedFingerprint||(this.cachedFingerprint=this.v()),this.m(t,this.cachedFingerprint)}getFingerprintData(){return{screen:this.k(),browser:this.C(),timezone:this.S()}}isLocalStorageWebApiAvailable(){return this.h()}m(t,e){return(t+"_"+e).toLowerCase()}h(){if(null!==this.isLocalStorageAvailable)return this.isLocalStorageAvailable;try{0;const t=window.localStorage,e="__localStorage_test_"+Date.now()+"__",n="test";t.setItem(e,n);const r=t.getItem(e);return r!==n?(this.isLocalStorageAvailable=![],![]):(t.removeItem(e),this.isLocalStorageAvailable=!![],!![])}catch(t){const n=t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name);if(n)try{const t=window.localStorage;return t&&t.length>0?(this._()&&console.warn("localStorage is full in webview environment - consider data cleanup"),this.isLocalStorageAvailable=!![],!![]):(console.warn("localStorage reports zero quota - likely Safari private mode or similar restriction"),this.isLocalStorageAvailable=![],![])}catch(e){return this.isLocalStorageAvailable=![],![]}if(this.isLocalStorageAvailable=![],t instanceof DOMException){const e={SecurityError:"Access denied due to security policies (third-party cookies, Firefox cookie settings, or iframe restrictions)",InvalidStateError:"Invalid state error",InvalidAccessError:"Invalid access to storage",NotFoundError:"Storage not found"},n=e[t.name]||"Storage error: "+t.name,r=this._()?"webview":"browser";console.warn("localStorage unavailable in "+r+": "+n)}else console.warn("localStorage unavailable:",t.message||"Unknown error");return![]}}u(t){try{const e=this.clientConfig.get("localStorageKeyPrefix")+"_"+t.toLowerCase()+"_";for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(null==n?void 0:n.startsWith(e)){const t=n.substring(e.length);if(t&&/^[a-f0-9]+$/.test(t))return t}}return null}catch(e){return null}}v(){const t=this.getFingerprintData(),e=Object.keys(t).sort().map(e=>e+":"+t[e]).join("|");return this.T(e)}k(){try{const t=screen,e=t.colorDepth||24,n=t.pixelDepth||e,r=this.I(),s=Math.round(100*(window.devicePixelRatio||1));return e+"|"+n+"|"+r+"|"+s}catch(t){return"24|24|srgb|100"}}I(){try{if(window.matchMedia&&"function"==="object".matchMedia){if(window.matchMedia("(color-gamut: rec2020)").matches)return"rec2020";if(window.matchMedia("(color-gamut: p3)").matches)return"p3";if(window.matchMedia("(color-gamut: srgb)").matches)return"srgb"}}catch(Q){}return"srgb"}C(){var t;try{const e=navigator,n=[],r=((null===(t=e.languages)||void 0===t?void 0:t[0])||e.language||"en").substring(0,2);n.push(r),n.push(e.hardwareConcurrency||4);const s=(e.platform||"unknown").toLowerCase().replace(/\s+/g,"_").substring(0,10);n.push(s),n.push(e.cookieEnabled?"1":"0"),n.push(e.maxTouchPoints||0),n.push(e.deviceMemory||0),n.push(this.P()),n.push(this._()?"webview":"browser");const a=["bluetooth"in e?"1":"0","usb"in e?"1":"0","mediaDevices"in e?"1":"0","permissions"in e?"1":"0","credentials"in e?"1":"0","storage"in e?"1":"0","ServiceWorker"in window?"1":"0","PushManager"in window?"1":"0"];return n.push(a.join("")),n.join("|")}catch(e){return"en|4|unknown|1|0|0|unknown|webview|00000000"}}P(){try{const t=navigator.userAgent.toLowerCase();return t.includes("instagram")?"ig_webview":t.includes("fban")||t.includes("fbav")?"fb_webview":t.includes("tiktok")?"tiktok_webview":t.includes("linkedin")?"linkedin_webview":t.includes("snapchat")?"snapchat_webview":t.includes("twitter")?"twitter_webview":t.includes("line/")?"line_webview":t.includes("micromessenger")?"wechat_webview":t.includes("firefox")?"gecko":t.includes("edg/")?"edge":t.includes("opr/")||t.includes("opera")?"opera":t.includes("chrome")&&!t.includes("edg")?"blink":t.includes("safari")&&!t.includes("chrome")?"webkit":"unknown"}catch(t){return"unknown"}}_(){try{const t=navigator.userAgent.toLowerCase(),e=navigator,n=["wv","instagram","fban","fbav","tiktok","linkedin","snapchat","twitter","line/","micromessenger","kakaotalk","telegram"];return n.some(e=>t.includes(e))?!![]:void 0===e.standalone||e.standalone?window.self!==window.top?!![]:![]:!![]}catch(t){return![]}}S(){try{const t=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";return t.replace(/\//g,"_").substring(0,30)}catch(t){return"UTC"}}T(t){const e=16777619;let n=2166136261,r=2166136261,s=2166136261,a=2166136261;for(let c=0;c<t.length;c++){const l=t.charCodeAt(c);n^=l,n=Math.imul(n,e),r^=l<<1,r=Math.imul(r,e),s^=l<<2,s=Math.imul(s,e),a^=l<<3,a=Math.imul(a,e)}return n=Math.abs(n),r=Math.abs(r),s=Math.abs(s),a=Math.abs(a),n.toString(16)+r.toString(16)+s.toString(16)+a.toString(16)}}class TelemetryService{constructor(){this.eventQueue=[],this.batchTimer=null,this.stats={totalEvents:0,eventsByLevel:{debug:0,log:0,info:0,warn:0,error:0,fatal:0},batchesSent:0,failedBatches:0,queuedEvents:0,droppedEvents:0},this.isShuttingDown=![],this.clientConfig=ClientConfigService.getInstance(),this.store=StoreService.getInstance();const e=this.clientConfig.get("env"),n=new URL("/api/telemetry",this.clientConfig.get("baseUrl")).toString();this.config={enabled:!this.clientConfig.get("hasCustomApiUrl"),endpoint:n,batchSize:e===t.PRODUCTION?5:10,batchInterval:e===t.PRODUCTION?5e3:3e3,includeDebugLogs:![],includeWarnings:!![],includeErrors:!![],maxQueueSize:50},window.addEventListener("beforeunload",()=>this.shutdown()),window.addEventListener("pagehide",()=>this.shutdown()),this.config.enabled&&this.startBatchTimer()}static getInstance(){return SingletonManager.getClassInstance("TelemetryService",()=>new TelemetryService)}isEnabled(){return this.config.enabled}captureEvent(t,e,n={}){if(!this.isEnabled()||this.isShuttingDown)return;if(!this.shouldCapture(t))return;const r=Date.now();try{const s={eventId:"event_"+r,timestamp:r,level:t,message:e,context:n.context,error:n.error?this.buildErrorContext(n.error):void 0,component:n.component,data:n.data,metadata:{sdk:this.buildSDKContext(),user:this.buildUserContext(),browser:this.buildBrowserContext()}};this.addToQueue(s)}catch(s){this.handleInternalError(s)}}buildErrorContext(t){return{name:t.name,message:t.message,stack:this.truncateStackTrace(t.stack),code:t.code}}buildSDKContext(){return{version:this.clientConfig.get("version")||"unknown",env:this.clientConfig.get("env"),isBuilder:this.clientConfig.get("isBuilder"),partnerCode:this.clientConfig.get("partnerCode")}}buildUserContext(){const t=this.store.get("address.formattedAddress");return{deviceId:this.clientConfig.get("userDeviceId")||"not_defined",isLocalStorageAvailable:this.clientConfig.get("isLocalStorageAvailable")||![],selectedAddress:t||void 0}}buildBrowserContext(){return{userAgent:navigator.userAgent,deviceType:this.clientConfig.get("deviceType"),url:window.location.href,referrer:document.referrer||void 0,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}shouldCapture(t){switch(t){case"debug":case"log":case"info":return this.config.includeDebugLogs;case"warn":return this.config.includeWarnings;case"error":case"fatal":return this.config.includeErrors;default:return![]}}addToQueue(t){this.eventQueue.length>=this.config.maxQueueSize&&(this.eventQueue.shift(),this.stats.droppedEvents++),this.eventQueue.push(t),this.stats.totalEvents++,this.stats.eventsByLevel[t.level]++,this.stats.queuedEvents=this.eventQueue.length,this.eventQueue.length>=this.config.batchSize&&this.flushQueue()}startBatchTimer(){this.batchTimer&&clearInterval(this.batchTimer),this.batchTimer=setInterval(()=>{this.eventQueue.length>0&&this.flushQueue()},this.config.batchInterval)}flushQueue(){var t;if(0===this.eventQueue.length||!(null===(t=this.config)||void 0===t?void 0:t.endpoint))return;const e=this.eventQueue.splice(0,this.config.batchSize);this.stats.queuedEvents=this.eventQueue.length;const n=this.createBatch(e);try{this.sendBatch(n),this.stats.batchesSent++}catch(r){this.stats.failedBatches++,this.handleInternalError(r),this.eventQueue.unshift(...e),this.stats.queuedEvents=this.eventQueue.length}}createBatch(t){const e=Date.now();return{batchId:"batch_"+e,timestamp:e,events:t}}sendBatch(t){if("undefined"!=typeof navigator&&navigator.sendBeacon)try{const e=new Blob([JSON.stringify(t)],{type:"text/plain"}),n=navigator.sendBeacon(this.config.endpoint,e);if(n)return}catch(e){return this.sendBatchViaXHR(t),void 0}this.sendBatchViaXHR(t)}sendBatchViaXHR(t){try{const e=new XMLHttpRequest;if(e.open("POST",this.config.endpoint,![]),e.setRequestHeader("Content-Type","text/plain"),e.send(JSON.stringify(t)),e.status<200||e.status>=300)throw new SDKError("XHR request failed with status: "+e.status)}catch(e){throw new SDKError("Both sendBeacon and XHR failed: "+e.message)}}truncateStackTrace(t){if(t)return t.split("\n").slice(0,10).join("\n")}handleInternalError(t){this.clientConfig.isProduction()&&!this.clientConfig.isDebuggingEnabled()||console.error("[LiquidCommerce Elements][Telemetry Internal Error]",t)}shutdown(){var t;if(!this.isShuttingDown&&(this.isShuttingDown=!![],this.batchTimer&&(clearInterval(this.batchTimer),this.batchTimer=null),this.eventQueue.length>0&&(null===(t=this.config)||void 0===t?void 0:t.endpoint))){const t=this.createBatch(this.eventQueue);this.eventQueue=[];try{this.sendBatch(t),this.stats.batchesSent++}catch(e){this.stats.failedBatches++}}}}class BaseComponent extends HTMLElement{get hostClasses(){return[]}get hostAttributes(){return{}}constructor(t={}){super(),this.initialized=![],this.isDestroyed=![],this.renderScheduled=![],this.unsubscribers=[],this.lastRenderTrigger="initial",this.renderCount=0,this.store=StoreService.getInstance(),this.commands=CommandService.getInstance(),this.themeProvider=ThemeProviderService.getInstance(),this.pubSub=PubSubService.getInstance(),this.logger=LoggerFactory.get("BaseComponent"),this.clientConfig=ClientConfigService.getInstance(),this.telemetry=TelemetryService.getInstance(),this.reactiveOptions={watchStorePaths:[],watchOnlyStorePaths:[],autoDestroy:![],autoDestroyDelay:0,...t}}initialize({data:t,config:e}){var n;this.D=Object.freeze(t),this.A=Object.freeze({type:e.type,tagName:this.tagName.toLowerCase(),useShadowDom:null!==(n=null==e?void 0:e.useShadowDom)&&void 0!==n?n:![]}),this.initialized&&(this.setup(),this.triggerRender("initialize"))}interpolateStorePaths(t){return t.map(t=>this.interpolatePath(t))}interpolatePath(t){if("string"!=typeof t)return t;const e=/\{([^}]+)}/g;return t.replace(e,(e,n)=>{const r=this.D[n];return null==r?(this.logger.warn('Parameter "'+n+'" not found in component params for path "'+t+'"'),e):String(r)})}connectedCallback(){var t,e;try{if(this.isDestroyed)return;this.initialized=!![],this.container=this.A.useShadowDom?this.attachShadow({mode:this.clientConfig.get("openShadowDom")?"open":"closed"}):this,this.setup(),this.triggerRender("connected"),null===(t=this.connected)||void 0===t||t.call(this)}catch(n){this.logger.error("Component connectedCallback error in "+((null===(e=this.A)||void 0===e?void 0:e.tagName)||"unknown"),n),n instanceof Error&&this.captureComponentError(n,"connectedCallback")}}disconnectedCallback(){var t,e;try{this.cleanup(),null===(t=this.disconnected)||void 0===t||t.call(this)}catch(n){this.logger.error("Component disconnectedCallback error in "+((null===(e=this.A)||void 0===e?void 0:e.tagName)||"unknown"),n),n instanceof Error&&this.captureComponentError(n,"disconnectedCallback")}}setup(){var t,e,n;try{this.updateHostClasses(),this.updateHostAttributes(),null===(t=this.beforeSetupStoreWatchers)||void 0===t||t.call(this),this.setupStoreWatchers(),this.setupNonRenderingWatchers(),this.setupAutoDestroy(),null===(e=this.beforeConnected)||void 0===e||e.call(this)}catch(r){this.logger.error("Component setup error in "+((null===(n=this.A)||void 0===n?void 0:n.tagName)||"unknown"),r),r instanceof Error&&this.captureComponentError(r,"setup")}}cleanup(){this.isDestroyed=!![],this.renderTimeout&&cancelAnimationFrame(this.renderTimeout),this.autoDestroyTimeout&&clearTimeout(this.autoDestroyTimeout);for(const e of this.unsubscribers)try{e()}catch(t){this.logger.error("Cleanup error during component destruction",t),t instanceof Error&&this.captureComponentError(t,"cleanup")}this.unsubscribers=[]}setupAutoDestroy(){var t;if(!this.reactiveOptions.autoDestroy)return;let e=this.reactiveOptions.autoDestroyPath;if(!e&&(null===(t=this.reactiveOptions.watchStorePaths)||void 0===t?void 0:t.length)&&(e=this.reactiveOptions.watchStorePaths[0]),!e)return this.logger.warn("AutoDestroy enabled but no path specified and no watchStorePaths found"),void 0;const n=this.interpolatePath(e),r=this.store.watch(n,(t,e)=>{this.isDestroyed||void 0===t&&void 0!==e&&this.handleAutoDestroy(n)});this.unsubscribers.push(r)}handleAutoDestroy(t){var e;if(this.isDestroyed)return;null===(e=this.beforeAutoDestroy)||void 0===e?void 0:e.call(this,t);const n=this.reactiveOptions.autoDestroyDelay||0;n>0?this.autoDestroyTimeout=setTimeout(()=>{this.destroyComponent()},n):this.destroyComponent()}destroyComponent(){var t;if(!this.isDestroyed)try{null===(t=this.onAutoDestroy)||void 0===t?void 0:t.call(this),this.remove()}catch(e){this.logger.error("Error during auto-destroy of "+this.A.tagName,e),e instanceof Error&&this.captureComponentError(e,"auto-destroy")}}setupStoreWatchers(){var t;try{let t=this.reactiveOptions.watchStorePaths;if(!(null==t?void 0:t.length)||!this.D)return;t=this.interpolateStorePaths(t);const e=this.store.watchMany(t,t=>{var e,n;try{if(this.isDestroyed)return;const n=t.map(t=>t.path).join(", "),r="store:["+n+"]",s=null===(e=this.onStoreChanged)||void 0===e?void 0:e.call(this,t);s!==![]&&this.triggerRender(r)}catch(r){this.logger.error("Store watcher callback error in "+((null===(n=this.A)||void 0===n?void 0:n.tagName)||"unknown"),r),r instanceof Error&&this.captureComponentError(r,"storeWatcher")}});this.unsubscribers.push(e)}catch(e){this.logger.error("Store watchers setup error in "+((null===(t=this.A)||void 0===t?void 0:t.tagName)||"unknown"),e),e instanceof Error&&this.captureComponentError(e,"setupStoreWatchers")}}setupNonRenderingWatchers(){var t;try{let t=this.reactiveOptions.watchOnlyStorePaths;if(!(null==t?void 0:t.length)||!this.D)return;t=this.interpolateStorePaths(t);const e=this.store.watchMany(t,t=>{var e,n;try{if(this.isDestroyed)return;null===(e=this.onStoreWatch)||void 0===e?void 0:e.call(this,t)}catch(r){this.logger.error("Non-rendering watcher callback error in "+((null===(n=this.A)||void 0===n?void 0:n.tagName)||"unknown"),r),r instanceof Error&&this.captureComponentError(r,"nonRenderingWatcher")}});this.unsubscribers.push(e)}catch(e){this.logger.error("Non-rendering watchers setup error in "+((null===(t=this.A)||void 0===t?void 0:t.tagName)||"unknown"),e),e instanceof Error&&this.captureComponentError(e,"setupNonRenderingWatchers")}}triggerRender(t){this.lastRenderTrigger=t,this.scheduleRender()}scheduleRender(){this.renderScheduled||this.isDestroyed||(this.renderScheduled=!![],this.renderTimeout=requestAnimationFrame(()=>{this.render(),this.renderScheduled=![]}))}render(){var t,e;if(!this.initialized||this.isDestroyed)return;const n=performance.now();this.renderCount++;try{const e=this.template();"string"==typeof e&&(this.container.innerHTML=e),e instanceof HTMLElement&&safeReplaceChildren(this.container,e),Array.isArray(e)&&safeReplaceChildren(this.container,...e);const s=performance.now()-n;this.logRenderInfo(s);try{null===(t=this.afterRender)||void 0===t?void 0:t.call(this)}catch(r){this.logger.error("❌ afterRender hook error in "+this.A.tagName,r),r instanceof Error&&this.captureComponentError(r,"afterRender")}}catch(s){const t=performance.now()-n;this.logger.error("❌ Component render error in "+this.A.tagName,s),this.captureComponentError(s,"render",t),safeReplaceChildren(this.container,ComponentFactoryService.componentError({componentType:this.A.type,message:s instanceof Error?s.message:String(s)}));try{null===(e=this.onError)||void 0===e?void 0:e.call(this,s,"render")}catch(a){this.logger.error("❌ onError hook error in "+this.A.tagName,a)}}}logRenderInfo(t){const e=this.A.type,n=this.A.tagName,r=t>16?"🐌":t>8?"⚡":"🚀";this.logger.debug("Rendered "+r+" "+e+" </"+n+"> | #"+this.renderCount+" | "+t.toFixed(2)+"ms | "+this.lastRenderTrigger),t>16&&(this.logger.warn("⚠️ Slow render in "+e+"("+n+"): "+t.toFixed(2)+"ms triggered by "+this.lastRenderTrigger,{duration:t,threshold:16,componentType:e,tagName:n,renderTrigger:this.lastRenderTrigger,renderCount:this.renderCount}),this.telemetry.captureEvent("warn","Slow render: "+t.toFixed(2)+"ms",{context:"Component:"+n+":performance",component:{type:e,tagName:n,renderCount:this.renderCount,renderTrigger:this.lastRenderTrigger,renderDuration:t,useShadowDom:this.A.useShadowDom}}))}rerender(t){this.triggerRender(t?"manual:rerender:"+t:"manual:rerender()")}captureComponentError(t,e,n){if(this.telemetry.isEnabled())try{this.telemetry.captureEvent("error",t.message,{context:"Component:"+this.A.tagName+":"+e,component:{type:this.A.type,tagName:this.A.tagName,renderCount:this.renderCount,renderTrigger:this.lastRenderTrigger,renderDuration:n,useShadowDom:this.A.useShadowDom}})}catch(r){}}updateHostClasses(){const t=this.hostClasses;if(t.length>0){const e=t.filter(t=>t&&"string"==typeof t&&t.trim());e.length>0&&this.classList.add(...e)}}addHostClasses(...t){const e=t.filter(t=>t&&"string"==typeof t&&t.trim());e.length>0&&this.classList.add(...e)}removeHostClasses(...t){const e=t.filter(t=>t&&"string"==typeof t&&t.trim());e.length>0&&this.classList.remove(...e)}toggleHostClasses(...t){const e=t.filter(t=>t&&"string"==typeof t&&t.trim());for(const n of e)this.classList.toggle(n)}addHostAttribute(t,e){t&&"string"==typeof t&&e&&"string"==typeof e&&(this.setAttribute(t,String(e)),this.hostAttributes[t]=String(e))}removeHostAttribute(t){t&&"string"==typeof t&&(this.removeAttribute(t),delete this.hostAttributes[t])}updateHostAttributes(){const t=this.hostAttributes;for(const[e,n]of Object.entries(t))e&&"string"==typeof e&&n&&"string"==typeof n&&this.setAttribute(e,String(n))}get params(){return this.D}get config(){return this.themeProvider.getComponentConfig(this.A.type)}get elementConfig(){return this.A}getConfigs(t){return this.themeProvider.getConfigs(t)}getStoreValue(t){return this.store.get(t)}setStoreValue(t,e){return this.store.set(t,e)}watchStore(t,e){const n=this.store.watch(t,e);return this.unsubscribers.push(n),n}}const kt={CT:"America/New_York",DE:"America/New_York",FL:"America/New_York",GA:"America/New_York",IN:"America/New_York",KY:"America/New_York",ME:"America/New_York",MD:"America/New_York",MA:"America/New_York",MI:"America/New_York",NH:"America/New_York",NJ:"America/New_York",NY:"America/New_York",NC:"America/New_York",OH:"America/New_York",PA:"America/New_York",RI:"America/New_York",SC:"America/New_York",TN:"America/New_York",VT:"America/New_York",VA:"America/New_York",WV:"America/New_York",AL:"America/Chicago",AR:"America/Chicago",IL:"America/Chicago",IA:"America/Chicago",KS:"America/Chicago",LA:"America/Chicago",MN:"America/Chicago",MS:"America/Chicago",MO:"America/Chicago",NE:"America/Chicago",ND:"America/Chicago",OK:"America/Chicago",SD:"America/Chicago",TX:"America/Chicago",WI:"America/Chicago",AZ:"America/Phoenix",CO:"America/Denver",ID:"America/Denver",MT:"America/Denver",NV:"America/Los_Angeles",NM:"America/Denver",UT:"America/Denver",WY:"America/Denver",CA:"America/Los_Angeles",OR:"America/Los_Angeles",WA:"America/Los_Angeles",AK:"America/Anchorage",HI:"Pacific/Honolulu"},xt="America/New_York";function detectUserTimezone(t){try{if(t){const e=t.toUpperCase(),n=kt[e];return n||xt}return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return xt}}function getCurrentTimeInTimezone(t){try{const e=new Date,n=e.getTime(),r=6e4*e.getTimezoneOffset(),s=new Date(n+r),a=new Date(s.toLocaleString("en-US",{timeZone:t})),c=s.getTime()-a.getTime();return new Date(n+c)}catch(e){return new Date}}function getCurrentTimeInUserTimezone(t){const e=detectUserTimezone(t);return getCurrentTimeInTimezone(e)}function isDateTimeInRange(t){const{startDate:e,endDate:n,addressState:r}=t;try{const t=getCurrentTimeInUserTimezone(r),s=!e||t>=new Date(e),a=!n||t<=new Date(n);return s&&a}catch(s){return![]}}function filterActiveItems(t,e){return t.filter(t=>isDateTimeInRange({startDate:t.activeFrom,endDate:t.activeUntil,addressState:e}))}function hasActiveItems(t,e){return filterActiveItems(t,e).length>0}class CheckoutComponent extends BaseComponent{constructor(){super({watchStorePaths:["checkout.rerender","checkout.presale"]})}template(){const t=this.store.get("checkout.presale"),e=this.getPromoTickerData(),n=this.checkForActiveTickers(e),s=document.createElement("div");s.classList.add("checkout-container"),this.params.isIndependentComponent&&s.classList.add("independent"),s.appendChild(ComponentFactoryService.createElement({type:r.CHECKOUT_INFORMATION})),s.appendChild(ComponentFactoryService.createElement({type:r.CHECKOUT_ORDER_SUMMARY}));const a=this.createHeaderWrapper(t,e,n);return[a,s]}getPromoTickerData(){var t,e;const n=this.getConfigs("global"),r=this.clientConfig.get("promoTicker"),s=null!==(e=null===(t=null==n?void 0:n.experienceFeatures)||void 0===t?void 0:t.promoTicker)&&void 0!==e?e:[];return null!=r?r:s}checkForActiveTickers(t){var e;const n=this.store.get("address");return hasActiveItems(t,null===(e=null==n?void 0:n.address)||void 0===e?void 0:e.state)}createHeaderWrapper(t,e,n){const s=this.params.isIndependentComponent,a=document.createElement("div");return a.classList.add("checkout-header-wrapper"),s&&a.classList.add("hosted"),a.appendChild(ComponentFactoryService.createElement({type:r.CHECKOUT_HEADER,isHostedCheckout:s})),e.length>0&&n&&!t&&a.appendChild(ComponentFactoryService.createElement({context:"checkout",type:r.PROMO_CODE_TICKER,tickers:e})),t&&a.appendChild(ComponentFactoryService.createElement({type:r.CHECKOUT_PRESALE_COUNTDOWN})),a}}function getDrawerStyles(){return"\n /* Drawer wrapper container */\n .drawer-wrapper {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: "+p.DRAWER_WRAPPER+";\n pointer-events: none;\n }\n\n .drawer-wrapper.open {\n pointer-events: auto;\n }\n\n /* Backdrop overlay */\n .drawer-backdrop {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: "+p.DRAWER_BACKDROP+";\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.3s ease, visibility 0.3s ease;\n pointer-events: none;\n }\n\n .drawer-backdrop.visible {\n opacity: 1;\n visibility: visible;\n pointer-events: auto;\n }\n\n /* Main drawer */\n .drawer {\n position: absolute;\n top: 0;\n right: 0;\n width: 400px;\n height: 100vh; /* Fallback for browsers that don't support dvh */\n height: 100dvh;\n z-index: "+p.DRAWER_CONTENT+";\n background-color: #ffffff;\n overflow: hidden;\n transform: translateX(100%);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n }\n\n /* Opened drawer state */\n .drawer.open {\n transform: translateX(0);\n }\n\n .drawer.address-input .drawer-content,\n .drawer.engraving-form .drawer-content,\n .drawer.product-retailers-popup-list .drawer-content {\n padding: 16px;\n }\n\n /* Content area - fills the remaining space */\n .drawer-content {\n position: relative;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n overflow-y: auto;\n background-color: var(--drawer-background-color, #FAFAFA);\n }\n\n /* Content swap animation classes */\n .drawer-content-fade-out {\n opacity: 1;\n transition: opacity 150ms ease-out;\n }\n\n .drawer-content-fade-out.fading {\n opacity: 0;\n }\n\n .drawer-content-fade-in {\n opacity: 0;\n transition: opacity 150ms ease-in;\n }\n\n .drawer-content-fade-in.visible {\n opacity: 1;\n }\n\n /* Mobile adjustments */\n @media (max-width: 576px) {\n .drawer {\n width: 100%;\n }\n }\n\n /* Accessibility - respect user's motion preferences */\n @media (prefers-reduced-motion: reduce) {\n .drawer,\n .drawer-backdrop,\n .drawer-content-fade-out,\n .drawer-content-fade-in {\n transition: none;\n }\n }\n "}const getProductLoadingStyles=()=>"\n .skeleton-container {\n min-width: 320px;\n width: 100%;\n height: auto;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n }\n\n .skeleton-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .skeleton-container .wave {\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n }\n\n .skeleton-container .wave::before {\n content: '';\n position: absolute;\n top: 0;\n left: -100%;\n width: 100%;\n height: 100%;\n background: linear-gradient(\n 90deg,\n transparent 0%,\n rgba(255, 255, 255, 0.8) 50%,\n transparent 100%\n );\n animation: wave 1.8s infinite ease-in-out;\n z-index: "+p.SKELETON_WAVE+";\n }\n\n .sc-title {\n height: 32px;\n width: 100%;\n }\n\n .sc-sizes {\n height: 36px;\n width: 100%;\n display: flex;\n }\n\n .sc-size-button {\n height: 36px;\n width: 30%;\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n }\n\n .sc-size-button:not(:first-child) {\n margin-left: 8px;\n }\n\n .sc-row {\n display: flex;\n background: none !important;\n height: auto;\n }\n\n .sc-row > *:not(:first-child) {\n margin-left: 12px;\n }\n\n .sc-price {\n height: 36px;\n width: 30%;\n }\n\n .sc-personalization {\n height: 36px;\n width: 40%;\n margin-right: 0;\n margin-left: auto;\n }\n\n .sc-deliver-to {\n height: 16px;\n width: 25%;\n margin-bottom: -16px;\n }\n\n .sc-address {\n height: 16px;\n width: 75%;\n }\n\n .sc-retailers {\n height: 140px;\n width: 100%;\n }\n\n .sc-quantity {\n height: 36px;\n width: 30%;\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n }\n\n .sc-add-to-cart {\n height: 36px;\n flex: 1;\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n }\n\n .sc-description-title {\n height: 16px;\n width: 45%;\n margin-bottom: -12px;\n }\n\n .sc-description-line {\n height: 16px;\n width: 100%;\n margin-bottom: -20px;\n }\n\n .sc-description-more {\n height: 16px;\n width: 30%;\n margin-top: 8px;\n }\n\n .sc-title::before { animation-delay: 0s; }\n .sc-price::before { animation-delay: 0.1s; }\n .sc-size-button::before { animation-delay: 0.2s; }\n .sc-price::before { animation-delay: 0.3s; }\n .sc-personalization::before { animation-delay: 0.4s; }\n .sc-deliver-to::before { animation-delay: 0.5s; }\n .sc-address::before { animation-delay: 0.6s; }\n .sc-retailers::before { animation-delay: 0.7s; }\n .sc-quantity::before { animation-delay: 0.8s; }\n .sc-add-to-cart::before { animation-delay: 0.9s; }\n .sc-description-title::before { animation-delay: 1.0s; }\n .sc-description-line:nth-child(10)::before { animation-delay: 1.1s; }\n .sc-description-line:nth-child(11)::before { animation-delay: 1.2s; }\n .sc-description-line:nth-child(12)::before { animation-delay: 1.3s; }\n .sc-description-more::before { animation-delay: 1.4s; }\n\n .sc-main-image {\n width: 100%;\n height: 350px;\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n flex: 1;\n }\n\n .sc-carousel-dot {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: #c4d1e0;\n margin-right: 10px;\n }\n\n .sc-carousel-dot:last-child {\n margin-right: 0;\n }\n\n .sc-gallery-thumbnail {\n width: 60px;\n height: 60px;\n background-color: #c4d1e0;\n border-radius: 6px;\n position: relative;\n overflow: hidden;\n }\n\n .sc-main-image::before { animation-delay: 1.5s; }\n .sc-carousel-dot::before { animation-delay: 1.6s; }\n .sc-gallery-thumbnail::before { animation-delay: 1.7s; }\n\n @media (min-width: 480px) {\n .sc-carousel-dot {\n width: 8px;\n height: 8px;\n margin-right: 8px;\n }\n }\n\n @media (min-width: 769px) {\n .sc-gallery-thumbnail {\n width: 80px;\n height: 80px;\n }\n\n .sc-main-image {\n height: 474px;\n }\n }\n\n @keyframes wave {\n 0% {\n left: -100%;\n }\n 100% {\n left: 100%;\n }\n }\n",getProductListCardLoadingStyles=()=>"\n .product-list-card-loading__container {\n width: 100%;\n height: 100%;\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: 24px;\n --gap-per-card: calc(24px * (var(--columns, 4) - 1) / var(--columns, 4));\n }\n\n .slc__card {\n width: calc(var(--card-width, 25%) - var(--gap-per-card, 18px));\n min-width: 226px;\n flex: 0 0 calc(var(--card-width, 25%) - var(--gap-per-card, 18px));\n pointer-events: none;\n background-color: transparent;\n border: none;\n border-radius: var(--card-border-radius, 0.375rem);\n overflow: hidden;\n cursor: default;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n height: 100%;\n }\n\n .slc__card .wave {\n background-color: #c4d1e0;\n position: relative;\n overflow: hidden;\n }\n\n .slc__card .wave::before {\n content: '';\n position: absolute;\n top: 0;\n left: -100%;\n width: 100%;\n height: 100%;\n background: linear-gradient(\n 90deg,\n transparent 0%,\n rgba(255, 255, 255, 0.8) 50%,\n transparent 100%\n );\n animation: wave 1.8s infinite ease-in-out;\n z-index: "+p.SKELETON_WAVE+";\n }\n\n .slc__image-content {\n width: 100%;\n height: 100%;\n padding: 10px 0;\n }\n\n .slc__image-wrapper {\n width: 100%;\n height: 14rem;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n border-bottom: none;\n padding-bottom: 10px;\n }\n\n .slc__image {\n width: 100%;\n height: 14rem;\n background-color: #c4d1e0;\n }\n\n .slc__content {\n width: 100%;\n display: flex;\n flex-direction: column;\n margin-bottom: 10px;\n }\n\n .slc__title-container {\n display: flex;\n flex-direction: column;\n margin-bottom: 20px;\n width: 100%;\n }\n\n .slc__title-container > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .slc__title {\n height: 18px;\n background-color: #c4d1e0;\n }\n\n .slc__title-line-1 {\n width: 90%;\n }\n\n .slc__title-line-2 {\n width: 75%;\n }\n\n .slc__price {\n width: 60px;\n height: 20px;\n background-color: #c4d1e0;\n }\n\n .slc__size-price-wrapper {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n }\n\n .slc__size {\n width: 45px;\n height: 20px;\n background-color: #c4d1e0;\n }\n\n .slc__button {\n width: 100%;\n height: 42px;\n margin-top: 10px;\n background-color: var(--primary-color, #3b82f6);\n opacity: 0.7;\n }\n\n .slc__card:nth-child(1) .slc__image::before { animation-delay: 0s; }\n .slc__card:nth-child(1) .slc__title-line-1::before { animation-delay: 0.05s; }\n .slc__card:nth-child(1) .slc__title-line-2::before { animation-delay: 0.1s; }\n .slc__card:nth-child(1) .slc__price::before { animation-delay: 0.2s; }\n .slc__card:nth-child(1) .slc__size::before { animation-delay: 0.2s; }\n .slc__card:nth-child(1) .slc__button::before { animation-delay: 0.25s; }\n\n .slc__card:nth-child(2) .slc__image::before { animation-delay: 0.05s; }\n .slc__card:nth-child(2) .slc__title-line-1::before { animation-delay: 0.1s; }\n .slc__card:nth-child(2) .slc__title-line-2::before { animation-delay: 0.15s; }\n .slc__card:nth-child(2) .slc__price::before { animation-delay: 0.25s; }\n .slc__card:nth-child(2) .slc__size::before { animation-delay: 0.25s; }\n .slc__card:nth-child(2) .slc__button::before { animation-delay: 0.3s; }\n\n .slc__card:nth-child(3) .slc__image::before { animation-delay: 0.1s; }\n .slc__card:nth-child(3) .slc__title-line-1::before { animation-delay: 0.15s; }\n .slc__card:nth-child(3) .slc__title-line-2::before { animation-delay: 0.2s; }\n .slc__card:nth-child(3) .slc__price::before { animation-delay: 0.3s; }\n .slc__card:nth-child(3) .slc__size::before { animation-delay: 0.3s; }\n .slc__card:nth-child(3) .slc__button::before { animation-delay: 0.35s; }\n\n .slc__card:nth-child(4) .slc__image::before { animation-delay: 0.15s; }\n .slc__card:nth-child(4) .slc__title-line-1::before { animation-delay: 0.2s; }\n .slc__card:nth-child(4) .slc__title-line-2::before { animation-delay: 0.25s; }\n .slc__card:nth-child(4) .slc__price::before { animation-delay: 0.35s; }\n .slc__card:nth-child(4) .slc__size::before { animation-delay: 0.35s; }\n .slc__card:nth-child(4) .slc__button::before { animation-delay: 0.4s; }\n\n .slc__card:nth-child(n+5) .slc__image::before { animation-delay: 0.2s; }\n .slc__card:nth-child(n+5) .slc__title-line-1::before { animation-delay: 0.25s; }\n .slc__card:nth-child(n+5) .slc__title-line-2::before { animation-delay: 0.3s; }\n .slc__card:nth-child(n+5) .slc__price::before { animation-delay: 0.4s; }\n .slc__card:nth-child(n+5) .slc__size::before { animation-delay: 0.4s; }\n .slc__card:nth-child(n+5) .slc__button::before { animation-delay: 0.45s; }\n\n @media (max-width: 639px) {\n .product-list-card-loading__container {\n --columns: 1;\n --gap-per-card: 0px;\n }\n\n .slc__card {\n width: 100%;\n flex: 0 0 100%;\n max-width: 336px;\n }\n }\n\n @media (min-width: 640px) and (max-width: 767px) {\n .product-list-card-loading__container {\n --columns: 2;\n --gap-per-card: 12px;\n }\n\n .slc__card {\n width: calc(50% - 12px);\n flex: 0 0 calc(50% - 12px);\n }\n }\n\n @media (min-width: 768px) and (max-width: 1023px) {\n .product-list-card-loading__container {\n --columns: 3;\n --gap-per-card: 16px;\n }\n\n .slc__card {\n width: calc(33.333% - 16px);\n flex: 0 0 calc(33.333% - 16px);\n }\n }\n\n @media (min-width: 1024px) {\n .product-list-card-loading__container {\n --gap-per-card: calc(24px * (var(--columns, 4) - 1) / var(--columns, 4));\n }\n\n .slc__card {\n width: calc(var(--card-width, 25%) - var(--gap-per-card, 18px));\n flex: 0 0 calc(var(--card-width, 25%) - var(--gap-per-card, 18px));\n }\n }\n";function getModalStyles(){return"\n .modal-wrapper {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: "+p.MODAL+";\n pointer-events: none;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px;\n }\n\n .modal-wrapper.open {\n pointer-events: auto;\n }\n\n .modal-backdrop {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n opacity: 0;\n visibility: hidden;\n transition: opacity 150ms ease-out, visibility 150ms ease-out;\n }\n\n .modal-backdrop.visible {\n opacity: 1;\n visibility: visible;\n }\n\n .modal {\n position: relative;\n max-width: 512px;\n max-height: 576px;\n width: 100%;\n height: 100%;\n background: transparent;\n opacity: 0;\n transform: scale(0.95);\n transition: opacity 150ms ease-out, transform 150ms ease-out;\n z-index: 1; /* Higher than backdrop within the wrapper context */\n }\n\n .modal.open {\n opacity: 1;\n transform: scale(1);\n }\n\n .modal-content {\n position: relative;\n max-width: 512px;\n max-height: 576px;\n width: 100%;\n box-sizing: border-box;\n background: var(--drawer-background-color, #FAFAFA);\n border-radius: var(--border-radius-rounded, 6px);\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);\n padding: 16px;\n overflow-y: auto;\n }\n\n @media (max-width: 576px) {\n .modal-wrapper {\n padding: 8px;\n }\n\n .modal {\n max-width: 100%;\n }\n\n .modal-content {\n max-height: calc(100vh - 16px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .modal,\n .modal-backdrop {\n transition: none;\n }\n }\n "}function getPromoCodeTickerStyles(){return"\n .promo-ticker {\n display: flex;\n align-items: stretch;\n width: 100%;\n height: 30px;\n background: var(--accent-color-70, #fff);\n position: relative;\n overflow: hidden;\n }\n\n .promo-ticker__content {\n width: calc(100% - 55px);\n display: flex;\n align-items: center;\n overflow: hidden;\n position: relative;\n border-top: 1px solid var(--accent-color, #E4E4E7);\n border-bottom: 1px solid var(--accent-color, #E4E4E7);\n transition: width 0.3s ease;\n }\n\n .promo-ticker:has(.promo-ticker__cta:disabled) .promo-ticker__content {\n width: calc(100% - 60px);\n }\n\n .promo-ticker__content::before,\n .promo-ticker__content::after {\n content: '';\n position: absolute;\n top: 0;\n width: 60px;\n height: 100%;\n z-index: 2;\n pointer-events: none;\n }\n\n .promo-ticker__content::before {\n left: 0;\n background: linear-gradient(90deg, var(--accent-color-70, #fff) 0%, transparent 100%);\n }\n\n .promo-ticker__content::after {\n right: 0;\n background: linear-gradient(90deg, transparent 0%, var(--accent-color-70, #fff) 100%);\n }\n\n .promo-ticker__track {\n display: flex;\n animation: promo-scroll 30s linear infinite;\n will-change: transform;\n }\n\n .promo-ticker__content:hover .promo-ticker__track {\n animation-play-state: paused;\n }\n\n .promo-ticker__text-group {\n display: flex;\n align-items: center;\n color: var(--default-text-color, #fff);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n letter-spacing: 0.5px;\n text-transform: uppercase;\n }\n\n .promo-ticker__text-item {\n display: inline-flex;\n align-items: center;\n }\n\n .promo-ticker__separator {\n margin: 0 16px;\n color: var(--default-text-color, #fff);\n font-size: 12px;\n }\n\n @keyframes promo-scroll {\n 0% { transform: translateX(0); }\n 100% { transform: translateX(-50%); }\n }\n\n .promo-ticker__cta {\n width: 55px;\n height: 100%;\n background-color: var(--primary-color, #FF5733);\n color: var(--selected-text-color, #fff);\n font-family: var(--heading-font-family, Poppins);\n font-size: 12px;\n font-weight: 600;\n text-transform: uppercase;\n user-select: none;\n position: absolute;\n right: 0;\n top: 0;\n transition: width 0.3s ease;\n }\n\n .promo-ticker__cta:disabled {\n width: 60px;\n background-color: var(--primary-color-70, #FF5733);\n cursor: not-allowed;\n }\n "}const getGlobalStyles=()=>"\n html, body, div, span, applet, object, iframe,\n h1, h2, h3, h4, h5, h6, p, blockquote, pre,\n a, abbr, acronym, address, big, cite, code,\n del, dfn, em, img, ins, kbd, q, s, samp,\n small, strike, strong, sub, sup, tt, var,\n b, u, i, center,\n dl, dt, dd, ol, ul, li,\n fieldset, form, label, legend,\n table, caption, tbody, tfoot, thead, tr, th, td,\n article, aside, canvas, details, embed,\n figure, figcaption, footer, header, hgroup,\n menu, nav, output, ruby, section, summary,\n time, mark, audio, video {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n\n *, :after, :before {\n box-sizing: border-box;\n }\n\n article, aside, details, figcaption, figure,\n footer, header, hgroup, menu, nav, section {\n display: block;\n }\n body {\n line-height: 1;\n }\n ol, ul {\n list-style: none;\n }\n blockquote, q {\n quotes: none;\n }\n blockquote:before, blockquote:after,\n q:before, q:after {\n content: '';\n content: none;\n }\n table {\n border-collapse: collapse;\n border-spacing: 0;\n }\n\n button {\n background: none;\n border: none;\n padding: 0;\n font: inherit;\n color: inherit;\n cursor: pointer;\n }\n\n input,\n textarea {\n background: none;\n border: none;\n padding: 0;\n resize: none;\n }\n\n input[type=\"checkbox\"] {\n /* Add if not using autoprefixer */\n -webkit-appearance: none;\n appearance: none;\n /* For iOS < 15 to remove gradient background */\n background-color: #fff;\n /* Not removed via appearance */\n margin: 0;\n }\n\n .custom-input {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: flex-start;\n align-self: stretch;\n flex: 1 0 0;\n font-family: var(--heading-font-family, Poppins);\n }\n\n .disabled-input {\n opacity: 0.5;\n pointer-events: disable;\n }\n\n .custom-input.birthdate .date-input-container {\n display: flex;\n height: 36px;\n align-items: center;\n align-self: stretch;\n }\n\n .date-input-container .month-field,\n .date-input-container .day-field {\n flex: 0 1 50px;\n max-width: 50px;\n }\n\n .date-input-container .year-field {\n flex: 1 0 70px;\n max-width: 70px;\n }\n\n .date-input-container .date-separator {\n color: var(--accent-color, #18181B);\n font-size: 14px;\n line-height: 24px;\n margin: 0 8px;\n }\n\n .custom-input.birthdate input {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n align-items: flex-start;\n font-size: 16px;\n height: 36px;\n font-family: var(--paragraph-font-family, Poppins);\n color: var(--default-text-color, #18181B);\n font-weight: 500;\n padding: 4px 11px;\n align-self: stretch;\n border-radius: var(--button-border-radius, 6px);\n box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05);\n min-width: 53px;\n }\n\n .custom-input.birthdate.outlined input {\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .custom-input.birthdate.filled input {\n background-color: var(--accent-color, #E4E4E7);\n }\n\n .custom-input label {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 1;\n color: var(--default-text-color, #18181B);\n text-align: left;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n font-family: var(--paragraph-font-family, Poppins);\n text-overflow: ellipsis;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 14px;\n padding-bottom: 2px;\n margin-bottom: 6px;\n }\n\n /* Enhanced fallback for browsers without line-clamp */\n @supports not (-webkit-line-clamp: 1) {\n .custom-input label {\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n }\n\n .custom-input > input,\n .custom-input textarea {\n width: 100%;\n display: flex;\n height: 36px;\n padding: 4px 12px;\n align-items: center;\n font-size: 16px;\n align-self: stretch;\n border-radius: var(--button-border-radius, 6px);\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-weight: 500;\n }\n\n .custom-input.outlined > input,\n .custom-input.outlined textarea {\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .custom-input.filled > input,\n .custom-input.filled textarea {\n background-color: var(--accent-color, #E4E4E7);\n }\n\n .custom-input input:focus,\n .custom-input textarea:focus,\n .custom-input select:focus {\n outline: none;\n border-color: var(--primary-color, #3b82f6);\n }\n\n .custom-input input:disabled,\n .custom-input select:disabled {\n cursor: not-allowed;\n }\n\n .custom-input.textarea textarea {\n height: auto;\n }\n\n .custom-input input.input-error {\n border-color: var(--error-color, #EF4444);\n }\n\n .custom-input .error-container {\n display: none;\n }\n\n .custom-input .error-container.show {\n display: block;\n margin-top: 8px;\n }\n\n .custom-input .error-message {\n color: var(--error-color, #EF4444);\n font-size: 0.875rem;\n margin-bottom: 0.25rem;\n }\n\n p > strong {\n font-weight: 700;\n }\n\n /* Alert Styles\n ** Global styles for alerts\n */\n\n .alert {\n display: flex;\n flex-direction: row;\n padding: 8px 16px;\n align-items: flex-start;\n align-self: stretch;\n border-radius: var(--border-radius-rounded, 6px);\n margin-bottom: 8px;\n }\n\n .alert-warning {\n border: 1px solid var(--warning-color, #EA580C);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--warning-color, #EA580C);\n }\n\n .alert-success {\n border: 1px solid var(--success-color, #10b981);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--success-color, #10b981);\n }\n\n .alert-info {\n border: 1px solid var(--base-blue, #3b82f6);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--base-blue, #3b82f6);\n }\n\n .alert-message {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: 13px;\n word-break: break-word;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n flex: 1;\n }\n\n .alert-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n flex-shrink: 0;\n margin-right: 5px;\n }\n\n .alert-icon-warning {\n color: var(--warning-color, #EA580C);\n }\n\n .alert-icon-success {\n color: var(--success-color, #10b981);\n }\n\n .alert-icon-info {\n color: var(--base-blue, #3b82f6);\n }\n\n .alert-icon svg {\n width: 16px;\n height: 16px;\n }\n\n .alert-icon-svg {\n width: 12px;\n height: 12px;\n fill: currentColor;\n }\n\n .alert-details {\n margin-top: 8px;\n padding-left: 24px;\n }\n\n .alert-details-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: var(--typography-base-sizes-small-font-size, 12px);\n font-weight: var(--font-weight-normal, 400);\n opacity: 0.8;\n }\n\n /** Engraving FORM **/\n\n .engraving-form {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .engraving-form > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .engraving-form .product-info-section,\n .engraving-form .fulfillment-section,\n .engraving-form .engraving-section {\n display: flex;\n padding: 16px 16px;\n align-items: flex-start;\n align-self: stretch;\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .engraving-form .product-info-section {\n flex-direction: row;\n align-items: center;\n }\n\n .product-info-section > *:not(:last-child) {\n margin-right: 12px;\n }\n\n .product-details-container {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .product-details-container > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .engraving-form .product-info-section .product-image-container {\n display: flex;\n width: 68px;\n height: 68px;\n flex-direction: column;\n align-items: flex-start;\n aspect-ratio: 1/1;\n }\n\n .engraving-form .product-info-section .product-image-container .product-image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: var(--card-border-radius, 6px);\n }\n\n .product-details-container .product-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .product-details-container .product-title,\n .product-details-container .product-price {\n color: var(--default-text-color, #18181B);\n font-feature-settings: 'haln' on;\n font-family: var(--heading-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 24px;\n }\n\n .product-details-container .product-price {\n margin-left: 4px;\n white-space: nowrap;\n }\n\n .product-size-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n align-self: stretch;\n text-align: left;\n }\n\n .engraving-fees-disclaimer {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 16px;\n align-self: stretch;\n text-align: left;\n }\n\n .engraving-form .fulfillment-section .shipping-from-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n margin-bottom: 8px;\n }\n\n .engraving-form .fulfillment-section .shipping-from-text b {\n font-weight: 600;\n }\n\n .engraving-form .fulfillment-section {\n flex-direction: column;\n }\n\n .fulfillment-options-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n max-height: 0;\n overflow: hidden;\n transition: max-height 0.3s ease;\n }\n\n .fulfillment-options-container.expanded {\n max-height: 100%;\n }\n\n .fulfillment-options-container.expanded + .see-more-fulfillments {\n margin-top: 8px;\n }\n\n .fulfillment-options-container .fulfillment-option {\n width: 100%;\n display: flex;\n min-width: 216px;\n padding: 16px;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n cursor: pointer;\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n color: var(--default-text-color, #18181B);\n flex-shrink: 0;\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .fulfillment-options-container .fulfillment-option:not(:first-child) {\n margin-top: 8px;\n }\n\n .fulfillment-options-container .fulfillment-option.selected {\n color: var(--selected-text-color, #FAFAFA);\n border-radius: var(--card-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n border: 1px solid transparent;\n box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.06) inset;\n }\n\n .fulfillment-options-container .fulfillment-option .option-row {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n }\n\n .fulfillment-options-container .fulfillment-option .option-row > *:not(:last-child) {\n margin-right: 8px;\n }\n\n .fulfillment-options-container .fulfillment-option .option-row:first-child span {\n font-weight: 600;\n }\n\n .fulfillment-options-container .fulfillment-option .option-row:last-child {\n margin-top: 8px;\n }\n\n .fulfillment-options-container .fulfillment-option > span {\n width: 50%;\n }\n\n .see-more-fulfillments {\n color: var(--link-text-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n text-decoration-line: underline;\n text-decoration-style: solid;\n text-decoration-skip-ink: none;\n text-decoration-thickness: auto;\n text-underline-offset: auto;\n text-underline-position: from-font;\n cursor: pointer;\n }\n\n .engraving-section {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .engraving-section .engraving-title {\n color: var(--default-text-color, #18181B);\n font-feature-settings: 'haln' on;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .engraving-section .engraving-location-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .engraving-inputs-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n margin-top: 16px;\n }\n\n .engraving-inputs-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .engraving-input-wrapper {\n display: flex;\n height: 36px;\n padding: 4px 12px;\n align-items: center;\n align-self: stretch;\n border-radius: var(--button-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n }\n\n .engraving-input-wrapper > *:not(:last-child) {\n margin-right: 4px;\n }\n\n .engraving-input-wrapper .engraving-input {\n flex: 1;\n border: none;\n outline: none;\n overflow: hidden;\n color: var(--default-text-color, #18181B);\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n text-transform: uppercase;\n }\n\n .engraving-input-wrapper .engraving-char-count {\n color: var(--default-text-color-50, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n white-space: nowrap;\n }\n\n .action-buttons-container {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n align-content: flex-start;\n align-self: stretch;\n }\n\n .action-buttons-container > *:not(:last-child) {\n margin-right: 16px;\n }\n\n .action-buttons-container .cancel-action-button {\n width: 20%;\n padding: 8px 16px;\n color: var(--primary-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n white-space: nowrap;\n }\n\n .action-buttons-container .add-to-cart-button {\n width: 80%;\n padding: 8px 16px;\n border-radius: var(--button-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n box-shadow: 0 1.5px 3px 0 rgba(0, 0, 0, 0.10), 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n color: var(--selected-text-color, #FAFAFA);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n white-space: nowrap;\n }\n\n .action-buttons-container .add-to-cart-button:disabled {\n background: var(--primary-color-70, #E4E4E7);\n cursor: not-allowed;\n }\n\n .engraving-disclaimer {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 16px;\n }\n\n .engraving-disclaimer b {\n font-weight: 600;\n }\n\n /** Component Error View **/\n .error-view {\n padding: 20px;\n background: #fff5f5;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n color: #c53030;\n text-align: center;\n }\n\n .error-view h3 {\n margin-bottom: 10px;\n }\n\n .error-view p {\n margin-bottom: 20px;\n font-size: 16px;\n font-style: italic;\n }\n\n .error-view button {\n padding: 8px 16px;\n background: #c53030;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n .powered-by-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .pb-title-container {\n display: flex;\n justify-content: center;\n align-items: baseline;\n align-self: stretch;\n margin-bottom: 4px;\n padding-bottom: 7px;\n }\n\n .pb-text {\n text-align: center;\n font-family: 'Poppins';\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 100%;\n margin-right: 4px;\n }\n\n .pb-lc {\n font-family: 'Poppins';\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .pb-dot {\n font-family: 'Poppins';\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .light .pb-text,\n .light .pb-lc {\n color: #0F172A;\n }\n\n .light .pb-dot {\n color: #1D4ED8;\n }\n\n .dark .pb-text,\n .dark .pb-lc,\n .dark .pb-dot {\n color: #FAFAFA;\n }\n\n .pb-disclaimer-container {\n align-self: stretch;\n text-align: center;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 11px;\n font-style: normal;\n font-weight: 300;\n line-height: 16px;\n word-break: break-word;\n }\n\n .pb-link {\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 11px;\n font-style: normal;\n font-weight: 300;\n line-height: 16px;\n }\n\n .dark .pb-disclaimer-container, .dark .pb-link {\n color: #FAFAFA;;\n }\n\n .light .pb-disclaimer-container {\n color: #0F172A;\n }\n\n .light .pb-link {\n color: #1D4ED8;\n }\n\n .lce-ui-button {\n display: block;\n position: relative;\n cursor: pointer;\n width: 24px;\n height: 24px;\n }\n\n .lce-ui-button.independent {\n position: absolute;\n top: 12px;\n right: 12px;\n z-index: "+p.INDEPENDENT_BUTTON+';\n }\n\n /* Cart Button Components */\n .lce-cart-button-icon {\n display: block;\n }\n\n .lce-cart-button-badge {\n position: absolute;\n top: -6px;\n right: -6px;\n background: var(--primary-color, #1D4ED8);\n color: var(--selected-text-color, #FAFAFA);\n border-radius: 50%;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 10px;\n font-weight: bold;\n font-family: var(--heading-font-family, Poppins);\n pointer-events: none;\n z-index: 10;\n line-height: 1;\n }\n\n /* Global Icon Styling - Automatic Accent Color Application */\n svg {\n color: var(--icon-color, var(--accent-color, #E4E4E7));\n }\n\n svg path,\n svg circle,\n svg rect,\n svg line,\n svg polygon,\n svg polyline,\n svg ellipse {\n fill: currentColor;\n stroke: currentColor;\n }\n\n /* Respect explicit fill="none" */\n svg [fill="none"] {\n fill: none !important;\n }\n\n /* Specific icon overrides for semantic colors */\n .checkbox-icon {\n color: var(--icon-color, var(--selected-text-color, #FAFAFA));\n }\n\n .error-info-icon {\n color: var(--icon-color, var(--error-color, #DC2626));\n }\n\n .success-icon {\n color: var(--icon-color, var(--success-color, #10b981));\n }\n\n .warning-icon {\n color: var(--icon-color, var(--warning-color, #EA580C));\n }\n\n .info-icon {\n color: var(--icon-color, var(--accent-color, #E4E4E7));\n }\n\n .search-icon {\n color: var(--icon-color, var(--accent-color, #E4E4E7));\n }\n\n .arrow-right-icon,\n .bag-icon,\n .completed-icon,\n .loading-spinner-icon,\n .trash-icon,\n .chevron-down-icon {\n color: var(--icon-color, var(--accent-color, #E4E4E7));\n }\n\n .chevron-left-icon,\n .close-icon {\n color: var(--icon-color, var(--default-text-color, #18181B));\n }\n\n\n /* Exception for icons that should not inherit color (logos, specific designs) */\n svg[data-no-color-inherit] * {\n fill: initial;\n stroke: initial;\n }\n\n /* Override for stroke-only icons */\n svg[data-stroke-only] * {\n fill: none;\n stroke: currentColor;\n }\n\n /* Override for fill-only icons */\n svg[data-fill-only] * {\n fill: currentColor;\n stroke: none;\n }\n\n /* Tablet and up */\n @media (min-width: 768px) {\n .lce-ui-button.independent {\n top: 16px;\n right: 16px;\n }\n }\n\n /* Desktop */\n @media (min-width: 1024px) {\n .lce-ui-button.independent {\n top: 20px;\n right: 20px;\n }\n }\n\n /** Engraving View Container */\n .engraving-view-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .engraving-view-container {\n width: 100%;\n padding: 16px;\n }\n\n .engraving-view-container.outlined {\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .engraving-view-container.filled {\n border-radius: var(--card-border-radius, 6px);\n background: linear-gradient(0deg, var(--alpha-50, rgba(254, 254, 254, 0.50)) 0%, var(--alpha-50, rgba(254, 254, 254, 0.50)) 100%), var(--accent-color, #E4E4E7);\n }\n\n .engraving-view-container .engraving-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n align-content: center;\n }\n\n .engraving-view-container .engraving-header {\n margin-bottom: 16px;\n }\n\n .engraving-view-container .engraving-header h3,\n .engraving-view-container .engraving-header span {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .engraving-view-container .engraving-header span.engraving-fee .engraving-fee-each {\n font-weight: 500;\n }\n\n .engraving-view-container .engraving-body {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n align-content: flex-end;\n align-self: stretch;\n flex-wrap: wrap;\n }\n\n .engraving-view-container .engraving-lines {\n display: flex;\n min-width: 136px;\n flex-direction: column;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .engraving-view-container .engraving-lines .engraving-line {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 100%;\n text-transform: uppercase;\n margin-top: 4px;\n }\n\n .engraving-view-container .engraving-lines .engraving-line:not(:first-child) {\n margin-top: 4px;\n }\n\n .engraving-view-container .engraving-actions {\n display: flex;\n align-items: center;\n }\n\n .engraving-view-container .engraving-actions .edit-button {\n margin-left: 16px;\n }\n\n .engraving-view-container .engraving-actions button {\n color: var(--link-text-color, #1D4ED8);\n font-family: var(--heading-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n text-decoration-line: underline;\n text-decoration-style: solid;\n text-decoration-skip-ink: none;\n text-decoration-thickness: auto;\n text-underline-offset: auto;\n text-underline-position: from-font;\n cursor: pointer;\n }\n\n .action-disabled {\n opacity: 0.7;\n cursor: not-allowed;\n }\n\n .disclaimer-header {\n overflow: hidden;\n color: var(--default-text-color, #18181B);\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-style: normal;\n font-weight: 600;\n line-height: 16px;\n }\n\n .disclaimer-description {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 16px;\n }\n\n /* Alert Container - Simplified version matching existing alert design */\n .alert-container {\n display: flex;\n padding: 8px 16px;\n align-items: flex-start;\n flex-direction: row;\n align-self: stretch;\n border-radius: var(--button-border-radius, 6px);\n border: 1px solid var(--error-color, #DC2626);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--error-color, #DC2626);\n }\n\n .alert-wrapper {\n display: flex;\n flex-direction: column;\n align-self: stretch;\n }\n\n .alert-wrapper > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .alert-wrapper.hidden {\n display: none;\n }\n\n .alert-item {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n }\n\n .alert-container.hidden {\n display: none;\n }\n\n .alert-container.alert-error {\n border-color: var(--error-color, #DC2626);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--error-color, #DC2626);\n }\n\n .alert-container.alert-warning {\n border-color: var(--warning-color, #FBBF24);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--warning-color, #FBBF24);\n }\n\n .alert-container.alert-success {\n border-color: var(--success-color, #4ADE80);\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--success-color, #4ADE80);\n }\n\n .alert-container .alert-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n margin-right: 8px;\n color: var(--error-color, #DC2626);\n }\n\n .alert-container .alert-icon svg {\n width: 16px;\n height: 16px;\n }\n\n .alert-container .alert-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: 13px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n flex: 1;\n }\n\n\n /*************************\n Animation\n *************************/\n @keyframes spin {\n 0% {\n transform: translateY(-50%) rotate(0deg);\n }\n 100% {\n transform: translateY(-50%) rotate(360deg);\n }\n }\n\n @keyframes slideIn {\n 0% {\n opacity: 0;\n transform: translateY(-8px);\n max-height: 0;\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n max-height: 100px;\n }\n }\n\n /*************************\n Accessibility - Focus Visible\n *************************/\n\n /* Remove default focus outline for mouse users */\n *:focus {\n outline: none;\n }\n\n /* Show focus only for keyboard navigation */\n *:focus-visible {\n outline: 1px solid var(--warning-color, #1D4ED8);\n outline-offset: 0px;\n border-radius: var(--button-border-radius, 6px);\n box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.1);\n }\n\n /* Screen reader only text */\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n }\n';lt.register("global",getGlobalStyles,0),lt.register("ui",getDrawerStyles,1),lt.register("ui",getProductLoadingStyles,2),lt.register("ui",getProductListCardLoadingStyles,3),lt.register("ui",getPromoCodeTickerStyles,4),lt.register("ui",getModalStyles,5);const getCheckoutStyles=()=>"\n .checkout-container {\n width: 100%;\n height: auto;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-self: stretch;\n gap: 24px;\n }\n\n .checkout-container:not(.independent) {\n padding: 24px;\n }\n\n .checkout-container.independent {\n padding: 24px;\n }\n\n .checkout-information-section {\n min-width: 320px;\n max-width: 512px;\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n flex-wrap: wrap;\n flex: 1 0 0;\n }\n\n .checkout-information-section > *:not(:first-child) {\n margin-top: 24px;\n padding-top: 24px;\n border-top: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .checkout-delivery-information,\n .checkout-buyer-information,\n .checkout-billing-form {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-delivery-information > *:not(:first-child),\n .checkout-buyer-information > *:not(:first-child),\n .checkout-billing-form > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-billing-form {\n margin-top: 24px;\n }\n\n .checkout-payment-form {\n display: flex;\n flex-direction: column;\n align-self: stretch;\n }\n\n .checkout-payment-form > *:not(:last-child) {\n margin-bottom: 24px;\n }\n\n .delivery-header-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n flex-wrap: wrap;\n }\n\n .delivery-title-container {\n display: flex;\n min-width: 200px;\n flex-direction: column;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .delivery-title-container > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .section-title-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .section-title-container > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .delivery-title-container > .delivery-title,\n .section-title-container > .section-title {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .delivery-title-container > .delivery-subtitle,\n .section-title-container > .section-subtitle {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .gift-toggle-container {\n display: flex;\n padding: 2px 0px;\n align-self: stretch;\n justify-content: space-between;\n align-items: flex-start;\n }\n\n .gift-toggle-container > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .gift-toggle-label {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .gift-label-wrapper {\n display: flex;\n flex-direction: column;\n min-width: 200px;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .gift-toggle-description {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n margin-top: 6px;\n }\n\n .toggle-switch {\n position: relative;\n width: 40px;\n height: 20px;\n background-color: var(--primary-color-30, #d1d5db);\n border-radius: 12px;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n\n .toggle-switch.active {\n background-color: var(--primary-color, #3b82f6);\n }\n\n .toggle-slider {\n position: absolute;\n top: 2px;\n left: 2px;\n width: 16px;\n z-index: "+p.TOGGLE_SLIDER+";\n height: 16px;\n background-color: var(--accent-color, #ffffff);\n border-radius: 50%;\n transition: transform 0.2s ease;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n\n .toggle-switch.active .toggle-slider {\n transform: translateX(20px);\n }\n\n .section-form-container {\n display: flex;\n flex-direction: column;\n align-self: stretch;\n }\n\n .section-form-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .textarea-message-disclaimer {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n margin-top: 6px;\n }\n\n .checkout-tips-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-tips-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-tip-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-tip-container > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .checkout-tip-distribution-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-tip-distribution-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .retailers-tips-list {\n display: none;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .retailers-tips-list > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .retailers-tips-list.show {\n display: flex;\n }\n\n .checkout-tip-distribution-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-tip-fulfillment-input-wrapper {\n display: flex;\n align-items: center;\n }\n\n .checkout-tip-fulfillment-input-wrapper > *:not(:first-child) {\n margin-left: 16px;\n }\n\n .checkout-tip-remove-button {\n color: var(--primary-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n text-decoration-line: underline;\n text-decoration-style: solid;\n text-decoration-skip-ink: none;\n text-decoration-thickness: auto;\n text-underline-offset: auto;\n text-underline-position: from-font;\n cursor: pointer;\n }\n\n .checkout-tip-distribution-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n cursor: pointer;\n }\n\n .checkout-sub-header {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .checkout-tip-disclaimer {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-tip-config-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-tip-config-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .checkout-tip-selection-container {\n display: flex;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-tip-selection-container > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-tip-button {\n display: flex;\n padding: 8px 16px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n flex: 1 0 0;\n border-radius: var(--button-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n }\n\n .checkout-tip-button.selected {\n background: var(--primary-color, #1D4ED8);\n color: var(--selected-text-color, #FAFAFA);\n }\n\n .checkout-tip-button > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .checkout-tip-input-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-tip-input-container > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .checkout-tip-input {\n display: flex;\n height: 36px;\n padding: 4px 12px;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-sections-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-sections-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-pc-gc-sub-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-pc-gc-sub-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .checkout-pc-gc-applied {\n display: flex;\n width: 100%;\n flex-direction: row;\n align-self: stretch;\n display: flex;\n padding: 0px 12px;\n justify-content: space-between;\n align-items: center;\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .checkout-pc-gc-applied span {\n overflow: hidden;\n color: var(--default-text-color, #18181B);\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n text-transform: uppercase;\n }\n\n .checkout-pc-gc-applied button {\n display: flex;\n height: 36px;\n padding: 8px 0px;\n justify-content: center;\n align-items: center;\n border-radius: var(--button-border-radius, 6px);\n color: var(--link-text-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .checkout-send-as-gift-toggle-container {\n position: absolute;\n top: 16px;\n right: 16px;\n z-index: "+p.FORM_CONTROLS+";\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-end;\n\n cursor: pointer;\n }\n\n .checkout-two-col-container {\n display: flex;\n align-items: flex-start;\n align-content: flex-start;\n align-self: stretch;\n flex-wrap: wrap;\n margin-right: -16px;\n margin-bottom: -16px;\n }\n\n .checkout-two-col-container > * {\n margin-right: 16px;\n margin-bottom: 16px;\n }\n\n .checkout-three-col-container {\n display: flex;\n flex-direction: row;\n }\n\n .checkout-three-col-container > *:not(:first-child) {\n margin-left: 16px;\n }\n\n .checkout-send-to-form.collapsed {\n display: none;\n }\n\n .checkout-send-to-title,\n .checkout-your-info-title,\n .checkout-billing-title,\n .checkout-payment-title {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .checkout-send-to-subtitle,\n .checkout-your-info-subtitle,\n .checkout-billing-subtitle,\n .checkout-payment-subtitle {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-summary-section {\n min-width: 320px;\n max-width: 400px;\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n }\n\n .checkout-summary-section > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-disclaimer-title,\n .checkout-summary-title {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .checkout-disclaimer-subtitle,\n .checkout-summary-subtitle {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-promo-code-container,\n .checkout-gift-cards-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-promo-code-container > *:not(:first-child),\n .checkout-gift-cards-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .input-promo-code-container,\n .input-gift-card-container {\n display: flex;\n flex-direction: row;\n align-self: stretch;\n }\n\n .input-promo-code-container > *:not(:first-child),\n .input-gift-card-container > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .input-promo-code-container .apply-button,\n .input-gift-card-container .apply-button {\n display: flex;\n padding: 8px 16px;\n justify-content: center;\n align-self: flex-start;\n align-items: center;\n\n border-radius: var(--button-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n box-shadow: 0px 1.5px 3px 0px rgba(0, 0, 0, 0.10), 0px 1px 2px 0px rgba(0, 0, 0, 0.06);\n color: var(--selected-text-color, #FAFAFA);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n }\n\n .input-promo-code-container .apply-button.disabled,\n .input-gift-card-container .apply-button.disabled {\n background: var(--primary-color-50, #1D4ED8);\n }\n\n .checkout-amounts-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-amounts-container > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .checkout-amount-line {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-amount-line span {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-amount-total {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n\n }\n\n .checkout-amount-total span {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n }\n\n .checkout-separator {\n width: 100%;\n height: 1px;\n margin: 0px;\n background: var(--accent-color, #E4E4E7);\n }\n\n .checkout-place-order-button-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-place-order-button {\n display: flex;\n padding: 8px 16px;\n justify-content: center;\n align-items: center;\n font-family: var(--paragraph-font-family, Poppins);\n align-self: stretch;\n font-weight: 600;\n border-radius: var(--button-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n box-shadow: 0px 1.5px 3px 0px rgba(0, 0, 0, 0.10), 0px 1px 2px 0px rgba(0, 0, 0, 0.06);\n color: var(--selected-text-color, #FAFAFA);\n transition: all 0.2s ease;\n cursor: pointer;\n position: relative;\n }\n\n .checkout-place-order-button-container .alert-container, .checkout-place-order-button-container .alert-wrapper {\n margin-bottom: 24px;\n }\n\n .checkout-place-order-button.ready {\n background: var(--primary-color, #1D4ED8);\n color: var(--selected-text-color, #FAFAFA);\n }\n\n .checkout-place-order-button.ready:hover {\n filter: brightness(0.9);\n transform: translateY(-1px);\n }\n\n .checkout-place-order-button.ready:active {\n transform: translateY(0);\n }\n\n /* States when things are missing/wrong - use your opacity variants */\n .checkout-place-order-button.form-invalid,\n .checkout-place-order-button.payment-incomplete,\n .checkout-place-order-button.payment-error {\n background: var(--primary-color-70);\n color: var(--selected-text-color);\n }\n\n .checkout-place-order-button.form-invalid:hover,\n .checkout-place-order-button.payment-incomplete:hover,\n .checkout-place-order-button.payment-error:hover {\n background: var(--primary-color-70);\n }\n\n /* Processing state - keep full primary color to show confidence */\n .checkout-place-order-button.processing {\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .checkout-place-order-button.processing::after {\n content: '';\n position: absolute;\n right: 16px;\n top: 50%;\n transform: translateY(-50%);\n z-index: "+p.LOADING_INDICATOR+';\n width: 18px;\n height: 18px;\n border: 2px solid transparent;\n border-top: 2px solid var(--selected-text-color);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n /* Disabled state - very muted */\n .checkout-place-order-button.disabled {\n background: var(--primary-color-70, #D1D5DB);\n cursor: not-allowed;\n }\n\n /* Focus states for accessibility */\n .checkout-place-order-button:focus {\n outline: none;\n box-shadow: 0 0 0 3px var(--primary-color-70);\n }\n\n .checkout-place-order-button.disabled:focus {\n box-shadow: none;\n }\n\n .checkout-marketing-opt-ins-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-marketing-opt-ins-container > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .checkout-billing-same-as-shipping-toggle-container {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n cursor: pointer;\n }\n\n .checkout-billing-same-as-shipping-toggle-container > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-items-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-items-container > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .checkout-items-toggler {\n display: flex;\n height: 14px;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n cursor: pointer;\n }\n\n .checkout-items-toggler-label {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .checkout-items-list {\n display: none;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-items-list > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .checkout-items-list.show {\n display: flex;\n }\n\n .checkout-item-card {\n display: flex;\n padding: 16px;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .checkout-item-card > *:not(:first-child) {\n margin-top: 16px;\n }\n\n .checkout-item-card-header {\n display: flex;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-item-card-header > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-item-details-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .checkout-item-card-footer {\n display: flex;\n height: 36px;\n align-items: center;\n align-content: center;\n justify-content: space-between;\n align-self: stretch;\n flex-wrap: wrap;\n margin-right: -8px;\n margin-bottom: -8px;\n }\n\n .checkout-item-card-footer > * {\n margin-right: 8px;\n margin-bottom: 8px;\n }\n\n .checkout-item-image {\n display: flex;\n width: 64px;\n height: 70px;\n flex-direction: column;\n align-items: center;\n border-radius: var(--card-border-radius, 6px);\n }\n\n .checkout-item-image img {\n max-width: 100%;\n max-height: 100%;\n object-fit: contain;\n }\n\n .checkout-item-card .checkout-item-subtitle {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n }\n\n .checkout-item-card .checkout-item-title,\n .checkout-item-card .checkout-item-subtitle > span,\n .checkout-item-price-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n word-break: break-word;\n }\n\n .checkout-item-price-each-text {\n font-weight: 500;\n }\n\n .checkout-item-card .checkout-item-subtitle > span {\n font-weight: 400 !important;\n }\n\n .checkout-item-quantity-container {\n display: flex;\n width: 106px;\n align-items: center;\n }\n\n .billing-checkbox-label {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n cursor: pointer;\n }\n\n .checkout-item-quantity-container .quantity-decrease,\n .checkout-item-quantity-container .quantity-increase {\n display: flex;\n width: 36px;\n height: 36px;\n padding: 8px 16px;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--accent-color, #E4E4E7);\n\n cursor: pointer;\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-item-quantity-container .quantity-decrease {\n border-radius: var(--button-border-radius, 6px) 0px 0px var(--button-border-radius, 6px);\n }\n\n .checkout-item-quantity-container .quantity-increase {\n border-radius: 0px var(--button-border-radius, 6px) var(--button-border-radius, 6px) 0px;\n }\n\n .checkout-item-quantity-container .quantity-decrease.disabled,\n .checkout-item-quantity-container .quantity-increase.disabled {\n opacity: 0.7;\n cursor: not-allowed;\n }\n\n .checkout-item-quantity-container .product-count {\n display: flex;\n padding: 6px 8px;\n justify-content: center;\n align-items: center;\n flex: 1 0 0;\n align-self: stretch;\n\n border-top: 1px solid var(--accent-color, #E4E4E7);\n border-bottom: 1px solid var(--accent-color, #E4E4E7);\n\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .dollar-input-container {\n display: flex;\n align-items: center;\n border: 1px solid var(--accent-color, #E4E4E7);\n border-radius: var(--button-border-radius, 6px);\n align-self: stretch;\n flex: 1 0 0;\n max-width: 100px;\n\n height: 36px;\n padding: 4px 12px;\n align-items: center;\n\n overflow: hidden;\n color: var(--default-text-color, #18181B);\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .dollar-input-container:focus-within {\n outline: none;\n border-color: var(--primary-color, #3b82f6);\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n }\n\n .dollar-sign {\n font-size: 14px;\n font-weight: 500;\n user-select: none;\n pointer-events: none;\n }\n\n .dollar-input {\n flex: 1;\n border: none;\n outline: none;\n background: transparent;\n }\n\n .dollar-input::placeholder {\n color: var(--default-text-color-70, #18181B);\n }\n\n .dollar-input::-webkit-outer-spin-button,\n .dollar-input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n .dollar-input[type=number] {\n -moz-appearance: textfield;\n }\n\n .dollar-input:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .dollar-input-container:has(.dollar-input:disabled) {\n opacity: 0.6;\n }\n\n .dollar-input-container:has(.dollar-input:disabled) .dollar-sign {\n color: var(--default-text-color-70, #18181B);\n }\n\n /* Checkout Thank You Page */\n .checkout-completed-container {\n display: flex;\n min-height: 100vh; /* Fallback for browsers that don\'t support dvh */\n min-height: 100dvh;\n min-width: 320px;\n flex-direction: column;\n justify-content: center;\n flex: 1 0 0;\n align-self: stretch;\n }\n\n .checkout-completed-header-container {\n display: flex;\n padding: 24px;\n justify-content: center;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-completed-header-container > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-completed-header-container img {\n width: 200px;\n height: auto;\n object-fit: contain;\n flex-shrink: 0;\n }\n\n .checkout-completed-sub-section {\n display: flex;\n min-width: 216px;\n padding: 16px;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n flex-shrink: 0;\n border-radius: var(--card-border-radius, 6px);\n border: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .checkout-completed-sub-section > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .checkout-completed-sub-section p {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n }\n\n .checkout-completed-section-container {\n display: flex;\n padding: 24px;\n flex-direction: column;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-completed-section-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-completed-help-section > *:not(:first-child) {\n margin-top: 8px;\n }\n\n .checkout-completed-help-section {\n overflow: hidden;\n color: var(--default-text-color, #18181B);\n text-overflow: ellipsis;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n text-align: center;\n line-height: 100%;\n }\n\n .checkout-completed-help-section a {\n color: var(--link-text-color, #1D4ED8);\n }\n\n .checkout-completed-section-container button {\n display: flex;\n height: 36px;\n min-width: 182px;\n padding: 8px 16px;\n justify-content: center;\n align-items: center;\n border-radius: var(--button-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n box-shadow: 0px 1.5px 3px 0px rgba(0, 0, 0, 0.10), 0px 1px 2px 0px rgba(0, 0, 0, 0.06);\n }\n\n .checkout-completed-section-container button svg {\n stroke: var(--selected-text-color, #1D4ED8);\n fill: var(--selected-text-color, #1D4ED8);\n }\n\n .checkout-completed-section-container button span {\n color: var(--selected-text-color, #FAFAFA);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n margin-right: 8px;\n }\n\n .checkout-completed-title-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-completed-title-container > *:not(:first-child) {\n margin-top: 24px;\n }\n\n .checkout-completed-title-section {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n align-self: stretch;\n text-align: center;\n }\n\n .checkout-completed-title-section .presale-expired-title {\n font-family: var(--heading-font-family, Poppins);\n font-size: 24px;\n font-weight: 600;\n line-height: 32px;\n }\n\n .checkout-completed-title-section > *:not(:first-child) {\n margin-top: 4px;\n }\n\n .checkout-completed-title-section {\n color: var(--default-text-color, #18181B);\n }\n\n .checkout-completed-title-section p:first-child,\n .checkout-completed-auto-close-seconds {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 24px;\n font-style: normal;\n font-weight: 600;\n line-height: 32px;\n }\n\n .checkout-completed-title-section h3 {\n color: var(--default-text-color, #18181B);\n font-family: var(--heading-font-family, Poppins);\n font-size: 24px;\n font-style: normal;\n font-weight: 600;\n line-height: 32px;\n }\n\n .checkout-completed-title-section p, .checkout-completed-auto-close-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 24px;\n }\n\n .checkout-completed-line {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n }\n\n .checkout-completed-line span {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-completed-line:first-child span {\n font-weight: 600;\n }\n\n .checkout-completed-line h3 {\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-payment-form-error {\n color: var(--error-color, #EF4444);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n margin-top: 8px;\n }\n\n .checkout-error-wrapper {\n animation: slideIn 0.2s ease-out;\n display: flex;\n align-self: stretch;\n margin-bottom: 8px;\n }\n\n .checkout-error-wrapper > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-error {\n display: flex;\n padding: 12px 16px;\n }\n\n .checkout-error > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-error\n border-radius: var(--button-border-radius, 6px);\n font-size: 14px;\n line-height: 1.5;\n font-family: var(--body-font-family, inherit);\n flex: 1;\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n\n background: var(--error-color-30, #DC2626);\n border: 1px solid var(--error-color, #DC2626);\n }\n\n .checkout-error .icon-error {\n flex-shrink: 0;\n width: 16px;\n height: 16px;\n display: inline-block;\n }\n\n .checkout-error .error-text {\n font-family: var(--body-font-family, inherit);\n }\n\n .checkout-error-wrapper[style*="display: none"] {\n display: none !important;\n }\n\n .checkout-checkbox-container {\n display: flex;\n align-items: flex-start;\n }\n\n .checkout-checkbox-container > *:not(:first-child) {\n margin-left: 12px;\n }\n\n .checkout-checkbox-visual {\n width: 16px;\n height: 16px;\n border: 1px solid var(--primary-color, #1D4ED8);\n border-radius: 2px;\n background: var(--primary-color, #1D4ED8);\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n flex-shrink: 0;\n transition: all 0.2s ease;\n margin-top: 3px;\n }\n\n .checkout-checkbox-visual svg {\n opacity: 1;\n transition: opacity 0.2s ease;\n }\n\n .checkout-checkbox-visual:not(.checked) {\n background: transparent;\n }\n\n .checkout-checkbox-visual:not(.checked) svg {\n opacity: 0;\n }\n\n .checkbox-label {\n cursor: pointer;\n user-select: none;\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkbox-label a {\n color: var(--link-text-color, #1D4ED8);\n }\n\n .checkbox-label strong {\n font-weight: 600;\n }\n\n .checkbox-label em {\n font-style: italic;\n }\n\n .error-banner-checkout {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n color: var(--default-text-color, #18181B);\n padding: 8px 16px;\n flex-grow: 1;\n align-self: stretch;\n word-break: break-word;\n\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n\n background: linear-gradient(0deg, var(--alpha-20, rgba(254, 254, 254, 0.80)) 0%, var(--alpha-20, rgba(254, 254, 254, 0.80)) 100%), var(--error-color, #DC2626);\n border: 1px solid var(--error-color, #DC2626);\n border-radius: var(--card-border-radius, 6px);\n }\n\n .error-banner-checkout > *:not(:first-child) {\n margin-left: 8px;\n }\n\n /* It needs background color since it is sticky to cover content behind it\n TODO: for standalone checkout\n */\n .checkout-header-wrapper {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n position: sticky;\n top: 0;\n z-index: '+p.CHECKOUT_HEADER+";\n background-color: var(--drawer-background-color, #F9FAFB);\n }\n\n /* Hosted checkout header - non-sticky */\n .checkout-header-wrapper.hosted {\n position: relative;\n background-color: transparent;\n }\n\n .checkout-header-container {\n display: flex;\n min-width: 320px;\n flex-direction: row;\n align-items: center;\n align-self: stretch;\n padding: 8px;\n border-bottom: 1px solid var(--accent-color, #E4E4E7);\n }\n\n .checkout-header-button {\n display: flex;\n height: 36px;\n padding: 12px 16px;\n padding-right: 0px;\n justify-content: center;\n align-items: center;\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n stroke: var(--default-text-color, #18181B);\n }\n\n .checkout-header-button > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-header-button-close {\n display: flex;\n height: 36px;\n width: 36px;\n padding: 2px 4px;\n justify-content: center;\n align-items: center;\n stroke: var(--default-text-color, #18181B);\n }\n\n /* Spacer to maintain layout balance when close button is hidden */\n .checkout-header-spacer {\n width: 36px;\n height: 36px;\n flex-shrink: 0;\n }\n\n .checkout-header-title {\n display: flex;\n justify-content: center;\n align-items: center;\n flex: 1 0 0;\n align-self: stretch;\n color: var(--default-text-color, #18181B);\n text-align: center;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 100%;\n }\n\n .checkout-presale-countdown-container {\n display: flex;\n min-width: 320px;\n padding: 12px 24px 16px;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n\n &.is-scrolled {\n box-shadow: 0px 6px 10px -2px var(--primary-color-30);\n }\n\n &.time-warning {\n box-shadow: 0px 6px 10px -2px var(--error-color-30, #FDE68A);\n }\n }\n\n .checkout-presale-countdown {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n border-radius: 0;\n overflow: hidden;\n }\n\n .checkout-presale-countdown.time-warning {\n background: var(--error-color-30, #FDE68A);\n border: 1px solid var(--error-color, #E4E4E7);\n }\n\n .checkout-presale-countdown.time-warning {\n background: transparent;\n border: none;\n }\n\n .checkout-presale-countdown.time-warning .checkout-presale-progress-bar {\n background: var(--error-color-70, #FDE68A);\n }\n\n .checkout-presale-countdown.time-warning .checkout-presale-progress-fill {\n background: var(--error-color, #EF4444);\n }\n\n .checkout-presale-text-container {\n display: flex;\n padding: 0px 0px 6px;\n justify-content: flex-end;\n align-self: stretch;\n flex-direction: column;\n align-items: flex-start;\n flex: 1 0 0;\n }\n\n .checkout-presale-progress-bar {\n display: flex;\n height: 6px;\n align-items: center;\n align-self: stretch;\n border-radius: 40px;\n background: var(--primary-color-50, #E4E4E7);\n position: relative;\n overflow: hidden;\n }\n\n .checkout-presale-progress-fill {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n z-index: "+p.PROGRESS_BAR+';\n background: var(--primary-color, #16a34a);\n transition: width 0.1s linear;\n border-radius: inherit;\n }\n\n .checkout-presale-heading {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n align-self: stretch;\n }\n\n .checkout-presale-timer {\n font-variant-numeric: tabular-nums;\n letter-spacing: 0.02em;\n font-variant-numeric: tabular-nums;\n font-feature-settings: "tnum" 1, "kern" 0;\n min-width: 76px;\n white-space: nowrap;\n\n &.time-warning {\n color: var(--error-color, #EF4444);\n }\n }\n\n .checkout-presale-subtitle {\n transition: opacity 0.3s ease, max-height 0.3s ease;\n opacity: 1;\n max-height: 100px;\n overflow: hidden;\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n\n .checkout-presale-countdown.is-scrolled .checkout-presale-subtitle {\n opacity: 0;\n max-height: 0;\n }\n\n .checkout-completed-container .powered-by-container {\n margin-top: auto;\n padding: 24px;\n }\n\n .checkout-completed-container .checkout-legal-message {\n padding: 0 24px;\n }\n\n .checkout-legal-message {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n text-align: center;\n word-break: break-word;\n margin: 10px 0 !important;\n }\n\n .checkout-legal-message + .checkout-separator {\n margin-top: 0 !important;\n }\n\n .checkout-legal-message a {\n color: var(--link-text-color, #1D4ED8);\n }\n\n .checkout-legal-message strong {\n font-weight: 600;\n }\n\n .checkout-legal-message em {\n font-style: italic;\n }\n\n .checkout-amount-due {\n display: flex;\n justify-content: space-between;\n align-items: center;\n align-self: stretch;\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-amount-due span:first-child {\n color: var(--default-text-color-70, #18181B);\n }\n\n .checkout-amount-due span:last-child {\n color: var(--default-text-color, #1D4ED8);\n }\n\n .checkout-presale-locked-message {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n align-self: stretch;\n }\n\n .checkout-presale-locked-message > *:not(:first-child) {\n margin-left: 8px;\n }\n\n .checkout-presale-locked-message p {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 13px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-presale-locked-message svg {\n width: 16px;\n height: 16px;\n stroke-width: 0.5px;\n stroke: var(--default-text-color, #1D4ED8);\n }\n\n .checkout-zero-amount-container {\n display: flex;\n padding: 0 24px;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n color: var(--default-text-color-70, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: italic;\n font-weight: 500;\n line-height: 20px;\n }\n\n .checkout-items-toggler-button .chevron-icon {\n transition: transform 0.3s ease;\n transform-origin: center;\n }\n\n .checkout-items-toggler-button.expanded .chevron-icon {\n transform: rotate(180deg); /* Chevron now points up */\n }\n\n .checkout-summary-form-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .checkout-summary-form-header {\n width: 100%;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n margin-bottom: 8px;\n }\n\n .checkout-summary-form-header h2 {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n text-align: left;\n }\n\n .checkout-summary-form-header span {\n color: var(--link-text-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n cursor: pointer;\n }\n\n .checkout-summary-form-line {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 20px;\n text-align: left;\n }\n\n .checkout-summary-form-line-container {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n align-self: stretch;\n margin-top: 8px;\n }\n\n .checkout-summary-form-line-container-label {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 20px;\n opacity: 0.7;\n }\n\n .save-form-info-button {\n width: 100%;\n display: flex;\n height: 36px;\n justify-content: center;\n align-items: center;\n border-radius: var(--button-border-radius, 6px);\n background: var(--primary-color, #1D4ED8);\n color: var(--selected-text-color, #FAFAFA);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n box-shadow: 0 1.5px 3px 0 rgba(0, 0, 0, 0.10), 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n }\n\n .save-form-info-button:disabled {\n background: var(--primary-color-70, #D1D5DB);\n cursor: not-allowed;\n }\n\n .stripe-summary-container {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n }\n\n .stripe-summary-container .stripe-summary-text {\n color: var(--default-text-color, #18181B);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 24px;\n text-align: left;\n }\n\n .stripe-summary-container .change-payment-link {\n color: var(--link-text-color, #1D4ED8);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n cursor: pointer;\n }\n\n .payment-error-message {\n color: var(--warning-color, #6B7280);\n font-family: var(--paragraph-font-family, Poppins);\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 16px;\n margin-top: 16px;\n }\n\n .hardcoded-payment-notice {\n background-color: #fff3cd;\n color: #856404;\n font-family: Poppins;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 16px;\n border-radius: 4px;\n padding: 16px;\n border: 1px solid #ffc107;\n word-break: break-all;\n }\n ';lt.register("checkout",getCheckoutStyles,10);const ArrowRightIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="arrow-right-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M7.52794 2.86225C7.78829 2.6019 8.2104 2.6019 8.47075 2.86225L13.1374 7.52892C13.3978 7.78927 13.3978 8.21138 13.1374 8.47173L8.47075 13.1384C8.2104 13.3987 7.78829 13.3987 7.52794 13.1384C7.26759 12.878 7.26759 12.4559 7.52794 12.1956L11.0565 8.66699H3.33268C2.96449 8.66699 2.66602 8.36851 2.66602 8.00033C2.66602 7.63214 2.96449 7.33366 3.33268 7.33366H11.0565L7.52794 3.80506C7.26759 3.54471 7.26759 3.1226 7.52794 2.86225Z"/>\n </svg>\n '},CheckboxIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="checkbox-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13.8047 3.52885C14.0651 3.7892 14.0651 4.21131 13.8047 4.47166L6.4714 11.805C6.21106 12.0653 5.78894 12.0653 5.5286 11.805L2.19526 8.47166C1.93491 8.21131 1.93491 7.7892 2.19526 7.52885C2.45561 7.2685 2.87772 7.2685 3.13807 7.52885L6 10.3908L12.8619 3.52885C13.1223 3.2685 13.5444 3.2685 13.8047 3.52885Z"/>\n </svg>\n '},ChevronDownIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="'+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M3.52827 5.52876C3.78862 5.26841 4.21073 5.26841 4.47108 5.52876L7.99967 9.05735L11.5283 5.52876C11.7886 5.26841 12.2107 5.26841 12.4711 5.52876C12.7314 5.78911 12.7314 6.21122 12.4711 6.47157L8.47108 10.4716C8.21073 10.7319 7.78862 10.7319 7.52827 10.4716L3.52827 6.47157C3.26792 6.21122 3.26792 5.78911 3.52827 5.52876Z" fill="#18181B"/>\n </svg>\n '},ChevronLeftIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="chevron-left-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M10.4721 3.52864C10.7324 3.78899 10.7324 4.2111 10.4721 4.47145L6.94346 8.00004L10.4721 11.5286C10.7324 11.789 10.7324 12.2111 10.4721 12.4714C10.2117 12.7318 9.7896 12.7318 9.52925 12.4714L5.52925 8.47145C5.2689 8.2111 5.2689 7.78899 5.52925 7.52864L9.52925 3.52864C9.7896 3.26829 10.2117 3.26829 10.4721 3.52864Z"/>\n </svg>\n '},CloseIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="close-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M3.52925 3.52864C3.7896 3.26829 4.21171 3.26829 4.47206 3.52864L8.00065 7.05723L11.5292 3.52864C11.7896 3.26829 12.2117 3.26829 12.4721 3.52864C12.7324 3.78899 12.7324 4.2111 12.4721 4.47145L8.94346 8.00004L12.4721 11.5286C12.7324 11.789 12.7324 12.2111 12.4721 12.4714C12.2117 12.7318 11.7896 12.7318 11.5292 12.4714L8.00065 8.94285L4.47206 12.4714C4.21171 12.7318 3.7896 12.7318 3.52925 12.4714C3.2689 12.2111 3.2689 11.789 3.52925 11.5286L7.05784 8.00004L3.52925 4.47145C3.2689 4.2111 3.2689 3.78899 3.52925 3.52864Z"/>\n </svg>\n '},ErrorInfoIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'<svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="error-info-icon '+n+'" style="'+s+'" data-fill-only>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M8.00033 1.99996C4.68662 1.99996 2.00033 4.68625 2.00033 7.99996C2.00033 11.3137 4.68662 14 8.00033 14C11.314 14 14.0003 11.3137 14.0003 7.99996C14.0003 4.68625 11.314 1.99996 8.00033 1.99996ZM0.666992 7.99996C0.666992 3.94987 3.95024 0.666626 8.00033 0.666626C12.0504 0.666626 15.3337 3.94987 15.3337 7.99996C15.3337 12.05 12.0504 15.3333 8.00033 15.3333C3.95024 15.3333 0.666992 12.05 0.666992 7.99996ZM8.00033 4.66663C8.36852 4.66663 8.66699 4.9651 8.66699 5.33329V7.99996C8.66699 8.36815 8.36852 8.66663 8.00033 8.66663C7.63213 8.66663 7.33366 8.36815 7.33366 7.99996V5.33329C7.33366 4.9651 7.63213 4.66663 8.00033 4.66663ZM7.33366 10.6666C7.33366 10.2984 7.63213 9.99996 8.00033 9.99996H8.00699C8.37518 9.99996 8.67366 10.2984 8.67366 10.6666C8.67366 11.0348 8.37518 11.3333 8.00699 11.3333H8.00033C7.63213 11.3333 7.33366 11.0348 7.33366 10.6666Z"/>\n</svg>'},InfoIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="info-icon '+n+'" style="'+s+'" data-fill-only>\n <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>\n <path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>\n </svg>\n '},SuccessIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="success-icon '+n+'" style="'+s+'" data-fill-only>\n <path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>\n </svg>\n '},TrashIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="trash-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M6.22157 2.22161C6.06513 2.37804 6.00016 2.55036 6.00016 2.66687V3.33354H10.0002V2.66687C10.0002 2.55036 9.93519 2.37804 9.77876 2.22161C9.62232 2.06517 9.45001 2.0002 9.3335 2.0002H6.66683C6.55032 2.0002 6.378 2.06517 6.22157 2.22161ZM11.3335 3.33354V2.66687C11.3335 2.11672 11.0651 1.62236 10.7216 1.2788C10.378 0.935235 9.88365 0.66687 9.3335 0.66687H6.66683C6.11668 0.66687 5.62232 0.935235 5.27876 1.2788C4.93519 1.62236 4.66683 2.11672 4.66683 2.66687V3.33354H2.00016C1.63197 3.33354 1.3335 3.63201 1.3335 4.0002C1.3335 4.36839 1.63197 4.66687 2.00016 4.66687H2.66683V13.3335C2.66683 13.8837 2.93519 14.378 3.27876 14.7216C3.62232 15.0652 4.11668 15.3335 4.66683 15.3335H11.3335C11.8837 15.3335 12.378 15.0652 12.7216 14.7216C13.0651 14.378 13.3335 13.8837 13.3335 13.3335V4.66687H14.0002C14.3684 4.66687 14.6668 4.36839 14.6668 4.0002C14.6668 3.63201 14.3684 3.33354 14.0002 3.33354H11.3335ZM4.00016 4.66687V13.3335C4.00016 13.45 4.06513 13.6224 4.22157 13.7788C4.378 13.9352 4.55032 14.0002 4.66683 14.0002H11.3335C11.45 14.0002 11.6223 13.9352 11.7788 13.7788C11.9352 13.6224 12.0002 13.45 12.0002 13.3335V4.66687H4.00016ZM6.66683 6.66687C7.03502 6.66687 7.3335 6.96535 7.3335 7.33354V11.3335C7.3335 11.7017 7.03502 12.0002 6.66683 12.0002C6.29864 12.0002 6.00016 11.7017 6.00016 11.3335V7.33354C6.00016 6.96535 6.29864 6.66687 6.66683 6.66687ZM9.3335 6.66687C9.70169 6.66687 10.0002 6.96535 10.0002 7.33354V11.3335C10.0002 11.7017 9.70169 12.0002 9.3335 12.0002C8.96531 12.0002 8.66683 11.7017 8.66683 11.3335V7.33354C8.66683 6.96535 8.96531 6.66687 9.3335 6.66687Z"/>\n </svg>\n '},WarningIcon=({width:t=16,height:e=16,className:n="",color:r=null})=>{const s=r?"--icon-color: "+r:"";return'\n <svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+e+'" viewBox="0 0 16 16" class="warning-icon '+n+'" style="'+s+'" data-fill-only>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M7.99984 2.00033C4.68613 2.00033 1.99984 4.68662 1.99984 8.00033C1.99984 11.314 4.68613 14.0003 7.99984 14.0003C11.3135 14.0003 13.9998 11.314 13.9998 8.00033C13.9998 4.68662 11.3135 2.00033 7.99984 2.00033ZM0.666504 8.00033C0.666504 3.95024 3.94975 0.666992 7.99984 0.666992C12.0499 0.666992 15.3332 3.95024 15.3332 8.00033C15.3332 12.0504 12.0499 15.3337 7.99984 15.3337C3.94975 15.3337 0.666504 12.0504 0.666504 8.00033ZM7.99984 4.66699C8.36803 4.66699 8.6665 4.96547 8.6665 5.33366V8.00033C8.6665 8.36852 8.36803 8.66699 7.99984 8.66699C7.63165 8.66699 7.33317 8.36852 7.33317 8.00033V5.33366C7.33317 4.96547 7.63165 4.66699 7.99984 4.66699ZM7.33317 10.667C7.33317 10.2988 7.63165 10.0003 7.99984 10.0003H8.0065C8.37469 10.0003 8.67317 10.2988 8.67317 10.667C8.67317 11.0352 8.37469 11.3337 8.0065 11.3337H7.99984C7.63165 11.3337 7.33317 11.0352 7.33317 10.667Z"/>\n </svg>\n '};class CheckoutAmountsComponent extends BaseComponent{get hostClasses(){return["checkout-amounts-container"]}constructor(){super({watchStorePaths:["checkout.amounts"]})}template(){var t,e,n;const r=this.getStoreValue("checkout"),a=Boolean(r.promoCode),c=Boolean(null===(t=r.giftCards)||void 0===t?void 0:t.length),l=this.getConfigs("global"),d=Object.values(r.fulfillments).some(t=>t.type===s.SHIPPING),h=Object.values(r.fulfillments).some(t=>t.type===s.ON_DEMAND),p=[],m=document.createElement("div");m.classList.add("checkout-amount-line");const f=document.createElement("span");f.textContent="Subtotal ("+r.itemsQuantity+" item"+(r.itemsQuantity>1?"s":"")+")",m.appendChild(f);const g=document.createElement("span");if(g.textContent=formatCentToDollarText(r.amounts.subtotal),m.appendChild(g),p.push(m),d){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Shipping",t.appendChild(e);const n=document.createElement("span");n.textContent=formatCentToDollarText(r.amounts.shipping),t.appendChild(n),p.push(t)}if(h){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Delivery",t.appendChild(e);const n=document.createElement("span");n.textContent=formatCentToDollarText(r.amounts.delivery),t.appendChild(n),p.push(t)}if((null===(e=null==r?void 0:r.amounts)||void 0===e?void 0:e.engraving)>0){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Engraving",t.appendChild(e);const n=document.createElement("span");n.textContent=formatCentToDollarText(r.amounts.engraving),t.appendChild(n),p.push(t)}const v=document.createElement("div");v.classList.add("checkout-amount-line");const y=document.createElement("span");y.textContent="Taxes & Fees",v.appendChild(y);const b=document.createElement("span");if(b.textContent=formatCentToDollarText(r.amounts.tax+r.amounts.service+r.amounts.platform),v.appendChild(b),p.push(v),a){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Promo Code ("+(null===(n=r.promoCode)||void 0===n?void 0:n.code.toUpperCase())+")",t.appendChild(e);const s=document.createElement("span");s.textContent="-"+formatCentToDollarText(r.amounts.discounts),t.appendChild(s),p.push(t)}if(c){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Gift Cards Applied",t.appendChild(e);const n=document.createElement("span");n.textContent="-"+formatCentToDollarText(r.amounts.giftCards),t.appendChild(n),p.push(t)}if(h){const t=document.createElement("div");t.classList.add("checkout-amount-line");const e=document.createElement("span");e.textContent="Tips",t.appendChild(e);const n=document.createElement("span");n.textContent=formatCentToDollarText(r.amounts.tip),t.appendChild(n),p.push(t)}const x=document.createElement("div");x.classList.add("checkout-separator"),p.push(x);const w=document.createElement("div");w.classList.add("checkout-amount-total");const C=document.createElement("span");C.textContent="Total",w.appendChild(C);const _=document.createElement("span");if(_.textContent=formatCentToDollarText(r.amounts.total),w.appendChild(_),p.push(w),r.presale){const t=document.createElement("div");t.classList.add("checkout-amount-due");const e=document.createElement("span");e.textContent="Amount due today",t.appendChild(e);const n=document.createElement("span");n.textContent=formatCentToDollarText(0),t.appendChild(n),p.push(t);const r=document.createElement("div");r.classList.add("checkout-presale-locked-message");const s=htmlStringToElement(InfoIcon({color:l.theme.defaultTextColor}));r.appendChild(s);const a=document.createElement("p");a.textContent="Pre-ordered items will be charged when shipped.",r.appendChild(a),p.push(r)}return p}}class CheckoutBillingComponent extends BaseComponent{get hostClasses(){return["checkout-billing-form"]}constructor(){super({watchStorePaths:["checkout.paymentForm.billingSameAsShipping"]}),this.billingData={firstName:{isValid:![],value:""},lastName:{isValid:![],value:""},email:{isValid:![],value:""},phone:{isValid:![],value:""},company:{isValid:!![],value:""},addressOne:{isValid:![],value:""},addressTwo:{isValid:!![],value:""},city:{isValid:![],value:""},state:{isValid:![],value:""},zipCode:{isValid:![],value:""}}}billingSameAsShippingToggle(){const t=this.getStoreValue("checkout.paymentForm.billingSameAsShipping"),e=document.createElement("div");e.classList.add("checkout-billing-same-as-shipping-toggle-container");const n=document.createElement("div");n.classList.add("checkout-checkbox-container");const r=document.createElement("span");r.id="billingSameAsShipping",r.classList.add("checkout-checkbox-visual"),r.setAttribute("role","checkbox"),r.setAttribute("tabindex","0"),r.setAttribute("aria-label","Billing same as shipping checkbox"),r.setAttribute("aria-checked",t?"true":"false"),t&&r.classList.add("checked"),r.innerHTML=CheckboxIcon({width:16,height:16}),e.addEventListener("click",async()=>{await this.commands.checkout.toggleBillingSameAsShipping()}),e.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.commands.checkout.toggleBillingSameAsShipping())});const s=document.createElement("label");return s.textContent="Billing address same as shipping address",s.setAttribute("for","billingSameAsShipping"),s.classList.add("billing-checkbox-label"),n.appendChild(r),n.appendChild(s),e.appendChild(n),e}updateSaveButtonState(){const t=!Object.values(this.billingData).every(t=>t.isValid),e={firstName:this.billingData.firstName.value,lastName:this.billingData.lastName.value,email:this.billingData.email.value,phone:this.billingData.phone.value,company:this.billingData.company.value,one:this.billingData.addressOne.value,two:this.billingData.addressTwo.value,city:this.billingData.city.value,state:this.billingData.state.value,zip:this.billingData.zipCode.value};this.params.isFormValid(!t,e)}template(){const t=this.getStoreValue("checkout.paymentForm"),e=[],s=this.billingSameAsShippingToggle();if(e.push(s),t.billingSameAsShipping)return e;t.data&&(t.data.firstName&&(this.billingData.firstName={isValid:!![],value:t.data.firstName}),t.data.lastName&&(this.billingData.lastName={isValid:!![],value:t.data.lastName}),t.data.email&&(this.billingData.email={isValid:!![],value:t.data.email}),t.data.phone&&(this.billingData.phone={isValid:!![],value:t.data.phone}),t.data.company&&(this.billingData.company={isValid:!![],value:t.data.company}),t.data.one&&(this.billingData.addressOne={isValid:!![],value:t.data.one}),t.data.two&&(this.billingData.addressTwo={isValid:!![],value:t.data.two}),t.data.city&&(this.billingData.city={isValid:!![],value:t.data.city}),t.data.state&&(this.billingData.state={isValid:!![],value:t.data.state}),t.data.zip&&(this.billingData.zipCode={isValid:!![],value:t.data.zip})),this.updateSaveButtonState();const a=document.createElement("div");a.classList.add("section-title-container");const c=document.createElement("h3");c.textContent="Your billing info",c.classList.add("section-title"),a.appendChild(c);const l=document.createElement("p");l.textContent="Provide the info relevant to your payment method",l.classList.add("section-subtitle"),a.appendChild(l),e.push(a);const d=document.createElement("div");d.classList.add("section-form-container");const h=document.createElement("div");h.classList.add("checkout-two-col-container");const p=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.firstName,label:"First Name",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.firstName.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.firstName})},onValidation:t=>{this.billingData.firstName.isValid=t,this.updateSaveButtonState()}});p.setAttribute("aria-label","First name input"),h.appendChild(p);const m=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.lastName,label:"Last Name",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.lastName.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.lastName})},onValidation:t=>{this.billingData.lastName.isValid=t,this.updateSaveButtonState()}});m.setAttribute("aria-label","Last name input"),h.appendChild(m),d.appendChild(h);const f=ComponentFactoryService.createElement({type:r.INPUT,inputType:"email",name:vt.email,label:"Email",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.email.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.email})},onValidation:t=>{this.billingData.email.isValid=t,this.updateSaveButtonState()}});f.setAttribute("aria-label","Email input"),d.appendChild(f);const g=document.createElement("div");g.classList.add("checkout-two-col-container");const v=ComponentFactoryService.createElement({type:r.INPUT,inputType:"tel",name:vt.phone,label:"Phone",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.phone.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.phone})},onValidation:t=>{this.billingData.phone.isValid=t,this.updateSaveButtonState()}});v.setAttribute("aria-label","Phone input"),g.appendChild(v);const y=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.company,label:"Company (optional)",autocomplete:!![],onChange:async t=>{this.billingData.company.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.company})},onValidation:t=>{this.billingData.company.isValid=t,this.updateSaveButtonState()}});y.setAttribute("aria-label","Company input"),g.appendChild(y),d.appendChild(g);const b=document.createElement("div");b.classList.add("checkout-two-col-container");const x=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.addressOne,label:"Street Address",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.addressOne.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.addressOne})},onValidation:t=>{this.billingData.addressOne.isValid=t,this.updateSaveButtonState()}});x.setAttribute("aria-label","Street address input"),b.appendChild(x);const w=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.addressTwo,label:"Apt, suite, etc. (optional)",onChange:async t=>{this.billingData.addressTwo.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.addressTwo})},onValidation:t=>{this.billingData.addressTwo.isValid=t,this.updateSaveButtonState()}});w.setAttribute("aria-label","Apt, suite, etc. (optional) input"),b.appendChild(w),d.appendChild(b);const C=document.createElement("div");C.classList.add("checkout-three-col-container");const _=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.city,label:"City",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.city.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.city})},onValidation:t=>{this.billingData.city.isValid=t,this.updateSaveButtonState()}});_.setAttribute("aria-label","City input"),C.appendChild(_);const E=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.state,label:"State",autocomplete:!![],placeholder:"NY",validation:{required:!![],customValidator:t=>t&&2===t.length&&/^[A-Z]{2}$/.test(t)?null:"State must be 2 uppercase characters"},onChange:async t=>{this.billingData.state.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.state})},onValidation:t=>{this.billingData.state.isValid=t,this.updateSaveButtonState()}});E.setAttribute("aria-label","State input"),C.appendChild(E);const T=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:vt.zipCode,label:"Zip Code",autocomplete:!![],validation:{required:!![]},onChange:async t=>{this.billingData.zipCode.value=t,this.pubSub.publishForm(n.BILLING,{fieldName:vt.zipCode})},onValidation:t=>{this.billingData.zipCode.isValid=t,this.updateSaveButtonState()}});return T.setAttribute("aria-label","Zip Code input"),C.appendChild(T),d.appendChild(C),e.push(d),e}}class CheckoutBuyer extends BaseComponent{get hostClasses(){return["checkout-buyer-information"]}constructor(){super({watchStorePaths:["checkout.customerForm.data"],watchOnlyStorePaths:["checkout.customerForm.isSaving"]}),this.customerData={firstName:{isValid:![],value:""},lastName:{isValid:![],value:""},email:{isValid:![],value:""},phone:{isValid:![],value:""},addressTwo:{isValid:![],value:""},company:{isValid:![],value:""},birthDate:{isValid:![],value:""}},this.saveButtonText="Save Buyer Information"}onStoreWatch(t){const e=t.find(t=>"checkout.customerForm.isSaving"===t.path);e&&(e.value?(this.saveButton.textContent="Saving...",this.saveButton.disabled=!![]):(this.saveButton.textContent=this.saveButtonText,this.updateSaveButtonState()))}updateSaveButtonState(){this.saveButton.disabled=!(this.customerData.firstName.isValid&&this.customerData.lastName.isValid&&this.customerData.email.isValid&&this.customerData.phone.isValid&&this.customerData.birthDate.isValid)}template(){const t=this.store.get("checkout.customerForm.data");t.firstName&&(this.customerData.firstName={isValid:!![],value:t.firstName}),t.lastName&&(this.customerData.lastName={isValid:!![],value:t.lastName}),t.email&&(this.customerData.email={isValid:!![],value:t.email}),t.phone&&(this.customerData.phone={isValid:!![],value:t.phone}),t.company&&(this.customerData.company={isValid:!![],value:t.company}),t.birthDate&&(this.customerData.birthDate={isValid:!![],value:t.birthDate});const e=[],s=document.createElement("div");s.classList.add("section-title-container");const a=document.createElement("h3");a.textContent="Buyer Information",a.classList.add("section-title"),s.appendChild(a);const c=document.createElement("p");c.textContent="Buyer information is used to process your order and for delivery purposes.",c.classList.add("section-subtitle"),s.appendChild(c),e.push(s);const l=document.createElement("div");l.classList.add("section-form-container");const d=document.createElement("div");d.classList.add("checkout-two-col-container");const h=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:ft.firstName,label:"First Name",autocomplete:!![],validation:{required:!![]},value:t.firstName,onChange:async t=>{this.customerData.firstName.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.firstName})},onValidation:t=>{this.customerData.firstName.isValid=t,this.updateSaveButtonState()}});d.appendChild(h);const p=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:ft.lastName,label:"Last Name",autocomplete:!![],validation:{required:!![]},value:t.lastName,onChange:async t=>{this.customerData.lastName.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.lastName})},onValidation:t=>{this.customerData.lastName.isValid=t,this.updateSaveButtonState()}});d.appendChild(p),l.appendChild(d);const m=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:ft.company,label:"Company (optional)",autocomplete:!![],value:t.company,onChange:async t=>{this.customerData.company.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.company})},onValidation:t=>{this.customerData.company.isValid=t,this.updateSaveButtonState()}});l.appendChild(m);const f=ComponentFactoryService.createElement({type:r.INPUT,inputType:"email",name:ft.email,label:"Email",autocomplete:!![],validation:{required:!![]},value:t.email,onChange:async t=>{this.customerData.email.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.email})},onValidation:t=>{this.customerData.email.isValid=t,this.updateSaveButtonState()}});l.appendChild(f);const g=ComponentFactoryService.createElement({type:r.INPUT,inputType:"tel",name:ft.phone,label:"Phone",autocomplete:!![],validation:{required:!![]},value:t.phone,onChange:async t=>{this.customerData.phone.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.phone})},onValidation:t=>{this.customerData.phone.isValid=t,this.updateSaveButtonState()}});l.appendChild(g);const v=ComponentFactoryService.createElement({type:r.INPUT,inputType:"birthdate",name:ft.birthDate,label:"Birthdate",validation:{required:!![],minAge:21,minYear:1930},value:t.birthDate,onChange:async t=>{this.customerData.birthDate.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.birthDate})},onValidation:t=>{this.customerData.birthDate.isValid=t,this.updateSaveButtonState()}});return l.appendChild(v),e.push(l),this.saveButton=document.createElement("button"),this.saveButton.type="button",this.saveButton.classList.add("save-form-info-button"),this.saveButton.textContent=this.saveButtonText,this.saveButton.addEventListener("click",async()=>{await this.commands.checkout.saveCustomerForm({customerData:{firstName:this.customerData.firstName.value,lastName:this.customerData.lastName.value,email:this.customerData.email.value,phone:this.customerData.phone.value,company:this.customerData.company.value,birthDate:this.customerData.birthDate.value},shippingAddressTwo:this.customerData.addressTwo.value,deliveryInstructions:""})}),e.push(this.saveButton),this.updateSaveButtonState(),e}}class CheckoutBuyerSummaryComponent extends BaseComponent{get hostClasses(){return["checkout-summary-form-container"]}constructor(){super({watchStorePaths:["checkout.customerForm"]})}template(){const t=[],e=this.getStoreValue("checkout.customerForm.data"),n=document.createElement("div");n.classList.add("checkout-summary-form-header");const r=document.createElement("h2");r.textContent="Buyer: "+e.firstName+" "+e.lastName,n.appendChild(r);const s=document.createElement("span");if(s.textContent="Edit",s.setAttribute("aria-label","Edit Buyer Information"),s.setAttribute("role","button"),s.setAttribute("tabindex","0"),s.addEventListener("click",async()=>{await this.commands.checkout.editCustomerForm()}),s.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.commands.checkout.editCustomerForm())}),n.appendChild(s),t.push(n),e.company){const n=document.createElement("p");n.classList.add("checkout-summary-form-line"),n.textContent=e.company,t.push(n)}const a=document.createElement("p");a.classList.add("checkout-summary-form-line"),a.textContent=e.email,t.push(a);const c=document.createElement("p");c.classList.add("checkout-summary-form-line"),c.textContent=e.phone,t.push(c);const l=document.createElement("p");return l.classList.add("checkout-summary-form-line"),l.textContent=formatISODateToMMDDYYYY(e.birthDate),t.push(l),t}}const wt=["span","p","a","b","i","div","strong","em","u","br","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","code","pre","img"],Ct={a:["href","title","target","rel"],img:["src","alt","width","height","title"],blockquote:["cite"],div:["class"],span:["class"],p:["class"],strong:["class"],em:["class"],code:["class"],pre:["class"],h1:["class"],h2:["class"],h3:["class"],h4:["class"],h5:["class"],h6:["class"],ul:["class"],ol:["class"],li:["class"]};function sanitizeAttributeValue(t,e){return"href"===t?/^(https?:\/\/[^\s<>"']+|mailto:[^\s<>"']+|tel:[^\s<>"']+|\/[^\s<>"']*|#[^\s<>"']*)$/i.test(e)?e:null:"src"===t?/^https?:\/\/[^\s<>"']+$/i.test(e)?e:null:"class"===t?e.replace(/[^a-zA-Z0-9\s\-_]/g,"").trim():e.replace(/[<>"']/g,"").trim()}function cleanNode(t){if(t.nodeType===Node.TEXT_NODE){const e=t.textContent||"",n=e.replace(/<[^>]*>/g,"");if(n.trim()){const t=document.createTextNode(n);return t}return null}if(t.nodeType===Node.ELEMENT_NODE){const e=t,n=e.tagName.toLowerCase();if(wt.includes(n)){const t=document.createElement(n),r=Ct[n]||[];for(const n of Array.from(e.attributes)){const e=n.name.toLowerCase();if(r.includes(e)){const r=sanitizeAttributeValue(e,n.value);null!==r&&t.setAttribute(e,r)}}"a"===n&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"));for(const n of Array.from(e.childNodes)){const e=cleanNode(n);e&&t.appendChild(e)}return t}const r=document.createDocumentFragment();for(const t of Array.from(e.childNodes)){const e=cleanNode(t);e&&r.appendChild(e)}return r.childNodes.length>0?r:null}return null}function sanitizeHTML(t){if(!t||"string"!=typeof t)return"";try{const e=new DOMParser,n=e.parseFromString(t,"text/html"),r=n.querySelector("parsererror");if(r)return console.warn("HTML parsing error detected"),"";const s=document.createDocumentFragment();for(const t of Array.from(n.body.childNodes)){const e=cleanNode(t);e&&s.appendChild(e)}const a=document.createElement("div");return a.appendChild(s),a.innerHTML}catch(e){return console.error("HTML sanitization error:",e),""}}class CheckoutCompletedComponent extends BaseComponent{get hostClasses(){return["checkout-completed-container"]}template(){var t,e,n,s,a,c;const l=[],d=this.getConfigs("configurations"),h=this.getConfigs("global"),p=this.getConfigs("checkout"),m=this.config.layout.continueShoppingUrl||window.location.host,f=this.config.layout.thankYouButtonText||"Continue Shopping";if(null===(e=null===(t=this.config.layout)||void 0===t?void 0:t.checkoutCompleted)||void 0===e?void 0:e.customLogo){const t=document.createElement("div");t.classList.add("checkout-completed-header-container");const e=document.createElement("img");e.src=null===(s=null===(n=this.config.layout)||void 0===n?void 0:n.checkoutCompleted)||void 0===s?void 0:s.customLogo,e.alt=d.partnerName+" Logo",t.appendChild(e),l.push(t)}const g=document.createElement("div");g.classList.add("checkout-completed-section-container");const v=document.createElement("div");v.classList.add("checkout-completed-title-container");const y=document.createElement("div");y.classList.add("checkout-completed-title-section");const b=document.createElement("h3");b.innerHTML=(null===(c=null===(a=this.config.layout)||void 0===a?void 0:a.checkoutCompleted)||void 0===c?void 0:c.customText)||"Thank You for Your Order!",y.appendChild(b);const x=document.createElement("p");x.textContent="Your payment has been successfully processed.",y.appendChild(x),v.appendChild(y),g.appendChild(v);const w=document.createElement("div");w.classList.add("checkout-completed-sub-section");const C=document.createElement("div");C.classList.add("checkout-completed-line");const _=document.createElement("h3");_.textContent="Order Number",C.appendChild(_);const E=document.createElement("span");E.textContent=this.params.orderNumber,C.appendChild(E),w.appendChild(C);const T=document.createElement("div");T.classList.add("checkout-completed-line");const P=document.createElement("h3");P.textContent="Order Amount",T.appendChild(P);const D=document.createElement("span");D.textContent=""+formatCentToDollarText(this.params.orderTotal),T.appendChild(D),w.appendChild(T);const A=document.createElement("div");A.classList.add("checkout-completed-line");const F=document.createElement("h3");F.textContent="Payment Method",A.appendChild(F);const O=document.createElement("span");if(O.textContent="** "+this.params.cardLast4,A.appendChild(O),w.appendChild(A),!this.clientConfig.isProduction()){if(this.params.checkoutToken){const t=document.createElement("div");t.classList.add("checkout-completed-line");const e=document.createElement("h3");e.textContent="Checkout Token",t.appendChild(e);const n=document.createElement("span");n.textContent=this.params.checkoutToken,n.style.fontSize="12px",n.style.wordBreak="break-all",t.appendChild(n),w.appendChild(t)}if(this.params.cartId){const t=document.createElement("div");t.classList.add("checkout-completed-line");const e=document.createElement("h3");e.textContent="Cart ID",t.appendChild(e);const n=document.createElement("span");n.textContent=this.params.cartId,n.style.fontSize="12px",n.style.wordBreak="break-all",t.appendChild(n),w.appendChild(t)}}g.appendChild(w);const M=document.createElement("div");M.classList.add("checkout-completed-sub-section");const L=document.createElement("p");L.innerHTML=this.params.giftRecipientEmail?"Order updates and your gift message will be sent to <strong>"+this.params.giftRecipientEmail+"</strong>.<br><br>A confirmation email and receipt has been sent to <strong>"+this.params.customerEmail+"</strong>.":"A confirmation email and receipt has been sent to <strong>"+this.params.customerEmail+"</strong>.",M.appendChild(L),g.appendChild(M),l.push(g);const N=document.createElement("div");N.classList.add("checkout-completed-section-container");const z=document.createElement("button");z.type="button";const j=document.createElement("span");j.textContent=f,z.setAttribute("tabindex","0"),z.setAttribute("role","button"),z.setAttribute("aria-label",f),z.appendChild(j);const B=htmlStringToElement(ArrowRightIcon({width:16,height:16,color:h.theme.selectedTextColor}));z.appendChild(B),z.addEventListener("click",()=>{window.location.href=m}),z.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),window.location.href=m)}),N.appendChild(z),l.push(N);const q=document.createElement("div");q.classList.add("checkout-completed-section-container");const U=document.createElement("div");U.classList.add("checkout-completed-help-section"),q.appendChild(U);const V=document.createElement("p");V.textContent="Questions about your order? Contact us at ";const G=document.createElement("a");G.href="mailto:"+d.supportEmail,G.textContent=d.supportEmail,V.appendChild(G),U.appendChild(V);const H=document.createElement("p"),K=(new Date).toLocaleDateString("en-US",{month:"2-digit",day:"2-digit",year:"numeric"});if(H.textContent="Order placed on "+K,U.appendChild(H),l.push(q),p.layout.legalMessage.show){const t=document.createElement("div");t.classList.add("checkout-separator");const e=document.createElement("div");e.classList.add("checkout-legal-message"),e.innerHTML=sanitizeHTML(p.layout.legalMessage.text);const n=document.createElement("div");n.classList.add("checkout-separator"),l.push(t),l.push(e),l.push(n)}if(h.layout.showPoweredBy){const t=ComponentFactoryService.createElement({type:r.POWERED_BY,context:"general"});l.push(t)}return l}}class CheckoutDeliverToComponent extends BaseComponent{get hostClasses(){return["checkout-delivery-information"]}constructor(){super({watchStorePaths:["checkout.isGift"],watchOnlyStorePaths:["checkout.customerForm.isSaving","checkout.giftRecipientForm.isSaving"]}),this.customerData={firstName:{isValid:![],value:""},lastName:{isValid:![],value:""},email:{isValid:![],value:""},phone:{isValid:![],value:""},company:{isValid:!![],value:""},birthDate:{isValid:![],value:""},addressTwo:{isValid:!![],value:""},deliveryInstructions:{isValid:!![],value:""}},this.giftData={firstName:{isValid:![],value:""},lastName:{isValid:![],value:""},email:{isValid:![],value:""},phone:{isValid:![],value:""},message:{isValid:![],value:""},addressTwo:{isValid:!![],value:""},deliveryInstructions:{isValid:!![],value:""}},this.saveButtonText="Save Delivery Information"}onStoreWatch(t){const e=t.find(t=>"checkout.customerForm.isSaving"===t.path),n=t.find(t=>"checkout.giftRecipientForm.isSaving"===t.path);(null==e?void 0:e.value)||(null==n?void 0:n.value)?(this.saveButton.textContent="Saving...",this.saveButton.disabled=!![]):(this.saveButton.textContent=this.saveButtonText,this.updateSaveButtonState())}updateSaveButtonState(){const t=this.getStoreValue("checkout.isGift")||![];let e;e=t?!(this.giftData.firstName.isValid&&this.giftData.lastName.isValid&&this.giftData.email.isValid&&this.giftData.phone.isValid&&this.giftData.message.isValid&&this.giftData.addressTwo.isValid):!(this.customerData.firstName.isValid&&this.customerData.lastName.isValid&&this.customerData.email.isValid&&this.customerData.phone.isValid&&this.customerData.birthDate.isValid),this.saveButton.disabled=e}template(){const t=this.getConfigs("global"),e=this.getStoreValue("checkout.isGift"),a=this.store.get("checkout.giftRecipientForm.data"),c=this.store.get("checkout.customerForm.data"),l=this.store.get("checkout.shippingAddress"),d=e?a:c,h=this.store.get("checkout.deliveryInstructions");c.firstName&&(this.customerData.firstName={isValid:!![],value:c.firstName}),c.lastName&&(this.customerData.lastName={isValid:!![],value:c.lastName}),c.email&&(this.customerData.email={isValid:!![],value:c.email}),c.phone&&(this.customerData.phone={isValid:!![],value:c.phone}),c.company&&(this.customerData.company={isValid:!![],value:c.company}),c.birthDate&&(this.customerData.birthDate={isValid:!![],value:c.birthDate}),a.firstName&&(this.giftData.firstName={isValid:!![],value:a.firstName}),a.lastName&&(this.giftData.lastName={isValid:!![],value:a.lastName}),a.email&&(this.giftData.email={isValid:!![],value:a.email}),a.phone&&(this.giftData.phone={isValid:!![],value:a.phone}),a.message&&(this.giftData.message={isValid:!![],value:a.message}),l.address.two&&(this.customerData.addressTwo={isValid:!![],value:l.address.two},this.giftData.addressTwo={isValid:!![],value:l.address.two}),h&&(this.customerData.deliveryInstructions={isValid:!![],value:h},this.giftData.deliveryInstructions={isValid:!![],value:h});const p=this.store.get("checkout.fulfillments")||{},m=Object.values(p).some(t=>t.type===s.ON_DEMAND),f=[],g=document.createElement("div");g.classList.add("delivery-header-container");const v=document.createElement("div");v.classList.add("delivery-header-content");const y=document.createElement("div");y.classList.add("delivery-title-container");const b=document.createElement("h3");b.textContent="Deliver to",b.classList.add("delivery-title");const x=document.createElement("p");x.textContent="Package recipient must be 21+",x.classList.add("delivery-subtitle"),y.appendChild(b),y.appendChild(x),g.appendChild(y),f.push(g);const w=document.createElement("div");w.classList.add("section-form-container");const C=document.createElement("div");C.classList.add("checkout-two-col-container");const _=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:e?gt.firstName:ft.firstName,label:"First Name",autocomplete:!![],validation:{required:!![]},value:d.firstName,onChange:t=>{e?(this.giftData.firstName.value=t,this.pubSub.publishForm(n.GIFT,{fieldName:gt.firstName})):(this.customerData.firstName.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.firstName}))},onValidation:t=>{e?this.giftData.firstName.isValid=t:this.customerData.firstName.isValid=t,this.updateSaveButtonState()}});_.setAttribute("aria-label","First Name Input"),C.appendChild(_);const E=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:e?gt.lastName:ft.lastName,label:"Last Name",autocomplete:!![],validation:{required:!![]},value:d.lastName,onChange:t=>{e?(this.giftData.lastName.value=t,this.pubSub.publishForm(n.GIFT,{fieldName:gt.lastName})):(this.customerData.lastName.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.lastName}))},onValidation:t=>{e?this.giftData.lastName.isValid=t:this.customerData.lastName.isValid=t,this.updateSaveButtonState()}});if(E.setAttribute("aria-label","Last Name Input"),C.appendChild(E),w.appendChild(C),!e){const t=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:ft.company,label:"Company (optional)",autocomplete:!![],value:d.company,onChange:async t=>{this.customerData.company.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.company})},onValidation:t=>{this.customerData.company.isValid=t,this.updateSaveButtonState()}});t.setAttribute("aria-label","Company Input"),w.appendChild(t)}const T=ComponentFactoryService.createElement({type:r.INPUT,inputType:"email",name:e?gt.email:ft.email,label:"Email",autocomplete:!![],validation:{required:!![]},value:d.email,onChange:t=>{e?(this.giftData.email.value=t,this.pubSub.publishForm(n.GIFT,{fieldName:gt.email})):(this.customerData.email.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.email}))},onValidation:t=>{e?this.giftData.email.isValid=t:this.customerData.email.isValid=t,this.updateSaveButtonState()}});T.setAttribute("aria-label","Email Input"),w.appendChild(T);const P=ComponentFactoryService.createElement({type:r.INPUT,inputType:"tel",name:e?gt.phone:ft.phone,label:"Phone",autocomplete:!![],validation:{required:!![]},value:d.phone,onChange:t=>{e?(this.giftData.phone.value=t,this.pubSub.publishForm(n.GIFT,{fieldName:gt.phone})):(this.customerData.phone.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.phone}))},onValidation:t=>{e?this.giftData.phone.isValid=t:this.customerData.phone.isValid=t,this.updateSaveButtonState()}});if(P.setAttribute("aria-label","Phone Input"),w.appendChild(P),!e){const t=ComponentFactoryService.createElement({type:r.INPUT,inputType:"birthdate",name:ft.birthDate,label:"Birthdate",validation:{required:!![],minAge:21,minYear:1930},value:d.birthDate,onChange:async t=>{this.customerData.birthDate.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.birthDate})},onValidation:t=>{this.customerData.birthDate.isValid=t,this.updateSaveButtonState()}});t.setAttribute("aria-label","Birthdate Input"),w.appendChild(t)}const D=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:"address_one",label:"Delivery address",value:l.formattedAddress,disabled:!![],className:"disabled-input"});D.setAttribute("aria-label","Delivery Address Input"),w.appendChild(D);const A=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:e?gt.addressTwo:ft.addressTwo,label:"Apt, suite, etc. (optional)",value:l.address.two,onChange:t=>{e?(this.giftData.addressTwo.value=t,this.pubSub.publishForm(n.GIFT,{fieldName:gt.addressTwo})):(this.customerData.addressTwo.value=t,this.pubSub.publishForm(n.CUSTOMER,{fieldName:ft.addressTwo}))},onValidation:t=>{e?this.giftData.addressTwo.isValid=t:this.customerData.addressTwo.isValid=t,this.updateSaveButtonState()}});if(A.setAttribute("aria-label","Address Line 2 Input"),w.appendChild(A),e){const e=document.createElement("div");e.classList.add("custom-input","textarea",t.layout.inputFieldStyle);const r=document.createElement("label");r.textContent="Gift Message*",r.setAttribute("for",gt.message);const s=document.createElement("textarea");s.name=gt.message,s.id=gt.message,s.rows=4,s.value=a.message||"",s.setAttribute("aria-label","Gift Message Textarea"),s.addEventListener("input",async t=>{const e=t.target.value;this.giftData.message.value=e,this.giftData.message.isValid=e.length>0,this.pubSub.publishForm(n.GIFT,{fieldName:gt.message}),this.updateSaveButtonState()});const c=document.createElement("p");c.textContent="Your gift message will be emailed to the recipient along with delivery details.",c.classList.add("textarea-message-disclaimer"),e.appendChild(r),e.appendChild(s),e.appendChild(c),w.appendChild(e)}if(m){const n=document.createElement("div");n.classList.add("custom-input","textarea",t.layout.inputFieldStyle);const r=document.createElement("label");r.textContent="Delivery Instructions",r.setAttribute("for","delivery_instructions");const s=document.createElement("textarea");s.id="delivery_instructions",s.name="delivery_instructions",s.rows=4,s.setAttribute("aria-label","Delivery Instructions Textarea"),s.value=h,s.addEventListener("input",async t=>{const n=t.target.value;e?(this.giftData.deliveryInstructions.value=n,this.giftData.deliveryInstructions.isValid=n.length>0):(this.customerData.deliveryInstructions.value=n,this.customerData.deliveryInstructions.isValid=n.length>0)});const a=document.createElement("p");a.textContent="Include gate codes, apartment numbers, or preferred drop-off locations for your driver.",a.classList.add("textarea-message-disclaimer"),n.appendChild(r),n.appendChild(s),n.appendChild(a),w.appendChild(n)}f.push(w),this.saveButton=document.createElement("button"),this.saveButton.type="button",this.saveButton.classList.add("save-form-info-button"),this.saveButton.textContent=this.saveButtonText,this.saveButton.setAttribute("aria-label","Save Delivery Information"),this.saveButton.setAttribute("role","button"),this.saveButton.setAttribute("tabindex","0");const S=async()=>{e?await this.commands.checkout.saveGiftRecipientForm({firstName:this.giftData.firstName.value,lastName:this.giftData.lastName.value,email:this.giftData.email.value,phone:this.giftData.phone.value,message:this.giftData.message.value,shippingAddressTwo:this.giftData.addressTwo.value,deliveryInstructions:this.giftData.deliveryInstructions.value}):await this.commands.checkout.saveCustomerForm({customerData:{firstName:this.customerData.firstName.value,lastName:this.customerData.lastName.value,email:this.customerData.email.value,phone:this.customerData.phone.value,company:this.customerData.company.value,birthDate:this.customerData.birthDate.value},shippingAddressTwo:this.customerData.addressTwo.value,deliveryInstructions:this.customerData.deliveryInstructions.value})};return this.saveButton.addEventListener("click",S),this.saveButton.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await S())}),f.push(this.saveButton),this.updateSaveButtonState(),f}}class CheckoutDeliverToSummaryComponent extends BaseComponent{get hostClasses(){return["checkout-summary-form-container"]}constructor(){super({watchStorePaths:["checkout.isGift","checkout.customerForm","checkout.giftRecipientForm","checkout.deliveryInstructions"]})}template(){const t=[],e=this.getStoreValue("checkout.isGift"),n=this.getStoreValue("checkout.customerForm.data"),r=this.getStoreValue("checkout.giftRecipientForm.data"),s=this.getStoreValue("checkout.shippingAddress"),a=this.getStoreValue("checkout.deliveryInstructions"),c=document.createElement("div");c.classList.add("checkout-summary-form-header");const l=document.createElement("h2");l.textContent=e?"Delivering to "+r.firstName+" "+r.lastName:"Delivering to "+n.firstName+" "+n.lastName,c.appendChild(l);const d=document.createElement("span");d.textContent="Edit",d.setAttribute("aria-label","Edit Delivery Information"),d.setAttribute("role","button"),d.setAttribute("tabindex","0");const R=async()=>{e?await this.commands.checkout.editGiftRecipientForm():await this.commands.checkout.editCustomerForm()};if(d.addEventListener("click",R),d.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await R())}),c.appendChild(d),t.push(c),!e&&n.company){const e=document.createElement("p");e.classList.add("checkout-summary-form-line"),e.textContent=n.company,t.push(e)}const h=document.createElement("p");h.classList.add("checkout-summary-form-line"),h.textContent=s.formattedAddress,t.push(h);const p=document.createElement("p");p.classList.add("checkout-summary-form-line"),p.textContent=e?r.email:n.email,t.push(p);const m=document.createElement("p");if(m.classList.add("checkout-summary-form-line"),m.textContent=e?r.phone:n.phone,t.push(m),!e&&n.birthDate){const e=document.createElement("p");e.classList.add("checkout-summary-form-line"),e.textContent=formatISODateToMMDDYYYY(n.birthDate),t.push(e)}if(e){const e=document.createElement("div");e.classList.add("checkout-summary-form-line-container");const n=document.createElement("span");n.classList.add("checkout-summary-form-line-container-label"),n.textContent="Gift Message:",e.appendChild(n);const s=document.createElement("span");s.classList.add("checkout-summary-form-line"),s.textContent=r.message||"No message provided.",e.appendChild(s),t.push(e)}if(a){const e=document.createElement("div");e.classList.add("checkout-summary-form-line-container");const n=document.createElement("span");n.classList.add("checkout-summary-form-line-container-label"),n.textContent="Delivery Instructions:",e.appendChild(n);const r=document.createElement("span");r.classList.add("checkout-summary-form-line"),r.textContent=a||"No instructions provided.",e.appendChild(r),t.push(e)}return t}}class CheckoutGiftCardsComponent extends BaseComponent{get hostClasses(){return["input-gift-card-container"]}constructor(){super({watchOnlyStorePaths:["checkout.giftCards","checkout.giftCardError","checkout.loading"]}),this.isApplying=![],this.giftCardInput=null,this.applyButton=null}onStoreWatch(t){var e;const n=t.find(t=>"checkout.giftCards"===t.path),r=t.find(t=>"checkout.loading"===t.path);n&&n.value.length>((null===(e=n.oldValue)||void 0===e?void 0:e.length)||0)&&this.giftCardInput&&this.giftCardInput.setValue(""),r&&this.updateApplyButtonState()}updateApplyButtonState(){if(!this.applyButton||!this.giftCardInput)return;const t=this.giftCardInput.getValue().trim(),e=t.length>=3&&t.length<=255,n=this.getStoreValue("checkout.loading"),r=this.getStoreValue("checkout.giftCardError");this.applyButton.disabled=!e||n||Boolean(r)||this.isApplying}createGiftCardInput(){return this.giftCardInput=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:"giftCards",placeholder:"Enter gift card code",autocomplete:![],validation:{min:3,max:255},onChange:t=>{const e=t.toUpperCase(),n=this.giftCardInput;n.setValue(e),this.updateApplyButtonState()}}),this.giftCardInput}createApplyButton(){this.applyButton=document.createElement("button"),this.applyButton.type="button",this.applyButton.classList.add("apply-button"),this.applyButton.disabled=!![],this.applyButton.textContent="Apply",this.applyButton.setAttribute("tabindex","0"),this.applyButton.setAttribute("role","button"),this.applyButton.setAttribute("aria-label","Apply gift card");const o=async()=>{const t=this.giftCardInput.getValue().trim().toUpperCase();if(t)try{this.isApplying=!![],this.updateApplyButtonState(),await this.commands.checkout.applyGiftCard(t)}catch(e){this.logger.error("Checkout gift card application failed",{giftCardCode:t,error:e instanceof Error?e.message:String(e)})}finally{this.isApplying=![],this.updateApplyButtonState()}};return this.applyButton.addEventListener("click",o),this.applyButton.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o())}),this.applyButton}template(){this.giftCardInput=null,this.applyButton=null;const t=[];return t.push(this.createGiftCardInput()),t.push(this.createApplyButton()),t}disconnected(){this.giftCardInput=null,this.applyButton=null}}class CheckoutHeaderComponent extends BaseComponent{get hostClasses(){return["checkout-header-container"]}template(){var t,e;const n=this.store.get("checkout.presale"),s=this.getConfigs("checkout"),a=null!==(e=null===(t=this.params)||void 0===t?void 0:t.isHostedCheckout)&&void 0!==e?e:![];let c=null;if(!n){c=document.createElement("button"),c.type="button",c.classList.add("checkout-header-button"),c.setAttribute("aria-label",a?"Back":"Back to Cart"),c.addEventListener("click",()=>{if(this.clientConfig.isBuilder())return this.logger.info("Back Button Is Disabled In Builder Mode"),void 0;if(a){const t=null==s?void 0:s.layout.continueShoppingUrl;t&&(window.location.href=t)}else this.commands.ui.openDrawer(r.CART)});const t=document.createElement("span");t.innerHTML=ChevronLeftIcon({}),c.appendChild(t)}const l=document.createElement("h1");if(l.textContent=(null==s?void 0:s.layout.drawerHeaderText)||"Checkout",l.classList.add("checkout-header-title"),l.setAttribute("aria-label","Checkout Page"),a){const t=document.createElement("div");return t.classList.add("checkout-header-spacer"),c?[c,l,t]:[l,t]}const d=document.createElement("button");return d.innerHTML=CloseIcon({width:16,height:16}),d.classList.add("checkout-header-button-close"),d.setAttribute("aria-label","Close Checkout"),d.addEventListener("click",()=>{this.commands.ui.closeDrawer()}),c?[c,l,d]:[l,d]}}class CheckoutInformationComponent extends BaseComponent{get hostClasses(){return["checkout-information-section"]}constructor(){super({watchOnlyStorePaths:["checkout.isGift","checkout.customerForm.isEditing","checkout.giftRecipientForm.isEditing","checkout.paymentForm.isEditing"]})}onStoreWatch(){const t=this.getStoreValue("checkout.isGift"),e=this.getStoreValue("checkout.customerForm.isEditing"),n=this.getStoreValue("checkout.giftRecipientForm.isEditing"),r=this.getStoreValue("checkout.paymentForm.isEditing");t?(this.buyerForm.style.display=e?"block":"none",this.buyerSummary.style.display=e?"none":"block",this.deliveryToForm.style.display=n?"block":"none",this.deliverToSummary.style.display=n?"none":"block"):(this.deliveryToForm.style.display=e?"block":"none",this.deliverToSummary.style.display=e?"none":"block",this.buyerForm.style.display="none",this.buyerSummary.style.display="none"),this.paymentForm.style.display=r?"block":"none",this.paymentSummary.style.display=r?"none":"block"}template(){const t=[],e=this.getStoreValue("checkout.isGift"),n=this.getStoreValue("checkout.customerForm"),s=this.getStoreValue("checkout.giftRecipientForm"),a=this.getStoreValue("checkout.paymentForm"),c=ComponentFactoryService.createElement({type:r.CHECKOUT_SEND_AS_GIFT});return t.push(c),this.deliveryToForm=ComponentFactoryService.createElement({type:r.CHECKOUT_DELIVER_TO}),this.deliveryToForm.style.display=e?s.isEditing?"block":"none":n.isEditing?"block":"none",t.push(this.deliveryToForm),this.deliverToSummary=ComponentFactoryService.createElement({type:r.CHECKOUT_DELIVER_TO_SUMMARY}),this.deliverToSummary.style.display=e?s.isEditing?"none":"block":n.isEditing?"none":"block",t.push(this.deliverToSummary),this.buyerForm=ComponentFactoryService.createElement({type:r.CHECKOUT_BUYER}),this.buyerForm.style.display=e&&n.isEditing?"block":"none",t.push(this.buyerForm),this.buyerSummary=ComponentFactoryService.createElement({type:r.CHECKOUT_BUYER_SUMMARY}),this.buyerSummary.style.display=e&&!n.isEditing?"block":"none",t.push(this.buyerSummary),this.paymentForm=ComponentFactoryService.createElement({type:r.CHECKOUT_PAYMENT}),this.paymentForm.style.display=a.isEditing?"block":"none",t.push(this.paymentForm),this.paymentSummary=ComponentFactoryService.createElement({type:r.CHECKOUT_PAYMENT_SUMMARY}),this.paymentSummary.style.display=a.isEditing?"none":"block",t.push(this.paymentSummary),t}}class CheckoutItemComponent extends BaseComponent{get hostClasses(){return["checkout-item-card"]}constructor(){super({autoDestroy:!![],autoDestroyPath:"checkout.items.{itemId}",watchStorePaths:["checkout.items.{itemId}","checkout.items"]}),this.trashButton=null}onStoreChanged(t){var e,n,r,s;const a=t.find(t=>"checkout.items"===t.path);a&&(this.updateTrashButtonState(),this.setupMinimumPurchaseAlert(),this.checkAndUpdateLoadingState());const c=t.find(t=>t.path==="checkout.items."+this.params.itemId);if(c){const t=c.oldValue,a=c.value;if(a.updating)return![];const l=(null==t?void 0:t.quantity)!==(null==a?void 0:a.quantity),d=(null===(n=null===(e=null==t?void 0:t.attributes)||void 0===e?void 0:e.engraving)||void 0===n?void 0:n.lines)||[],h=(null===(s=null===(r=null==a?void 0:a.attributes)||void 0===r?void 0:r.engraving)||void 0===s?void 0:s.lines)||[],p=JSON.stringify(d)!==JSON.stringify(h);(l||p)&&this.updateEngravingElement(a)}return![]}updateEngravingElement(t){var e,n;const s=this.getConfigs("global"),a=this.container.querySelector(".engraving-view-container");if(a&&a.remove(),(null===(n=null===(e=null==t?void 0:t.attributes)||void 0===e?void 0:e.engraving)||void 0===n?void 0:n.hasEngraving)===!![]&&s.layout.enablePersonalization){const e=ComponentFactoryService.createElement({type:r.ENGRAVING_VIEW,identifier:t.cartItemId,context:"checkout"}),n=this.container.querySelector(".checkout-item-card-footer");n&&n.before(e)}}setupMinimumPurchaseAlert(){const t=this.getStoreValue("checkout.items."+this.params.itemId);if(!t)return;const e=t.fulfillmentId;if(!e)return;if(!this.container)return;const n=this.container.querySelector(".checkout-item-card-header");if(n){const t=this.getStoreValue("cart.fulfillments."+e),s=this.container.querySelector('[data-component-type="checkout-retailer-alert"]');if(s&&s.remove(),t.hasUnmetMinimumPurchaseAmount){const e=ComponentFactoryService.createElement({type:r.PURCHASE_MIN_ALERT,message:"+"+formatCentToDollarText(t.minimumPurchaseAmount-t.subtotal)+" needed for order minimum",messageType:"warning",currentTotal:t.subtotal,config:{showIcon:!![],alertType:"minimal"}});e.setAttribute("data-component-type","checkout-retailer-alert"),n.before(e)}}}updateTrashButtonState(){if(!this.trashButton)return;const t=this.getStoreValue("checkout"),e=Object.keys(t.items).length,n=1===e;this.trashButton.disabled=n,n?this.trashButton.classList.add("action-disabled"):this.trashButton.classList.remove("action-disabled")}createLoadingOverlay(){const t=document.createElement("div");t.className="cart-loading-backdrop",t.setAttribute("data-loading-id","item-loading-overlay");const e=document.createElement("div");e.className="cart-loading-spinner-container";const n=document.createElement("div");return n.className="cart-loading-spinner",n.innerHTML='\n <svg class="cart-spinner" width="32" height="32" viewBox="0 0 50 50">\n <circle\n class="cart-spinner-path"\n cx="25"\n cy="25"\n r="20"\n fill="none"\n stroke-width="3"\n stroke-linecap="round"\n stroke-dasharray="31.416"\n stroke-dashoffset="31.416"\n />\n </svg>\n ',e.appendChild(n),t.appendChild(e),t}hasLoadingOverlay(){return!!this.container.querySelector('[data-loading-id="item-loading-overlay"]')}showLoadingOverlay(){if(this.hasLoadingOverlay())return;const t=this.createLoadingOverlay();this.container.appendChild(t),this.container instanceof HTMLElement&&(this.container.style.position="relative")}hideLoadingOverlay(){const t=this.container.querySelector('[data-loading-id="item-loading-overlay"]');t&&(t.remove(),this.container instanceof HTMLElement&&(this.container.style.position=""))}isItemUpdating(){const t=this.getStoreValue("checkout.items."+this.params.itemId);return t?t.updating===!![]:![]}checkAndUpdateLoadingState(){const t=this.isItemUpdating(),e=this.hasLoadingOverlay();t&&!e?this.showLoadingOverlay():!t&&e&&this.hideLoadingOverlay()}afterRender(){this.updateTrashButtonState(),this.checkAndUpdateLoadingState()}template(){var t,e,n;const s=this.getConfigs("global"),a=this.getStoreValue("checkout.items."+this.params.itemId),c=null===(t=null==a?void 0:a.attributes)||void 0===t?void 0:t.presale,l=(null==c?void 0:c.isActive)&&(null==c?void 0:c.estimatedShipBy)?"Ships by "+formatISODateToMMDDYYYY(c.estimatedShipBy):"";if(!a)return[];const d=this.getStoreValue("checkout.fulfillments."+a.fulfillmentId),h=this.getStoreValue("checkout.retailers."+a.retailerId),p=document.createElement("div");p.classList.add("checkout-item-card-header");const m=document.createElement("div");m.classList.add("checkout-item-image");const f=document.createElement("img");f.src=a.mainImage,f.alt=a.name,f.loading="lazy",m.appendChild(f),p.appendChild(m);const g=document.createElement("div");g.classList.add("checkout-item-details-container");const v=document.createElement("h4");v.classList.add("checkout-item-title"),v.textContent=a.name,g.appendChild(v);const y=document.createElement("div");y.classList.add("checkout-item-subtitle");const b=document.createElement("span");b.textContent=c.isActive?l+",":(a.attributes.engraving.hasEngraving?null==d?void 0:d.engravingExpectation:null==d?void 0:d.expectation)+",",y.appendChild(b);const x=document.createElement("span");x.textContent="From "+((null==h?void 0:h.name)||"Retailer"),y.appendChild(x),g.appendChild(y),p.appendChild(g),this.trashButton=document.createElement("button"),this.trashButton.type="button",this.trashButton.innerHTML=TrashIcon({}),this.trashButton.addEventListener("click",async t=>{var e;if(t.preventDefault(),t.stopPropagation(),!(null===(e=this.trashButton)||void 0===e?void 0:e.disabled))try{await this.commands.checkout.removeItem(a.cartItemId)}catch(n){this.logger.error("Checkout item removal failed",n)}}),p.appendChild(this.trashButton);const w=ComponentFactoryService.createElement({type:r.CHECKOUT_ITEM_QUANTITY,itemId:a.cartItemId}),C=[];if(C.push(p),s.layout.enablePersonalization&&(null===(n=null===(e=null==a?void 0:a.attributes)||void 0===e?void 0:e.engraving)||void 0===n?void 0:n.hasEngraving)===!![]){const t=ComponentFactoryService.createElement({type:r.ENGRAVING_VIEW,identifier:a.cartItemId,context:"checkout"});C.push(t)}return C.push(w),C}disconnected(){this.hideLoadingOverlay()}}class CheckoutItemQuantityComponent extends BaseComponent{get hostClasses(){return["checkout-item-card-footer"]}constructor(){super({watchStorePaths:["checkout.items.{itemId}"],watchOnlyStorePaths:["checkout.items"],autoDestroy:!![],autoDestroyPath:"checkout.items.{itemId}"})}onStoreWatch(t){const e=t.find(t=>"checkout.items"===t.path);if(e){const t=this.calculateQuantityLimits();this.updateButtonStates(t)}}getAvailableQuantity(){var t,e,n;const r=this.getStoreValue("checkout.items."+this.params.itemId);if(!r)return 0;const s=this.getStoreValue("products");if(!s)return 0;const a=r.partNumber,c=r.fulfillmentId,l=null===(n=null===(e=null===(t=Object.values(s).find(t=>t.sizes[r.liquidId]))||void 0===t?void 0:t.sizes)||void 0===e?void 0:e[r.liquidId])||void 0===n?void 0:n.maxQuantityPerOrder;if(!l)return 0;const d=this.getStoreValue("checkout.items")||{},h=Object.values(d).filter(t=>t.partNumber===a&&t.fulfillmentId===c),p=h.reduce((t,e)=>t+e.quantity,0);return l-p}calculateQuantityLimits(){var t;const e=this.getStoreValue("checkout.items."+this.params.itemId);if(!e)return{currentQuantity:0,availableQuantity:0,isTheOnlyItem:![],canIncrease:![],canDecrease:![]};const n=this.getStoreValue("checkout"),r=1===(null===(t=Object.values(n.items))||void 0===t?void 0:t.length),s=e.quantity,a=this.getAvailableQuantity(),c=a>0,l=!(r&&1===s);return{currentQuantity:s,availableQuantity:a,isTheOnlyItem:r,canIncrease:c,canDecrease:l}}updateButtonStates(t){this.decreaseButton&&(this.decreaseButton.disabled=!t.canDecrease,this.decreaseButton.classList.toggle("disabled",!t.canDecrease)),this.increaseButton&&(this.increaseButton.disabled=!t.canIncrease,this.increaseButton.classList.toggle("disabled",!t.canIncrease),t.canIncrease?this.increaseButton.setAttribute("aria-label","Increase quantity"):this.increaseButton.setAttribute("aria-label","Cannot increase quantity above maximum")),this.quantitySpan&&(this.quantitySpan.textContent=t.currentQuantity.toString(),this.quantitySpan.setAttribute("aria-label","Current quantity: "+t.currentQuantity))}async handleQuantityChange(t){const e=this.calculateQuantityLimits(),n=this.params.itemId;if((!(t<0)||e.canDecrease)&&(!(t>0)||e.canIncrease)){if(!n)return this.logger.error("Checkout item quantity change failed: Item ID not found in component params",{componentParams:this.params,delta:t}),void 0;try{await this.commands.checkout.updateCheckoutItemQuantity(n,t)}catch(r){this.logger.error("Checkout item quantity change operation failed",r)}}}template(){const t=this.getStoreValue("checkout.items."+this.params.itemId);if(!t)return this.logger.warn("Checkout item not found during template render",{itemId:this.params.itemId}),[];const e=this.calculateQuantityLimits(),n=document.createElement("div");n.classList.add("checkout-item-quantity-container"),this.decreaseButton=document.createElement("button"),this.decreaseButton.type="button",this.decreaseButton.classList.add("quantity-decrease"),this.decreaseButton.textContent="-",this.decreaseButton.setAttribute("aria-label","Decrease quantity"),this.decreaseButton.addEventListener("click",async t=>{t.preventDefault(),t.stopPropagation(),await this.handleQuantityChange(-1)}),n.appendChild(this.decreaseButton),this.quantitySpan=document.createElement("span"),this.quantitySpan.classList.add("product-count"),n.appendChild(this.quantitySpan),this.increaseButton=document.createElement("button"),this.increaseButton.type="button",this.increaseButton.classList.add("quantity-increase"),this.increaseButton.textContent="+",this.increaseButton.addEventListener("click",async t=>{t.preventDefault(),t.stopPropagation(),await this.handleQuantityChange(1)}),n.appendChild(this.increaseButton),this.updateButtonStates(e);const r=document.createElement("span");if(r.classList.add("checkout-item-price-text"),r.textContent=formatCentToDollarText(t.price),t.quantity>1){const e=document.createElement("span");e.classList.add("checkout-item-price-each-text"),e.textContent=" ("+formatCentToDollarText(t.unitPrice)+" ea)",r.appendChild(e)}return[n,r]}}class CheckoutItemsComponent extends BaseComponent{get hostClasses(){return["checkout-items-container"]}constructor(){super({watchStorePaths:["checkout.items"]}),this.togglerElement=null,this.togglerButton=null,this.togglerLabel=null,this.itemsList=null}createItemElement(t){return ComponentFactoryService.createElement({type:r.CHECKOUT_ITEM,itemId:t})}getCurrentItemsMap(){const t=this.getStoreValue("checkout.items")||{},e=new Map;for(const n of Object.values(t))n&&n.cartItemId&&e.set(n.cartItemId,n);return e}syncItemsWithStore(){if(!this.itemsList)return;const t=this.getCurrentItemsMap(),e=this.itemsList.querySelectorAll("[data-item-id]"),n=new Set;for(const r of e){const t=r.getAttribute("data-item-id");t&&n.add(t)}for(const r of e){const e=r.getAttribute("data-item-id");e&&!t.has(e)&&r.remove()}for(const[r]of t)if(!n.has(r)){const t=this.createItemElement(r);t.setAttribute("data-item-id",r),this.itemsList.appendChild(t)}if(this.togglerLabel){const t=this.getStoreValue("checkout.itemsQuantity");this.togglerLabel.textContent=t+" item"+(t>1?"s":"")}}onStoreChanged(t){let e=null;for(let n=0;n<t.length;n++){const r=t[n];if("checkout"===r.path||"checkout.items"===r.path||"checkout.items."===r.path.substring(0,15)){e=r;break}}return e?(this.syncItemsWithStore(),![]):![]}handleToggle(){if(!this.togglerButton||!this.itemsList)return;const t=this.itemsList.classList.contains("show");this.itemsList.classList.toggle("show"),this.togglerButton.classList.toggle("expanded"),t?(this.togglerButton.setAttribute("aria-expanded","false"),this.togglerButton.setAttribute("aria-label","Expand checkout items")):(this.togglerButton.setAttribute("aria-expanded","true"),this.togglerButton.setAttribute("aria-label","Collapse checkout items"))}setupToggler(){if(!this.togglerElement||!this.togglerButton||!this.itemsList)return;const t=this.itemsList.classList.contains("show");this.togglerButton.setAttribute("tabindex","0"),this.togglerButton.setAttribute("aria-expanded",t?"true":"false"),this.togglerButton.setAttribute("aria-label",t?"Collapse checkout items":"Expand checkout items"),this.togglerElement.addEventListener("click",()=>this.handleToggle()),this.togglerElement.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleToggle())})}afterRender(){this.setupToggler(),this.syncItemsWithStore()}template(){const t=this.getStoreValue("checkout.itemsQuantity"),e=this.getStoreValue("checkout.items");this.togglerElement=document.createElement("div"),this.togglerElement.classList.add("checkout-items-toggler"),this.togglerLabel=document.createElement("span"),this.togglerLabel.classList.add("checkout-items-toggler-label"),this.togglerLabel.textContent=t+" item"+(t>1?"s":""),this.togglerElement.appendChild(this.togglerLabel),this.togglerButton=document.createElement("button"),this.togglerButton.type="button",this.togglerButton.classList.add("checkout-items-toggler-button"),this.togglerButton.innerHTML=ChevronDownIcon({width:20,height:20,className:"chevron-icon"}),this.togglerElement.appendChild(this.togglerButton),this.itemsList=document.createElement("div"),this.itemsList.classList.add("checkout-items-list","show");for(const n of Object.values(e)){const t=this.createItemElement(n.cartItemId);t.setAttribute("data-item-id",n.cartItemId),this.itemsList.appendChild(t)}return[this.togglerElement,this.itemsList]}}class CheckoutOrderSummaryComponent extends BaseComponent{get hostClasses(){return["checkout-summary-section"]}constructor(){super({watchOnlyStorePaths:["checkout.amounts"]})}onStoreWatch(t){const e=t.find(t=>"checkout.amounts"===t.path);if(e){const t=this.getStoreValue("checkout"),e=Object.values(t.items||{}).length;this.updateZeroAmountElement(0===t.amounts.total&&e>0)}}updateZeroAmountElement(t){const e=this.container.querySelector(".checkout-zero-amount-container");if(t&&!e){const t=document.createElement("div");t.classList.add("checkout-zero-amount-container"),t.textContent="Credit card required to complete order (even when fully covered by gift card)";const e=this.container.querySelector("checkout-amounts-lc, .checkout-amounts-container");e&&e.after(t)}else!t&&e&&e.remove()}afterRender(){const t=this.getStoreValue("checkout.amounts");t&&this.updateZeroAmountElement(0===t.total)}handleEmailToggle(t){this.commands.checkout.toggleMarketingPreferences("canEmail"),t.classList.toggle("checked");const e=t.classList.contains("checked");t.setAttribute("aria-checked",e?"true":"false")}handleSmsToggle(t){this.commands.checkout.toggleMarketingPreferences("canSms"),t.classList.toggle("checked");const e=t.classList.contains("checked");t.setAttribute("aria-checked",e?"true":"false")}marketingOptInsContainer(){const t=this.config.layout.emailOptIn,e=this.config.layout.smsOptIn;if(!t.show&&!e.show)return null;const n=document.createElement("div");if(n.classList.add("checkout-marketing-opt-ins-container"),t.show){const e=document.createElement("div");let r;e.classList.add("checkout-checkbox-container"),r=this.clientConfig.isBuilder()?t.checked:this.store.get("checkout.marketingPreferences.canEmail");const s=document.createElement("span");s.id="emailOptIn",s.classList.add("checkout-checkbox-visual"),r&&s.classList.add("checked"),s.innerHTML=CheckboxIcon({width:16,height:16}),s.setAttribute("role","checkbox"),s.setAttribute("tabindex","0"),s.setAttribute("aria-label","Email opt-in checkbox"),s.setAttribute("aria-checked",r?"true":"false"),s.addEventListener("click",()=>this.handleEmailToggle(s)),s.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleEmailToggle(s))});const a=document.createElement("label");a.setAttribute("for","emailOptIn"),a.classList.add("checkbox-label"),a.innerHTML=sanitizeHTML(t.text),a.addEventListener("click",t=>{const e=t.target,n="A"===e.tagName||e.closest("a");n||(this.commands.checkout.toggleMarketingPreferences("canEmail"),s.classList.toggle("checked"))}),e.appendChild(s),e.appendChild(a),n.appendChild(e)}if(e.show){const t=document.createElement("div");let r;t.classList.add("checkout-checkbox-container"),r=this.clientConfig.isBuilder()?e.checked:this.store.get("checkout.marketingPreferences.canSms");const s=document.createElement("span");s.classList.add("checkout-checkbox-visual"),s.id="smsOptIn",r&&s.classList.add("checked"),s.innerHTML=CheckboxIcon({width:16,height:16}),s.setAttribute("role","checkbox"),s.setAttribute("tabindex","0"),s.setAttribute("aria-label","SMS opt-in checkbox"),s.setAttribute("aria-checked",r?"true":"false"),s.addEventListener("click",()=>this.handleSmsToggle(s)),s.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleSmsToggle(s))});const a=document.createElement("label");a.setAttribute("for","smsOptIn"),a.classList.add("checkbox-label"),a.innerHTML=sanitizeHTML(e.text),a.addEventListener("click",t=>{const e=t.target,n="A"===e.tagName||e.closest("a");n||(this.commands.checkout.toggleMarketingPreferences("canSms"),s.classList.toggle("checked"))}),t.appendChild(s),t.appendChild(a),n.appendChild(t)}return n}hasOnDemandOrder(){const t=this.getStoreValue("checkout.fulfillments")||{};return Object.values(t).some(t=>t.type===s.ON_DEMAND)}template(){var t;const e=[],n=this.getConfigs("global"),s=this.getConfigs("checkout"),a=this.getConfigs("global"),c=s.layout.allowGiftCards,l=null===(t=null==a?void 0:a.layout)||void 0===t?void 0:t.allowPromoCodes,d=document.createElement("div");d.classList.add("section-title-container");const h=document.createElement("h3");h.textContent="Order Summary",h.classList.add("section-title"),d.appendChild(h),e.push(d);const p=ComponentFactoryService.createElement({type:r.CHECKOUT_ITEMS});e.push(p);const m=document.createElement("div");m.classList.add("checkout-separator");const f=document.createElement("div");if(f.classList.add("checkout-separator"),e.push(m),c||l){const t=ComponentFactoryService.createElement({type:r.CHECKOUT_PC_GC});e.push(t)}if(this.hasOnDemandOrder()){const t=ComponentFactoryService.createElement({type:r.CHECKOUT_TIPS});e.push(t),e.push(f)}const g=document.createElement("div");g.classList.add("section-title-container");const v=document.createElement("h3");v.textContent="100% Secure Payments",v.classList.add("disclaimer-header"),g.appendChild(v);const y=document.createElement("p");y.textContent="If a person over 21 is not available to receive this order, it will be returned for a $20 restocking fee. Valid Government ID required.",y.classList.add("disclaimer-description"),g.appendChild(y),e.push(g);const b=ComponentFactoryService.createElement({type:r.CHECKOUT_AMOUNTS});e.push(b);const x=ComponentFactoryService.createElement({type:r.CHECKOUT_PLACE_ORDER_BUTTON});e.push(x);const w=this.marketingOptInsContainer();if(w&&e.push(w),s.layout.legalMessage.show){const t=document.createElement("div");t.classList.add("checkout-separator");const n=document.createElement("div");n.classList.add("checkout-legal-message"),n.innerHTML=sanitizeHTML(s.layout.legalMessage.text),e.push(t),e.push(n)}const C=document.createElement("div");if(C.classList.add("checkout-separator"),e.push(C),n.layout.showPoweredBy){const t=ComponentFactoryService.createElement({type:r.POWERED_BY,context:"checkout"});e.push(t)}return e}}class CheckoutPaymentComponent extends BaseComponent{get hostClasses(){return["checkout-payment-form"]}constructor(){super({watchOnlyStorePaths:["checkout.paymentForm.isSaving","checkout.paymentForm.billingSameAsShipping"]}),this.stripeHandlerElement=null,this.hardcodedPaymentElement=null,this.billingFormData=null,this.isValidBillingForm=![],this.isBillingSameAsShipping=!![],this.stripeFormStatus={isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null},this.savedCardInfo=null,this.showingStripeSummary=![],this.isSavingPayment=![]}onStoreWatch(t){for(const e of t)switch(e.path){case"checkout.paymentForm.isSaving":this.isSavingPayment=e.value,this.updateSaveButtonState();break;case"checkout.paymentForm.billingSameAsShipping":this.handleBillingSameAsShippingChange(e.value)}}handleBillingSameAsShippingChange(t){this.isBillingSameAsShipping=t,t&&(this.billingFormData=null,this.isValidBillingForm=![]),this.updateSaveButtonState(),this.updateErrorMessage()}async afterRender(){var t;this.isBillingSameAsShipping=null!==(t=this.getStoreValue("checkout.paymentForm.billingSameAsShipping"))&&void 0!==t?t:!![],this.clientConfig.isDevelopment()&&this.clientConfig.get("paymentMethodId")&&(this.stripeFormStatus={isFormComplete:!![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null}),this.updateSaveButtonState()}updateSaveButtonState(){if(!this.saveButton)return;let t=!![],e="Save Payment Information";if(this.isSavingPayment||this.stripeFormStatus.isProcessing)e="Saving...",t=!![];else if(this.stripeFormStatus.hasError)e="Fix Errors and Retry",t=![];else if(this.showingStripeSummary&&this.savedCardInfo){const e=this.isBillingSameAsShipping||this.isValidBillingForm;t=!e}else{const e=this.stripeFormStatus.isFormComplete,n=this.isBillingSameAsShipping||this.isValidBillingForm;t=!(e&&n)}this.saveButton.disabled=t,this.saveButton.textContent=e,this.saveButton.classList.toggle("processing",this.isSavingPayment||this.stripeFormStatus.isProcessing),this.saveButton.classList.toggle("error",this.stripeFormStatus.hasError)}updateErrorMessage(){if(!this.errorMessageElement)return;let t="";this.stripeFormStatus.hasError&&this.stripeFormStatus.errorMessage?t=this.stripeFormStatus.errorMessage:this.isBillingSameAsShipping||this.isValidBillingForm||!this.stripeFormStatus.isFormComplete||(t="Please complete the billing address form"),t?(this.errorMessageElement.textContent=t,this.errorMessageElement.style.display="block"):(this.errorMessageElement.textContent="",this.errorMessageElement.style.display="none")}showError(t){this.errorMessageElement&&(this.errorMessageElement.textContent=t,this.errorMessageElement.style.display="block",setTimeout(()=>{this.errorMessageElement&&this.errorMessageElement.textContent===t&&(this.errorMessageElement.style.display="none")},5e3))}template(){const t=[],e=document.createElement("div");e.classList.add("section-title-container");const n=document.createElement("h3");n.textContent="Payment",n.classList.add("section-title"),e.appendChild(n);const s=document.createElement("p");if(s.textContent="All transactions are secure and encrypted.",s.classList.add("section-subtitle"),e.appendChild(s),t.push(e),this.clientConfig.isDevelopment()&&this.clientConfig.get("paymentMethodId")){this.hardcodedPaymentElement=document.createElement("div"),this.hardcodedPaymentElement.classList.add("hardcoded-payment-notice");const e=document.createElement("p");e.innerHTML="⚠️ Development Mode<br/>Payment Method: "+this.clientConfig.get("paymentMethodId"),this.hardcodedPaymentElement.appendChild(e),t.push(this.hardcodedPaymentElement)}else this.stripeHandlerElement=ComponentFactoryService.createElement({type:r.CHECKOUT_STRIPE_HANDLER,callbacks:{onStripeFormStatusChanged:t=>{this.stripeFormStatus=t,this.updateSaveButtonState(),this.updateErrorMessage()},onSavedCardInfoChanged:t=>{this.savedCardInfo=t},onEditModeVisibilityChanged:t=>{this.showingStripeSummary=t,this.updateSaveButtonState()},onPaymentSessionConfirmed:async(t,e)=>{const n={paymentSession:{confirmationTokenId:t,setupIntentId:e}};!this.isBillingSameAsShipping&&this.billingFormData&&(n.billingFormData=this.billingFormData),await this.commands.checkout.savePaymentForm(n)}}}),t.push(this.stripeHandlerElement);this.errorMessageElement=document.createElement("div"),this.errorMessageElement.classList.add("payment-error-message"),this.errorMessageElement.style.display="none",this.errorMessageElement.setAttribute("role","alert"),t.push(this.errorMessageElement);const a=ComponentFactoryService.createElement({type:r.CHECKOUT_BILLING,isFormValid:(t,e)=>{this.billingFormData=e,this.isValidBillingForm=t,this.updateSaveButtonState(),this.updateErrorMessage()}});return t.push(a),this.saveButton=document.createElement("button"),this.saveButton.type="button",this.saveButton.classList.add("save-form-info-button"),this.saveButton.textContent="Save Payment Information",this.saveButton.setAttribute("aria-label","Save payment information"),this.saveButton.setAttribute("role","button"),this.saveButton.setAttribute("tabindex","0"),this.saveButton.addEventListener("click",async()=>{await this.handleSaveButtonClick()}),this.saveButton.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.handleSaveButtonClick())}),t.push(this.saveButton),t}async handleSaveButtonClick(){var t;if(!this.isSavingPayment&&!this.stripeFormStatus.isProcessing)if(this.showingStripeSummary&&this.savedCardInfo)try{const t={};!this.isBillingSameAsShipping&&this.isValidBillingForm&&this.billingFormData&&(t.billingFormData=this.billingFormData),await this.commands.checkout.savePaymentForm(t)}catch(e){this.logger.error("Failed to save payment form in edit mode",e),this.showError("Failed to save payment information.")}else if(this.clientConfig.isDevelopment()&&this.clientConfig.get("paymentMethodId"))try{const t={};!this.isBillingSameAsShipping&&this.isValidBillingForm&&this.billingFormData&&(t.billingFormData=this.billingFormData),await this.commands.checkout.savePaymentForm(t)}catch(n){this.logger.error("Failed to save payment form in beta mode",n),this.showError("Failed to save payment information.")}else this.updateErrorMessage(),this.validatePrerequisites()&&(null===(t=this.stripeHandlerElement)||void 0===t||t.submitStripeForm())}validatePrerequisites(){return this.isBillingSameAsShipping||this.isValidBillingForm?this.stripeFormStatus.isFormComplete?!![]:(this.showError("Please complete all required payment fields."),![]):(this.showError("Please complete the billing address form before saving."),![])}disconnected(){var t;this.isSavingPayment=![],null===(t=super.disconnected)||void 0===t||t.call(this)}}class CheckoutPaymentSummaryComponent extends BaseComponent{get hostClasses(){return["checkout-summary-form-container"]}constructor(){super({watchStorePaths:["checkout.paymentForm"]})}template(){var t,e,n,r,s,a,c,l,d;const h=[],p=this.getStoreValue("checkout.paymentForm"),m=document.createElement("div");m.classList.add("checkout-summary-form-header");const f=document.createElement("h2");f.textContent="Paying with "+(null!==(n=null===(e=null===(t=p.paymentMethod)||void 0===t?void 0:t.card)||void 0===e?void 0:e.brand)&&void 0!==n?n:"")+" "+(null===(s=null===(r=p.paymentMethod)||void 0===r?void 0:r.card)||void 0===s?void 0:s.last4),m.appendChild(f);const g=document.createElement("span");g.textContent="Edit",g.setAttribute("aria-label","Edit Payment Information"),g.setAttribute("role","button"),g.setAttribute("tabindex","0"),g.addEventListener("click",async()=>{await this.commands.checkout.editPaymentForm()}),g.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.commands.checkout.editPaymentForm())}),m.appendChild(g),h.push(m);const v=document.createElement("p");return v.classList.add("checkout-summary-form-line"),v.textContent="Exp. "+(null===(c=null===(a=p.paymentMethod)||void 0===a?void 0:a.card)||void 0===c?void 0:c.expMonth)+"/"+(null===(d=null===(l=p.paymentMethod)||void 0===l?void 0:l.card)||void 0===d?void 0:d.expYear),h.push(v),h}}class CheckoutPlaceOrderButtonComponent extends BaseComponent{get hostClasses(){return["checkout-place-order-button-container"]}constructor(){super({watchOnlyStorePaths:["checkout.loading","checkout.error","checkout.customerForm.isValid","checkout.giftRecipientForm.isValid","checkout.paymentForm.isValid"]}),this.errorTimeoutId=null}afterRender(){this.placeOrderButton=this.container.querySelector(".checkout-place-order-button"),this.errorContainer=this.container.querySelector(".checkout-error-wrapper"),this.updateButtonState()}disconnected(){this.clearErrorTimeout()}onStoreWatch(t){const e=t.some(t=>"checkout.loading"===t.path||"checkout.error"===t.path||"checkout.customerForm.isValid"===t.path||"checkout.giftRecipientForm.isValid"===t.path||"checkout.paymentForm.isValid"===t.path);e&&this.updateButtonState()}updateButtonState(){if(!this.placeOrderButton)return;const t=this.store.get("checkout.loading")||![],e=this.store.get("checkout.error")||null;this.updateErrorDisplay(e);const n=this.determineButtonState({isCheckoutLoading:t,hasCheckoutError:!!e});this.placeOrderButton.classList.remove("processing","ready","disabled"),this.placeOrderButton.classList.add(n.state),this.placeOrderButton.disabled=n.disabled,this.placeOrderButton.textContent=n.text}clearErrorTimeout(){null!==this.errorTimeoutId&&(clearTimeout(this.errorTimeoutId),this.errorTimeoutId=null)}updateErrorDisplay(t){if(!this.errorContainer)return;const e=this.errorContainer.querySelector(".error-text");e&&(this.clearErrorTimeout(),t?(e.textContent=t,this.errorContainer.style.display="block",this.errorTimeoutId=setTimeout(async()=>{this.errorTimeoutId=null,await this.commands.checkout.clearCheckoutError()},3e3)):(e.textContent="",this.errorContainer.style.display="none"))}determineButtonState({isCheckoutLoading:t,hasCheckoutError:e}){const n=this.config.layout.placeOrderButtonText,r=this.store.get("checkout.presale");let s=![];if(!r){const t=this.getStoreValue("cart.fulfillments")||{};s=Object.values(t).some(t=>t.hasUnmetMinimumPurchaseAmount)}const a=this.store.get("checkout.isGift"),c=this.store.get("checkout.customerForm.isValid"),l=this.store.get("checkout.giftRecipientForm.isValid"),d=this.store.get("checkout.paymentForm.isValid");return s||a&&!l||!c||!d?{state:"disabled",text:n,disabled:!![]}:t?{state:"processing",text:"Placing Order...",disabled:!![]}:e?{state:"disabled",text:n,disabled:!![]}:{state:"ready",text:n,disabled:![]}}async handlePlaceOrderClick(){try{if(this.clientConfig.isBuilder())return this.logger.info("Checkout Place Order Button Is Disabled In Builder Mode"),void 0;const t=this.store.get("checkout.loading");if(t)return;await this.commands.checkout.checkoutComplete()}catch(t){this.logger.error("Error handling place order click",t)}}template(){const t=document.createElement("button");t.type="button",t.textContent=this.config.layout.placeOrderButtonText,t.classList.add("checkout-place-order-button"),t.disabled=!![],t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label","Place Order"),t.addEventListener("click",this.handlePlaceOrderClick.bind(this)),t.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.handlePlaceOrderClick())});const e=document.createElement("div");e.classList.add("checkout-error-wrapper"),e.setAttribute("role","alert"),e.style.display="none";const n=document.createElement("div");n.classList.add("checkout-error");const s=document.createElement("span");s.classList.add("icon-error"),s.innerHTML=ErrorInfoIcon({});const a=document.createElement("span");a.classList.add("error-text"),n.appendChild(s),n.appendChild(a),e.appendChild(n);const c=ComponentFactoryService.createElement({type:r.ALERT,errorStorePath:"checkout.events",fromEvents:!![],showFirstEvent:![]});return[e,c,t]}}class CheckoutPresaleCountdownComponent extends BaseComponent{get hostClasses(){return["checkout-presale-countdown-container"]}constructor(){super({watchStorePaths:["checkout.presale","ui.drawer"]}),this.countdownInterval=null,this.expiresAt=null,this.initialDurationSeconds=null,this.rootElement=null,this.scrollHandler=null,this.scrollContainer=null,this.isCurrentlyScrolled=![],this.isUnderOneMinute=![]}onStoreChanged(t){var e;const n=t.find(t=>"checkout.presale"===t.path);if(null==n?void 0:n.value)return this.updateExpiresAt(n.value.expiresAt),!![];const r=t.find(t=>"ui.drawer"===t.path);return(null===(e=null==r?void 0:r.value)||void 0===e?void 0:e.isOpen)===![]&&this.resetCountdownState(),![]}resetCountdownState(){this.stopCountdown(),this.cleanupScrollListener(),this.isCurrentlyScrolled=![],this.isUnderOneMinute=![]}afterRender(){const t=this.store.get("checkout.presale");(null==t?void 0:t.expiresAt)&&this.updateExpiresAt(t.expiresAt),this.setupDrawerScrollDetection()}disconnected(){this.stopCountdown(),this.cleanupScrollListener()}setupDrawerScrollDetection(){if(this.scrollContainer=this.findScrollContainer(),!this.scrollContainer)return this.logger.warn("Could not find scrollable drawer container"),void 0;const t=70,e=10;this.scrollHandler=()=>{if(!this.scrollContainer)return;const n=this.scrollContainer.scrollTop;!this.isCurrentlyScrolled&&n>t?this.setScrolledState(!![]):this.isCurrentlyScrolled&&n<e&&this.setScrolledState(![])},this.scrollContainer.addEventListener("scroll",this.scrollHandler,{passive:!![]}),this.scrollHandler()}findScrollContainer(){var t,e;const n=[".drawer-content"];for(const s of n){const e=null===(t=this.rootElement)||void 0===t?void 0:t.closest(s);if(e&&this.isScrollable(e))return e}let r=null===(e=this.rootElement)||void 0===e?void 0:e.parentElement;for(;r&&r!==document.body;){if(this.isScrollable(r))return r;r=r.parentElement}return null}setScrolledState(t){var e,n;this.isCurrentlyScrolled=t,t?(null===(e=this.rootElement)||void 0===e?void 0:e.classList.add("is-scrolled"),this.addHostClasses("is-scrolled")):(null===(n=this.rootElement)||void 0===n?void 0:n.classList.remove("is-scrolled"),this.removeHostClasses("is-scrolled"))}isScrollable(t){const e=window.getComputedStyle(t),n=e.overflowY;return t.scrollHeight>=t.clientHeight&&("auto"===n||"scroll"===n||"overlay"===n)}cleanupScrollListener(){this.scrollHandler&&this.scrollContainer&&(this.scrollContainer.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null,this.scrollContainer=null)}updateExpiresAt(t){this.stopCountdown();try{if(this.expiresAt=new Date(t),Number.isNaN(this.expiresAt.getTime()))return this.logger.error("Invalid presale expiration date",{expiresAtString:t}),this.handleExpire(),void 0;if(this.expiresAt<=new Date)return this.handleExpire(),void 0;const e=new Date,n=Math.floor((this.expiresAt.getTime()-e.getTime())/1e3);this.initialDurationSeconds=Math.min(n,CheckoutPresaleCountdownComponent.DEFAULT_PRESALE_DURATION_SECONDS),this.startCountdown()}catch(e){this.logger.error("Failed to parse presale expiration date",e),this.handleExpire()}}startCountdown(){this.updateCountdown(),this.countdownInterval=window.setInterval(()=>{this.updateCountdown()},CheckoutPresaleCountdownComponent.COUNTDOWN_UPDATE_INTERVAL_MS)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}updateCountdown(){if(!this.expiresAt||!this.rootElement||!this.initialDurationSeconds)return;const t=new Date,e=Math.max(0,this.expiresAt.getTime()-t.getTime()),n=e/1e3,r=this.initialDurationSeconds-n,s=Math.max(0,Math.min(100,r/this.initialDurationSeconds*100)),a=n<CheckoutPresaleCountdownComponent.ONE_MINUTE_THRESHOLD_SECONDS;a!==this.isUnderOneMinute&&(this.isUnderOneMinute=a,this.updateWarningState()),this.updateTimerDisplay(e),this.updateProgressBar(s),0===e&&this.handleExpire()}updateWarningState(){if(!this.rootElement)return;const t=this.rootElement.querySelector(".checkout-presale-timer");this.isUnderOneMinute?(this.rootElement.classList.add("time-warning"),null==t||t.classList.add("time-warning"),this.addHostClasses("time-warning")):(this.rootElement.classList.remove("time-warning"),null==t||t.classList.remove("time-warning"),this.removeHostClasses("time-warning"))}updateTimerDisplay(t){if(!this.rootElement)return;const e=this.rootElement.querySelector("[data-timer]");e&&(e.textContent=this.formatTime(t))}updateProgressBar(t){if(!this.rootElement)return;const e=this.rootElement.querySelector("[data-progress-fill]");e&&(e.style.width=t+"%")}formatTime(t){const e=Math.floor(t/1e3),n=Math.floor(e/60),r=e%60,s=Math.floor(t%1e3/10);return n.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+":"+s.toString().padStart(2,"0")}handleExpire(){this.clientConfig.isBuilder()||(this.stopCountdown(),this.commands.checkout.showPresaleExpired())}template(){const t=document.createElement("div");t.classList.add("checkout-presale-countdown"),this.rootElement=t;const e=this.createTextContainer(),n=this.createProgressBar();return t.appendChild(e),t.appendChild(n),t}createTextContainer(){const t=document.createElement("div");t.classList.add("checkout-presale-text-container");const e=this.createHeader(),n=this.createSubtitle();return t.appendChild(e),t.appendChild(n),t}createHeader(){const t=document.createElement("div");t.classList.add("checkout-presale-heading");const e=document.createElement("h2");e.textContent="LIMITED PRE-ORDER:";const n=document.createElement("div");return n.classList.add("checkout-presale-timer"),n.setAttribute("data-timer",""),n.textContent="00:00:00",t.appendChild(e),t.appendChild(n),t}createSubtitle(){const t=document.createElement("p");return t.classList.add("checkout-presale-subtitle"),t.textContent="Please complete your transaction within the time limit. Time expiration or page refresh will release the product to other customers.",t}createProgressBar(){const t=document.createElement("div");t.className="checkout-presale-progress-bar",t.setAttribute("data-progress","");const e=document.createElement("div");return e.className="checkout-presale-progress-fill",e.setAttribute("data-progress-fill",""),e.style.width="0%",t.appendChild(e),t}}CheckoutPresaleCountdownComponent.DEFAULT_PRESALE_DURATION_SECONDS=300,CheckoutPresaleCountdownComponent.ONE_MINUTE_THRESHOLD_SECONDS=60,CheckoutPresaleCountdownComponent.COUNTDOWN_UPDATE_INTERVAL_MS=10;class CheckoutPresaleExpiredComponent extends BaseComponent{constructor(){super(...arguments),this.autoCloseInterval=null,this.autoCloseSeconds=10,this.autoCloseElement=null}get hostClasses(){return["checkout-completed-container"]}get hostAttributes(){return{role:"alert","aria-live":"assertive"}}isItemsUnavailable(){var t;return"items_unavailable"===(null===(t=this.params)||void 0===t?void 0:t.reason)}isTimeExpired(){var t,e;return"time_expired"===(null===(t=this.params)||void 0===t?void 0:t.reason)||!(null===(e=this.params)||void 0===e?void 0:e.reason)}afterRender(){this.isTimeExpired()&&this.startAutoCloseCountdown()}disconnected(){this.stopAutoCloseCountdown()}handleExit(){this.stopAutoCloseCountdown();const t=this.commands.checkout.getReturnUrl();if(t)return window.location.assign(t),void 0;this.commands.ui.closeDrawer()}startAutoCloseCountdown(){this.updateAutoCloseDisplay(),this.autoCloseInterval=window.setInterval(()=>{this.autoCloseSeconds--,this.updateAutoCloseDisplay(),this.autoCloseSeconds<=0&&this.handleExit()},1e3)}stopAutoCloseCountdown(){null!==this.autoCloseInterval&&(clearInterval(this.autoCloseInterval),this.autoCloseInterval=null)}updateAutoCloseDisplay(){this.autoCloseElement&&(this.autoCloseElement.textContent=""+this.autoCloseSeconds)}template(){const t=[],e=this.getConfigs("global"),n=document.createElement("div");n.classList.add("checkout-completed-section-container");const s=document.createElement("div");s.classList.add("checkout-completed-title-section");const a=document.createElement("div");a.classList.add("checkout-completed-title-section");const c=document.createElement("p");c.classList.add("presale-expired-title");const l=document.createElement("p"),d=document.createElement("div");d.classList.add("checkout-completed-help-section"),this.isItemsUnavailable()&&(c.textContent="Items No Longer Available",l.textContent="The presale items you were trying to purchase are no longer available.",d.textContent="These items may have sold out or are no longer part of the presale. Please check our catalog for other available products."),this.isTimeExpired()&&(c.textContent="Session Expired",l.textContent="Your reservation time has ended. The item has been released for other customers.",d.textContent="To ensure fair access for all customers, we can only hold items for a limited time. You can try to reserve the item again if it's still available."),a.appendChild(c),a.appendChild(l),s.appendChild(a),n.appendChild(s),n.appendChild(d),t.push(n);const h=document.createElement("div");h.classList.add("checkout-completed-section-container");const p=document.createElement("button");p.setAttribute("aria-label","Continue shopping"),p.type="button";const m=document.createElement("span");m.textContent="Continue Shopping",p.setAttribute("tabindex","0"),p.setAttribute("role","button"),p.setAttribute("aria-label","Continue Shopping"),p.appendChild(m);const f=htmlStringToElement(ArrowRightIcon({width:16,height:16,color:e.theme.selectedTextColor}));if(p.appendChild(f),p.addEventListener("click",()=>this.handleExit()),p.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleExit())}),h.appendChild(p),t.push(h),this.isTimeExpired()){const e=document.createElement("div");e.classList.add("checkout-completed-section-container");const n=document.createElement("p");n.classList.add("checkout-completed-auto-close-text"),n.textContent="This view will close automatically in:",this.autoCloseElement=document.createElement("div"),this.autoCloseElement.classList.add("checkout-completed-auto-close-seconds"),this.autoCloseElement.setAttribute("aria-live","polite"),this.autoCloseElement.setAttribute("aria-atomic","true"),this.autoCloseElement.textContent=""+this.autoCloseSeconds;const r=document.createElement("span");r.classList.add("checkout-completed-auto-close-text"),r.textContent="seconds",e.appendChild(n),e.appendChild(this.autoCloseElement),e.appendChild(r),t.push(e)}if(e.layout.showPoweredBy){const e=document.createElement("div");e.classList.add("checkout-completed-powered-by-container");const n=ComponentFactoryService.createElement({type:r.POWERED_BY,context:"checkout"});e.appendChild(n),t.push(e)}return t}}class CheckoutPromoCodeComponent extends BaseComponent{get hostClasses(){return["input-promo-code-container"]}constructor(){super({watchOnlyStorePaths:["checkout.promoCode","checkout.loading"]}),this.isApplying=![],this.promoInput=null,this.applyButton=null,this.promoCodeText=null}onStoreWatch(t){const e=t.find(t=>"checkout.promoCode"===t.path),n=t.find(t=>"checkout.loading"===t.path);if(e){const{value:t,oldValue:n}=e,r=Boolean(n),s=Boolean(t);if(!r&&s)return this.container.innerHTML="",this.createAppliedContainer(t),void 0;if(r&&!s)return this.container.innerHTML="",this.createInputContainer(),void 0;s&&this.promoCodeText&&t.discount!==(null==n?void 0:n.discount)&&(this.promoCodeText.textContent=t.code+" (- "+formatCentToDollarText(t.discount)+")")}n&&this.updateApplyButtonState()}updateApplyButtonState(){if(!this.applyButton||!this.promoInput)return;const t=this.promoInput.getValue().trim(),e=t.length>=3&&t.length<=255,n=this.getStoreValue("checkout.loading"),r=this.getStoreValue("checkout.promoCode"),s=this.getStoreValue("checkout.promoCodeError");this.applyButton.disabled=!e||n||Boolean(r)||Boolean(s)||this.isApplying}createPromoInput(){return this.promoInput=ComponentFactoryService.createElement({type:r.INPUT,inputType:"text",name:"promoCode",placeholder:"Enter promo code",autocomplete:![],validation:{min:3,max:255},onChange:t=>{const e=t.toUpperCase(),n=this.promoInput;n.setValue(e),this.updateApplyButtonState()}}),this.promoInput}createApplyButton(){this.applyButton=document.createElement("button"),this.applyButton.type="button",this.applyButton.classList.add("apply-button"),this.applyButton.disabled=!![],this.applyButton.textContent="Apply",this.applyButton.setAttribute("tabindex","0"),this.applyButton.setAttribute("role","button"),this.applyButton.setAttribute("aria-label","Apply promo code");const o=async()=>{const t=this.promoInput.getValue().trim().toUpperCase();if(t)try{this.isApplying=!![],this.updateApplyButtonState(),await this.commands.checkout.applyPromoCode(t)}catch(e){this.logger.error("Checkout promo code application failed",{promoCode:t,error:e instanceof Error?e.message:String(e)})}finally{this.isApplying=![],this.updateApplyButtonState()}};return this.applyButton.addEventListener("click",o),this.applyButton.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o())}),this.applyButton}createAppliedContainer(t){const e=document.createElement("div");e.classList.add("checkout-pc-gc-applied"),this.promoCodeText=document.createElement("span"),this.promoCodeText.textContent=(null==t?void 0:t.code)+" (- "+formatCentToDollarText((null==t?void 0:t.discount)||0)+")";const n=document.createElement("button");n.type="button",n.classList.add("remove-button"),n.textContent="Remove",n.addEventListener("click",async()=>{await this.commands.checkout.removePromoCode()}),e.appendChild(this.promoCodeText),e.appendChild(n),this.container.appendChild(e),this.promoInput=null,this.applyButton=null}createInputContainer(){this.container.appendChild(this.createPromoInput()),this.container.appendChild(this.createApplyButton()),this.promoCodeText=null}template(){const t=this.getStoreValue("checkout.promoCode");if(this.promoInput=null,this.applyButton=null,this.promoCodeText=null,t){const e=document.createElement("div");e.classList.add("checkout-pc-gc-applied"),this.promoCodeText=document.createElement("span"),this.promoCodeText.textContent=t.code+" (- "+formatCentToDollarText(t.discount)+")";const n=document.createElement("button");return n.type="button",n.classList.add("remove-button"),n.textContent="Remove",n.addEventListener("click",async()=>{await this.commands.checkout.removePromoCode()}),e.appendChild(this.promoCodeText),e.appendChild(n),e}const e=[];return e.push(this.createPromoInput()),e.push(this.createApplyButton()),e}disconnected(){this.promoInput=null,this.applyButton=null,this.promoCodeText=null}}class CheckoutSendAsGiftComponent extends BaseComponent{get hostClasses(){return["gift-toggle-container"]}constructor(){super({watchStorePaths:["checkout.isGift"]})}template(){const t=this.getStoreValue("checkout.isGift"),e=document.createElement("div");e.classList.add("gift-label-wrapper");const n=document.createElement("span");n.textContent="Send as Gift? (Free)",n.classList.add("gift-toggle-label"),e.appendChild(n);const r=document.createElement("span");r.textContent="With personalized note & gift receipt.",r.classList.add("gift-toggle-description"),e.appendChild(r);const s=document.createElement("div");s.classList.add("toggle-switch"),s.classList.toggle("active",t);const a=document.createElement("div");return a.classList.add("toggle-slider"),s.setAttribute("tabindex","0"),s.setAttribute("aria-label","Toggle Gift Option"),s.setAttribute("role","switch"),s.setAttribute("aria-checked",t?"true":"false"),s.appendChild(a),s.addEventListener("click",async()=>{await this.commands.checkout.toggleIsGift()}),s.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await this.commands.checkout.toggleIsGift())}),[e,s]}}class CheckoutStripeFormComponent extends HTMLElement{constructor(){super(...arguments),this.F=![],this.O=null,this.M=null,this.L=null,this.R=![],this.N=![],this.j=![],this.B=null}async initialize({data:t}){if(this.F)return console.warn("Stripe form already initialized, ignoring subsequent calls"),void 0;this.q=t.stripeConfig,await this.initializeStripe(),this.setupEventListeners(),this.F=!![],await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null})}async initializeStripe(){try{window.Stripe||await this.loadStripeJS();const t=this.q;this.O=window.Stripe(t.publishableKey),this.M=this.O.elements({clientSecret:t.clientSecret,appearance:t.appearance}),this.L=this.M.create("payment",t.elementOptions),this.L.mount(this),this.L.on("change",async t=>{const e=!!t.error,n=t.complete,r=e?t.error.message:null;this.N=n,this.R||await this.updateStripeFormStatus({isFormComplete:n,isProcessing:![],hasCompletedPayment:![],errorMessage:r,hasError:e})}),this.L.on("focus",async()=>{this.R||await this.updateStripeFormStatus({isFormComplete:this.N,isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null})}),this.j=![]}catch(t){throw await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:!![],errorMessage:"Failed to initialize payment form"}),t}}setupEventListeners(){this.addEventListener("lce:s:submit",async()=>{await this.handleSubmit()}),this.addEventListener("lce:s:refreshSession",this.handleRefreshSession.bind(this)),this.addEventListener("lce:s:reset",async()=>{await this.resetForm()})}async handleRefreshSession(t){const{stripeConfig:e}=t.detail;e&&(this.q=e,await this.refreshPaymentSession())}async handleSubmit(){var t,e;if(this.R)return console.warn("Payment already processing, ignoring duplicate submission"),void 0;if(!this.N)return await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:!![],errorMessage:"Please complete all required payment fields"}),void 0;this.R=!![],await this.updateStripeFormStatus({isFormComplete:this.N,isProcessing:!![],hasCompletedPayment:![],hasError:![],errorMessage:"Processing payment..."});try{this.j&&(console.log("Session already used, requesting refresh..."),await this.requestSessionRefresh());const t=await this.createConfirmationTokenId(),e=this.q.clientSecret,n=e.split("_secret_")[0];this.j=!![],this.dispatchEvent(new CustomEvent("lce:s:ps-confirmed",{detail:{confirmationTokenId:t,setupIntentId:n},bubbles:!![],composed:!![]})),await this.updateStripeFormStatus({isFormComplete:!![],isProcessing:![],hasCompletedPayment:!![],hasError:![],errorMessage:null})}catch(n){console.error("Payment submission error:",n),this.j=!![],await this.updateStripeFormStatus({isFormComplete:this.N,isProcessing:![],hasCompletedPayment:![],hasError:!![],errorMessage:(null==n?void 0:n.message)||"Payment processing failed. Please try again."}),((null===(t=null==n?void 0:n.message)||void 0===t?void 0:t.includes("expired"))||(null===(e=null==n?void 0:n.message)||void 0===e?void 0:e.includes("invalid")))&&setTimeout(()=>this.requestSessionRefresh(),1e3)}finally{this.R=![]}}async requestSessionRefresh(){return this.B||(this.B=new Promise((t,e)=>{const n=setTimeout(()=>{this.removeEventListener("lce:s:refreshSession",k),this.B=null,e(new Error("Session refresh timeout"))},1e4),k=()=>{clearTimeout(n),this.removeEventListener("lce:s:refreshSession",k),this.B=null,t()};this.addEventListener("lce:s:refreshSession",k,{once:!![]}),this.dispatchEvent(new CustomEvent("lce:s:requestSessionRefresh",{bubbles:!![],composed:!![]}))})),this.B}async refreshPaymentSession(){try{this.M&&this.M.update({clientSecret:this.q.clientSecret}),this.j=![],await this.updateStripeFormStatus({isFormComplete:this.N,isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null})}catch(Q){console.error("Failed to refresh payment session:",Q),await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:!![],errorMessage:"Failed to refresh payment session"})}}async resetForm(){try{this.L&&this.L.clear(),this.N=![],this.j=![],await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null})}catch(Q){console.error("Failed to reset form:",Q)}}async updateStripeFormStatus(t){this.dispatchEvent(new CustomEvent("lce:s:updateStripeFormStatus",{detail:{status:t},bubbles:!![],composed:!![]}))}async createConfirmationTokenId(){if(!this.M)throw new SDKError("Payment elements not initialized");try{const{error:t}=await this.M.submit();if(t)throw new SDKError(t.message||"Failed to submit payment information");const e={elements:this.M,params:{payment_method_data:{allow_redisplay:"always",billing_details:{name:"Guest",address:{country:"US"}}},shipping:{name:"Guest",address:{country:"US",city:null,line1:null,line2:null,postal_code:null,state:null}}}},{error:n,confirmationToken:r}=await this.O.createConfirmationToken(e);if(n)throw new SDKError(n.message||"Failed to create confirmation token");if(!r||!r.id)throw new SDKError("Invalid confirmation token received");return r.id}catch(t){if(t instanceof SDKError)throw t;throw new SDKError("Payment processing error: "+(t.message||"Unknown error"))}}async disconnected(){await this.cleanupForm()}disconnectedCallback(){this.cleanupForm().catch(t=>{console.error("Error during Stripe form disconnection cleanup:",t)})}async cleanupForm(){var t,e;try{this.B=null,this.L&&(this.L.unmount(),this.L=null),this.M&&(null===(e=(t=this.M).destroy)||void 0===e?void 0:e.call(t),this.M=null),this.O=null,this.R=![],this.N=![],this.j=![],this.F=![],this.isConnected&&await this.updateStripeFormStatus({isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null})}catch(n){console.warn("Error during Stripe form cleanup:",n)}}loadStripeJS(){return new Promise((t,e)=>{const n=document.querySelector('script[src*="stripe.com"]');if(n)return n.addEventListener("load",()=>t()),n.addEventListener("error",()=>e(new Error("Failed to load Stripe.js"))),void 0;const r=document.createElement("script");r.src="https://js.stripe.com/basil/stripe.js",r.async=!![],r.onload=()=>t(),r.onerror=()=>e(new Error("Failed to load Stripe.js")),document.head.appendChild(r)})}}class CheckoutStripeHandlerComponent extends BaseComponent{get hostClasses(){return["checkout-stripe-handler"]}constructor(){super({watchOnlyStorePaths:["checkout.paymentForm.paymentMethod","checkout.paymentForm.isEditing"]}),this.stripeFormElement=null,this.rootComponent=null,this.isCreatingStripeForm=![],this.stripeFormStatus={isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null},this.isInEditMode=![],this.savedCardInfo=null,this.isChangingPayment=![],this.callbacks={}}beforeConnected(){this.callbacks=this.params.callbacks||{}}onStoreWatch(t){for(const e of t)switch(e.path){case"checkout.paymentForm.paymentMethod":this.handleSavedCardChange(e.value);break;case"checkout.paymentForm.isEditing":this.handleEditModeChange(e.value)}}handleSavedCardChange(t){var e,n,r,s;(null===(e=null==t?void 0:t.card)||void 0===e?void 0:e.brand)&&(null===(n=null==t?void 0:t.card)||void 0===n?void 0:n.last4)?this.savedCardInfo={brand:t.card.brand,last4:t.card.last4}:this.savedCardInfo=null,null===(s=(r=this.callbacks).onSavedCardInfoChanged)||void 0===s||s.call(r,this.savedCardInfo),this.updateDisplayState()}handleEditModeChange(t){this.isInEditMode=t,this.updateDisplayState()}updateDisplayState(){var t,e,n,r,s,a;this.isInEditMode&&this.savedCardInfo&&!this.isChangingPayment?(this.showStripeSummary(),this.hideStripeForm(),null===(e=(t=this.callbacks).onEditModeVisibilityChanged)||void 0===e||e.call(t,!![])):this.isInEditMode||this.isChangingPayment?(this.hideStripeSummary(),this.showStripeForm(),null===(r=(n=this.callbacks).onEditModeVisibilityChanged)||void 0===r||r.call(n,![]),this.stripeFormElement||this.isCreatingStripeForm||this.createAndMountStripeForm().catch(t=>{this.logger.error("Failed to create stripe form in updateDisplayState",t)})):(this.hideStripeSummary(),this.hideStripeForm(),null===(a=(s=this.callbacks).onEditModeVisibilityChanged)||void 0===a||a.call(s,![]))}async afterRender(){var t,e,n,r;this.isInEditMode=null!==(t=this.getStoreValue("checkout.paymentForm.isEditing"))&&void 0!==t?t:![];const s=this.getStoreValue("checkout.paymentForm.paymentMethod");(null===(e=null==s?void 0:s.card)||void 0===e?void 0:e.brand)&&s.card.last4&&(this.savedCardInfo={brand:s.card.brand,last4:s.card.last4}),null===(r=(n=this.callbacks).onSavedCardInfoChanged)||void 0===r||r.call(n,this.savedCardInfo),this.updateDisplayState(),(this.isInEditMode&&!this.savedCardInfo||this.isChangingPayment)&&await this.createAndMountStripeForm()}setupStripeFormEventListeners(){if(!this.stripeFormElement)return this.logger.warn("Cannot set up event listeners: Stripe form element is null"),void 0;this.stripeFormElement.addEventListener("lce:s:updateStripeFormStatus",t=>{var e,n;this.stripeFormStatus=t.detail.status,null===(n=(e=this.callbacks).onStripeFormStatusChanged)||void 0===n||n.call(e,this.stripeFormStatus)}),this.stripeFormElement.addEventListener("lce:s:ps-confirmed",async t=>{var e,n,r,s,a;try{const{confirmationTokenId:r,setupIntentId:s}=t.detail;await(null===(n=(e=this.callbacks).onPaymentSessionConfirmed)||void 0===n?void 0:n.call(e,r,s)),this.isChangingPayment=![]}catch(c){this.logger.error("Failed to save payment form",c),this.stripeFormStatus={isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:!![],errorMessage:(null==c?void 0:c.message)||"Failed to save payment information. Please try again."},null===(s=(r=this.callbacks).onStripeFormStatusChanged)||void 0===s||s.call(r,this.stripeFormStatus),null===(a=this.stripeFormElement)||void 0===a||a.dispatchEvent(new CustomEvent("lce:s:reset",{bubbles:!![],composed:!![]}))}}),this.stripeFormElement.addEventListener("lce:s:requestSessionRefresh",async()=>{var t;try{const e=await this.doStripeConfig();null===(t=this.stripeFormElement)||void 0===t?void 0:t.dispatchEvent(new CustomEvent("lce:s:refreshSession",{detail:{stripeConfig:e}}))}catch(e){this.logger.error("Failed to refresh payment session",e)}})}showStripeSummary(){if(!this.stripeSummaryContainer||!this.savedCardInfo)return;this.stripeSummaryContainer.innerHTML="";const t=document.createElement("span");t.classList.add("stripe-summary-text"),t.textContent=(this.savedCardInfo.brand||"")+" ending in "+this.savedCardInfo.last4;const e=document.createElement("button");e.type="button",e.classList.add("change-payment-link"),e.textContent="Change",e.setAttribute("aria-label","Change Payment Method"),e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.addEventListener("click",()=>this.handleChangePayment()),e.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleChangePayment())}),this.stripeSummaryContainer.append(t,e),this.stripeSummaryContainer.style.display="flex"}hideStripeSummary(){this.stripeSummaryContainer&&(this.stripeSummaryContainer.style.display="none",this.stripeSummaryContainer.innerHTML="")}showStripeForm(){this.stripeFormContainer&&(this.stripeFormContainer.style.display="block")}hideStripeForm(){this.stripeFormContainer&&(this.stripeFormContainer.style.display="none"),this.removeExistingStripeForm()}async handleChangePayment(){var t,e;this.isChangingPayment=!![],this.stripeFormStatus={isFormComplete:![],isProcessing:![],hasCompletedPayment:![],hasError:![],errorMessage:null},null===(e=(t=this.callbacks).onStripeFormStatusChanged)||void 0===e||e.call(t,this.stripeFormStatus),this.updateDisplayState()}template(){const t=[];this.stripeSummaryContainer=document.createElement("div"),this.stripeSummaryContainer.classList.add("stripe-summary-container"),this.stripeSummaryContainer.style.display="none",t.push(this.stripeSummaryContainer),this.stripeFormContainer=document.createElement("div"),this.stripeFormContainer.classList.add("stripe-form-container");const e=document.createElement("slot");return e.setAttribute("name",mt),this.stripeFormContainer.appendChild(e),t.push(this.stripeFormContainer),t}submitStripeForm(){this.stripeFormElement&&this.stripeFormStatus.isFormComplete&&!this.stripeFormStatus.hasCompletedPayment&&this.stripeFormElement.dispatchEvent(new CustomEvent("lce:s:submit"))}getStripeFormStatus(){return{...this.stripeFormStatus}}findRootComponent(){if(this.rootComponent)return this.rootComponent;let t=this,e=null;for(;t&&t!==document.body;){const n=t.hasAttribute("checkout"),s=t.tagName.toLowerCase()===ComponentFactoryService.getComponentTagName(r.LCE_ELEMENT),a=t.hasAttribute("drawer"),c=(null==e?void 0:e.tagName.toLowerCase())===ComponentFactoryService.getComponentTagName(r.DRAWER),l="checkout"===(null==e?void 0:e.getAttribute("data-target"));if(n||s&&a&&c&&l)return this.rootComponent=t,t;e=t,t=t.parentElement||t.getRootNode().host}return null}removeExistingStripeForm(){this.stripeFormElement&&(this.stripeFormElement.remove(),this.stripeFormElement=null)}async doStripeConfig(){const t=this.store.get("checkout.paymentForm.paymentSession");!this.isChangingPayment&&(null==t?void 0:t.key)&&(null==t?void 0:t.secret)||await this.commands.checkout.getPaymentSession();const e=this.store.get("checkout.paymentForm.paymentSession"),n=this.getConfigs("global");return{publishableKey:e.key,clientSecret:e.secret,appearance:{theme:"dark"===n.layout.poweredByMode?"night":"stripe",variables:{fontFamily:n.theme.paragraphFont.name+", system-ui, sans-serif",borderRadius:n.theme.buttonCornerRadius},rules:{".Input":{border:"filled"===n.layout.inputFieldStyle?"none":"1px solid "+n.theme.accentColor,backgroundColor:"filled"===n.layout.inputFieldStyle?n.theme.accentColor:"transparent"}}},elementOptions:{layout:"tabs",defaultValues:{billingDetails:{name:"Guest",address:{country:"US"}}},fields:{billingDetails:{address:{postalCode:"auto",country:"never"}}},terms:{applePay:"never",auBecsDebit:"never",bancontact:"never",card:"never",cashapp:"never",googlePay:"never",ideal:"never",paypal:"never",sepaDebit:"never",sofort:"never",usBankAccount:"never"}}}}async createAndMountStripeForm(){var t,e,n;if(this.isCreatingStripeForm)return this.logger.info("Stripe form creation already in progress, skipping"),void 0;if(this.isInEditMode&&this.savedCardInfo&&!this.isChangingPayment)return this.logger.info("In edit mode with saved card, skipping stripe form creation"),void 0;const s=this.findRootComponent();if(!s)return this.logger.error("Could not find root component for Stripe form"),void 0;if(null===(t=this.stripeFormElement)||void 0===t?void 0:t.isConnected)return this.logger.info("Stripe form already exists and is connected, skipping creation"),void 0;const a=s.querySelectorAll('[slot="'+mt+'"]');if(a.length>0)for(const r of a)r.remove();this.isCreatingStripeForm=!![];try{const t=await this.doStripeConfig();this.stripeFormElement=ComponentFactoryService.createElement({type:r.CHECKOUT_STRIPE_FORM,stripeConfig:t}),this.setupStripeFormEventListeners(),this.stripeFormElement.setAttribute("slot",mt),s.appendChild(this.stripeFormElement)}catch(c){this.logger.error("Stripe form element creation failed",c),this.stripeFormStatus={...this.stripeFormStatus,hasError:!![],errorMessage:"Failed to initialize payment form. Please reload the page."},null===(n=(e=this.callbacks).onStripeFormStatusChanged)||void 0===n||n.call(e,this.stripeFormStatus),this.stripeFormElement=null}finally{this.isCreatingStripeForm=![]}}disconnected(){var t;this.removeExistingStripeForm(),this.rootComponent=null,this.isCreatingStripeForm=![],this.isChangingPayment=![],null===(t=super.disconnected)||void 0===t||t.call(this)}}class CheckoutTipsComponent extends BaseComponent{get hostClasses(){return["checkout-tips-container"]}constructor(){super({watchStorePaths:["checkout.fulfillments","checkout.tipSelection","checkout.updating","checkout.amounts"]}),this.isInitialized=![]}afterRender(){this.setupToggler()}getTipSelection(){const t=this.getStoreValue("checkout.tipSelection");return null!=t?t:10}getOnDemandFulfillments(){const t=this.getStoreValue("checkout.fulfillments")||{};return Object.values(t).filter(t=>t.type===s.ON_DEMAND)}getRetailerNameForFulfillment(t){const e=this.getStoreValue("checkout.items")||{},n=this.getStoreValue("checkout.retailers")||{},r=Object.values(e).find(e=>e.fulfillmentId===t);if(!r)return"Retailer";const s=n[r.retailerId];return(null==s?void 0:s.name)||"Retailer"}async handlePercentageSelect(t){const e=this.getStoreValue("checkout.updating")||![];if(!e)try{await this.commands.checkout.updateTips(t)}catch(n){this.logger.error("Checkout tips update failed",n)}}async handleFulfillmentTipInput(t,e){const n=this.getStoreValue("checkout.updating")||![];if(n)return;const r=this.getOnDemandFulfillments();if(!r.find(e=>e.id===t))return;const s=Math.round(100*e);try{await this.commands.checkout.updateFulfillmentTip(t,s)}catch(a){this.logger.error("Checkout fulfillment tip update failed",a)}}async removeTipFromFulfillment(t){const e=this.getStoreValue("checkout.updating")||![];if(e)return;const n=this.getOnDemandFulfillments();if(n.find(e=>e.id===t))try{await this.commands.checkout.removeFulfillmentTip(t)}catch(r){this.logger.error("Checkout fulfillment tip removal failed",r)}}createTipSelectionButtons(){const t=document.createElement("div");t.classList.add("checkout-tip-selection-container");const e=[10,18,20],n=this.getStoreValue("checkout.updating")||![],r=this.getTipSelection();for(const s of e){const e=document.createElement("button");e.type="button",e.textContent=s+"%",e.classList.add("checkout-tip-button"),e.disabled=n,r===s&&e.classList.add("selected"),e.addEventListener("click",()=>this.handlePercentageSelect(s)),t.appendChild(e)}return t}setupToggler(){const t=this.container.querySelector(".checkout-tip-distribution-header"),e=this.container.querySelector(".checkout-items-toggler-button"),n=this.container.querySelector(".retailers-tips-list");t&&e&&n&&t.addEventListener("click",()=>{const t=n.classList.contains("show");n.classList.toggle("show"),t?(e.setAttribute("aria-expanded","false"),e.setAttribute("aria-label","Expand tips section")):(e.setAttribute("aria-expanded","true"),e.setAttribute("aria-label","Collapse tips section")),e.classList.toggle("expanded")})}createTipDistribution(){const t=document.createElement("section");t.classList.add("checkout-tip-distribution-container");const e=this.getOnDemandFulfillments();if(0===e.length)return t;const n=document.createElement("div");n.classList.add("checkout-tip-distribution-header");const r=document.createElement("h3");r.textContent="View Tip Distribution",r.classList.add("checkout-sub-header"),n.appendChild(r);const s=document.createElement("button");s.type="button",s.classList.add("checkout-items-toggler-button"),s.innerHTML=ChevronDownIcon({width:20,height:20,className:"chevron-icon"}),n.appendChild(s),t.appendChild(n);const a=document.createElement("div");a.classList.add("retailers-tips-list","show");for(const c of e){const t=document.createElement("div");t.classList.add("checkout-tip-distribution-item");const e=document.createElement("h4");e.textContent=this.getRetailerNameForFulfillment(c.id),e.classList.add("checkout-sub-header"),t.appendChild(e);const n=document.createElement("div");n.classList.add("checkout-tip-fulfillment-input-wrapper");const r=document.createElement("div");r.classList.add("dollar-input-container");const s=document.createElement("span");s.classList.add("dollar-sign"),s.textContent="$";const l=document.createElement("input");let d;l.type="number",l.id="tip-input-"+c.id,l.name="tip-"+c.id,l.min="0",l.step="0.01",l.placeholder="0.00",l.classList.add("dollar-input"),l.value=c.amounts.tip>0?(c.amounts.tip/100).toFixed(2):"",l.disabled=this.getStoreValue("checkout.updating")||![],l.addEventListener("wheel",t=>{t.preventDefault()}),l.addEventListener("keydown",t=>{"-"!==t.key&&"+"!==t.key||t.preventDefault()}),l.addEventListener("keydown",t=>{"ArrowUp"!==t.key&&"ArrowDown"!==t.key||t.preventDefault()}),l.addEventListener("paste",t=>{t.preventDefault()}),l.addEventListener("contextmenu",t=>{t.preventDefault()}),l.addEventListener("input",t=>{const e=t.target;let n=e.value;if(Number.parseFloat(n)<0&&(e.value=Math.abs(Number.parseFloat(n)).toString(),n=e.value),n.includes(".")){const t=n.split(".");t.length>1&&t[1].length>2&&(e.value=t[0]+"."+t[1].substring(0,2))}}),l.addEventListener("input",t=>{const e=t.target,n=Number.parseFloat(e.value)||0;d&&clearTimeout(d),d=setTimeout(()=>{this.handleFulfillmentTipInput(c.id,n)},500)}),r.appendChild(s),r.appendChild(l),n.appendChild(r);const h=document.createElement("button");h.type="button",h.textContent="Remove",h.classList.add("checkout-tip-remove-button"),h.disabled=this.getStoreValue("checkout.updating")||![],h.addEventListener("click",()=>this.removeTipFromFulfillment(c.id)),n.appendChild(h),t.appendChild(n),a.appendChild(t)}return t.appendChild(a),t}async initializeDefaultTip(){if(this.isInitialized)return;const t=this.getStoreValue("checkout.tipSelection"),e=this.getOnDemandFulfillments();if(t&&e.length>0){const r=e.every(t=>t.amounts.tip>0);if(r)this.isInitialized=!![];else try{this.isInitialized=!![],await this.commands.checkout.updateTips(t)}catch(n){this.logger.error("Default tip initialization failed",n),this.isInitialized=![]}}if(null==t)try{this.isInitialized=!![],await this.commands.checkout.updateTips(10)}catch(r){this.logger.error("Default tip initialization failed during fallback",r),this.isInitialized=![]}}template(){const t=[],e=this.getOnDemandFulfillments();if(0===e.length)return t;e.length>0&&this.initializeDefaultTip();const n=document.createElement("section");n.classList.add("checkout-tip-container");const r=document.createElement("h3");r.classList.add("checkout-sub-header"),r.textContent="Add a tip",n.appendChild(r);const s=document.createElement("div");s.classList.add("checkout-tip-config-container");const a=this.createTipSelectionButtons();s.appendChild(a),n.appendChild(s);const c=document.createElement("p");c.classList.add("checkout-tip-disclaimer"),c.textContent="Tips will be split proportionally between retailers.",n.appendChild(c);const l=this.createTipDistribution();return t.push(n,l),t}}class CheckoutPcGcComponent extends BaseComponent{get hostClasses(){return["checkout-sections-container"]}constructor(){super({watchOnlyStorePaths:["checkout.loading","checkout.giftCardError","checkout.promoCodeError","checkout.giftCards"]}),this.appliedGiftCardsContainer=null}onStoreWatch(t){var e,n;const r=t.find(t=>"checkout.giftCardError"===t.path),s=t.find(t=>"checkout.promoCodeError"===t.path),a=t.find(t=>"checkout.giftCards"===t.path);if(a&&this.updateAppliedGiftCards(a.value),r){const t=this.container.querySelector(".input-gift-card-container");if(t){const n=t.nextElementSibling;if((null===(e=null==n?void 0:n.classList)||void 0===e?void 0:e.contains("error-banner-checkout"))&&(null==n?void 0:n.remove()),r.value){const e=this.createErrorElement(r.value);t.after(e)}const s=t.querySelector(".apply-button");s&&(s.disabled=Boolean(r.value))}}if(s){const t=this.container.querySelector(".input-promo-code-container");if(t){const e=t.nextElementSibling;if((null===(n=null==e?void 0:e.classList)||void 0===n?void 0:n.contains("error-banner-checkout"))&&(null==e?void 0:e.remove()),s.value){const e=this.createErrorElement(s.value);t.after(e)}const r=t.querySelector(".apply-button");r&&(r.disabled=Boolean(s.value))}}}updateAppliedGiftCards(t){const e=t&&t.length>0;if(!e)return this.appliedGiftCardsContainer&&(this.appliedGiftCardsContainer.remove(),this.appliedGiftCardsContainer=null),void 0;this.appliedGiftCardsContainer||(this.appliedGiftCardsContainer=document.createElement("div"),this.appliedGiftCardsContainer.classList.add("checkout-pc-gc-sub-container"),this.container.appendChild(this.appliedGiftCardsContainer)),this.appliedGiftCardsContainer.innerHTML="",t.forEach(t=>{const e=this.createAppliedGiftCardElement(t);this.appliedGiftCardsContainer.appendChild(e)})}createAppliedGiftCardElement(t){const e=document.createElement("div");e.classList.add("checkout-pc-gc-applied"),e.setAttribute("data-gift-card-code",t.code);const n=document.createElement("span");n.textContent=t.code+" (- "+formatCentToDollarText(t.applied)+")",e.appendChild(n);const r=document.createElement("button");return r.type="button",r.textContent="Remove",r.addEventListener("click",async()=>{await this.commands.checkout.removeGiftCard(t.code)}),e.appendChild(r),e}inputContainer(){var t;const e=this.getConfigs("checkout"),n=this.getConfigs("global"),s=e.layout.allowGiftCards,a=null===(t=null==n?void 0:n.layout)||void 0===t?void 0:t.allowPromoCodes,c=document.createElement("div");c.classList.add("checkout-pc-gc-sub-container");const l=ComponentFactoryService.createElement({type:r.CHECKOUT_PROMO_CODE,classList:["input-promo-code-container"]}),d=ComponentFactoryService.createElement({type:r.CHECKOUT_GIFT_CARDS});a&&c.appendChild(l);const h=this.getStoreValue("checkout.promoCodeError");if(h){const t=this.createErrorElement(h);t.classList.add("promo-code-error-wrapper"),c.appendChild(t)}s&&c.appendChild(d);const p=this.getStoreValue("checkout.giftCardError");if(p){const t=this.createErrorElement(p);c.appendChild(t)}return c}createErrorElement(t){const e=document.createElement("div");e.classList.add("error-banner-checkout");const n=document.createElement("div");n.innerHTML=ErrorInfoIcon({});const r=document.createElement("p");return r.textContent=t.toString(),e.appendChild(n),e.appendChild(r),setTimeout(async()=>{await this.commands.checkout.clearPromoCodeError(),await this.commands.checkout.clearGiftCardError(),e.remove()},3e3),e}template(){const t=this.getStoreValue("checkout.giftCards");this.appliedGiftCardsContainer=null;const e=[];return e.push(this.inputContainer()),t&&t.length>0&&(this.appliedGiftCardsContainer=document.createElement("div"),this.appliedGiftCardsContainer.classList.add("checkout-pc-gc-sub-container"),t.forEach(t=>{const e=this.createAppliedGiftCardElement(t);this.appliedGiftCardsContainer.appendChild(e)}),e.push(this.appliedGiftCardsContainer)),e}disconnected(){this.appliedGiftCardsContainer=null}}class AlertComponent extends BaseComponent{constructor(){super(...arguments),this.hideTimeout=null,this.elements=[]}get hostClasses(){return["alert-wrapper","hidden"]}get hostAttributes(){return{role:"alert","aria-live":"polite"}}beforeSetupStoreWatchers(){this.reactiveOptions.watchStorePaths=[this.params.errorStorePath]}afterRender(){this.updateAlert()}onStoreWatch(t){t.length>0&&this.updateAlert()}getErrorMessages(){var t,e;const n=null!==(t=this.params.fromEvents)&&void 0!==t?t:![],r=null!==(e=this.params.showFirstEvent)&&void 0!==e?e:!![];if(n){const t=this.store.get(this.params.errorStorePath)||[],e=t.filter(t=>null==t?void 0:t.message).map(t=>({message:t.message,level:t.level||"error",type:t.type}));return r?e.slice(0,1):e}const s=this.store.get(this.params.errorStorePath);return s?[{message:s,level:"error"}]:[]}createErrorElement(t){const e=document.createElement("div");e.classList.add("alert-container","alert-"+t.level);const n=document.createElement("span");n.classList.add("alert-icon"),n.innerHTML=ErrorInfoIcon({className:t.level+"-icon"});const r=document.createElement("span");return r.classList.add("alert-text"),r.textContent=t.message,e.appendChild(n),e.appendChild(r),e}scheduleHide(){var t;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const e=null!==(t=this.params.autoHideDelay)&&void 0!==t?t:3e3;this.hideTimeout=setTimeout(()=>{this.hideAllErrors(),this.hideTimeout=null},e)}hideAllErrors(){var t;this.addHostClasses("hidden"),this.removeHostClasses("alert-success","alert-info","alert-warning","alert-error"),this.elements.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.elements=[];const e=null!==(t=this.params.fromEvents)&&void 0!==t?t:![];e?this.store.set(this.params.errorStorePath,[]):this.store.set(this.params.errorStorePath,null)}updateAlert(){const t=this.getErrorMessages();if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.elements.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.elements=[],0===t.length)return this.addHostClasses("hidden"),this.removeHostClasses("alert-success","alert-info","alert-warning","alert-error"),void 0;this.removeHostClasses("hidden"),this.elements=t.map(t=>this.createErrorElement(t)),this.elements.forEach(t=>{this.container.appendChild(t)}),this.scheduleHide()}template(){return[]}disconnectedCallback(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),super.disconnectedCallback()}}class EngravingViewComponent extends BaseComponent{get hostClasses(){const t=this.getConfigs("global");return["engraving-view-container",t.layout.personalizationCardStyle,this.params.context]}engravingQuantityFee(){const t=this.params.identifier;if("cart"===this.params.context){const e=this.getStoreValue("cart.items."+t),n=(null==e?void 0:e.attributes.engraving.fee)||0,r=(null==e?void 0:e.quantity)||1;return{quantity:r,fee:n,total:n*r}}if("checkout"===this.params.context){const e=this.getStoreValue("checkout.items."+t),n=(null==e?void 0:e.attributes.engraving.fee)||0,r=(null==e?void 0:e.quantity)||1;return{quantity:r,fee:n,total:n*r}}return{quantity:0,fee:0,total:0}}engravingLines(){const t=this.params.identifier;if("cart"===this.params.context){const e=this.getStoreValue("cart.items."+t);return(null==e?void 0:e.attributes.engraving.lines)||[]}if("checkout"===this.params.context){const e=this.getStoreValue("checkout.items."+t);return(null==e?void 0:e.attributes.engraving.lines)||[]}return[]}handleEdit(){var t,e,n,s,a,c,l,d,h,p,m,f,g,v,y,b,x,w,C,_;const E=this.params.identifier,T={identifier:E,context:this.params.context,lines:[],maxLines:1,maxCharsPerLine:16,fee:0,location:""};if("cart"===this.params.context){const r=this.getStoreValue("cart.items."+E);T.lines=(null===(e=null===(t=null==r?void 0:r.attributes)||void 0===t?void 0:t.engraving)||void 0===e?void 0:e.lines)||[],T.maxLines=(null===(s=null===(n=null==r?void 0:r.attributes)||void 0===n?void 0:n.engraving)||void 0===s?void 0:s.maxLines)||1,T.maxCharsPerLine=(null===(c=null===(a=null==r?void 0:r.attributes)||void 0===a?void 0:a.engraving)||void 0===c?void 0:c.maxCharsPerLine)||16,T.fee=(null===(d=null===(l=null==r?void 0:r.attributes)||void 0===l?void 0:l.engraving)||void 0===d?void 0:d.fee)||0,T.location=(null===(p=null===(h=null==r?void 0:r.attributes)||void 0===h?void 0:h.engraving)||void 0===p?void 0:p.location)||""}if("checkout"===this.params.context){const t=this.getStoreValue("checkout.items."+E);T.lines=(null===(f=null===(m=null==t?void 0:t.attributes)||void 0===m?void 0:m.engraving)||void 0===f?void 0:f.lines)||[],T.maxLines=(null===(v=null===(g=null==t?void 0:t.attributes)||void 0===g?void 0:g.engraving)||void 0===v?void 0:v.maxLines)||1,T.maxCharsPerLine=(null===(b=null===(y=null==t?void 0:t.attributes)||void 0===y?void 0:y.engraving)||void 0===b?void 0:b.maxCharsPerLine)||16,T.fee=(null===(w=null===(x=null==t?void 0:t.attributes)||void 0===x?void 0:x.engraving)||void 0===w?void 0:w.fee)||0,T.location=(null===(_=null===(C=null==t?void 0:t.attributes)||void 0===C?void 0:C.engraving)||void 0===_?void 0:_.location)||""}this.commands.ui.openDrawer(r.ENGRAVING_FORM,T)}async handleRemove(){const t=this.params.identifier;"cart"===this.params.context&&await this.commands.cart.updateItemEngraving(t,[]),"checkout"===this.params.context&&await this.commands.checkout.removeItemEngraving(t)}template(){const t=this.engravingQuantityFee(),e=this.engravingLines();if(0===e.length)return"";const n=document.createElement("div");n.className="engraving-header";const r=document.createElement("h3");r.textContent="Personalization";const s=document.createElement("span");if(s.className="engraving-fee",1===t.quantity&&(s.textContent=formatCentToDollarText(t.total,![])),t.quantity>1){s.textContent=formatCentToDollarText(t.total,![]);const e=document.createElement("span");e.className="engraving-fee-each",e.textContent=" ("+formatCentToDollarText(t.fee,![])+" ea)",s.appendChild(e)}n.appendChild(r),n.appendChild(s);const a=document.createElement("div");a.className="engraving-body";const c=document.createElement("div");c.className="engraving-lines";for(const h of e){const t=document.createElement("span");t.className="engraving-line",t.textContent=h,c.appendChild(t)}const l=document.createElement("div");l.className="engraving-actions";const d=document.createElement("button");d.type="button",d.classList.add("remove-button"),d.textContent="Remove",d.setAttribute("aria-label","Remove engraving");const i=async()=>{await this.handleRemove()};if(d.addEventListener("click",i),d.addEventListener("keydown",async t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),await i())}),l.appendChild(d),"checkout"!==this.params.context){const t=document.createElement("button");t.type="button",t.classList.add("edit-button"),t.textContent="Edit",t.setAttribute("aria-label","Edit engraving"),t.addEventListener("click",this.handleEdit.bind(this)),t.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleEdit())}),l.appendChild(t)}return a.appendChild(c),a.appendChild(l),[n,a]}}class InputComponent extends BaseComponent{constructor(){super(...arguments),this.validationTimeout=null}get hostClasses(){const t=this.getConfigs("global");return["custom-input",t.layout.inputFieldStyle]}handlePhoneKeydown(t){if("Backspace"===t.key){const e=t.target,n=e.selectionStart||0,r=e.value;n>0&&/\D/.test(r[n-1])&&setTimeout(()=>{const t=Math.max(0,n-2);e.setSelectionRange(t,t)},0)}}formatPhoneNumber(t){const e=t.target;let n=e.value.replace(/\D/g,"");n.length>10&&(n=n.substring(0,10)),n.length>=6?n="("+n.substring(0,3)+") "+n.substring(3,6)+"-"+n.substring(6):n.length>=3&&(n="("+n.substring(0,3)+") "+n.substring(3)),e.value=n}formatDate(t){const e=t.target,n=e.value,r=e.selectionStart||0;let s=0,a;if(r>2&&(s=1),r>5&&(s=2),n.includes("/")){const t=n.split("/");let e=(t[0]||"").replace(/\D/g,"").substring(0,2);const r=(t[1]||"").replace(/\D/g,"");let s=r.substring(0,2);const c=r.substring(2);let l=(t[2]||"").replace(/\D/g,"");if(l=(c+l).substring(0,4),""===e&&3===t.length&&(e="01"),2===e.length){let t=Number.parseInt(e,10);t>12&&(t=12),t<1&&(t=1),e=t.toString().padStart(2,"0")}if(""===s&&3===t.length&&(s="01"),2===s.length){let t=Number.parseInt(s,10);t>31&&(t=31),t<1&&(t=1),s=t.toString().padStart(2,"0")}a=e,(t.length>1||s)&&(a+="/"+s),(l||t.length>2)&&(a+="/"+l)}else{let t=n.replace(/\D/g,"");if(t.length>8&&(t=t.substring(0,8)),t.length>=2){let e=Number.parseInt(t.substring(0,2),10);e>12&&(e=12),t=e.toString().padStart(2,"0")+t.substring(2)}if(t.length>=4){let e=Number.parseInt(t.substring(2,4),10);e>31&&(e=31),t=t.substring(0,2)+e.toString().padStart(2,"0")+t.substring(4)}a=t.length>=5?t.substring(0,2)+"/"+t.substring(2,4)+"/"+t.substring(4):t.length>=3?t.substring(0,2)+"/"+t.substring(2):t}if(e.value=a,n.includes("/")){let t;t=0===s?Math.min(r,2):1===s?Math.min(r,5):a.length,e.setSelectionRange(t,t)}}validateEmail(t){const e=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;return e.test(t)}validateTel(t){const e=/^\(\d{3}\) \d{3}-\d{4}$/;return e.test(t)}validateDate(t){const e=/^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/;if(!e.test(t))return![];const[n,r,s]=t.split("/").map(Number),a=new Date(s,n-1,r);return a.getFullYear()===s&&a.getMonth()===n-1&&a.getDate()===r}parseDateString(t){if(!this.validateDate(t))return null;const[e,n,r]=t.split("/").map(Number);return new Date(r,e-1,n)}calculateAge(t){const e=new Date;let n=e.getFullYear()-t.getFullYear();const r=e.getMonth()-t.getMonth();return(r<0||0===r&&e.getDate()<t.getDate())&&n--,n}validateDateConstraints(t){const e=[],n=this.params.validation;if(!n)return e;const r=this.parseDateString(t);if(!r)return e;const s=r.getFullYear();void 0!==n.minYear&&s<n.minYear&&e.push("Year must be "+n.minYear+" or later"),void 0!==n.maxYear&&s>n.maxYear&&e.push("Year must be "+n.maxYear+" or earlier");const a=this.calculateAge(r);return void 0!==n.minAge&&a<n.minAge&&e.push("Must be at least "+n.minAge+" years old"),void 0!==n.maxAge&&a>n.maxAge&&e.push("Must be no more than "+n.maxAge+" years old"),e}isFieldComplete(){var t,e,n;const r=this.inputElement.value.trim();if(!r)return![];switch(this.params.inputType){case"tel":return this.validateTel(r);case"date":case"birthdate":return this.validateDate(r);case"email":return r.includes("@")&&(null===(t=r.split("@")[1])||void 0===t?void 0:t.includes("."));case"number":return!Number.isNaN(Number.parseFloat(r));default:return(null===(e=this.params.validation)||void 0===e?void 0:e.max)&&r.length>=this.params.validation.max||(null===(n=this.params.validation)||void 0===n?void 0:n.min)&&r.length>=this.params.validation.min?!![]:r.length>=3}}validateInput(){const t=this.inputElement.value,e=[],n=this.params.validation;if(!n)return this.showErrors([]),!![];if(n.required&&!t.trim()&&e.push("This field is required"),!n.required&&!t.trim())return this.showErrors([]),!![];if(t.trim()){if("email"!==this.params.inputType||this.validateEmail(t)||e.push("Please enter a valid email address"),"tel"!==this.params.inputType||this.validateTel(t)||e.push("Please enter a valid phone number ((XXX) XXX-XXXX)"),"date"===this.params.inputType||"birthdate"===this.params.inputType)if(this.validateDate(t)){const n=this.validateDateConstraints(t);e.push(...n)}else e.push("Please enter a valid date (MM/DD/YYYY)");if("number"===this.params.inputType){const r=Number.parseFloat(t);Number.isNaN(r)?t.trim()&&e.push("Please enter a valid number"):(void 0!==n.min&&r<n.min&&e.push("Value must be at least "+n.min),void 0!==n.max&&r>n.max&&e.push("Value must be no more than "+n.max))}if("text"!==this.params.inputType&&"email"!==this.params.inputType||(void 0!==n.min&&t.length<n.min&&e.push("Must be at least "+n.min+" characters"),void 0!==n.max&&t.length>n.max&&e.push("Must be no more than "+n.max+" characters")),n.pattern){const r=new RegExp(n.pattern);r.test(t)||e.push("Invalid format")}if(n.customValidator){const r=n.customValidator(t);r&&e.push(r)}}this.showErrors(e);const r=0===e.length;return this.params.onValidation&&this.params.onValidation(r,e),r}scheduleValidation(){if(null!==this.validationTimeout&&clearTimeout(this.validationTimeout),this.isFieldComplete())return this.validateInput(),void 0;this.validationTimeout=setTimeout(()=>{this.validateInput(),this.validationTimeout=null},500)}showErrors(t){if(this.errorContainer.innerHTML="",t.length>0){this.errorContainer.classList.add("show"),this.inputElement.classList.add("input-error");for(const e of t){const t=document.createElement("div");t.className="error-message",t.textContent=e,this.errorContainer.appendChild(t)}}else this.inputElement.classList.remove("input-error")}clearErrors(){this.inputElement.classList.contains("input-error")&&(this.inputElement.classList.remove("input-error"),this.errorContainer.innerHTML="",this.errorContainer.classList.remove("show"))}getValue(){return this.inputElement.value}setValue(t){this.inputElement.value=t,"tel"===this.params.inputType&&this.formatPhoneNumber({target:this.inputElement}),"date"!==this.params.inputType&&"birthdate"!==this.params.inputType||this.formatDate({target:this.inputElement})}validate(){return this.validateInput()}focus(){this.inputElement.focus()}disable(){this.inputElement.disabled=!![]}enable(){this.inputElement.disabled=![]}template(){var t;const e=[];if(this.params.label){const n=document.createElement("label");n.textContent=this.params.label,(null===(t=this.params.validation)||void 0===t?void 0:t.required)&&(n.textContent+="*"),n.setAttribute("for",this.params.name),e.push(n)}return this.inputElement=document.createElement("input"),this.inputElement.type="birthdate"===this.params.inputType?"text":this.params.inputType,this.inputElement.placeholder=this.params.placeholder||"",this.inputElement.name=this.params.name,this.inputElement.id=this.params.name,this.params.autocomplete&&(this.inputElement.autocomplete=this.params.autocomplete?"on":"off"),this.params.className&&(this.inputElement.className=this.params.className),this.params.hostClassName&&this.addHostClasses(this.params.hostClassName),this.params.disabled&&(this.inputElement.disabled=!![]),this.params.value&&(this.inputElement.value=this.params.value),this.params.validation&&(this.params.validation.required&&(this.inputElement.required=!![]),void 0!==this.params.validation.min&&(this.inputElement.min=this.params.validation.min.toString()),void 0!==this.params.validation.max&&(this.inputElement.max=this.params.validation.max.toString()),this.params.validation.pattern&&(this.inputElement.pattern=this.params.validation.pattern)),"tel"===this.params.inputType&&(this.inputElement.addEventListener("keydown",this.handlePhoneKeydown.bind(this)),this.inputElement.addEventListener("input",this.formatPhoneNumber.bind(this))),"date"!==this.params.inputType&&"birthdate"!==this.params.inputType||(this.inputElement.addEventListener("input",this.formatDate.bind(this)),this.params.placeholder||(this.inputElement.placeholder="MM/DD/YYYY")),this.inputElement.addEventListener("focusout",this.validateInput.bind(this)),this.inputElement.addEventListener("input",t=>{this.clearErrors(),this.scheduleValidation(),this.params.onChange&&this.params.onChange(t.target.value)}),this.errorContainer=document.createElement("div"),this.errorContainer.className="error-container",e.push(this.inputElement),e.push(this.errorContainer),e}}class LceElementComponent extends HTMLElement{constructor(){super(),this.F=![],this.U=null;const t=ClientConfigService.getInstance();this.V=this.attachShadow({mode:t.get("openShadowDom")?"open":"closed"})}initialize(t,e){if(this.F)return;if(!t||"string"!=typeof t)throw new SDKError("LceElementComponent: contentType must be a non-empty string");if(!(e&&e instanceof HTMLElement))throw new SDKError("LceElementComponent: contentElement must be a valid HTMLElement");if(this.setAttribute(t.toLowerCase(),""),!this.V)throw new SDKError("LceElementComponent: Shadow DOM container is not available");e&&"function"==typeof e.rerender&&(this.U=t=>{e.rerender(t||"LceElementRerender")}),this.V.appendChild(e),this.applyBasicStyles();const n=ThemeProviderService.getInstance(),r=n.getStylesheet(t);this.applyThemeStyles(r),this.F=!![],this.V=null}rerender(t){this.U&&this.U(t)}applyBasicStyles(){const t="\n :host {\n display: block;\n contain: layout style paint;\n isolation: isolate;\n width: 100%;\n height: auto;\n }\n\n :host([drawer]),\n :host([modal]),\n :host([address]),\n :host([buttons-cart-open]) {\n contain: none;\n isolation: auto;\n }\n ";try{if(this.isCSSStyleSheetSupported()){const e=new CSSStyleSheet;e.replaceSync(t),this.V.adoptedStyleSheets=[e,...this.V.adoptedStyleSheets]}else this.createFallbackStylesheet(t)}catch(Q){this.createFallbackStylesheet(t)}}isCSSStyleSheetSupported(){try{if("undefined"==typeof CSSStyleSheet)return![];if("function"!=typeof CSSStyleSheet.prototype.replaceSync)return![];const t=new CSSStyleSheet;return t.replaceSync("/* test */"),!![]}catch(t){return![]}}applyThemeStyles(t){t.forEach(t=>{"string"==typeof t?this.createFallbackStylesheet(t):this.V.adoptedStyleSheets=[...this.V.adoptedStyleSheets,t]})}createFallbackStylesheet(t){const e=document.createElement("style");e.textContent=t,this.V&&this.V.appendChild(e)}}class PoweredByComponent extends BaseComponent{get hostClasses(){return["powered-by-container",this.params.context,this.getConfigs("global").layout.poweredByMode]}createPoweredBySection(){const t=document.createElement("div");t.className="pb-title-container";const e=document.createElement("span");e.className="pb-text",e.textContent="Powered by",t.appendChild(e);const n=document.createElement("span");n.className="pb-lc",n.textContent="LiquidCommerce",t.appendChild(n);const r=document.createElement("span");return r.className="pb-dot",r.textContent=".",t.appendChild(r),t}createDisclaimerSection(){const t=document.createElement("div");t.className="pb-disclaimer-container";const e=this.getDisclaimerConfig();return e.parts.forEach(e=>{"text"===e.type?t.appendChild(document.createTextNode(e.content)):"link"===e.type&&t.appendChild(this.createLink(e.href,e.text))}),t}getDisclaimerConfig(){return"checkout"===this.params.context?{parts:[{type:"text",content:"All orders are fulfilled by LiquidCommerce, which is owned and operated by ReserveBar Holdings Corp., an independent third party that facilitates transactions between customers and licensed retailers. By placing an order, you agree to "},{type:"link",href:"https://www.reservebar.com/privacy-policy.html",text:"LiquidCommerce's Privacy Policy"},{type:"text",content:" and "},{type:"link",href:"https://www.reservebar.com/terms-conditions",text:"Terms and Conditions of Sale"},{type:"text",content:"."}]}:{parts:[{type:"text",content:"LiquidCommerce is owned & operated by ReserveBar. See our "},{type:"link",href:"https://www.reservebar.com/privacy-policy.html",text:"Privacy Policy"},{type:"text",content:" and "},{type:"link",href:"https://www.reservebar.com/terms-conditions",text:"Terms & Conditions"},{type:"text",content:"."}]}}createLink(t,e){const n=document.createElement("a");return n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.className="pb-link",n.textContent=e,n.setAttribute("role","link"),n.setAttribute("aria-label","Read "+e),n}template(){const t=this.createPoweredBySection(),e=this.createDisclaimerSection();return[t,e]}}class PromoCodeTickerComponent extends BaseComponent{constructor(){super(...arguments),this.applyButton=null,this.promoCodeApplied=![],this.currentActiveTicker=null}get hostClasses(){return["promo-ticker",this.params.context]}beforeSetupStoreWatchers(){this.reactiveOptions.watchOnlyStorePaths=["cart.promoCode","checkout.promoCode"]}onStoreWatch(t){const e=t.find(t=>"cart.promoCode"===t.path||"checkout.promoCode"===t.path);if(!e||!this.applyButton||!this.currentActiveTicker)return;const n=this.isPromoCodeApplied(this.currentActiveTicker.promoCode);n&&!this.promoCodeApplied?(this.applyButton.disabled=!![],this.applyButton.textContent="APPLIED",this.promoCodeApplied=!![]):!n&&this.promoCodeApplied&&(this.applyButton.disabled=![],this.applyButton.textContent="APPLY",this.promoCodeApplied=![])}isPromoCodeApplied(t){const e=this.store.get("cart.promoCode"),n=this.store.get("checkout.promoCode");return(null==e?void 0:e.code)===t||(null==n?void 0:n.code)===t}getActiveTickers(){var t;const e=this.store.get("address");return null===(t=this.params.tickers)||void 0===t?void 0:t.filter(t=>{var n;return isDateTimeInRange({startDate:t.activeFrom,endDate:t.activeUntil,addressState:null===(n=null==e?void 0:e.address)||void 0===n?void 0:n.state})})}selectCurrentTicker(t){return 0===t.length?null:t[0]}generateTextContent(t){const e=document.createElement("div");e.classList.add("promo-ticker__text-group");const n=t.text.map(t=>t.trim()).map(t=>t.substring(0,50)).filter(t=>""!==t.trim()).slice(0,5);for(const r of n){const n=r.trim();if(!n)continue;const s=document.createElement("span");s.classList.add("promo-ticker__text-item"),s.textContent=n,e.appendChild(s);const a=document.createElement("span");a.classList.add("promo-ticker__separator"),a.textContent=t.separator,e.appendChild(a)}return e}async handlePromoClick(){var t;(null===(t=this.currentActiveTicker)||void 0===t?void 0:t.promoCode)&&("cart"===this.params.context&&await this.commands.cart.applyPromoCode(this.currentActiveTicker.promoCode),"checkout"===this.params.context&&await this.commands.checkout.applyPromoCode(this.currentActiveTicker.promoCode))}template(){const t=this.getActiveTickers();if(this.currentActiveTicker=this.selectCurrentTicker(t),!this.currentActiveTicker)return[];this.promoCodeApplied=this.isPromoCodeApplied(this.currentActiveTicker.promoCode);const e=document.createElement("div");e.classList.add("promo-ticker__content");const n=document.createElement("div");n.classList.add("promo-ticker__track");for(let s=0;s<5;s++)n.appendChild(this.generateTextContent(this.currentActiveTicker));e.appendChild(n);const r=document.createElement("button");return r.type="button",r.classList.add("promo-ticker__cta"),r.textContent="APPLY",r.setAttribute("aria-label","Apply promo code"),this.promoCodeApplied&&(r.disabled=!![],r.textContent="APPLIED"),r.addEventListener("click",()=>this.handlePromoClick()),r.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handlePromoClick())}),this.applyButton=r,[e,r]}}class PurchaseMinAlertComponent extends BaseComponent{get hostClasses(){return["alert","alert-"+this.params.messageType]}getIconElement(){const t=this.config||{};if(t.showIcon===![])return null;const e={warning:"warning",success:"success",info:"info"},n={warning:WarningIcon,success:SuccessIcon,info:InfoIcon},r=e[this.params.messageType]||"warning",s=document.createElement("div");return s.className="alert-icon alert-icon-"+this.params.messageType,s.appendChild(htmlStringToElement(n[r]({width:16,height:16,className:"alert-icon-svg"}))),s}template(){var t;const e=[],n=this.getIconElement();n&&e.push(n);const r=document.createElement("span");if(r.className="alert-message",r.textContent=this.params.message,e.push(r),"detailed"===(null===(t=this.config)||void 0===t?void 0:t.alertType)&&this.params.currentTotal){const t=document.createElement("div");t.className="alert-details";const n=document.createElement("small");n.className="alert-details-text",n.textContent="Current subtotal: "+formatCentToDollarText(this.params.currentTotal),t.appendChild(n),e.push(t)}return e}}const St=LoggerFactory.get("ClientHelpers"),isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),getType=t=>null===t?"null":Array.isArray(t)?"array":typeof t;function deepMergeConfigs(t,e){if(!t||!e)return t;const n={...t},r=[];for(const s in e){const a=e[s],c=n[s];if(!(s in t)){r.push('Property "'+s+'" does not exist in target schema, skipping merge.');continue}const l=getType(a),d=getType(c);l===d?isObject(a)&&isObject(c)?n[s]=deepMergeConfigs(c,a):n[s]=a:r.push('Type mismatch for key "'+s+'": source is '+l+", target is "+d+". Skipping merge.")}return r.length>0&&St.warn("Merging configurations with warnings:",r),n}class ElementsCheckoutClient{constructor(t){this.clientPrepared=![],this.componentsRegistered=![],this.clientConfig=ClientConfigService.getInstance(),this.store=StoreService.getInstance(),this.apiClient=ApiClientService.getInstance(),this.themeProvider=ThemeProviderService.getInstance(),this.fingerPrintService=FingerPrintService.getInstance(),this.googleTagManager=GoogleTagManagerService.getInstance(),this.telemetry=TelemetryService.getInstance(),this.debugPanel=DebugPanelService.getInstance(),this.checkoutCommands=CheckoutCommands.getInstance(),this.checkoutActionService=ClientCheckoutActionService.getInstance(),this.logger=LoggerFactory.get("CheckoutClient"),this.authClient=AuthClientService.getInstance({apiKey:t.apiKey,env:t.env,baseUrl:t.baseUrl})}async prepare(){try{if(this.clientPrepared)return;await this.prepareServices(),this.clientPrepared=!![],this.clientConfig.set("clientPrepared",!![])}catch(t){throw this.logger.error("Checkout client preparation failed",t),this.clientPrepared=![],this.clientConfig.set("clientPrepared",![]),t}}async prepareServices(){this.clientConfig.set("version",Q.version);const t=this.clientConfig.isProduction(),e=this.clientConfig.isDebuggingEnabled();!t&&e&&(LoggerFactory.setEnableLogging(!![]),this.logger.info("🐞 Debugging mode is enabled")),this.telemetry.isEnabled()&&(LoggerFactory.setTelemetryService(this.telemetry),this.logger.info("📊 Telemetry initialized")),!t&&e&&this.clientConfig.isDebugPanelEnabled()&&(this.debugPanel.initialize(),this.logger.info("🔧 Debug panel initialized")),this.logger.info("🔐 Starting authentication...");const{success:n,configs:r}=await this.authClient.authenticateAndGetConfigs();if(!n||!r)throw this.clientPrepared=![],new SDKError("Authentication failed",!![]);this.logger.info("✅ Authentication completed"),this.logger.info("🌐 Setting up API client..."),await this.apiClient.setClient(this.authClient),this.logger.info("✅ API client setup completed");let s=r;this.clientConfig.set("partnerCode",s.configurations.partnerCode),this.clientConfig.set("partnerName",s.configurations.partnerName),this.logger.info("🔍 Setting up fingerprinting and store...");const a=await this.fingerPrintService.getId(s.configurations.partnerCode),c=this.fingerPrintService.isLocalStorageWebApiAvailable();this.clientConfig.set("userDeviceId",a),this.clientConfig.set("isLocalStorageAvailable",c);const l=c?null:await this.apiClient.getPersistedStore(a);if(await this.store.initialize({userDeviceId:a,isLocalStorageAvailable:c,persistedStore:l}),this.logger.info("✅ Store setup completed"),this.logger.info("🎨 Initializing theme provider..."),this.clientConfig.hasCustomTheme()){const t=this.clientConfig.get("customTheme"),e=s.global.layout.showPoweredBy;s=deepMergeConfigs(s,t),s.global.layout.showPoweredBy=e}await this.themeProvider.initialize(s),this.logger.info("✅ Theme provider initialized"),this.logger.info("📦 Registering checkout components..."),this.registerCheckoutComponents(),this.logger.info("✅ Checkout components registered"),this.initializeGTM(),this.logger.info("🎯 Checkout client preparation completed")}async initializeGTM(){try{const t=this.themeProvider.getConfigs("configurations");await this.googleTagManager.initialize({partnerName:t.partnerName,partnerCode:t.partnerCode,enablePartnerGTM:t.enablePartnerGTM,partnerGTMId:t.partnerGTMId||void 0,enableLiquidCommerceGTM:t.enableLiquidCommerceGTM,liquidCommerceGTMId:t.liquidCommerceGTMId})}catch(t){this.logger.warn("GTM initialization failed",t)}}registerCheckoutComponents(){this.componentsRegistered||(ComponentFactoryService.registerComponent(r.LCE_ELEMENT,LceElementComponent),ComponentFactoryService.registerComponent(r.INPUT,InputComponent),ComponentFactoryService.registerComponent(r.POWERED_BY,PoweredByComponent),ComponentFactoryService.registerComponent(r.ENGRAVING_VIEW,EngravingViewComponent),ComponentFactoryService.registerComponent(r.ALERT,AlertComponent),ComponentFactoryService.registerComponent(r.PURCHASE_MIN_ALERT,PurchaseMinAlertComponent),ComponentFactoryService.registerComponent(r.PROMO_CODE_TICKER,PromoCodeTickerComponent),ComponentFactoryService.registerComponent(r.CHECKOUT,CheckoutComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_INFORMATION,CheckoutInformationComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PAYMENT,CheckoutPaymentComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PAYMENT_SUMMARY,CheckoutPaymentSummaryComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_STRIPE_HANDLER,CheckoutStripeHandlerComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_STRIPE_FORM,CheckoutStripeFormComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_BILLING,CheckoutBillingComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_ORDER_SUMMARY,CheckoutOrderSummaryComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PROMO_CODE,CheckoutPromoCodeComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_GIFT_CARDS,CheckoutGiftCardsComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_AMOUNTS,CheckoutAmountsComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_ITEMS,CheckoutItemsComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_COMPLETED,CheckoutCompletedComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_DELIVER_TO,CheckoutDeliverToComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_DELIVER_TO_SUMMARY,CheckoutDeliverToSummaryComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_BUYER,CheckoutBuyer),ComponentFactoryService.registerComponent(r.CHECKOUT_BUYER_SUMMARY,CheckoutBuyerSummaryComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_TIPS,CheckoutTipsComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PC_GC,CheckoutPcGcComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_ITEM,CheckoutItemComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_ITEM_QUANTITY,CheckoutItemQuantityComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PLACE_ORDER_BUTTON,CheckoutPlaceOrderButtonComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_HEADER,CheckoutHeaderComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PRESALE_COUNTDOWN,CheckoutPresaleCountdownComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_PRESALE_EXPIRED,CheckoutPresaleExpiredComponent),ComponentFactoryService.registerComponent(r.CHECKOUT_SEND_AS_GIFT,CheckoutSendAsGiftComponent),this.componentsRegistered=!![])}async injectCheckout(t,e){if(!t||"string"!=typeof t)throw new SDKError("Checkout requires a valid container ID. Received: "+("string"==typeof t?'"'+t+'"':t),!![]);const n=t.replace("#",""),s=document.getElementById(n);if(!s)throw new SDKError('Cannot find element with ID "'+t+'". Make sure the element exists before injecting checkout.',!![]);const a=ComponentFactoryService.createElement({type:r.CHECKOUT,useShadowDom:!![],isIndependentComponent:!![],wrapInLceElement:!![]});return s.innerHTML="",safeReplaceChildren(s,a),this.store.set("metadata.checkout.injection",{containerId:n,injectedAt:Date.now()}),await this.checkoutCommands.loadCheckout({checkoutId:void 0===e?"":e}),this.createInjectedComponentWrapper(n,a)}createInjectedComponentWrapper(t,e){return{getType:()=>r.CHECKOUT,getElement:()=>document.getElementById(t),rerender:()=>{try{e&&"function"==typeof e.rerender&&e.rerender("CheckoutRerender")}catch(n){this.logger.warn("Failed to rerender checkout in container '"+t+"'")}}}}get actions(){const t=this.checkoutActionService.actions;return{checkout:{applyPromoCode:t.applyPromoCode,removePromoCode:t.removePromoCode,applyGiftCard:t.applyGiftCard,removeGiftCard:t.removeGiftCard,toggleIsGift:t.toggleIsGift,toggleBillingSameAsShipping:t.toggleBillingSameAsShipping,toggleMarketingPreferences:t.toggleMarketingPreferences,updateCustomerInfo:t.updateCustomerInfo,updateBillingInfo:t.updateBillingInfo,updateGiftInfo:t.updateGiftInfo,getDetails:t.getDetails}}}}async function ElementsCheckout(t,n){try{SingletonManager.setContext({isBuilder:![]});const r=ClientConfigService.getInstance();r.initialize(t,{env:n.env,isBuilder:![],debugMode:n.debugMode,customTheme:n.customTheme,promoTicker:void 0,proxy:n.proxy,development:n.development,checkout:n.checkout});const s=r.getConfigs(),a=new ElementsCheckoutClient(s);if(await a.prepare(),!a.clientPrepared)throw new SDKError("Failed to initialize checkout client.",!![]);const c={injectCheckout:a.injectCheckout.bind(a),actions:a.actions};window.elementsCheckout=c;const l=PubSubService.getInstance();return l.publishAction(e.CLIENT_READY,{isReady:!![],message:"Elements Checkout Client Is Ready",timestamp:Date.now(),version:r.get("version")}),c}catch(r){return console.error("[LiquidCommerce Elements] Checkout client initialization failed",r),null}}const _t={SCRIPT:{CHECKOUT_PARAM:"data-checkout-param"},ELEMENT:{CHECKOUT:"data-lce-checkout"},JSON_SCRIPT:{DEVELOPMENT:"data-liquid-commerce-elements-development"}};function startsWithLcePrefix(t){return null!==t&&"lce_"===t.substring(0,4)}function getDevelopmentConfigs(){const t=document.querySelector("script["+_t.JSON_SCRIPT.DEVELOPMENT+"]");if(t)try{return JSON.parse(t.textContent||"{}")}catch(e){return console.error("[LiquidCommerce Elements Auto Initialization] Invalid JSON in development config script",e),void 0}}function triggerAutoInit(t,e){try{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",async()=>{setTimeout(async()=>{try{await t()}catch(n){console.error(e+" Failed to initialize:",n)}},50)}):setTimeout(async()=>{try{await t()}catch(n){console.error(e+" Failed to initialize:",n)}},50)}catch(n){console.error(e+" Failed to setup initialization:",n)}}async function setupCheckout(t,e,n){try{const r=document.querySelector("div["+_t.ELEMENT.CHECKOUT+"]");if(!r)return n.requireCheckoutId||console.warn(n.errorPrefix+" No checkout container found. Add a div with data-lce-checkout attribute."),void 0;const s="lce-checkout-container";let a;r.className="lce-checkout-container",r.id=s;const c=t.getAttribute(_t.SCRIPT.CHECKOUT_PARAM)||"lce_checkout";if(c&&startsWithLcePrefix(c)){const t=new URLSearchParams(window.location.search);if(a=t.get(c)||void 0,!a&&n.requireCheckoutId)return console.warn(n.errorPrefix+" Checkout ID not found in query parameters."),void 0}else if(console.warn(n.errorPrefix+' Ignoring checkout query parameter "'+c+'" because it does not start with "lce_" prefix.'),n.requireCheckoutId)return;await e(s,a)}catch(r){console.error(n.errorPrefix+" Failed to setup checkout:",r)}}const Et={SCRIPT:{MAIN:"data-liquid-commerce-checkout",TOKEN:"data-token",ENV:"data-env",DEBUG_MODE:"data-debug-mode",CHECKOUT_URL:"data-checkout-url"}};async function ElementsCheckoutAutoInitialize(){try{const e=document.querySelector("script["+Et.SCRIPT.MAIN+"]");if(!e)return;const n=e.getAttribute(Et.SCRIPT.TOKEN),r=e.getAttribute(Et.SCRIPT.ENV)||t.PRODUCTION,s=e.getAttribute(Et.SCRIPT.DEBUG_MODE);if(!n)throw new SDKError('Missing required data-token attribute on the script tag. Add data-token="your-api-key" to the Elements Checkout script tag.',!![]);const c=e.getAttribute(Et.SCRIPT.CHECKOUT_URL)||void 0;let l=a.NONE;s&&r!==t.PRODUCTION&&(l=s);const d=await ElementsCheckout(n,{env:r,debugMode:l,checkout:c?{pageUrl:c}:void 0,development:getDevelopmentConfigs()});if(!d)throw new SDKError("ElementsCheckout SDK client initialization failed",!![]);await setupCheckout(e,d.injectCheckout.bind(d),{requireCheckoutId:![],errorPrefix:"[LiquidCommerce Checkout Auto Initialization]"})}catch(e){console.error("[LiquidCommerce Checkout Auto Initialization]",e)}}function triggerElementsCheckoutAutoInit(){triggerAutoInit(ElementsCheckoutAutoInitialize,"[LiquidCommerce Checkout Auto Initialization]")}if(void 0===window.customElements)console.error("[LiquidCommerce Checkout] SDK requires support for Web Components. Please include a Web Components polyfill for older browsers.");else if(void 0===HTMLElement.prototype.attachShadow)console.error("[LiquidCommerce Checkout] SDK requires support for Shadow DOM. Please include a Shadow DOM polyfill for older browsers.");else try{const t=window.onerror;window.onerror=(e,n,r,s,a)=>isSDKError(a,n)?(console.error("[LiquidCommerce Checkout] Unhandled SDK error:",{message:e,source:n,lineno:r,colno:s,error:a}),!![]):t?t(e,n,r,s,a):![];const e=window.onunhandledrejection;window.onunhandledrejection=t=>{if(t.reason&&isSDKError(t.reason))return console.error("[LiquidCommerce Checkout] Unhandled SDK promise rejection:",t.reason),t.preventDefault(),void 0;e&&e.call(window,t)};try{initializeDOMPolyfills()}catch(Tt){console.error("[LiquidCommerce Checkout] DOM polyfills initialization failed:",Tt)}window.ElementsCheckout=ElementsCheckout;try{triggerElementsCheckoutAutoInit()}catch(It){console.error("[LiquidCommerce Checkout] Auto-initialization failed:",It)}}catch(Pt){console.error("[LiquidCommerce Checkout] SDK initialization failed:",Pt)}exports.ElementsCheckout=ElementsCheckout,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});