{"version":3,"file":"useInheritedSectionBreakpoint.DhsOD9MK.mjs","names":["useContext","__esmMin","oe","B","init_npm_react_18_3_1","useSlotFallbackBreakpoint","contextBreakpoint","SectionBreakpointContext","ownBreakpoint","SECTION_BREAKPOINT_ATTR","init_useInheritedSectionBreakpoint"],"sources":["https:/framerusercontent.com/modules/GXLXiYd3hoMReGGx4l0f/b4UbE0ZuqfXx81EZYOtE/useInheritedSectionBreakpoint.js"],"sourcesContent":["import{createContext,useContext,useLayoutEffect,useState}from\"react\";export const SECTION_BREAKPOINT_ATTR=\"data-bunq-section-breakpoint\";export const SectionBreakpointContext=/*#__PURE__*/createContext(undefined);function parseBreakpoint(value){if(value===\"desktop\"||value===\"tablet\"||value===\"phone\"){return value;}return undefined;}export function readInheritedSectionBreakpoint(element){if(!element)return undefined;const host=element.closest(`[${SECTION_BREAKPOINT_ATTR}]`);if(!(host instanceof HTMLElement))return undefined;return parseBreakpoint(host.getAttribute(SECTION_BREAKPOINT_ATTR));}export function useInheritedSectionBreakpoint(ref){const contextBreakpoint=useContext(SectionBreakpointContext);const[domBreakpoint,setInheritedBreakpoint]=useState();const inheritedBreakpoint=domBreakpoint??contextBreakpoint;useLayoutEffect(()=>{const element=ref.current;if(!element)return undefined;let observer;let cancelled=false;const syncBreakpoint=()=>{setInheritedBreakpoint(readInheritedSectionBreakpoint(element));};const tryAttach=()=>{const host=element.closest(`[${SECTION_BREAKPOINT_ATTR}]`);if(!(host instanceof HTMLElement))return false;syncBreakpoint();observer?.disconnect();observer=new MutationObserver(syncBreakpoint);observer.observe(host,{attributes:true,attributeFilter:[SECTION_BREAKPOINT_ATTR]});return true;};if(!tryAttach()){queueMicrotask(()=>{if(!cancelled)tryAttach();});}return()=>{cancelled=true;observer?.disconnect();};},[ref]);return inheritedBreakpoint;}export function useSlotFallbackBreakpoint(ownBreakpoint){const contextBreakpoint=useContext(SectionBreakpointContext);if(ownBreakpoint!==\"desktop\"||contextBreakpoint===undefined){return ownBreakpoint;}return contextBreakpoint;}// recompile: 1792505897503\n\nexport const __FramerMetadata__ = {\"exports\":{\"readInheritedSectionBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSlotFallbackBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SectionBreakpointContext\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SECTION_BREAKPOINT_ATTR\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useInheritedSectionBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useInheritedSectionBreakpoint.map"],"mappings":"A,2GAAi9C,SAAgBK,EAA0B,EAAc,CAAC,IAAMC,EAAkBN,EAAWO,CAAwB,EAAqF,OAAhFC,IAAgB,WAAWF,IAAoB,IAAA,GAAkBE,EAAsBF,CAAkB,C,0CAAjmD,EAAwB,+BAA4C,EAAsC,gBAAc,IAAA,EAAS,C"}