"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[21],[,,,,,,,,,,function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PriceComponent=void 0;const n=r(0),a=(r(1),r(2)),i=s(r(29)),{wrapper:o,wrapperArtificialPrice:c,wrapperSavingsLabel:d,wrapperRetailPrice:l}=i.default;t.PriceComponent=({priceData:{price:e,displayPrice:t,retailPrice:r},savingsLabel:s,isArtificialPriceAvailable:i})=>{const u="number"==typeof r&&r>0,p=(0,a.transformLabelByMultipleOptions)(s,{price:e,displayPrice:t,retailPrice:r}),m=i&&p&&p.length>0;return(0,n.jsxs)("div",Object.assign({className:o},{children:[u&&(0,n.jsx)("span",Object.assign({className:l},{children:(0,a.formatCurrency)(r)})),(0,n.jsx)("span",Object.assign({className:(0,a.cx)(o,m?c:"")},{children:(0,a.formatCurrency)(t)})),m&&(0,n.jsx)("div",{className:d,dangerouslySetInnerHTML:{__html:p}})]}))}},function(e,t){var r=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useCustomerActions=void 0,t.useCustomerActions=()=>({getCustomer:()=>r(void 0,void 0,void 0,(function*(){return{}})),login:e=>r(void 0,void 0,void 0,(function*(){try{return{errors:[],customer:{id:"12345",name:"Customer Example",email:"example@example.com"}}}catch(e){return{errors:[{message:"Login failed"}],customer:null}}})),register:e=>r(void 0,void 0,void 0,(function*(){try{return{errors:[],customer:{id:"12345",name:"Customer Example",email:"example@example.com"}}}catch(e){return{errors:[{message:"Registration failed"}]}}})),recoverPassword:e=>r(void 0,void 0,void 0,(function*(){try{return null}catch(e){return console.log(e),{errors:[{message:"Password recovery failed"}]}}})),resetPassword:({resetUrl:e,password:t})=>r(void 0,void 0,void 0,(function*(){try{return null}catch(e){return console.log(e),{errors:[{message:"Password reset failed"}]}}})),logout:()=>r(void 0,void 0,void 0,(function*(){return{errors:[]}})),getAllAddresses:()=>{},updateAddress:e=>({customerAddress:"",errors:""}),deleteAddress:e=>({deletedCustomerAddressId:"",errors:""}),createAddress:e=>({customerAddress:"",errors:""}),getAllOrders:()=>r(void 0,void 0,void 0,(function*(){return[]})),updateCustomer:({firstName:e,lastName:t,email:s,phone:n,company:a,newPassword:i})=>r(void 0,void 0,void 0,(function*(){return{customer:"",errors:""}})),getOrderMessages:e=>r(void 0,void 0,void 0,(function*(){})),createOrderMessage:({subject:e,message:t,orderId:s})=>r(void 0,void 0,void 0,(function*(){}))})},,,,,,,,,,function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useOrderExist=void 0;const n=r(3);t.useOrderExist=({orderId:e,getAllOrders:t,goBack:r})=>{const[a,i]=(0,n.useState)(!1);return(0,n.useEffect)((()=>{!function(){s(this,void 0,void 0,(function*(){const r=yield t();i(!!r&&(()=>r&&r.some((t=>t.id===e))))}))}()}),[e]),(0,n.useEffect)((()=>{a||r()}),[a,r]),a}},,,,,,(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s={percentOffBox:"G1JbCPc1",youSaveValue:"KzTiZoRL",youSaveValueLarge:"eUcJMdYq",youSaveValueArtificial:"WzCe2F5p",percentOffBoxPosition:"TxGdVR8A"}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s={percentOffBox:"qf0y61Jz",percentOffBoxCustom:"a3f4KALk",percentOffBoxWithoutOffset:"ch484voj",percentOffBoxPosition:"U0mpqiUu",percentOffBoxBig:"cHpyMILH"}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s={wrapper:"YqsRl3TO",wrapperRetailPrice:"FHRPbFLW",wrapperArtificialPrice:"jbISFmiQ",wrapperSavingsLabel:"F6dXIuYq"}},,,,,function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.triggerErrorNotification=t.useAddressForm=t.useAddresses=void 0;const a=r(9),i=r(3),o=n(r(5));t.useAddresses=({customer:e,customerAddresses:r,customerInfo:n,getCurrentCustomer:a,getCustomerAddresses:c,createCustomerAddress:d,updateCustomerAddress:l,deleteCustomerAddress:u})=>{const[p,m]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[g,j]=(0,i.useState)(!1),[x,b]=(0,i.useState)(!1),v=(0,i.useRef)(n);(0,i.useEffect)((()=>{!function(){s(this,void 0,void 0,(function*(){v.current=n,g&&(null===v.current?(o.default.fire({icon:"success",text:"Address Added Successfully!"}).then((()=>f(null))),j(!1),m(!1),yield O()):null!==v.current&&200!==v.current.status&&(o.default.fire({icon:"error",text:v.current.message}).then((()=>f(null))),j(!1),m(!1),yield O(),yield a())),x&&(null===v.current?(o.default.fire({icon:"success",text:"Address Updated Successfully!"}).then((()=>f(null))),j(!1),m(!1),yield O()):null!==v.current&&200!==v.current.status&&(o.default.fire({icon:"error",text:v.current.message}).then((()=>f(null))),b(!1),m(!1),yield O(),yield a()))}))}()}),[n,g,x]);const w=(r||[]).find((({id:e})=>e==h)),O=()=>s(void 0,void 0,void 0,(function*(){try{yield c()}catch(e){console.error("Error when fetching Address Data",e)}}));return(0,i.useEffect)((()=>{O().catch((()=>a()))}),[]),{isLoading:p,addressId:h,selectedAddress:w,setAddressId:f,handleAddAddressSubmission:r=>s(void 0,void 0,void 0,(function*(){const s={firstName:"",lastName:"",city:"",countryCode:"US",company:"",stateOrProvince:"",address1:"",address2:"",postalCode:"",phone:"",addressType:"residential"};try{if(m(!0),!e)return;const t=[Object.assign(Object.assign(Object.assign({},s),r),{customerId:e.entityId})];j(!0),yield d(t),j(!1),m(!1)}catch(e){(0,t.triggerErrorNotification)(e.message),j(!1),m(!1),a()}})),handleEditAddressSubmission:e=>s(void 0,void 0,void 0,(function*(){try{m(!0);const t=Object.assign({id:h},(e=>{const{address1:t}=e;if(w&&t!==w.address1)return e;const r=/\.$/.test(w?w.address1:"");return Object.assign(Object.assign({},e),{address1:r?null==t?void 0:t.replace(/\.$/,""):`${t}.`})})(e));b(!0),yield l([t]),b(!1),m(!1)}catch(e){(0,t.triggerErrorNotification)(e.message),b(!1),m(!1),a()}})),handleDeleteAddress:e=>s(void 0,void 0,void 0,(function*(){try{if(isNaN(e))throw new Error("Invalid Address ID");yield u(e),null!==v.current?o.default.fire({icon:"error",text:"Something went wrong, could not delete address."}).then((()=>f(null))):o.default.fire({icon:"success",text:"Address Deleted Successfully!"}).then((()=>f(null))),yield c()}catch(e){(0,t.triggerErrorNotification)(e.message),yield a()}}))}},t.useAddressForm=e=>{const t=Object.assign(Object.assign({},{firstName:"",lastName:"",city:"",countryCode:"US",company:"",stateOrProvince:"",address1:"",address2:"",postalCode:"",phone:"",addressType:"residential"}),e),{formData:r,setField:s,validateFields:n}=(0,a.useValidationForm)({fields:Object.assign(Object.assign({},t),{address1:t.address1.replace(/\.$/,"")}),validations:{firstName:e=>!e&&"The 'First Name' field cannot be blank.",lastName:e=>!e&&"The 'Last Name' field cannot be blank.",address1:e=>!e&&"The 'Address Line 1' field cannot be blank.",city:e=>!e&&"The 'Suburb/City' field cannot be blank.",state:e=>!e&&"The 'State' field cannot be blank.",postalCode:e=>!e&&"The 'Zip/Postcode' field cannot be blank.",phone:e=>!e&&"The 'Phone Number' field cannot be blank."}});return{formData:r,setField:s,validateFields:n}},t.triggerErrorNotification=e=>{o.default.fire({icon:"error",text:e})}},,,,,,,function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StoreCredit=void 0;const n=r(0),a=(r(1),s(r(198))),{wrapper:i}=a.default;t.StoreCredit=({customer:e})=>{if(!e)return null;const{storeCredit:t}=e;if(!t)return null;const r=t[0];if(void 0===r)return null;const s=r.value;return(0,n.jsxs)("div",Object.assign({className:i},{children:["You have ",(0,n.jsxs)("p",{children:["$",s]})," of store credit. To use it, simply place your order and you will be able to choose store credit as the payment method when it comes time to pay for your order."]}))}},,,,,,,,,,,,,,,,,,function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),i=r(1),o=r(3),c=r(26),d=n(r(7)),l=r(41),u=r(83),p=r(84),m=r(60),h=r(86),f=r(61),g=n(r(203)),j=r(2),{ordersHeading:x,ordersMessages:b}=g.default;t.default=({items:e,inventoryProducts:t,customer:r,orderMessages:n,getOrderMessages:g,getCurrentCustomer:v,setSubAuthState:w,setAuthState:O,addToCart:y,getAllOrders:C})=>{const{currentOrderId:N,currentReturnOrderId:I,currentMessagesOrderId:_,setCurrentOrderId:A,setCurrentMessagesOrderId:S,setCurrentReturnOrderId:P}=(0,u.useOrdersState)(),[{orders:F,isLoaded:L},k]=(0,o.useState)({isLoaded:!1,orders:null});(0,o.useEffect)((()=>{var e;(null==r?void 0:r.entityId)&&!L&&(e=r.entityId,s(void 0,void 0,void 0,(function*(){const{success:t,data:r}=yield fetch(`https://us-central1-de-pay-after-app.cloudfunctions.net/customer/customer-orders?customerId=${e}`).then((e=>e.json()));t||console.error("Failed to fetch easy pay orders for customerId -",e);const{customerOrders:s}=r,n=yield C(),a=null==n?void 0:n.map((e=>{const{id:t}=e,r=s.find((({bc_order_id:e})=>e===String(t)));return r?Object.assign(Object.assign({},e),{easyPayData:Object.assign({},r)}):e}));k({orders:null!=a?a:null,isLoaded:!0})})))}),[null==r?void 0:r.entityId,L]),w&&N&&w(`Order #${N}`);const B=(0,o.useMemo)((()=>(F||[]).reduce(((e,{products:t})=>e.concat(t.map((({productId:e})=>e)))),[])),[F]),{productsById:M,isProductsFetching:D}=(0,c.useProducts)(B);if((0,o.useEffect)((()=>{C().then((e=>{k({orders:null!=e?e:null,isLoaded:!0})})).catch((()=>v()))}),[]),!L)return(0,a.jsx)(d.default,{});if(I)return(0,a.jsx)(p.OrderReturn,{orderId:I,getAllOrders:C,goBack:()=>P(null)});if(_)return(0,a.jsx)(f.OrderMessages,{orderId:_,goBack:()=>S(null),orderMessages:n,getAllOrders:C,getOrderMessages:g,getCurrentCustomer:v});if(D)return(0,a.jsx)(d.default,{});if(!F||!F.length)return(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(l.StoreCredit,{customer:r}),(0,a.jsx)("h3",Object.assign({className:(0,j.cx)(x)},{children:"Orders"})),(0,a.jsx)("div",Object.assign({className:(0,j.cx)(b)},{children:"You do not have any orders with us yet."}))]});const T=N&&F.find((e=>e.id===N)),R={productsById:M,setCurrentOrderId:A,setCurrentReturnOrderId:P};return T?(0,a.jsx)(m.OrderDetail,Object.assign({orderId:N,order:T,items:e,inventoryProducts:t,addToCart:y,getAllOrders:C,goBack:()=>A(null)},R)):(0,a.jsx)(h.OrderList,Object.assign({orders:F,setCurrentMessagesOrderId:S,showPaymentSchedule:()=>{O("Buy Now/Pay Later")}},R))}},function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OrderDetail=void 0;const a=r(0),i=(r(1),r(3)),o=n(r(5)),c=r(8),d=r(2),l=n(r(7)),u=r(21),p=n(r(200)),m=r(2),{wrapper:h,wrapperContent:f,wrapperContentListItem:g,wrapperContentListItemProduct:j,wrapperContentListItemProductFigure:x,wrapperContentListItemProductBody:b,wrapperContentListItemProductCheckItem:v,wrapperContentTotal:w,wrapperSidebar:O,wrapperSidebarBlock:y,wrapperSidebarBlockInfo:C,wrapperSidebarBlockAddress:N,wrapperButton:I,wrapperButtonSecondary:_,wrapperHeading:A,wrapperDefinitionList:S,wrapperDefinitionListGroup:P,wrapperDefinitionListKey:F,wrapperDefinitionListValue:L,wrapperFormLabel:k,wrapperFormCheckbox:B}=p.default;t.OrderDetail=({orderId:e,productsById:t,order:r,items:n,inventoryProducts:p,addToCart:M,setCurrentReturnOrderId:D,getAllOrders:T,goBack:R})=>{const E=(0,u.useOrderExist)({orderId:e,getAllOrders:T,goBack:R}),[q,H]=(0,i.useState)([]),{push:U}=(0,c.useRouter)();if(!r||!E)return(0,a.jsx)(l.default,{});const{billingAddress:V,shippingAddresses:Y,products:K,subtotalExTax:z,storeCreditAmount:G,totalIncTax:Q,status:W,dateCreated:J,paymentMethod:Z}=r,X=Y&&Y.length?Y[0]:void 0,$=e=>{const t=e.currentTarget;if(!t)return null;const r=Array.from(q),s=Number(t.value);r.includes(s)?r.splice(r.indexOf(s),1):r.push(s),H(r)};return(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(h)},{children:[(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(f)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(A)},{children:"Order Contents"})),(0,a.jsx)("ul",{children:K.map(((e,r)=>{const{productId:s,name:n,basePrice:i,quantity:o,productOptions:c}=e,l=t[s]&&t[s].defaultImage.size320;return(0,a.jsx)("li",Object.assign({className:(0,m.cx)(g)},{children:(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(j)},{children:[(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(v)},{children:[(0,a.jsx)("input",{className:(0,m.cx)(B),type:"checkbox",id:`orderDetail-product-id-${s}`,value:r,checked:q.includes(r),onChange:$}),(0,a.jsx)("label",Object.assign({htmlFor:`orderDetail-product-id-${s}`,className:(0,m.cx)(k)},{children:(0,a.jsxs)("span",Object.assign({style:{display:"none"},className:(0,m.cx)("is-srOnly")},{children:["Checkbox ",s," label"]}))}))]})),(0,a.jsx)("figure",Object.assign({className:(0,m.cx)(x)},{children:(0,a.jsx)("img",{src:l,alt:n,title:n,sizes:"70px"})})),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(b)},{children:[(0,a.jsx)("span",{children:(0,d.formatCurrency)(i)}),(0,a.jsxs)("h5",{children:[o," × ",n]}),(0,a.jsx)("dl",Object.assign({className:(0,m.cx)(S)},{children:c.map((({display_name:e,display_value:t},r)=>(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsxs)("dt",Object.assign({className:(0,m.cx)(F)},{children:[" ",e,":"," "]})),(0,a.jsxs)("dd",Object.assign({className:(0,m.cx)(L)},{children:[" ",t," "]}))]}),r)))}))]}))]}))}),r)}))}),(0,a.jsxs)("dl",Object.assign({className:(0,m.cx)(w)},{children:[(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",{children:"Subtotal:"}),(0,a.jsx)("dd",{children:(0,d.formatCurrency)(z)})]})),Number(G)>=.001&&(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",{children:"Store Credit:"}),(0,a.jsxs)("dd",{children:["-",(0,d.formatCurrency)(G)]})]}))]}))]})),(0,a.jsxs)("aside",Object.assign({className:(0,m.cx)(O)},{children:[(0,a.jsxs)("section",Object.assign({className:(0,m.cx)(y)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(A)},{children:"Order Details"})),(0,a.jsxs)("dl",Object.assign({className:(0,m.cx)(S)},{children:[(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",Object.assign({className:(0,m.cx)(F)},{children:"Order status:"})),(0,a.jsx)("dd",Object.assign({className:(0,m.cx)(L)},{children:W}))]})),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",Object.assign({className:(0,m.cx)(F)},{children:"Order date:"})),(0,a.jsx)("dd",Object.assign({className:(0,m.cx)(L)},{children:J}))]})),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",Object.assign({className:(0,m.cx)(F)},{children:"Order total:"})),(0,a.jsx)("dd",Object.assign({className:(0,m.cx)(L)},{children:(0,d.formatCurrency)(Q)}))]})),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(P)},{children:[(0,a.jsx)("dt",Object.assign({className:(0,m.cx)(F)},{children:"Payment method:"})),(0,a.jsx)("dd",Object.assign({className:(0,m.cx)(L)},{children:Z}))]}))]})),(0,a.jsx)("a",Object.assign({className:(0,m.cx)(I,_),onClick:()=>{window.open(`/account.php?action=print_invoice&order_id=${e}`,"printInvoice","location=no,width=900,height=650,top=100")}},{children:"Print Invoice"}))]})),(0,a.jsxs)("section",Object.assign({className:(0,m.cx)(y)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(A)},{children:"Ship To"})),(0,a.jsxs)("ul",Object.assign({className:(0,m.cx)(N)},{children:[(0,a.jsxs)("li",{children:[null==X?void 0:X.firstName," ",null==X?void 0:X.lastName]}),(0,a.jsx)("li",{children:null==X?void 0:X.company}),(0,a.jsx)("li",{children:null==X?void 0:X.street1}),(null==X?void 0:X.street2)&&(0,a.jsx)("li",{children:X.street2}),(0,a.jsxs)("li",{children:[null==X?void 0:X.city,", ",null==X?void 0:X.state," ",null==X?void 0:X.zip]}),(0,a.jsx)("li",{children:null==X?void 0:X.country})]}))]})),(0,a.jsxs)("section",Object.assign({className:(0,m.cx)(y)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(A)},{children:"Bill To"})),(0,a.jsxs)("ul",Object.assign({className:(0,m.cx)(N)},{children:[(0,a.jsxs)("li",{children:[V.firstName," ",V.lastName]}),(0,a.jsx)("li",{children:V.company}),(0,a.jsx)("li",{children:V.street1}),V.street2&&(0,a.jsx)("li",{children:V.street2}),(0,a.jsxs)("li",{children:[V.city,", ",V.state," ",V.zip]}),(0,a.jsx)("li",{children:V.country})]}))]})),(0,a.jsxs)("section",Object.assign({className:(0,m.cx)(y)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(A)},{children:"Actions"})),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(C)},{children:[(0,a.jsx)("a",Object.assign({className:(0,m.cx)(I,_),onClick:()=>s(void 0,void 0,void 0,(function*(){if(0===q.length)return o.default.fire({text:"Please select one or more items to reorder.",icon:"error",showConfirmButton:!0});const e=[];q.forEach((t=>{const r=K[t];if(!r)return;const{productId:s,productOptions:n,quantity:a}=r;e.push({productId:s,productOptions:n,quantity:a})}));const t=[];e.forEach((({productId:e,productOptions:r,quantity:s})=>{const a={product_id:e,quantity:s,option_selections:r.map((({product_option_id:e,value:t})=>({option_id:e,option_value:t})))},i=n.reduce(((e,t)=>(e[t.id]||(e[t.id]=0),e[t.id]+=t.quantity,e)),{})[e]||0,c=p&&p[e];if(c||console.error("Could not find product"),i+s>((null==c?void 0:c.quantity)||1/0))return o.default.fire({title:"Could not Add Product to Cart",text:"There is not enough inventory available to fulfill your request.",icon:"error",showConfirmButton:!1,focusConfirm:!1,showCloseButton:!0});t.push(a)}));try{yield M({line_items:t})}catch(e){console.error("Error adding to cart",e),o.default.fire({icon:"error",text:"Sorry, there was a problem adding this product to cart."})}finally{U("/cart")}}))},{children:"Reorder"}))," ",(0,a.jsx)("a",Object.assign({className:(0,m.cx)(I,_),onClick:()=>D(e)},{children:"Return"}))]}))]}))]})),(0,a.jsx)("button",Object.assign({className:(0,m.cx)(I,_),onClick:R},{children:"Go back"}))]}))}},function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OrderMessages=void 0;const a=r(0),i=(r(1),r(3)),o=r(11),c=r(9),d=r(21),l=n(r(5)),u=n(r(7)),p=n(r(202)),m=r(2),{wrapper:h,wrapperHeading:f,wrapperMessages:g,wrapperMessagesItem:j,wrapperMessagesItemContent:x,wrapperMessagesItemContentRead:b,wrapperMessagesItemContentOrderStatus:v,wrapperMessagesItemContentProductTitle:w,wrapperForm:O,wrapperFormActions:y,wrapperButton:C,wrapperButtonSecondary:N}=p.default;t.OrderMessages=({orderId:e,goBack:t,orderMessages:r,getOrderMessages:n,getCurrentCustomer:p,getAllOrders:I})=>{const[_,A]=(0,i.useState)(!1),{createOrderMessage:S}=(0,o.useCustomerActions)(),{formData:P,setField:F,resetFields:L,validateFields:k}=(0,c.useValidationForm)({fields:{subject:"",message:""},validations:{subject:e=>!e&&"You must enter a subject.",message:e=>!e&&"You must enter a message."}}),B=(0,d.useOrderExist)({orderId:e,getAllOrders:I,goBack:t});if((0,i.useEffect)((()=>{B&&n(e).then((e=>{console.error("Error fetch order messages",e),p()}))}),[e,B]),!B)return(0,a.jsx)(u.default,{});const M=[{id:"subject",label:"Subject",required:!0,fieldState:P.subject},{id:"message",label:"Message",rows:"7",required:!0,fieldState:P.message}];return(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(h)},{children:[(0,a.jsx)("h3",Object.assign({className:(0,m.cx)(f)},{children:"Messages"})),Boolean(r.length)&&(0,a.jsx)("ul",Object.assign({className:(0,m.cx)(g)},{children:r.map(((e,t)=>{const{dateCreated:r,message:s,status:n,subject:i,type:o}=e,c=new Date(r).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),d=new Date(r).toLocaleTimeString("en-US",{hour:"numeric",minute:"numeric"});return(0,a.jsx)("li",Object.assign({className:(0,m.cx)(j)},{children:(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(x)},{children:[(0,a.jsx)("div",Object.assign({className:(0,m.cx)(v)},{children:(0,a.jsxs)("span",{children:[c," @ ",d]})})),(0,a.jsx)("h5",Object.assign({className:(0,m.cx)(w,b)},{children:i})),(0,a.jsxs)("p",Object.assign({className:(0,m.cx)("read"===n&&b)},{children:["admin"===o?(0,a.jsx)("span",{children:"Discount Electronics said:"}):(0,a.jsx)("span",{children:"You said:"})," ",(0,a.jsx)("span",{dangerouslySetInnerHTML:{__html:s}})]}))]}))}),t)}))})),(0,a.jsxs)("form",Object.assign({className:(0,m.cx)(O),onSubmit:t=>s(void 0,void 0,void 0,(function*(){var r,s;if(t.preventDefault(),_)return;const{values:n,errors:a}=yield k();if(!a){A(!0);try{yield S({subject:null!==(r=n.subject)&&void 0!==r?r:"",message:null!==(s=n.message)&&void 0!==s?s:"",orderId:e}),L()}catch(e){l.default.fire({icon:"error",text:e.message}),p()}A(!1)}}))},{children:[M.map((({id:e,label:t,rows:r,required:s,fieldState:n})=>(0,a.jsx)(c.Field,{id:e,rows:r,label:t,required:s,fieldState:n,onChange:F},e))),(0,a.jsxs)("div",Object.assign({className:(0,m.cx)(y)},{children:[(0,a.jsx)("button",Object.assign({className:(0,m.cx)(C),type:"submit",disabled:_},{children:_?"Loading...":"Send message"})),(0,a.jsx)("button",Object.assign({className:(0,m.cx)(C,N),type:"reset",onClick:L},{children:"Clear"}))]}))]})),(0,a.jsx)("button",Object.assign({className:(0,m.cx)(C,N),onClick:e=>{e.preventDefault(),t()}},{children:"Go back"}))]}))}},function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AddressNotification=void 0;const a=r(0),i=(r(1),n(r(207))),o=r(2),{wrapper:c,wrapperField:d,wrapperPhone:l,wrapperPhoneLabel:u,wrapperPhoneValue:p,wrapperActions:m,wrapperActionsButton:h,wrapperActionsButtonEdit:f,wrapperActionsButtonDelete:g}=i.default;t.AddressNotification=({address:e,deleteCustomerAddress:t,setAddressId:r})=>{const{id:n,firstName:i,lastName:j,city:x,country:b,company:v,stateOrProvince:w,address1:O,postalCode:y,address2:C,phone:N}=e,I=[`${i} ${j}`,v,O.replace(/\.$/,""),C,`${x}, ${w} ${y}`,b].filter(Boolean);return(0,a.jsxs)("li",Object.assign({className:(0,o.cx)(c)},{children:[I.map(((e,t)=>(0,a.jsx)("div",Object.assign({className:(0,o.cx)(d)},{children:e}),t))),(0,a.jsxs)("div",Object.assign({className:(0,o.cx)(l)},{children:[(0,a.jsx)("span",Object.assign({className:(0,o.cx)(u)},{children:"Phone:"})),(0,a.jsx)("span",Object.assign({className:(0,o.cx)(p)},{children:N}))]})),(0,a.jsxs)("div",Object.assign({className:(0,o.cx)(m)},{children:[(0,a.jsx)("button",Object.assign({className:(0,o.cx)(h,f),onClick:e=>{e.preventDefault(),r(n)}},{children:"Edit"})),(0,a.jsx)("button",Object.assign({className:(0,o.cx)(h,g),onClick:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield t(n)}))},{children:"Delete"}))]}))]}))}},function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProductCard=void 0;const a=r(0),i=(r(1),r(3)),o=r(2),c=n(r(5)),d=r(22),l=r(10),u=n(r(211)),p=r(2),m=r(176),{wrapper:h,wrapperLink:f,wrapperFigure:g,wrapperImagePositioner:j,wrapperImage:x,wrapperBody:b,wrapperTitle:v,button:w}=u.default;t.ProductCard=({product:e,addToCart:t,cart:r,modalSetPriceData:n,removeCtaButton:u,useHeadingTitle:O,className:y})=>{var C,N,I,_,A,S;const[P,F]=(0,i.useState)(!1),{images:L=[],defaultImage:k,price:B,displayPrice:M,prices:D,retailPrice:T,options:R=[],modifiers:E=[],isPreOrderOnly:q,inventoryLevel:H,inventoryTracking:U,productOptions:V}=e,Y=((null==V?void 0:V.edges)||R.concat(E)).length>0,K=L;let z="https://cdn11.bigcommerce.com/s-r4tr0/product_images/uploaded_images/image-coming-soon.jpg";if(k)z=(null==k?void 0:k.size320)||(null==k?void 0:k.url);else if(null===(N=null===(C=null==K?void 0:K[0])||void 0===C?void 0:C.node)||void 0===N?void 0:N.size320)z=null===(_=null===(I=null==K?void 0:K[0])||void 0===I?void 0:I.node)||void 0===_?void 0:_.size320;else if(null==K?void 0:K[0]){const e=(0,o.sortEntries)(K)[0];z=e.media?e.media.src:e.urlStandard}else z="https://cdn11.bigcommerce.com/s-r4tr0/product_images/uploaded_images/image-coming-soon.jpg";const G={price:(null===(A=null==D?void 0:D.price)||void 0===A?void 0:A.value)||B,displayPrice:M,retailPrice:(null===(S=null==D?void 0:D.retailPrice)||void 0===S?void 0:S.value)||T};let Q="";Q=q?"PreOrder":void 0!==H&&H<=0?"OutOfStock":"InStock","none"===U&&(Q="InStock");const W=a=>s(void 0,void 0,void 0,(function*(){var s;const i=[{product_id:e.id,quantity:1,option_selections:null!==(s=e.options)&&void 0!==s?s:[]}];try{if(F(!0),!Y&&"InStock"===Q){a.preventDefault();const s=(void 0!==r?r.items.reduce(((e,t)=>(e[t.id]||(e[t.id]=0),e[t.id]+=t.quantity,e)),{}):{})[e.id]||0,d=(0,o.combineVariantInventory)(e.variants.edges);if(d||console.error("[Cart State Error] - Could not find Cart Inventory State for Product",e.id),s+1>(d||1/0))return c.default.fire({title:"Could not Add Product to Cart",text:"There is not enough inventory available to fulfill your request.",icon:"error",showConfirmButton:!1,focusConfirm:!1,showCloseButton:!0});if(t&&(yield t({line_items:i})),"undefined"!=typeof window)if(window.dataLayer){const t={name:e.name,id:e.id,price:e.price,brand:e.brand&&e.brand.name||"Discount Electronics",quantity:1};if(window.dataLayer.push({event:"add-to-cart",ecommerce:{currencyCode:"USD",add:{products:[t]}}}),window._learnq){const t={Name:e.name,ProductID:e.id,ImageURL:z,URL:e.url,Brand:e.brand&&e.brand.name||"Discount Electronics",Price:e.price,CompareAtPrice:e.retailPrice};window._learnq.push(["track","Added to Cart",t])}}else console.error("[Google Tag Manager Error] - Could Not Find DataLayer Object to Push To.");n&&n({modalIsOpen:!0,product:e})}}catch(e){console.log("Error adding to cart",e),c.default.fire({icon:"error",text:"Sorry, there was a problem adding this product to cart."})}finally{F(!1)}}));return(0,a.jsxs)("li",Object.assign({className:(0,p.cx)(h,y)},{children:[(0,a.jsxs)("a",Object.assign({className:f,href:(null==e?void 0:e.path)||(null==e?void 0:e.url),"aria-label":e.name},{children:[(0,a.jsx)("figure",Object.assign({className:g},{children:(0,a.jsx)("div",Object.assign({className:j},{children:k?(0,a.jsx)("img",{className:x,src:z,width:"25",alt:e.name}):(0,a.jsx)("img",{src:z,width:"25",className:x,alt:e.name,srcSet:(0,m.generateSrcSet)(z)})}))})),(0,a.jsxs)("div",Object.assign({className:b},{children:[O?(0,a.jsx)("h5",Object.assign({className:v},{children:e.name})):(0,a.jsx)("p",Object.assign({className:v},{children:e.name})),(0,a.jsx)(l.PriceComponent,{priceData:G})]}))]})),(0,a.jsx)(d.ShowPercentageOff,{price:B,displayPrice:M,retailPrice:T,options:{dealsOfTheDay:!0}}),!u&&(()=>{const{buttonURL:t,buttonText:r}=(()=>{const t=(null==e?void 0:e.path)||e.url;return P?{buttonURL:t,buttonText:"Adding to Cart..."}:"OutOfStock"===Q?{buttonURL:t,buttonText:"Out of Stock"}:"PreOrder"===Q?{buttonURL:t,buttonText:"Pre Order"}:Y?{buttonURL:t,buttonText:"Choose Options"}:{buttonURL:t,buttonText:"Add to Cart"}})();return(0,a.jsx)("a",Object.assign({className:w,onClick:W,href:t,"aria-label":r},{children:r}))})()]}))}},function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),i=(r(1),r(3)),o=n(r(5)),c=r(9),d=r(11),l=r(8),u=n(r(213)),{wrapper:p,wrapperForm:m,wrapperFormFields:h,wrapperFormActions:f,wrapperFormActionsButton:g}=u.default;t.default=({currentCustomer:e,changeCustomerAccountSettings:t})=>{var r,n,u,j,x;const{push:b}=(0,l.useRouter)(),{getCustomer:v}=(0,d.useCustomerActions)(),{formData:w,setFormData:O,setField:y,validateFields:C}=(0,c.useValidationForm)({fields:{firstName:null!==(r=null==e?void 0:e.firstName)&&void 0!==r?r:"",lastName:null!==(n=null==e?void 0:e.lastName)&&void 0!==n?n:"",email:null!==(u=null==e?void 0:e.email)&&void 0!==u?u:"",phone:null!==(j=null==e?void 0:e.phone)&&void 0!==j?j:"",company:null!==(x=null==e?void 0:e.company)&&void 0!==x?x:"",newPassword:"",confirmPassword:""},validations:{firstName:e=>!e&&"You must enter a first name.",lastName:e=>!e&&"You must enter a last name.",email:e=>c.validate.email(e)&&"You must enter a valid email.",newPassword:e=>Boolean(e)&&(c.validate.minLength(e,7)||c.validate.charAndNum(e))&&"Passwords must be at least 7 characters and contain both alphabetic and numeric characters.",confirmPassword:(e,t)=>e!==t.newPassword&&"Your passwords do not match."}}),[N,I]=(0,i.useState)(!1);(0,i.useEffect)((()=>{(null==e?void 0:e.firstName)&&(null==e?void 0:e.lastName)&&(null==e?void 0:e.email)&&(null==e?void 0:e.phone)&&O({firstName:e.firstName,lastName:e.lastName,email:e.email,phone:e.phone,company:e.company})}),[e]);const _=[{id:"firstName",label:"First Name",fieldState:w.firstName},{id:"lastName",label:"Last Name",fieldState:w.lastName},{id:"company",label:"Company",fieldState:w.company},{id:"phone",label:"Phone Number",fieldState:w.phone},{id:"email",label:"Email Address",fieldState:w.email},{id:"newPassword",label:"Password",fieldState:w.newPassword},{id:"confirmPassword",label:"Confirm Password",fieldState:w.confirmPassword}];return(0,a.jsx)("div",Object.assign({className:p},{children:(0,a.jsxs)("form",Object.assign({className:m,onSubmit:r=>s(void 0,void 0,void 0,(function*(){r.preventDefault();const{values:s,errors:n}=yield C();if(console.log("values",s,"errors",n),!(Object.keys(n).length>0))try{I(!0);const{firstName:r,lastName:n,email:a,phone:i,company:c,newPassword:d,confirmPassword:l}=s;if(d&&d!==l&&o.default.fire({icon:"error",text:"Your new passwords do not match!"}),!(null==e?void 0:e.entityId))return;const u=yield t({customer:{id:e.entityId,first_name:r,last_name:n,email:a,phone:i,company:c,authentication:d?{new_password:d}:void 0}}),{customer:p,errors:m}=u;(e=>{if(e){const t=Object.entries(e);Array.isArray(e)&&e.length>0?(e.map((({message:e})=>e)).join(" - "),console.log("Trigger Error Notification(allErrorsString))")):t.length>0&&console.log("Trigger Error Notification(entries[0][1]))")}})(m),p&&o.default.fire({icon:"info",text:"Account Settings Changed"}),I(!1)}catch(e){console.log(e),o.default.fire({icon:"error",text:`There was an error updating your account data: ${e.message}`}),I(!1),v()}}))},{children:[(0,a.jsx)("div",Object.assign({className:h},{children:_.map((({id:e,label:t,fieldState:r})=>(0,a.jsx)(c.Field,{id:e,half:!0,label:t,fieldState:r,onChange:y},e)))})),(0,a.jsx)("div",Object.assign({className:f},{children:(0,a.jsx)("input",{className:g,type:"submit",value:N?"Loading...":"Update Details","aria-label":"Update Details",disabled:N})}))]}))}))}},,,,,,,,,,,,,,function(e,t,r){var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,a){function i(e){try{c(s.next(e))}catch(e){a(e)}}function o(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useOrderReturn=void 0;const n=r(3),a=r(11),i=r(85);t.useOrderReturn=e=>{const{getCustomer:t}=(0,a.useCustomerActions)(),[r,o]=(0,n.useState)({products:[],reasons:[],actions:[],reasonFieldName:"",actionFieldName:"",commentsFieldName:"",error:null,isFetching:Boolean(e)}),c=(0,n.useRef)(r.isFetching);c.current=r.isFetching;const d=(0,n.useCallback)((({orderId:e,reason:r,action:n,comments:a,quantity:o})=>s(void 0,void 0,void 0,(function*(){if(e)return(0,i.getRestApiToken)().then((t=>{const s=new FormData;return s.append("order_id",e.toString()),s.append("return_reason",r),s.append("return_action",n),s.append("return_comments",a),s.append("authenticity_token",t||""),Object.keys(o).forEach((e=>{s.append(e,o[e])})),fetch("/account.php?action=save_new_return",{method:"POST",body:s})})).then((e=>/login\.php/.test(e.url)?Promise.reject():e.text())).then((e=>{const t=e.replace(/\n|\r/g,"").replace(/\s\s+/g,"");if(!/account-row/.test(t))return{};const r=t.replace(/.*"account-row">/,"").replace(/<\/div>.*/,"");return{message:r.replace(/<\/p>.*/,"").replace(/
/,""),address:r.replace(/.*
/,"").replace(/<\/p>/,"")}})).catch((()=>t()))}))),[]),l=(0,n.useCallback)((e=>fetch(`/account.php?action=new_return&order_id=${e}`).then((e=>/login\.php/.test(e.url)?Promise.reject("Error: Not logged in"):e.text())).then((e=>{const t=e.replace(/\n|\r/g,"").replace(/\s\s+/g,"").replace(/.*
.*/,"");if(/data-account-return-form/.test(t)){const e=(0,i.parseSelect)("return_reason",t),r=(0,i.parseSelect)("return_action",t);return{products:t.replace(/.*class="table-tbody">/,"").replace(/<\/tbody>.*/,"").split("