PageSourceSearch

https://www.maccosmetics.com/cdn/shop/t/182/assets/talon-one-coupon.VQyPrOyB.min.js

js maccosmetics.com collected 2026-09-24 17:11:18 UTC 7,786 bytes, 1 lines download raw bytes

1import{B as t}from"./BaseElement.wji90fuE.min.js";import{p as e,b as s,a as o}from"./cart-compute.CjdfbDq-.min.js";import{w as i,a as r}from"./coupon-writes.CUC5Ahur.min.js";import{p as n,h as a,s as c,T as l,r as u,a as d,c as p}from"./coupon-codes.DAWRRM7_.min.js";import{W as h}from"./WithShopifyCart.Dy1sQhoJ.min.js";import{x as m,n as g,t as v}from"./vendor-lit.2u3dzq2T.min.js";import"./format-money.CPSsGZ60.min.js";import"./report.LMKEGfPy.min.js";import"./WithApiClient.B8AOHZZP.min.js";import"./fetchWithCache.BJ12kVQ7.min.js";import"./vendor.D2HIaoTS.min.js";import"./cart-sections.BcMbGr3r.min.js";import"./debounce.uPZYEJlg.min.js";let b=null;var y=Object.defineProperty,f=Object.getOwnPropertyDescriptor,C=(t,e,s,o)=>{for(var i,r=o>1?void 0:o?f(e,s):e,n=t.length-1;n>=0;n--)(i=t[n])&&(r=(o?i(e,s,r):i(r))||r);return o&&r&&y(e,s,r),r};let w=class extends(h(t)){constructor(){super(...arguments),this.rootSelector="#cart-drawer-dialog",this.successMessage="",this.serviceErrorMessage="",this.loadingMessage="",this.removedMessage="",this.isLoading=!1,this.boundOnSubmit=this.onSubmit.bind(this),this.boundOnClick=this.onClick.bind(this),this.boundOnInput=this.onInput.bind(this),this.boundOnView=this.onCartView.bind(this)}get proxyBase(){return window.__T1_PROXY_BASE__||"/apps/talonone-proxy/api/public"}connectedCallback(){super.connectedCallback(),document.addEventListener("submit",this.boundOnSubmit),document.addEventListener("click",this.boundOnClick),document.addEventListener("input",this.boundOnInput),document.addEventListener("talon:cartview",this.boundOnView),void 0!==window.__T1_CARTVIEW__&&this.reconcile(window.__T1_CARTVIEW__??null)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("submit",this.boundOnSubmit),document.removeEventListener("click",this.boundOnClick),document.removeEventListener("input",this.boundOnInput),document.removeEventListener("talon:cartview",this.boundOnView)}render(){return m``}get root(){return document.querySelector(this.rootSelector)??document}ownsNode(t){return null!=t&&this.root.contains(t)}get form(){return this.root.querySelector("[data-t1-coupon-form]")}get input(){return this.root.querySelector("[data-t1-coupon-input]")}get applyButton(){return this.root.querySelector("[data-t1-coupon-apply]")}get messageEl(){return this.root.querySelector("[data-t1-coupon-message]")}get messageTextEl(){return this.root.querySelector("[data-t1-coupon-message-text]")}get messageIconEl(){return this.root.querySelector("[data-t1-coupon-message-icon]")}get appliedListEl(){return this.root.querySelector("[data-t1-coupon-applied-list]")}get chipTemplate(){return this.root.querySelector("[data-t1-coupon-chip-template]")}get removeButtons(){return Array.from(this.root.querySelectorAll("[data-t1-coupon-remove]"))}async onSubmit(t){var e,s,o;const r=null==(s=null==(e=t.target)?void 0:e.closest)?void 0:s.call(e,"[data-t1-coupon-form]");if(!this.ownsNode(r??null))return;if(t.preventDefault(),this.isLoading)return;const n=((null==(o=this.input)?void 0:o.value)??"").trim();n&&(this.setLoading(!0),await i(()=>this.applyCode(n)))}async applyCode(t){var e,s;const o=await this.readCart(),i=o?await this.fetchCartView(o,t):null;if(!this.isConnected)return;if(!i||!o)return this.setMessage(this.serviceErrorMessage,"error"),void this.setLoading(!1);const r=n(null==(e=i.coupon)?void 0:e.applied);if(a(r,t)){const t=await this.writeCoupons(r,o);if(!this.isConnected)return;if(t){this.renderApplied(r),this.setMessage(this.successMessage,"success");const t=this.input;t&&(t.value="")}else this.setMessage(this.serviceErrorMessage,"error")}else{const e=c(null==(s=i.coupon)?void 0:s.rejected,t);e?this.setMessage((t=>{const e=(()=>{if(b)return b;b={};const t=document.getElementById("t1-coupon-error-labels");if(!(null==t?void 0:t.textContent))return b;try{b=JSON.parse(t.textContent)}catch{}return b})();return t&&e[t]||e.default||""})(e.reason),"error",!0):this.setMessage(this.serviceErrorMessage,"error")}this.setLoading(!1)}onClick(t){var e,s;const o=(null==(s=null==(e=t.target)?void 0:e.closest)?void 0:s.call(e,"[data-t1-coupon-remove]"))??null;this.ownsNode(o)&&this.onRemove(o.getAttribute("data-t1-coupon-remove")??"")}async onRemove(t){this.isLoading||(this.setLoading(!0),await i(()=>this.removeCode(t)))}async removeCode(t){var e;const s=await this.readCart();if(!this.isConnected)return;if(!s)return this.setMessage(this.serviceErrorMessage,"error"),void this.setLoading(!1);const o=n(null==(e=s.attributes)?void 0:e[l]),i=t?u(o,t):[],r=await this.writeCoupons(i,s);this.isConnected&&(this.setLoading(!1),r?(this.renderApplied(i),this.setMessage(this.removedMessage,"success")):this.setMessage(this.serviceErrorMessage,"error"))}onInput(t){var e,s;const o=t.target;(null==(e=null==o?void 0:o.matches)?void 0:e.call(o,"[data-t1-coupon-input]"))&&this.ownsNode(o)&&"error"===(null==(s=this.messageEl)?void 0:s.dataset.state)&&this.setMessage("","")}onCartView(t){const e=t.detail??null;this.reconcile(e)}reconcile(t){var e;this.isLoading||this.renderApplied(n(null==(e=null==t?void 0:t.coupon)?void 0:e.applied))}async readCart(){try{return await this.getCart()}catch{return null}}async fetchCartView(t,e){const s=String(t.token??"").split("?")[0]||"cart";try{const o=await fetch(`${this.proxyBase}/cart/compute`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(this.buildRequest(t,s,e))});return o.ok?await o.json():null}catch{return null}}buildRequest(t,e,s){var o;const i=n(null==(o=t.attributes)?void 0:o[l]),r=d(i,s);return{cartToken:e,talon_one_session_id:e,currency:t.currency,lines:t.items.map(t=>({key:t.key,sku:t.sku||String(t.id),quantity:t.quantity,price:t.price,properties:t.properties||{}})),attributes:p(i),coupons:r.length?r:void 0}}writeCoupons(t,i){return r(this,t,{cart:i,sections:!1,mirrorSession:t=>e(this.proxyBase,s(t,o(t))),logPrefix:"[talon-one-coupon]"})}setLoading(t){var e;this.isLoading=t;const s=this.applyButton;s&&(s.disabled=t,s.setAttribute("aria-busy",String(t))),this.input&&(this.input.disabled=t),this.removeButtons.forEach(e
1=>e.disabled=t),null==(e=this.form)||e.toggleAttribute("data-loading",t),t&&this.setMessage(this.loadingMessage,"loading")}setMessage(t,e,s=!1){var o;const i=this.messageEl;if(i){const r=this.messageTextEl??i;s?r.innerHTML=t:r.textContent=t,i.dataset.state=e,i.hidden=0===t.length,i.style.color="success"===e?"var(--color-info)":"error"===e?"var(--color-danger)":"",null==(o=this.messageIconEl)||o.toggleAttribute("hidden","error"!==e)}const r=this.input;if(r){const t="error"===e;r.setAttribute("aria-invalid",String(t)),r.toggleAttribute("data-invalid",t)}}renderApplied(t){const e=this.appliedListEl;if(!e)return;const s=this.chipTemplate;e.replaceChildren(...t.map(t=>this.buildChip(s,t)).filter(t=>null!==t)),e.hidden=0===e.children.length}buildChip(t,e){var s;const o=null==(s=null==t?void 0:t.content.firstElementChild)?void 0:s.cloneNode(!0);if(!(o instanceof HTMLElement))return null;const i=o.querySelector("[data-t1-coupon-code]");i&&(i.textContent=e);const r=o.querySelector("[data-t1-coupon-remove]");if(r){r.setAttribute("data-t1-coupon-remove",e),r.disabled=this.isLoading;const t=r.getAttribute("aria-label");t&&r.setAttribute("aria-label",t.replaceAll("###code###",e))}return o}};C([g({type:String,attribute:"root-selector"})],w.prototype,"rootSelector",2),C([g({type:String,attribute:"success-message"})],w.prototype,"successMessage",2),C([g({type:String,attribute:"service-error-message"})],w.prototype,"serviceErrorMessage",2),C([g({type:String,attribute:"loading-message"})],w.prototype,"loadingMessage",2),C([g({type:String,attribute:"removed-message"})],w.prototype,"removedMessage",2),w=C([v("talon-one-coupon")],w);export{w as TalonOneCoupon};

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.