1var t,e,n=t=>{throw TypeError(t)},a=(t,e,a)=>(((t,e,a)=>{e.has(t)||n("Cannot "+a)})(t,e,"access private method"),a);import{c as i}from"./bluetti.theme.DMb47qTq.min.js";import{C as r}from"./bluetti.Component.DCUZfk5_.min.js";import{B as o}from"./bluetti.utils.BeiRElZ6.min.js";import{g as l,M as s,m as u}from"./bluetti.member-price-sdk.DEQAWf2_.min.js";import"./bluetti.preload-helper.DTdAas1V.min.js";import"./bluetti.modulepreload-polyfill.YP0FEG5d.min.js";import"./bluetti.Customer.Ckm4_sV5.min.js";import"./bluetti.constants.Cyvr9pHy.min.js";import"./bluetti.modal.BkmKJNm2.min.js";import"./bluetti.vendor.OdbWYEnF.min.js";import"./bluetti.mallApi.DsZj8Mwg.min.js";t=new WeakSet,e=async function(){if(!(await l()))return null;const[t,e]=await o(i.updateAttributes({[s]:String(Date.now())}));return t?null:e},window.customElements.define("bluetti-cart",class extends r{constructor(){var e,a,i;super(),e=this,(a=t).has(e)?n("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(e):a.set(e,i),this.removeConfirmResolver=null}get bluettiCartBadge(){return document.querySelector("#bluettiCartBadge")}get bluettiCartDrawer(){return document.querySelector("#bluettiCartDrawer")}get requiredRefs(){return["bluettiCartContent","bluettiCartSummary","bluettiCartPoints","bluettiFullDiscount","bluettiLadder","bluettiBuyGift","bluettiCartRecommend"]}async onMount(){await this.updateCartData(await a(this,t,e).call(this))}render(){var t;const{cart:e}=this.state||{};if(!e||"object"!=typeof e)return;const n=null==(t=this.bluettiCartDrawer)?void 0:t.querySelector("#bluettiCartDrawerItemCount");n&&(n.textContent=`(${e.item_count??0})`),window.customElements.whenDefined("bluetti-cart-content").then(()=>{this.refs.bluettiCartContent.setProps({cart:e})});const a=this.refs.bluettiCartPoints;(null==a?void 0:a.setProps)?a.setProps({cart:e}):window.customElements.whenDefined("bluetti-cart-points").then(()=>{var t;null==(t=this.refs.bluettiCartPoints)||t.setProps({cart:e})}),window.customElements.whenDefined("bluetti-full-discount").then(()=>{var t;null==(t=this.refs.bluettiFullDiscount)||t.setProps({"data-cart":e})}),window.customElements.whenDefined("bluetti-ladder").then(()=>{this.refs.bluettiLadder.setProps({"data-cart":e})}),window.customElements.whenDefined("bluetti-buygift").then(()=>{this.refs.bluettiBuyGift.setProps({"data-cart":e})}),window.customElements.whenDefined("bluetti-cart-summary").then(()=>{this.refs.bluettiCartSummary.setProps({cart:e})}),window.customElements.whenDefined("bluetti-cart-badge").then(()=>{var t;null==(t=this.bluettiCartBadge)||t.updateCartBadge({cart:e})}),window.customElements.whenDefined("bluetti-cart-recommend").then(()=>{this.refs.bluettiCartRecommend.setProps({"data-cart-count":e.item_count||0})})}toggleCartSummaryLoadding(t=!0){window.customElements.whenDefined("bluetti-cart-summary").then(()=>{"function"!=typeof this.refs.bluettiCartSummary.setLoadingState?this.refs.bluettiCartSummary.setState(()=>({loadding:t})):this.refs.bluettiCartSummary.setLoadingState(t)})}async onAddProduct(t){const{id:e,quantity:n,properties:a}=t;if(!e||!n)return;this.setCartStatus("loading");const[r]=await o(i.add({id:e,quantity:n,properties:a}));await this.updateCartData()}async onUpdateCartItems(t){const{updates:e}=t||{};if(!e||"object"!=typeof e||0===Object.keys(e).length)return;this.setCartStatus("loading");const[n]=await o(i.update(e));await this.updateCartData()}async onCartRemove({id:t}){if(!t)return;this.setCartStatus("loading");const e={[t]:0},[n,a]=await this.removeItems(e);this.updateCartData(a)}async onCartRemoveConfirm({id:t,key:e}){var n,a,i;if(!t)return;if(!(!0===(null==(n=window.bluettiCartDrawerWarrantyData)?void 0:n.enableAlertConfirm)))return void(await this.onCartRemove({id:t}));const r="string"==typeof e?decodeURIComponent(e):"",o=((null==(i=null==(a=this.state)?void 0:a.cart)?void 0:i.items)||[]).find(e=>r&&String(e.key)===r||String(e.id)===String(t));await this.showRemoveConfirmDialog(o)&&await this.onCartRemove({id:t})}onQuantityButtonClick(t,e){const{action:n,id:a,quantity:i}=t;"update"===n&&a&&i>=0&&this.updateQuantity(a,i)}async updateQuantity(t,e){if(!t||e<0)return;this.setCartStatus("loading");const[n]=await o(i.change({id:t,quantity:e}));await this.updateCartData()}onQuantityInput(t){const e=t.target;if("INPUT"===e.tagName&&"updates[]"===e.name){const t=parseInt(e.value,10)||1,n=e.getAttribute("data-index");t>0&&this.updateQuantity(n,t)}}async updateCartData(t=null){var e;let n=t;if(null==n){const[t,e]=await o(i.get());n=t?null:e}if(null==(e=null==n?void 0:n.items)?void 0:e.length){const[t,e]=await o(this.fetchCartMetaList());!t&&Array.isArray(e)&&(n=this.mergeCartMeta(n,e)),u.registerCartCatalog(n.items)}else u.registerCartCatalog([]);await this.setState(()=>({cart:n})),this.setCartStatus("loaded")}setCartStatus(t){switch(t){case"loading":this.toggleCartSummaryLoadding(!0);break;case"loaded":this.toggleCartSummaryLoadding(!1)}}async removeItems(t){var e;const{cart:n}=this.state||{};if(!(null==(e=null==n?void 0:n.items)?void 0:e.length))return;let a={};const r=[...n.items.filter(t=>{var e;return"gift"===(null==(e=t.properties)?void 0:e._buygift_gift)}),...n.items.filter(t=>{var e;return"gift"===(null==(e=t.properties)?void 0:e._ladder_gift)})];r.length>0&&(a=Object.fromEntries(r.map(t=>[t.variant_id,0])));const[l,s]=await o(i.update({...t,...a}));return[l,s]}async fetchCartMetaList(){var t,e;const n=(null==(e=null==(t=window.Shopify)?void 0:t.routes)?void 0:e.root)||"/",a=await fetch(`${n}cart?view=meta&t=${Date.now()}`);if(!a.ok)throw new Error(`Failed to load cart meta: ${a.status}`);const i=await a.text(),r=JSON.parse(i);if(!Array.isArray(r))throw new Error("Cart meta response is not an array");return r}mergeCartMeta(t,e){if(!Array.isArray(e))return t;const n=new Map,a=new Map,i=new Map;return e.forEach(t=>{t&&"object"==typeof t&&(t.key&&n.set(t.key,t),t.variant_id&&a.set(String(t.variant_id),t),t.item_id&&i.set(String(t.item_id),t))}),{...t,items:(t.items||[]).map(t=>{const e=n.get(t.key)??i.get(String(t.id))??a.get(String(t.variant_id))??null;return e?{...t,compare_at_price:e.compare_at_price,price:e.price??t.price,short_title:"string"==typeof e.short_title?e.short_title:"",mp:e.mp??null,product_price:e.product_price??null}:t})}}showRemoveConfirmDialog(t){return new Promise(e=>{var n,a,i,r;this.removeConfirmResolver=e;const o="bluetti-cart-remove-confirm-modal",l=document.getElementById(o);l&&l.remove();const s=this.getCartItemDisplayTitle(t),u=this.escapeHtml(s),d=this.escapeHtml(this.getCartItemImageAlt(t)),c=(null==(n=window.bluettiCartDrawerI18n)?void 0:n.remove)||"Remove",m=(null==(a=window.bluettiCartDrawerWarrantyData)?void 0:a.alertConfirmTitle)||"Remove this item?",p=(null==(i=window.bluettiCartDrawerWarrantyData)?void 0:i.alertConfirmCancelButtonText)||"Cancel",h=(null==(r=window.bluettiCartDrawerWarrantyData)?void 0:r.alertConfirmConfirmButtonText)||"Confirm",g=this.getCartItemVariantRows(t).map(t=>"pair"===t.type?`<p class="mt-1 text-xs font-normal text-neutral-500 lg:text-sm">${this.escapeHtml(t.name)}:${this.escapeHtml(t.value)}</p>`:`<p class="mt-1 text-xs font-normal text-neutral-500 lg:text-sm">${this.escapeHtml(t.value)}</p>`).join(""),f=document.body.style.overflow,v=document.createElement("div");v.id=o,v.className="fixed inset-0 z-[999] flex items-center justify-center bg-black/60 p-4 lg:p-8 backdrop-blur-[8px]",v.innerHTML=`\n <div class="w-full max-w-[632px] rounded-3xl bg-white px-4 pt-3 pb-8 shadow-2xl lg:px-6 lg:pt-6 flex flex-col gap-4">\n <div class="flex items-center justify-between mb-6">\n <p class="text-base font-semibold text-neutral-600 lg:text-1.5xl">${c}</p>\n <button\n type="button"\n data-action="cancel"\n class="flex h-8 w-8 rounded-full items-center justify-center text-neutral-700 transition-colors lg:h-9 lg:w-9"\n aria-label="close"\n >\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M6 18L18 6M6 6L18 18" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n </svg>\n </button>\n </div>\n\n <h3 class="text-lg font-bold text-neutral-900 lg:text-2xl">\n ${m}\n </h3>\n\n <div class="rounded-xl bg-neutral-100 py-6 px-4 lg:p-6">\n <div class="flex items-center gap-3 lg:gap-4">\n ${(null==t?void 0:t.image)?`<img data-bluetti-lazy-src="${t.image}" alt="${d}" class="h-20 w-20 rounded-md object-contain lg:h-24 lg:w-24" />`:""}\n <div class="min-w-0">\n <p class="text-base font-medium text-neutral-900 lg:text-lg">${u}</p>\n ${g}\n </div>\n </div>\n </div>\n\n <div class="grid grid-cols-1 gap-2 lg:grid-cols-2 lg:gap-4">\n <button type="button" data-action="cancel" class="btn btn-m lg:btn-l btn-primary-ghost rounded-full">\n ${p}\n </button>\n <button type="button" data-action="confirm" class="btn btn-m lg:btn-l btn-primary rounded-full">\n ${h}\n </button>\n </div>\n </div>\n `;const w=t=>{v.parentNode&&v.parentNode.removeChild(v),document.body.style.overflow=f,document.removeEventListener("keydown",b);const e=this.removeConfirmResolver;this.removeConfirmResolver=null,e&&e(t)}
1,b=t=>{"Escape"===t.key&&w(!1)};v.addEventListener("click",t=>{const e=t.target instanceof Element?t.target:null;if(!e)return;const n=e.closest("[data-action]"),a=null==n?void 0:n.dataset.action;"confirm"!==a?"cancel"!==a&&e!==v||w(!1):w(!0)}),document.body.style.overflow="hidden",document.addEventListener("keydown",b),document.body.appendChild(v)})}escapeHtml(t){const e=document.createElement("div");return e.textContent=String(t??""),e.innerHTML}getCartItemDisplayTitle(t){return"string"==typeof(null==t?void 0:t.short_title)&&t.short_title.trim()?t.short_title:null==t?void 0:t.product_title}getCartItemImageAlt(t){var e;return(null==t?void 0:t.image_alt)||(null==(e=null==t?void 0:t.product)?void 0:e.title)||this.getCartItemDisplayTitle(t)}getCartItemVariantRows(t){var e,n,a;const i=[];return!(null==(e=null==t?void 0:t.product)?void 0:e.has_only_default_variant)&&Array.isArray(null==t?void 0:t.options_with_values)&&t.options_with_values.forEach((t,e,n)=>{if(!(null==t?void 0:t.name)||!(null==t?void 0:t.value))return;const a=`${t.value}${e<n.length-1?", ":""}`;i.push({type:"pair",name:t.name,value:a})}),(null==t?void 0:t.properties)&&"object"==typeof t.properties&&Object.entries(t.properties).forEach(([t,e])=>{const n=null==t?void 0:t.charAt(0);if(!e||""===e||"_"===n)return;const a="string"==typeof e&&e.includes("/uploads/")?e.split("/").pop():e;i.push({type:"pair",name:t,value:String(a)})}),(null==(a=null==(n=null==t?void 0:t.selling_plan_allocation)?void 0:n.selling_plan)?void 0:a.name)&&i.push({type:"text",value:t.selling_plan_allocation.selling_plan.name}),i}async onCheckout(t){t.preventDefault(),window.location.href="/checkout"}});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.