PageSourceSearch

https://www.brooklinen.com/cdn/shop/t/4799/assets/brooklinen-page.js?v=10931453778345322811790085253

js brooklinen.com collected 2026-09-24 17:40:02 UTC 16,329 bytes, 2 lines download raw bytes

1import{h as $,u as R,C as j}from"./Swym-ddbcf3a1.js";import{a as N,p as q}from"./PubSub-1076bb07.js";import{R as O}from"./rewardsTableSlider-74e341bb.js";import"./DuoShop-74b49a8a.js";import"./splide.esm-688b6f4b.js";function _(o,t,e,a){const s=window.pageYOffset,n=t.offsetTop,r=t.offsetHeight,l=window.innerHeight;if(s+l>n&&s<n+r){const m=`translate3d(0, ${(s-n+l)*-a}px, 0)`;o.style.transform=m}}function U(){document.querySelectorAll(".parallax__layer").forEach(t=>{const e=parseFloat(t.getAttribute("data-speed")),a=t.closest(".parallax");_(t,a,window.pageYOffset,e),window.addEventListener("scroll",()=>{_(t,a,window.pageYOffset,e)})})}function z(){var n;const o=(n=window.Brooklinen)==null?void 0:n.parallax[0].config,t=document.querySelector(`#${o.id} .h_1`),e=document.querySelector(`#${o.id} .p_1`),a=document.querySelector(`#${o.id} .parallax__background-desktop`),s=document.querySelector(`#${o.id} .parallax__background-mobile`);t.innerHTML=o?.header,t.style.color=o?.headerColor,e.innerHTML=o?.subtext,e.style.color=o?.headerColor,a.setAttribute("src",o?.bgDesktop),s.setAttribute("src",o?.bgMobile)}function F(){document.addEventListener("dy:module:parallax",z),window.addEventListener("load",U)}class Y{constructor(t){this.elements={overlay:t,html:document.documentElement},this.submittedEmail=null,this.submittedPhone=null,this.init()}init(){this.ctaBtnEvtListeners()}ctaBtnEvtListeners(){this.elements.overlay.querySelectorAll(".cta_positive").forEach(e=>{e.addEventListener("click",a=>{a.preventDefault();const s=e.closest(".steps--item");s.querySelector(".js-bfcm-input")?this.validateInput(s):this.goToNextStep(s)})})}validateInput(t){const e=t.querySelector(".js-bfcm-input").type,a=t.querySelector(`.js-bfcm-input[type="${e}"]`);if({tel:/^1? ?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,email:/^[^\s@]+@[^\s@]+\.[^\s@]+$/}[e].test(a.value)){const r=e==="tel"?this.formatPhoneE164(a.value):a.value;t.querySelector("form").classList.add("email-capture--loading"),e==="tel"?(this.submittedPhone=r,this.phoneSubmit(r,t)):(this.submittedEmail=r,this.emailSubmit(r,t))}else this.outputError(e,t)}formatPhoneE164(t){const e=t.replace(/\D/g,"");return`+1${e.length===11?e.slice(1):e}`}outputError(t,e){e.querySelectorAll(".js-bfcm-input").forEach(m=>m.classList.remove("error")),e.querySelectorAll(".email-input--message").forEach(m=>m.ariaHidden=!0);let n="";t=="tel"?n="Enter a valid phone number":t=="emailExists"?n="Oops! That email address is already in use.":n="Enter a valid email address.";const r=e.querySelector("form"),l=e?.querySelector(`.js-bfcm-input[type="${t}"]`),f=r.querySelector(".input-message");l?.classList.add("error"),f.innerHTML=n,f.ariaHidden=!1}goToNextStep(t){const e=t.nextElementSibling;e&&e.classList.contains("steps--item")&&(t.classList.remove("active"),t.style.display="none",e.classList.add("active"),e.style.display="flex",this.setTabNavBehavior(e))}phoneSubmit(t,e){var l,f,m;const a=e.querySelector(".js-bfcm-input").getAttribute("data-keyword")||"TXTBFCM",s=e.querySelector(".js-bfcm-input").getAttribute("data-cookie")||((m=(f=(l=window?.Brooklinen)==null?void 0:l.themeSettings)==null?void 0:f.gatedCookie)==null?void 0:m.name),n=e.querySelector("form"),r={phone:t,sourceId:"1365204"};this.submittedEmail&&(r.email=this.submittedEmail),fetch("https://5w2edfby7e.execute-api.us-west-2.amazonaws.com/subscribe",{method:"POST",mode:"cors",headers:{"content-type":"application/json; charset=utf-8"},body:JSON.stringify(r)}).then(S=>S.json()).then(()=>{var S,g,p,b,y,v;try{window.heap.track("SMS Optin",{phone:t,signup_source:a})}catch(w){throw new Error(`Heap tracking failed: ${w}`)}if(s!==""){const w=(p=(g=(S=window?.Brooklinen)==null?void 0:S.themeSettings)==null?void 0:g.gatedCookie)!=null&&p.expiration?new Date((v=(y=(b=window?.Brooklinen)==null?void 0:b.themeSettings)==null?void 0:y.gatedCookie)==null?void 0:v.expiration):null;N.set(s,!0,{expires:w})}n.classList.remove("email-capture--loading"),this.goToNextStep(e)}).catch(S=>{throw n.classList.remove("email-capture--loading"),new Error(`Subscribe API error: ${S}`)})}emailSubmit(t,e){const a=e.querySelector("form"),s="EMBFCM",n={email:t,sourceId:"1365204"};this.submittedPhone&&(n.phone=this.submittedPhone),fetch("https://5w2edfby7e.execute-api.us-west-2.amazonaws.com/subscribe",{method:"POST",mode:"cors",headers:{"content-type":"application/json; charset=utf-8"},body:JSON.stringify(n)}).then(r=>r.json()).then(r=>{var g,p;const l=new $("SHA-256","TEXT");l.update(t.toLowerCase());const f=l.getHash("HEX");window.dataLayer=window.dataLayer||[],window.dataLayer.push({submittedEmail
1:f}),window.dataLayer.push({event:"dl_subscribe",formLocation:"bfcm_ecap"});const m=(g=r?.subscriptionResponses)==null?void 0:g.find(b=>{var y;return((y=b.subscription)==null?void 0:y.channel)==="EMAIL"});if(m?.subscriptionCreationStatus!=="PREVIOUSLY_CREATED"||!((p=window?.Brooklinen)!=null&&p.ometriaErrorHandling)){try{window.heap.track("Email Optin",{email:t,signup_source:s})}catch(b){throw new Error(`Heap tracking failed: ${b}`)}this.goToNextStep(e)}else this.outputError("emailExists",document.querySelector("#bfcm .steps-wrapper"));return a.classList.remove("email-capture--loading"),r}).catch(r=>{throw a.classList.remove("email-capture--loading"),new Error(`Subscribe API error: ${r}`)})}}class W{constructor(t){this.dom={body:t,instructions:t.querySelectorAll(".instruction"),addToCarts:t.querySelectorAll(".atc")},this.mountAtcListeners(),this.mountReadMoreListener()}mountAtcListeners(){const{addToCarts:t}=this.dom;t.forEach(e=>{e.addEventListener("click",a=>{a.preventDefault();const s=e.dataset.variant,n=new CustomEvent("cart:requestStarted"),l=document.querySelector(".site-header").querySelector(".vue-portal-target .site-header__cart a");s&&fetch("/cart/add.js",{method:"POST",quantity:1,id:s.toString()}).then(()=>{alert("Success!"),document.dispatchEvent(n),l&&l.click()})})})}mountReadMoreListener(){const{instructions:t}=this.dom;t.forEach(e=>{const a=e.querySelector(".read-more");a?.addEventListener("click",()=>{e.classList.contains("expanded")?e.classList.remove("expanded"):e.classList.add("expanded")})})}}function G(){const o=document.querySelector("#tradeForm"),t=document.querySelector(".forms-header"),e=o.querySelector("#tradeSubmit"),a=t.querySelector(".instructions"),s=t.querySelector(".thank-you"),n=document.querySelector("#tradeDocuments"),r=document.querySelector("#tradeDocumentList"),l=document.querySelector("#tradeDocumentError"),f=o.querySelector("[data-toggle-value='trade']"),m=o.querySelector("[data-toggle-value='hospitality']"),S=o.querySelector("[data-toggle-group='trade']"),g=o.querySelector("[data-toggle-group='hospitality']");f.addEventListener("click",()=>{S.classList.remove("hide"),g.classList.add("hide")}),m.addEventListener("click",()=>{g.classList.remove("hide"),S.classList.add("hide")});let p=new DataTransfer;const b=()=>{r.innerHTML="";for(const c of p.files){const u=document.createElement("li");u.className="document-upload__file-item";const h=document.createElement("span");h.className="document-upload__file-name p6",h.textContent=c.name;const i=document.createElement("button");i.type="button",i.className="document-upload__file-remove p6",i.textContent="Remove",i.setAttribute("aria-label",`Remove ${c.name}`),i.addEventListener("click",()=>{const L=new DataTransfer;for(const E of p.files)E.name!==c.name&&L.items.add(E);p=L,n.files=p.files,b()}),u.appendChild(h),u.appendChild(i),r.appendChild(u)}};n.addEventListener("change",()=>{for(const c of n.files)p.items.add(c);n.files=p.files,b(),l.textContent=""});const y=c=>{if(!c||c.trim().length<3)return!1;const u=6;return c.trim().split(/\s+/).some(h=>{if(h.length<u)return!1;if(/[bcdfghjklmnpqrstvwxyz]{7,}/i.test(h)||/[a-z][A-Z].*[a-z][A-Z]/.test(h))return!0;const i=h.replace(/[^a-z]/gi,"");if(!i.length)return!1;const L=(i.match(/[aeiou]/gi)||[]).length/i.length;return L<.2||L>.7})},v=(c,u)=>["CompanyName","CompanyAddressLine1","CompanyAddressLine2"].includes(c)&&u.length>20&&!u.includes(" "),w=()=>{const c=["image/jpeg","image/png","application/pdf"],h=Array.from(p.files);if(h.length===0)return l.textContent="Please upload at least one supporting document.",!1;for(const i of h){if(!c.includes(i.type))return l.textContent=`"${i.name}" is not an accepted format. Please upload JPG, PNG, or PDF files only.`,!1;if(i.size>10485760)return l.textContent=`"${i.name}" exceeds the 10 MB size limit.`,!1}return l.textContent="",!0},D=()=>{const c=new FormData;for(const i of o.querySelectorAll("input[type='text']"))i.id!=="website_url"&&c.append(i.name,i.value);for(const i of["ProductScope","HearAboutUs"])for(const L of o.querySelectorAll(`input[name="${i}"]:checked`))c.append(`${i}[]`,L.value);const u=o.querySelector('input[name="TaxExempt"]:checked');u&&c.append("TaxExempt",u.value);const h=o.querySelector('input[name="accountType"]:checked');h&&c.append("accountType",h.value);for(const i of p.files)c.append("documents[]",i);return c},I=async c=>{const u=await fetch("https://services.brooklinen.com/api/v1/trade_applications",{method:"POST",headers:{Accept:"application/json"},body:c});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`)};e.addEventListener("click",async c=>{if(c.preventDefault(),e.disabled)return;const u=o.querySelector("#website_url");
1if(u&&u.value!=="")return;const h=o.querySelectorAll("input[type='text']"),i=Array.from(h).filter(d=>d.matches("[required]"));for(const d of i)d.value===""?d.classList.add("invalid"):d.classList.remove("invalid");const L=["EmailAddress","PhoneNumber","CompanyLinksLine1","CompanyLinksLine2","CompanyAddressLine1","CompanyAddressLine2"],E=2,x=i.filter(d=>{if(L.includes(d.name))return!1;const T=d.value.trim();return T&&(y(T)||v(d.name,T))}),C=x.length>=E;if(C)for(const d of x)d.classList.add("invalid");const B=!(o.querySelectorAll(".invalid").length>0)&&w();if(C&&alert("Please enter valid information in all fields. Some entries appear to be invalid."),!B)return;e.disabled=!0;const P=e.textContent.trim();e.textContent="Submitting...",await new Promise(d=>setTimeout(d,0));for(const d of o.querySelectorAll("input"))d.setAttribute("disabled","");const k=()=>{for(const d of o.querySelectorAll("input"))d.removeAttribute("disabled")};try{const d=D();await I(d),k(),window.dataLayer.push({event:"dl_corporate_gifting_form_submit"}),o.style.display="none",a.style.display="none",s.style.display="block"}catch(d){throw k(),e.disabled=!1,e.textContent=P,new Error(`Form submission failed. ${d}`)}})}class M extends HTMLElement{constructor(){super(),this.dom={json:this.querySelector(".product-grid-json"),grid:this.querySelector(".js-product-grid"),banner:this.querySelector(".WishlistResultsBanner")},this.state={items:[],isInitialized:!1},this.handleServiceUpdate=this.updateResults.bind(this)}get listContents(){return R.listContents}updateResults(){if(this.state.isInitialized||(q.unsubscribe("swym:service:ready",this.handleServiceUpdate),this.state.isInitialized=!0),this.state.items=this.listContents??[],this.state.items<=0){this.handleEmptyResults(!0);return}const t=this.state.items.reduce((e,a)=>{var n;const s={};return s.cardType="PRODUCT",s.handle=(n=a?.cprops)==null?void 0:n.handle,s.sku=a.sku,s.badgeText="",s.badgeAsset="",s.bundleMessaging="",s.exclusionMessaging="",e.push(s),e},[]);this.handleEmptyResults(),q.publish("swym:results:update",t)}handleEmptyResults(t=!1){var s,n;const e=(s=this.dom)==null?void 0:s.banner,a=(n=this.dom)==null?void 0:n.grid;t?(a.classList.add("hidden"),e.classList.add("WishlistResultsBanner--Active")):(a.classList.remove("hidden"),e.classList.remove("WishlistResultsBanner--Active"))}connectedCallback(){q.subscribe("swym:service:update",this.handleServiceUpdate),q.subscribe("swym:service:ready",this.handleServiceUpdate)}disconnectedCallback(){q.unsubscribe("swym:service:update",this.handleServiceUpdate),q.unsubscribe("swym:service:ready",this.handleServiceUpdate)}}customElements.define("wishlist-results",M);function V(o){const t=document.querySelector("#uaDisplay"),e=JSON.stringify(o,null,2);t.innerHTML=e,t.style.height=t.scrollHeight+"px"}function J(){const o=document.querySelector("#uaDisplay"),t=document.querySelector("#uaCta");o.select(),document.execCommand("copy"),t.innerHTML="Copied!"}function X(){setTimeout(()=>{document.querySelector("#uaCta").innerHTML="Copy to Clipboard"},1e3)}const A=async()=>{const t=document.body.classList.contains("js-siena-enabled");try{t?window.SienaLaunchWidget():window.Gladly.show()}catch(e){throw new Error(`Chat failed to load: ${e}`)}},H=()=>{var g,p,b;const o=document.querySelector(".yotpo-widget-hero-section"),t=document.querySelector(".rewards__header"),e=t.querySelector(".story"),a=t.querySelector(".story__headline"),s=t.querySelector(".story__subhead"),n=e.dataset.customerName,r="Work and daily life are exhausting\u2014finding comfort shouldn&apos;t be. So sit back, relax, and earn more while you shop.",l='When you become a Brooklinen Rewards member you can earn points for every dollar spent, get free shipping <a class="link" href="https://www.brooklinen.com/pages/faq?a=Does-Brooklinen-offer-free-US-shipping---id--1b50Cl_wSuiEqf4NUNMMOQ" target="_blank">see terms</a>, exclusive access to events, sales and more...',f="Welcome to the Crew",m=()=>{n!==""?(a.innerHTML=`${f}, ${n}!`,s.innerHTML=r,a.innerHTML=a.innerHTML.replace("{{first_name}}",n)):(a.innerHTML=`${f}!`,s.innerHTML=l)};if(o&&t){const y=o.querySelector(".yotpo-title");y&&(a.innerHTML=y.innerHTML),m();const v=o.querySelector(".yotpo-text-on-background").style.backgroundImage,w=v.slice(4,-1).replace(/["']/g,"");w&&(t.querySelector(".story__media-img").src=w),e.dataset.content="widget"}else m(),e.dataset.content="fallback";if((g=document.querySelector("[data-customer]"))!=null&&g.dataset.customer){const y=(p=window.Brooklinen.loyalty)==null?void 0:p.points_balance,v=(b=window.Brooklinen.loyalty)==null?void 0:b.vip_tier_name,w=v?` <span class="t4" data-color="afternoon-delight-medium">${v}</span> `:"";s.innerHTML.includes("{{current_point_balance}}")?s.innerHTML=s.innerHTML.replace("{{current_vip_tier_name}}",w).replace("{{current_point_balance}}",`<span class="t4" data-color="afternoon-delight-medium">${y}</span>`).replace("You're currently a","<br/> <br/> You're currently a"):s.innerHTML+=`<br/> <br/> You're currently a ${w} member with <span class="t4" data-color="afternoon-delight-medium">${y}</span> points.`}e.classList.remove("hidden"),t.querySelector(".Stencil").classList.add("hidden"),document.querySelector(".rewards__widgets").classList.remove("hidden")};document.addEventListener("DOMContentLoaded",()=>{if(q.broadcast(),new M,document.querySelectorAll(".js-category-module").forEach(s=>new j(s)),document.querySelectorAll(".js-parallax-module").forEach(s=>new F),document.querySelectorAll(".js-care-module").forEach(s=>new W(s)),document.querySelectorAll(".js-sms-ecap-module").forEach(s=>new Y(s)),window.location.pathname.includes("trade"))G();else if(window.location.pathname.includes("pages/rewards")){if(document.querySelector(".yotpo-widget-hero-section"))H();else{const n=new MutationObserver(()=>{document.querySelector(".yotpo-widget-hero-section")&&document.querySelector(".yotpo-title")&&(n.disconnect(),H())});n.observe(document.body,{childList:!0,subtree:!0})}const s=document.querySelector(".tier-compare-mobile");new O(s)}else window.location.pathname.includes("pages/cart-support")&&(setTimeout(()=>A(),0),document.querySelector(".themeHero .button--primary-inverse").addEventListener("click",
1s=>{s.preventDefault(),setTimeout(()=>A(),0)}),document.querySelector(".primaryHero .button--primary").addEventListener("click",s=>{s.preventDefault(),document.dispatchEvent(new CustomEvent("cart:request"))}));if(document.querySelector(".module--ua")){const n=new UAParser().getResult();delete n.ua,delete n.cpu;const r=setInterval(()=>{var l;typeof((l=window.DY)==null?void 0:l.Audiences)=="object"&&(n.debug=window.DY.Audiences.getUserAudiences().join(),n.device=window.DY.deviceInfo,V(n),clearInterval(r))},100);setTimeout(()=>clearInterval(r),1e4),document.querySelector("#uaCta").addEventListener("mouseup",J),document.querySelector("#uaCta").addEventListener("mouseout",X)}});
2//# sourceMappingURL=/cdn/shop/t/4799/assets/brooklinen-page.js.map?v=10931453778345322811790085253

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.