{"version":3,"file":"CmsBridge.BEjFNitI.mjs","names":["useState","useEffect","useLayoutEffect"],"sources":["https:/framerusercontent.com/modules/I1EO5uAlnl0X449KdjrI/eyBYqDXCTN4qDJ6E68WE/CmsBridge.js"],"sourcesContent":["// HOLMCHROME · CMS bridge\n// Lets the strip, the light table, the magazine and the Loader take their\n// content from the CMS, so a project or an entry is edited in ONE place.\n//\n// Framer closed direct CMS access for code components (Framer Help:\n// \"Limitations when accessing the CMS with code\"); reading the collection\n// through props or module imports no longer works. What does work, and what\n// Framer's community uses: a normal Collection List on the page, hidden,\n// whose rendered items the component reads from the page.\n//\n// The contract is made of Framer layer names (data-framer-name):\n//   list:   \"CMS Projects\" or \"CMS Journal\" (the Collection List)\n//   item:   \"Item\" (each item's root frame; the item links to its CMS page)\n//   fields: text and image layers named after the field (\"Title\", \"Cover\",\n//           \"Take 1\", \"Print 1\", ...)\n// Only these names, plain text, <img> and <a href> are read, nothing of\n// Framer's own markup, so a Framer update is unlikely to break it. When the\n// list is missing or empty the components fall back to their demo content.\nimport{useEffect,useLayoutEffect,useState}from\"react\";const named=(root,name)=>root.querySelector(`[data-framer-name=\"${name}\"]`);// The image a field layer shows. Framer renders <img> with a srcset; the\n// largest size up to 2048 px is plenty for a texture (the same choice in\n// every component, so a URL fetched early is the URL used later).\nfunction imageOf(el){if(!el)return\"\";const img=el instanceof HTMLImageElement?el:el.querySelector(\"img\");if(img){const sizes=(img.getAttribute(\"srcset\")||\"\").split(\",\").map(s=>s.trim().split(/\\s+/)).map(([url,w])=>({url,w:parseInt(w)||0})).filter(s=>s.url&&s.w).sort((a,b)=>a.w-b.w);const fit=sizes.filter(s=>s.w<=2048).pop()||sizes[0];return absolute(fit?fit.url:img.getAttribute(\"src\")||\"\");}const bg=/url\\([\"']?(.*?)[\"']?\\)/.exec(getComputedStyle(el).backgroundImage);return bg?absolute(bg[1]):\"\";}const absolute=url=>url?new URL(url,location.href).href:\"\";// The list's items, or null when the page has no such list\nexport function readList(name){if(typeof document===\"undefined\")return null;const list=named(document,name);if(!list)return null;// It is data, not content: out of the reading order and the tab order\nlist.setAttribute(\"aria-hidden\",\"true\");list.setAttribute(\"inert\",\"\");const items=Array.from(list.querySelectorAll('[data-framer-name=\"Item\"]'));if(!items.length)return null;return items.map(it=>{const a=it.closest(\"a[href]\")||it.querySelector(\"a[href]\");return{link:a?new URL(a.getAttribute(\"href\"),location.href).pathname:undefined,text:field=>(named(it,field)?.textContent||\"\").trim(),image:field=>imageOf(named(it,field))};});}const useIsoLayout=typeof window===\"undefined\"?useEffect:useLayoutEffect;// undefined: not read yet (the list renders in the same commit, so this\n// waits one layout pass); null: no list on the page; else the mapped items\nexport function useCms(name,map){const[items,setItems]=useState(undefined);useIsoLayout(()=>{const list=readList(name);const mapped=list?list.map(map).filter(Boolean):null;setItems(mapped&&mapped.length?mapped:null);},[name]);return items;}// \"F/2.8\" or \"2.8\": the components add the F/ themselves\nexport const bareAperture=s=>s.replace(/^f\\s*\\/\\s*/i,\"\");// The magazine reads dates as dd.mm.yyyy. A CMS Date field renders in\n// Framer's display format (\"Sep 18, 2026\"), so anything else is parsed and\n// rewritten; unreadable text passes through unchanged.\nexport function dmy(s){if(/^\\d{2}\\.\\d{2}\\.\\d{4}$/.test(s))return s;const two=n=>String(n).padStart(2,\"0\");// Framer's US display (\"9/18/26\") is read by hand: browsers disagree on\n// two-digit years, and a 1926 date would put the issue in the wrong season\nconst us=/^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{2}|\\d{4})$/.exec(s);if(us)return`${two(+us[2])}.${two(+us[1])}.${us[3].length===2?2e3+ +us[3]:us[3]}`;const d=new Date(s);if(isNaN(d.getTime()))return s;return`${two(d.getDate())}.${two(d.getMonth()+1)}.${d.getFullYear()}`;}\nexport const __FramerMetadata__ = {\"exports\":{\"bareAperture\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"CmsItem\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"readList\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useCms\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"dmy\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CmsBridge.map"],"mappings":"gIAqBA,SAAS,EAAQ,EAAG,CAAC,GAAG,CAAC,EAAG,MAAM,GAAG,IAAM,EAAI,aAAc,iBAAiB,EAAG,EAAG,cAAc,KAAK,EAAE,GAAG,EAAI,CAAC,IAAM,GAAO,EAAI,aAAa,QAAQ,GAAG,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAI,MAAM,CAAC,MAAI,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAQ,EAAI,EAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,GAAG,EAAM,GAAG,OAAO,EAAS,EAAI,EAAI,IAAI,EAAI,aAAa,KAAK,GAAG,EAAE,CAAE,CAAC,IAAM,EAAG,yBAAyB,KAAK,iBAAiB,CAAE,CAAC,CAAC,eAAe,EAAE,OAAO,EAAG,EAAS,EAAG,EAAE,EAAE,EAAG,CACpf,SAAgB,EAAS,EAAK,CAAC,GAAG,OAAO,SAAW,IAAY,OAAO,KAAK,IAAM,EAAK,EAAM,SAAS,CAAI,EAAE,GAAG,CAAC,EAAK,OAAO,KAC5H,EAAK,aAAa,cAAc,MAAM,EAAE,EAAK,aAAa,QAAQ,EAAE,EAAE,IAAM,EAAM,MAAM,KAAK,EAAK,iBAAiB,2BAA2B,CAAC,EAA+B,OAAzB,EAAM,OAA0B,EAAM,IAAI,GAAI,C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