{"version":3,"file":"StudioLocaleLink.pc-vs3ug.mjs","names":[],"sources":["https:/framerusercontent.com/modules/wl8SyJxHUKIMYHaoQNy1/N5Eykdy9fPpcPcKHcD6X/StudioLocaleLink.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{useLocaleInfo}from\"framer\";// Framer's locale slug is the shop's own prefix set (nl, de, fr, es, it, uk,\n// us) and is empty for the default locale, which the shop serves without a\n// prefix. Matching on the language code instead would send English (United\n// States) to the EU shop, which has its own prices and category ids.\nfunction shopPrefix(localeCode,localeSlug){const clean=value=>String(value||\"\").trim().toLowerCase().replace(/_/g,\"-\").replace(/^\\/+|\\/+$/g,\"\");const slug=clean(localeSlug);if(slug)return\"/\"+slug;// Older Framer versions expose only the code; map the regional Englishes\n// by hand and treat plain \"en\" as the prefix-less default.\nconst code=clean(localeCode);const byCode={\"en-gb\":\"uk\",\"en-us\":\"us\"};const derived=byCode[code]||code.split(\"-\")[0];return!derived||derived===\"en\"?\"\":\"/\"+derived;}// Replaces whatever locale the link carries, so it is safe to run twice and it\n// corrects a link that was pointed at the wrong language by hand.\nfunction studioDestination(base,prefix){let url;try{url=new URL(base.startsWith(\"shop/\")?\"/\"+base:base,\"https://www.mondaymerch.com\");}catch{return null;}if(![\"mondaymerch.com\",\"www.mondaymerch.com\"].includes(url.hostname))return null;const match=url.pathname.match(/^\\/(?:[a-z]{2}(?:-[a-z0-9]+)*\\/)?shop\\/(?:studio-home|studio)(\\/.*)?$/i);if(!match)return null;url.hostname=\"www.mondaymerch.com\";url.protocol=\"https:\";url.pathname=prefix+\"/shop/studio\"+(match[1]||\"\");return url.toString();}function retarget(prefix){if(typeof document===\"undefined\")return;for(const anchor of Array.from(document.querySelectorAll(\"a[href]\"))){const href=anchor.getAttribute(\"href\");if(!href)continue;const next=studioDestination(href,prefix);if(next&&next!==anchor.href)anchor.href=next;}}/**\n * Points every shop-studio link on the page at the visitor's own locale.\n *\n * Attach it anywhere on the page: it never touches what the component renders,\n * so it cannot hide or break the element it is attached to, and one attachment\n * per page is enough. Links that are not studio links are left alone.\n */export function withStudioLocaleLink(Component){return function StudioLocaleLink(props){const{activeLocale}=useLocaleInfo();const code=activeLocale?.code||\"\";const slug=activeLocale?.slug||\"\";useEffect(()=>{if(typeof document===\"undefined\")return;const prefix=shopPrefix(code||document.documentElement.lang||\"\",slug);retarget(prefix);// Framer mounts sections as they scroll into view, so links that\n// arrive later need the same treatment. Batched through rAF to stay\n// cheap on pages that mutate a lot.\nlet queued=false;const observer=new MutationObserver(()=>{if(queued)return;queued=true;requestAnimationFrame(()=>{queued=false;retarget(prefix);});});observer.observe(document.body,{childList:true,subtree:true});return()=>observer.disconnect();},[code,slug]);return /*#__PURE__*/_jsx(Component,{...props});};}// The US shop is a separate Odoo website, so its collections carry other ids.\nconst US_COLLECTIONS={\"best-sellers-3\":\"best-sellers-12\",\"christmas-2026-18\":\"christmas-2026-21\",\"merch-packs-23\":\"swag-gift-packs-25\"};// Top-level categories have their own ids on the US website too.\nconst US_CATEGORIES={\"apparel-46\":\"apparel-271\",\"bags-64\":\"bags-293\",\"drinkware-45\":\"drinkware-286\",\"tech-63\":\"tech-298\",\"office-47\":\"office-282\",\"events-102\":\"events-305\",\"packaging-62\":\"packaging-266\",\"wellness-97\":\"wellness-312\",\"food-drinks-153\":\"food-drinks-320\",\"home-107\":\"home-308\"};// Subcategories the US website does not have: send them to their parent there.\nconst US_PATHS={\"apparel-46/workwear-134\":\"apparel-271\"};// Only rewrites shop links that carry no locale yet, so links the navbar has\n// already localized are left exactly as they are.\nfunction shopDestination(base,prefix){let url;try{url=new URL(base,\"https://www.mondaymerch.com\");}catch{return null;}if(url.hostname!==\"www.mondaymerch.com\")return null;if(!/^\\/shop(\\/|$)/.test(url.pathname))return null;if(!prefix)return null;let path=url.pathname;if(prefix===\"/us\"){path=path.replace(/^\\/shop\\/([^/]+\\/[^/]+)(?=\\/|$)/,(all,pair)=>US_PATHS[pair]?\"/shop/\"+US_PATHS[pair]:all);path=path.replace(/^\\/shop\\/collections\\/([^/]+)/,(all,slug)=>\"/shop/collections/\"+(US_COLLECTIONS[slug]||slug));path=path.replace(/^\\/shop\\/([^/]+)(?=\\/|$)/,(all,slug)=>\"/shop/\"+(US_CATEGORIES[slug]||slug));}url.pathname=prefix+path;return url.toString();}/**\n * Points every shop link without a locale at the visitor's own locale. Attach\n * it once per page, like withStudioLocaleLink.\n */export function withShopLocaleLinks(Component){return function ShopLocaleLinks(props){const{activeLocale}=useLocaleInfo();const code=activeLocale?.code||\"\";const slug=activeLocale?.slug||\"\";useEffect(()=>{if(typeof document===\"undefined\")return;const prefix=shopPrefix(code||document.documentElement.lang||\"\",slug);const run=()=>{for(const anchor of Array.from(document.querySelectorAll(\"a[href]\"))){const href=anchor.getAttribute(\"href\");if(!href)continue;const next=shopDestination(href,prefix);if(next&&next!==anchor.href)anchor.href=next;}};run();let queued=false;const observer=new MutationObserver(()=>{if(queued)return;queued=true;requestAnimationFrame(()=>{queued=false;run();});});observer.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:[\"href\"]});return()=>observer.disconnect();},[code,slug]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withStudioLocaleLink\":{\"type\":\"reactHoc\",\"name\":\"withStudioLocaleLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShopLocaleLinks\":{\"type\":\"reactHoc\",\"name\":\"withShopLocaleLinks\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StudioLocaleLink.map"],"mappings":"qKAIA,SAAS,EAAW,EAAW,EAAW,CAAC,IAAM,EAAM,GAAO,OAAO,GAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,QAAQ,aAAa,EAAE,EAAQ,EAAK,EAAM,CAAU,EAAE,GAAG,EAAK,M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