PageSourceSearch

https://muji.ca/cdn/shop/t/945/assets/inventory-by-location.min.js?v=4004481212932015491789070858

js muji.ca collected 2026-10-03 21:40:23 UTC 9,324 bytes, 1 lines download raw bytes

1(()=>{var p="filter.v.m.locationInventory.locations",S="region_id",y="canadianProvince",I=document.getElementById("MujiWarehouseLocations"),d={METROTOWN:{id:55947133081,name:"MUJI Metrotown",slug:"metrotown",provinces:I?.dataset?.warehouseMetrotown?.split(",")||[],default_province:I?.dataset?.warehouseMetrotown?.split(",")[0]||"BC"},ATRIUM:{id:55193239705,name:"MUJI Atrium",slug:"atrium",provinces:I?.dataset?.warehouseAtrium?.split(",")||[],default_province:I?.dataset?.warehouseAtrium?.split(",")[0]||"ON"}};function O(n){let o=new Date().getTime(),e={value:n,expiry:o+2592e6};localStorage.setItem(y,JSON.stringify(e))}function F(){let n=document.querySelectorAll(".province-selector");n.forEach(o=>{o.addEventListener("change",e=>{let t=e.target.value;O(t),n.forEach(r=>{r!==e.target&&(r.value=t)})})})}function g(n){let o=localStorage.getItem(n);if(!o)return null;let e=JSON.parse(o);return new Date().getTime()>e.expiry?(localStorage.removeItem(n),null):e.value}function U(n){document.querySelectorAll(".location-dropdown").forEach(e=>{let t=e.querySelector(".province-selector");if(!t)return;let r=n||"ON";t.disabled=!1,e.classList.remove("location-dropdown-loading"),t.value=r,t.removeAttribute("data-initial-load")})}function V(n){let o=L(n);if(!o)return;let e=document.querySelectorAll("footer a, .site-footer a, .footer a"),t=document.querySelectorAll(".site-navigation a, .site-header a, nav a, .main-navigation a"),r=document.querySelectorAll('[data-href*="/collections"]'),a=[...Array.from(e),...Array.from(t),...Array.from(r)].filter(c=>{let u=c.getAttribute("href"),l=c.getAttribute("data-href");return u&&u.includes("/collections")||l&&l.includes("/collections")}),s=(c,u)=>{let l=c.getAttribute(u);if(!(!l||!l.includes("/collections")))try{let f=l.startsWith("/")?new URL(l,window.location.origin):new URL(l);f.searchParams.get(p)!==o.location&&f.searchParams.set(p,o.location);let m=f.pathname+f.search;c.setAttribute(u,m)}catch(f){console.error("Error parsing URL:",l,f)}};return a.forEach(c=>{c.hasAttribute("href")&&c.getAttribute("href").includes("/collections")&&s(c,"href"),c.hasAttribute("data-href")&&c.getAttribute("data-href").includes("/collections")&&s(c,"data-href")}),document.querySelectorAll("[data-live-search-form]").forEach(c=>{let u=c.querySelector('input[name="filter.v.m.locationInventory.locations"]');u||(u=document.createElement("input"),u.type="hidden",u.name="filter.v.m.locationInventory.locations",c.insertBefore(u,c.firstChild)),u.value=o.location;let l=c.querySelector('input[name="type"]');l||(l=document.createElement("input"),l.type="hidden",l.name="type",l.value="product",c.insertBefore(l,u.nextSibling))}),a}function L(n){return d.ATRIUM.provinces.includes(n)?{location:d.ATRIUM.name,id:d.ATRIUM.id,slug:d.ATRIUM.slug}:d.METROTOWN.provinces.includes(n)?{location:d.METROTOWN.name,id:d.METROTOWN.id,slug:d.METROTOWN.slug}:null}function W(n,o){let e=n.find(t=>t.location.id===o);return e?e.quantity:0}function B(n){if(!document.getElementById("location-inventory-info"))return;let e=L(n);if(!e)return;let t=document.querySelectorAll(".lli-list-item");t&&t.forEach(r=>{r.dataset.locationName.toLocaleLowerCase().includes(e.location.toLocaleLowerCase())&&r.classList.remove("hide-lli")})}function P(n,o,e=["type","q"]){let t=new URLSearchParams;return t.append(p,o),e.forEach(r=>{n.has(r)&&t.append(r,n.get(r))}),n.forEach((r,i)=>{i!==p&&i!==S&&!e.includes(i)&&t.append(i,r)}),t}function M(n,o=!1,e=!1){let t=new URL(window.location.href),r=new URLSearchParams(t.search),i=L(n);if(i){if(o){if(r.has(p)){if(e){let a=P(r,i.location);t.search=a.toString()}else r.delete(p),r.delete(S),r.append(p,i.location),t.search=r.toString();window.history.replaceState(null,"",t.toString())}}else if(!r.has(p)){if(e){let s=P(r,i.location);t.search=s.toString()}else r.set(p,i.location),t.search=r.toString();window.history.replaceState(null,"",t.toString()),window.location.reload()}}}function R(n,o=!1){M(n,o,!1)}function C(n,o=!1){M(n,o,!0)}function x(n){let o=document.querySelectorAll(".productgrid--item"),e=L(n);Array.from(o).length===0||!e||o.forEach(t=>{let r=t.querySelector(".swatch-data");if(!r)return;let i=JSON.parse(r.innerHTML);t.querySelectorAll("label").forEach(s=>{let h=s.dataset.swatchColor;Object.entries(i.variants_quantity).filter(([l,f])=>f.color===h).reduce((l,[f,m])=>{let w=m.inventory_info.find(b=>b.location.id===e.id);return l+(w?w.quantity:0)},0)===0&&s.remove()})})}function T(n){let o=document.getElementById("inventory_info_metafield_data"),e=L(n);if(!o)return;let t=JSON.parse(o.dataset.inventoryInfoMetafieldData),r=JSON.parse(o.dataset.inventoryInfoTranslations);if(t=t.map(i=>{let a=i;return a.inventoryInfo=JSON.parse(a.inventoryInfo.replace(/&quoteFormat;/g,'"')),a}),!!t)return{inventoryInfoData:t,inventoryInfoTranslations:r,currentShippingLocation:e}}function _(n,o){let e={},t=[],i=document.querySelector("body[data-enable-hidden-variants]").getAttribute("data-enable-hidden-variants")==="true";if(!(!o||!i))return o.forEach(a=>{let s=a.option1;e[s]||(e[s]=0);let h=a.inventoryInfo.find(c=>c.location.id===n.id);h&&(e[s]+=h.quantity)}),Object.keys(e).forEach(a=>{e[a]===0&&t.push(a)}),t}function k(n){let o=T(n),e=document.querySelector("variant-selection");if(!e)return;let t=JSON.parse(e.dataset.variantLocation);j(o.currentShippingLocation,t,o.inventoryInfoTranslations),q(o.currentShippingLocation,o.inventoryInfoData)}function J(n){let{inventoryInfoData:o,currentShippingLocation:e}=T(n);q(e,o)}function q(n,o){let e=_(n,o);e.length>0&&H(e)}function H(n){let o=document.querySelectorAll(".options-selection__option-swatch-wrapper");
1o.length&&o.forEach(e=>{let t=e.getAttribute("data-swatch-tooltip"),r=e.getAttribute("data-product-name").toLowerCase(),i=t.replace(r,"").replace("muji thumbnail","").trim(),a=n.some(s=>i.toLowerCase()===s.toLowerCase());t&&a&&(e.style.display="none")})}function j(n,o,e){let t=document.querySelector(".product-form--atc-button");if(!t)return;W(o,n.id)>0?t.textContent=e.atc.add_to_cart:(t.textContent=e.atc.sold_out,t.classList.contains("disabled")||t.classList.add("disabled"),t.hasAttribute("disabled")||t.setAttribute("disabled",""))}function z(n,o){let e;return function(...t){clearTimeout(e),e=setTimeout(()=>n.apply(this,t),o)}}function Q(){let n=document.getElementById("quickshop-modal");if(!n)return;new MutationObserver(e=>{e.forEach(t=>{if((t.type==="childList"||t.type==="attributes")&&n.querySelector(".options-selection__option-values")){let i=g(y);i&&(J(i),X(i))}})}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})}function X(n){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o();function o(){let e=()=>document.querySelectorAll('.options-selection__option-values .options-selection__option-value-input[data-variant-option-available="true"]').length>0,r=document.querySelector(".options-selection__option-value-input:checked").ariaLabel.toLowerCase();function i(){let s=T(n);if(!s||!s.currentShippingLocation)return;let{inventoryInfoData:h,currentShippingLocation:c}=s,u=_(c,h),l=document.querySelectorAll(".product-gallery--media-thumbn
1ail"),f=document.querySelector('.options-selection__option-value--selected .options-selection__option-value-input[tabindex="0"][name="SIZE"]');l.forEach((m,w)=>{if(w===0)return;let b=m.getAttribute("aria-label").toLowerCase(),N=m.getAttribute("data-product-name").toLowerCase(),v=b.replace(N,"").replace("muji thumbnail","").trim(),A=m.getAttribute("data-product-size").replace(" /","").toLowerCase().trim();!A&&f&&(A=m.getAttribute("data-product-size-first-option").replace(" /","").toLowerCase().trim()),A&&(v.includes(r)&&v.replace(r,"").trim())&&(v=v.replace(A,"").trim());let D=u.some(E=>v===E.toLowerCase());v===""&&(r=""),m.style.display=D||v!==r?"none":"inline-block"})}if(e()){i();return}let a=new MutationObserver(()=>{e()&&(a.disconnect(),i())});a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["data-variant-option-available"]}),setTimeout(()=>{a.disconnect(),i()},5e3)}}function G(){let n=new URL(window.location.href),o=n.searchParams.get(S),e=n.searchParams.get(p);if(!o)return null;let t=null,r=null;if(o===d.ATRIUM.slug?(t=d.ATRIUM,r=d.ATRIUM.default_province):o===d.METROTOWN.slug&&(t=d.METROTOWN,r=d.METROTOWN.default_province),!t)return null;let i=g(y),a=e===t.name,s=t.provinces.includes(i);return s&&a?null:(s||O(r),!a&&e&&(n.searchParams.set(p,t.name),window.history.replaceState(null,"",n.toString())),s?i:r)}document.addEventListener("DOMContentLoaded",n=>{let o=document.querySelectorAll(".location-dropdown .province-selector"),e=document.querySelector("[data-page-type"),t=g(y),r=G();r?t=r:t||(O("ON"),t=g(y)),F(),Array.from(o).some(a=>a.hasAttribute("data-initial-load"))&&setTimeout(()=>{B(t),k(t),x(t),U(t),V(t)},300),o.length&&(e&&e.dataset.pageType==="collection"?R(t,!1):e&&e.dataset.pageType==="searchresults"&&C(t,!1),o.forEach(a=>{a.addEventListener("change",z(s=>{let h=s.target.value;document.querySelectorAll(".province-selector").forEach(l=>{l.value=h}),t=g(y);let c=e?.dataset?.pageType,u=new URL(window.location.href);u.searchParams.has(S)&&(u.searchParams.delete(S),window.history.replaceState(null,"",u.toString())),c==="collection"?R(t,!0):c==="searchresults"&&C(t,!0),location.reload()},1200))}),Q())});})();

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.