{"version":3,"file":"StudioLocaleLink.CsXtgRES.mjs","names":["__esmMin","init_npm_react_18_3_1","init_jsx_runtime","c","ce","useLocaleInfo","init_framer_DcxuU94H","shopPrefix","clean","value","slug","localeSlug","code","localeCode","derived","studioDestination","url","base","match","prefix","retarget","anchor","href","next","withStudioLocaleLink","activeLocale","queued","observer","Component","props","shopDestination","path","US_PATHS","pair","all","US_COLLECTIONS","US_CATEGORIES","withShopLocaleLinks","run","init_StudioLocaleLink"],"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//# s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