1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="564c572b-44d2-451c-816e-9c59a1e39909",e._sentryDebugIdIdentifier="sentry-dbid-564c572b-44d2-451c-816e-9c59a1e39909")}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9884],{38332:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return v}});var s=r(72985),n=r(95767),a=r(4824),o=r.n(a),i=r(50959),c=r(35061),l=r(38404),u=r(57134),d=r(54165),h=r(16988),m=r(45176),b=r(55863),f=r.n(b),p=r(11527);function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach(function(t){(0,n.Z)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var y=[{title:"Subscriptions",url:"/account/subscriptions"},{title:"Browse consumables",url:"/account/subscriptions/browse"}];function j(e){var t=e.address||{},r=[t.street,t.city,t.state,t.zip].filter(Boolean).join(", ");return e.title?"".concat(e.title," â ").concat(r):r}var x=function(e){var t,r,a,b,_=e.forYourAppliances,x=e.products,v=e.frequencies,w=e.addresses,N=e.cards,k=e.loadError,S=(0,c.useRouter)(),D=(0,i.useState)(""),O=D[0],M=D[1],P=(0,i.useState)({}),q=P[0],E=P[1],C=(0,i.useState)((null===(t=v[0])||void 0===t?void 0:t.id)||""),L=C[0],F=C[1],T=(0,i.useState)((null===(r=w.find(function(e){return e.isDefaultShipping})||w[0])||void 0===r?void 0:r.id)||""),B=T[0],R=T[1],I=(0,i.useState)((null===(a=w.find(function(e){return e.isDefaultBilling})||w[0])||void 0===a?void 0:a.id)||""),Y=I[0],W=I[1],Z=(0,i.useState)((null===(b=N[0])||void 0===b?void 0:b.id)||""),H=Z[0],z=Z[1],G=(0,i.useState)([]),J=G[0],U=G[1],A=(0,i.useState)(!1),V=A[0],X=A[1],$=(0,i.useMemo)(function(){var e=O.trim().toLowerCase();return e?x.filter(function(t){return"".concat(t.name," ").concat(t.brand," ").concat(t.sku).toLowerCase().includes(e)}):x},[x,O]),K=Object.keys(q).filter(function(e){return q[e]>0}),Q=K.length>0&&L&&B&&Y&&H&&!V;function ee(e,t){E(function(r){return g(g({},r),{},(0,n.Z)({},e,Math.max(0,t)))})}function et(e){var t,r,s=q[e.sku]||0,n=(0,d.jo)(e.image);return(0,p.jsxs)("div",{className:f().product,"data-selected":s>0?"true":"false",children:[(0,p.jsxs)("div",{className:f().productMain,children:[(0,p.jsx)("div",{className:f().thumb,children:n?(0,p.jsx)(u.default,{alt:e.name||e.sku,src:n,width:150}):(0,p.jsx)("div",{className:f().thumbEmpty,"aria-hidden":"true"})}),(0,p.jsxs)("div",{className:f().productInfo,children:[(0,p.jsx)(l.xv,{className:f().brand,color:"dark-grey",noDefaultMargin:!0,children:e.brand}),(0,p.jsx)(l.xv,{className:f().productName,color:"aj-blue",theme:"bodycopy-semi-bold",noDefaultMargin:!0,children:e.name||e.sku}),(0,p.jsx)(l.xv,{className:f().sku,color:"dark-grey",noDefaultMargin:!0,children:e.sku})]})]}),!!(null!==(r=e.fits)&&void 0!==r&&r.length)&&(0,p.jsx)("div",{className:f().fits,children:e.fits.map(function(e){var t=(0,d.jo)(e.image);return(0,p.jsxs)("div",{className:f().fitsRow,children:[t&&(0,p.jsx)(u.default,{alt:e.name||e.sku,className:f().fitsThumb,src:t,width:80}),(0,p.jsxs)("span",{className:f().fitsText,children:["Fits your ",(0,p.jsxs)("strong",{children:[e.brand||""," ",e.sku]})]})]},e.sku)})}),(0,p.jsxs)("div",{className:f().productFoot,children:[(0,p.jsx)(l.xv,{className:f().price,color:"aj-blue",noDefaultMargin:!0,children:null==(t=e.price)?"":"$".concat(Number(t).toFixed(2))}),(0,p.jsxs)("div",{className:f().qtyRow,children:[(0,p.jsx)("button",{type:"button",className:f().qtyButton,"aria-label":"Remove one ".concat(e.sku),onClick:function(){return ee(e.sku,s-1)},children:"â"}),(0,p.jsx)("span",{className:f().qty,children:s}),(0,p.jsx)("button",{type:"button",className:f().qtyButton,"aria-label":"Add one ".concat(e.sku),onClick:function(){return ee(e.sku,s+1)},children:"+"})]})]})]},e.sku)}function er(){return(er=(0,s.Z)(o().mark(function e(){var t,r,s;return o().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return X(!0),U([]),e.prev=2,e.next=5,fetch("".concat("https://www.ajmadison.com","/papi/account/subscriptions/create/"),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({frequency_id:Number(L),start_date:function(e){var t=new Date;if(e){var r=Number(e.time_number)||1;"year"===e.time_unit?t.setFullYear(t.getFullYear()+r):"week"===e.time_unit?t.setDate(t.getDate()+7*r):t.setMonth(t.getMonth()+r)}return"".concat(t.getFullYear(),"-").concat(String(t.getMonth()+1).padStart(2,"0"),"-").concat(String(t.getDate()).padStart(2,"0"))}(v.find(function(e){return Number(e.id)===Number(L)})),delivery_address_id:Number(B),billing_address_id:Number(Y),payment_method_id:Number(H),items:K.map(function(e){return{sku:e,quantity:q[e]}})})});case 5:return t=e.sent,e.next=8,t.json();
1case 8:if(r=e.sent,!(!t.ok||!1===r.success)){e.next=12;break}return U(null!==(s=r.messages)&&void 0!==s&&s.length?r.messages:[r.message||"We could not start that subscription"]),e.abrupt("return");case 12:S.push("/account/subscriptions"),e.next=18;break;case 15:e.prev=15,e.t0=e.catch(2),U(["We could not reach the server. Please try again."]);case 18:return e.prev=18,X(!1),e.finish(18);case 21:case"end":return e.stop()}},e,null,[[2,15,18,21]])}))).apply(this,arguments)}var es=!N.length||!w.length;return(0,p.jsx)(m.Z,{title:"Browse consumables",children:(0,p.jsxs)(h.Z,{crumbs:y,children:[(0,p.jsx)(l.H,{type:"h3",color:"aj-blue",noDefaultMargin:!0,children:"Start a subscription"}),(0,p.jsx)(l.xv,{color:"dark-grey",children:"Pick what you want on repeat and how often it should arrive."}),!!k&&(0,p.jsx)(l.xv,{className:f().error,theme:"h4",children:"We could not load the catalogue right now. Please refresh the page."}),!w.length&&(0,p.jsxs)(l.xv,{className:f().error,noDefaultMargin:!0,children:["Add an address to your"," ",(0,p.jsx)(l.rU,{color:"aj-blue",to:"/account/addresses",children:"address book"})," ","first."]}),!N.length&&(0,p.jsxs)(l.xv,{className:f().error,noDefaultMargin:!0,children:["Save a card in"," ",(0,p.jsx)(l.rU,{color:"aj-blue",to:"/account/payment-methods",children:"payment methods"})," ","first â subscriptions are billed automatically."]}),!!J.length&&(0,p.jsx)("ul",{className:f().errorList,children:J.map(function(e){return(0,p.jsx)("li",{children:e},e)})}),!es&&(0,p.jsxs)(p.Fragment,{children:[!!_.length&&(0,p.jsxs)("section",{className:f().section,children:[(0,p.jsx)(l.H,{type:"h4",color:"aj-blue",noDefaultMargin:!0,children:"For appliances you own"}),(0,p.jsx)(l.xv,{className:f().sectionNote,color:"dark-grey",noDefaultMargin:!0,children:"Replacements matched to what youâve bought from us."}),(0,p.jsx)("div",{className:f().grid,children:_.map(et)})]}),(0,p.jsxs)("section",{className:f().section,children:[(0,p.jsx)(l.H,{type:"h4",color:"aj-blue",noDefaultMargin:!0,children:_.length?"Browse everything else":"Browse consumables"}),(0,p.jsx)("input",{type:"search",className:f().search,placeholder:"Search filters, bags and accessories",value:O,onChange:function(e){return M(e.target.value)},"aria-label":"Search eligible consumables"}),(0,p.jsx)("div",{className:f().grid,children:$.map(et)})]}),!$.length&&(0,p.jsx)(l.xv,{className:f().sectionNote,color:"dark-grey",children:O?"Nothing matches â".concat(O,"â."):"No consumables are available yet."}),(0,p.jsxs)("div",{className:f().summary,children:[(0,p.jsx)(l.H,{type:"h4",color:"aj-blue",noDefaultMargin:!0,children:"Schedule"}),(0,p.jsxs)("label",{className:f().field,htmlFor:"frequency",children:[(0,p.jsx)("span",{className:f().fieldLabel,children:"Reorder every"}),(0,p.jsx)("select",{id:"frequency",className:f().select,value:L,onChange:function(e){return F(e.target.value)},children:v.map(function(e){return(0,p.jsx)("option",{value:e.id,children:e.name},e.id)})})]}),(0,p.jsxs)("label",{className:f().field,htmlFor:"delivery",children:[(0,p.jsx)("span",{className:f().fieldLabel,children:"Deliver to"}),(0,p.jsx)("select",{id:"delivery",className:f().select,value:B,onChange:function(e){return R(e.target.value)},children:w.map(function(e){return(0,p.jsx)("option",{value:e.id,children:j(e)},e.id)})})]}),(0,p.jsxs)("label",{className:f().field,htmlFor:"billing",children:[(0,p.jsx)("span",{className:f().fieldLabel,children:"Bill to"}),(0,p.jsx)("select",{id:"billing",className:f().select,value:Y,onChange:function(e){return W(e.target.value)},children:w.map(function(e){return(0,p.jsx)("option",{value:e.id,children:j(e)},e.id)})})]}),(0,p.jsxs)("label",{className:f().field,htmlFor:"card",children:[(0,p.jsx)("span",{className:f().fieldLabel,children:"Pay with"}),(0,p.jsx)("select",{id:"card",className:f().select,value:H,onChange:function(e){return z(e.target.value)},children:N.map(function(e){return(0,p.jsxs)("option",{value:e.id,children:[e.cc_type," ending ",e.last_4_digits]},e.id)})})]}),(0,p.jsx)(l.xv,{className:f().legal,color:"dark-grey",noDefaultMargin:!0,children:"Your first shipment is scheduled one full interval from today. Weâll email you 5 days before each shipment, and you can skip, reschedule or cancel at no charge."}),(0,p.jsx)(l.zx,{theme:"button-primary",onClick:function(){return er.apply(this,arguments)},disabled:!Q,children:V?"Startingâ¦":"Start subscription".concat(K.length>1?" (".concat(K.length," items)"):"")})]})]})]})})},v=!0;x.__docgenInfo={description:"",methods:[],displayName:"Browse"},t.default=x},46718:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/account/subscriptions/browse",function(){return r(38332)}])},55863:function(e){e.exports={search:"browse_search__WLGkP",grid:"browse_grid__1s4kL",product:"browse_product__x2hyo",productMain:"browse_productMain__mh2Bj",thumb:"browse_thumb__8w_4P",fitsThumb:"browse_fitsThumb__VmJuX",fitsRow:"browse_fitsRow__8JM_s",thumbEmpty:"browse_thumbEmpty__eabGG",productInfo:"browse_productInfo__b_OEa",brand:"browse_brand__gME5Y",productName:"browse_productName__OYg7i",sku:"browse_sku__OV_yJ",fits:"browse_fits__mOCCV",fitsText:"browse_fitsText__WhURg",productFoot:"browse_productFoot__n6Pvg",price:"browse_price__1gzpY",qtyRow:"browse_qtyRow__h_lad",qtyButton:"browse_qtyButton__vGouT",qty:"browse_qty__dnaEp",summary:"browse_summary__Z2TZ0",field:"browse_field__s_Nw7",fieldLabel:"browse_fieldLabel__RLILt",select:"browse_select__s0fqn",legal:"browse_legal__u5yty",error:"browse_error__IHScq",errorList:"browse_errorList__WRz_7",section:"browse_section__1oasD",sectionNote:"browse_sectionNote__ESU43"}}},function(e){e.O(0,[8429,1486,6299,1385,1889,8776,3131,2991,6988,2888,9774,179],function(){return e(e.s=46718)}),_N_E=e.O()}]);
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.