1var t=Object.defineProperty,e=(e,s,i)=>((e,s,i)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i)(e,"symbol"!=typeof s?s+"":s,i);import{c as s}from"./bluetti.theme.DMb47qTq.min.js";import{C as i}from"./bluetti.Component.DCUZfk5_.min.js";import{B as r}from"./bluetti.utils.BeiRElZ6.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";import"./bluetti.member-price-sdk.DEQAWf2_.min.js";class a extends i{constructor(){super(...arguments),e(this,"handleAddToCart",async t=>{if(t.preventDefault(),this.isLoading||this.isSuccess)return;const e=this.variantId;e&&await this.addToCart(e,this.quantity)})}static get observedAttributes(){return["data-add-cart","data-quantity","data-open-drawer","data-remove-on-success","data-remove-selector","disabled"]}get bluettiCart(){return document.querySelector("bluetti-cart")}get bluettiCartDrawer(){return document.querySelector("#bluettiCartDrawer")}get variantId(){const t=this.getAttribute("data-add-cart");return t?Number(t):null}get quantity(){const t=this.getAttribute("data-quantity");return t?Number(t):1}get shouldOpenDrawer(){const t=this.getAttribute("data-open-drawer");return null===t||("true"===t||"1"===t||""===t)}get shouldRemoveOnSuccess(){const t=this.getAttribute("data-remove-on-success");return null!==t&&("true"===t||"1"===t||""===t)}get removeSelector(){return this.getAttribute("data-remove-selector")}async onMount(){this.isLoading=!1,this.isSuccess=!1,this.isError=!1,this._originalText=null,this.addEventListener("click",this.handleAddToCart),this.hasAttribute("disabled")&&(this.disabled=!0)}async addToCart(t,e=1){var i,a;this.setLoadingState(!0);try{const[o,n]=await r(s.add({id:t,quantity:e}));
1if(o)return void this.setErrorState(o);if(this.setSuccessState(),(null==(i=window.GA4Ecommerce)?void 0:i.pushAddToCartEvent)&&window.GA4Ecommerce.pushAddToCartEvent(n),this.bluettiCart&&await this.bluettiCart.updateCartData(),this.shouldOpenDrawer&&(null==(a=this.bluettiCartDrawer)?void 0:a.handleOpen)&&this.bluettiCartDrawer.handleOpen(),document.dispatchEvent(new CustomEvent("cart:updated",{bubbles:!0})),this.shouldRemoveOnSuccess)return void this.removeElement();setTimeout(()=>{this.resetState()},2e3)}catch(o){this.setErrorState(o)}finally{setTimeout(()=>{this.setLoadingState(!1)},300)}}setLoadingState(t){if(this.isLoading=t,t){this.classList.add("loading","opacity-75","cursor-not-allowed"),this.setAttribute("aria-busy","true"),this.disabled=!0,this._originalText||(this._originalText=this.textContent);const t=this.getAttribute("data-loading-text")||"Adding...";this.textContent=t}else this.classList.remove("opacity-75","cursor-not-allowed"),this.removeAttribute("aria-busy"),this.disabled=!1}setSuccessState(){this.isSuccess=!0,this.classList.add("success"),this.classList.remove("loading","error");const t=this.getAttribute("data-success-text")||"Added!";this.textContent=t,this.getAttribute("data-success-icon")}setErrorState(t){var e;this.isError=!0,this.classList.add("error"),this.classList.remove("loading","success");let s=this.getAttribute("data-error-text");s||(s=[403,429,423].includes(null==t?void 0:t.status)?(null==(e=window.cartStrings)?void 0:e.error_403)||"Too many requests":(null==t?void 0:t.message)||"Failed to add"),this.textContent=s,setTimeout(()=>{this.resetState()},2e3)}removeElement(){const t=this.removeSelector;let e=null;if(t){if(e=this.querySelector(t),!e){const s=this.parentElement;s&&(e=s.querySelector(t))}if(!e){const s=this.closest(t);s&&s!==this&&(e=s)}e||(e=document.querySelector(t))}else e=this;e&&(e.style.transition="opacity 0.3s ease, transform 0.3s ease",e.style.opacity="0",e.style.transform="scale(0.9)",setTimeout(()=>{e.remove(),window.dispatchEvent(new CustomEvent("recommend:accessories:updated",{bubbles:!0}))},300))}resetState(){this.isLoading=!1,this.isSuccess=!1,this.isError=!1,this.classList.remove("loading","success","error","opacity-75","cursor-not-allowed"),this.removeAttribute("aria-busy"),this.disabled=!1,this._originalText&&(this.textContent=this._originalText,this._originalText=null)}attributeChangedCallback(t,e,s){"data-add-cart"===t&&e!==s&&this.resetState(),"disabled"===t&&(this.disabled=null!==s)}}window.customElements.get("bluetti-quick-add-cart")||window.customElements.define("bluetti-quick-add-cart",a);
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.