{"version":3,"file":"WithDevicePlatformButton.BpvqLRxd.mjs","names":["useRef","useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/WOlCkjaHca3JNubflanN/db2gueEXgKH9fVUVpAHB/WithDevicePlatformButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,useMemo,useCallback,startTransition,forwardRef}from\"react\";function detectPlatform(){if(typeof navigator===\"undefined\")return\"web\";const nav=navigator;const uaDataPlatform=nav.userAgentData?.platform?.toLowerCase()??\"\";const ua=(nav.userAgent||\"\").toLowerCase();const isIOSByUA=/iphone|ipad|ipod/.test(ua)||uaDataPlatform.includes(\"ios\")||uaDataPlatform.includes(\"iphone\")||uaDataPlatform.includes(\"ipad\");const isIPadOS13Up=(nav.platform||\"\").toLowerCase().includes(\"mac\")&&typeof nav.maxTouchPoints===\"number\"&&nav.maxTouchPoints>1;if(isIOSByUA||isIPadOS13Up)return\"ios\";const isAndroid=uaDataPlatform.includes(\"android\")||ua.includes(\"android\");if(isAndroid)return\"android\";return\"web\";}export function withDevicePlatformButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const rootRef=useRef(null);const secondaryRowRef=useRef(null);const platformButtonsRef=useRef([]);const[platform,setPlatform]=useState(\"web\");const[expanded,setExpanded]=useState(false);const[isNarrow,setIsNarrow]=useState(false);const toggleIdRef=useRef(`platform-toggle-${Math.random().toString(36).slice(2,10)}`);const setRefs=useCallback(node=>{rootRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);useEffect(()=>{if(typeof window!==\"undefined\"){const nextPlatform=detectPlatform();startTransition(()=>setPlatform(nextPlatform));}},[]);useEffect(()=>{if(typeof window!==\"undefined\"){const mediaQuery=window.matchMedia(\"(max-width: 479px)\");const applyMatch=()=>{startTransition(()=>setIsNarrow(mediaQuery.matches));};applyMatch();mediaQuery.addEventListener(\"change\",applyMatch);return()=>mediaQuery.removeEventListener(\"change\",applyMatch);}},[]);const primaryIndex=useMemo(()=>{if(platform===\"android\")return 1;if(platform===\"ios\")return 2;return 0;},[platform]);const toggleLabel=useMemo(()=>{if(platform===\"ios\")return\"Also on web and Android\";if(platform===\"android\")return\"Also on web and iPhone\";return\"Also on iPhone and Android\";},[platform]);const onToggle=useCallback(()=>{startTransition(()=>setExpanded(value=>!value));},[]);useEffect(()=>{const wrapper=rootRef.current;const secondaryRow=secondaryRowRef.current;if(!wrapper||!secondaryRow)return;wrapper.style.width=\"100%\";if(platformButtonsRef.current.length<3){const buttonNodes=Array.from(wrapper.children).slice(0,3);if(buttonNodes.length<3)return;platformButtonsRef.current=buttonNodes;}const buttonNodes=platformButtonsRef.current;if(buttonNodes.length<3)return;const primaryButton=buttonNodes[primaryIndex];const secondaryButtons=buttonNodes.filter((_,index)=>index!==primaryIndex);if(primaryButton.parentElement!==wrapper){wrapper.appendChild(primaryButton);}primaryButton.style.display=\"\";primaryButton.style.width=\"100%\";primaryButton.setAttribute(\"aria-hidden\",\"false\");for(const buttonNode of secondaryButtons){if(buttonNode.parentElement!==secondaryRow){secondaryRow.appendChild(buttonNode);}buttonNode.style.display=expanded?\"\":\"none\";// Size each pill to its label and wrap, rather than splitting the\n// row into equal halves that truncate \"Get it on Android\".\nbuttonNode.style.width=isNarrow?\"100%\":\"auto\";buttonNode.style.flex=isNarrow?\"none\":\"1 1 auto\";buttonNode.style.minWidth=isNarrow?\"\":\"max-content\";buttonNode.setAttribute(\"aria-hidden\",expanded?\"false\":\"true\");}secondaryRow.style.display=expanded?\"flex\":\"none\";secondaryRow.style.flexDirection=isNarrow?\"column\":\"row\";secondaryRow.style.flexWrap=\"wrap\";secondaryRow.style.gap=\"9px\";secondaryRow.style.justifyContent=\"center\";secondaryRow.style.alignItems=\"center\";secondaryRow.style.marginTop=\"11px\";secondaryRow.style.width=\"100%\";},[expanded,primaryIndex,isNarrow]);return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",display:\"inline-flex\",flexDirection:\"column\",alignItems:\"center\",width:\"100%\"},id:toggleIdRef.current,children:[/*#__PURE__*/_jsx(Component,{ref:setRefs,...props}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-expanded\":expanded,\"aria-controls\":toggleIdRef.current,onClick:onToggle,style:{position:\"relative\",width:\"100%\",marginTop:12,background:\"none\",border:\"none\",padding:0,fontFamily:\"Poppins, sans-serif\",fontSize:13,fontWeight:400,lineHeight:1.3,color:\"#6E839D\",cursor:\"pointer\",textAlign:\"center\",textDecorationLine:\"underline\",textUnderlineOffset:3,outlineOffset:3},children:toggleLabel}),/*#__PURE__*/_jsx(\"div\",{ref:secondaryRowRef})]});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withDevicePlatformButton\":{\"type\":\"reactHoc\",\"name\":\"withDevicePlatformButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithDevicePlatformButton.map"],"mappings":"mLAAqJ,SAAS,GAAgB,CAAC,GAAU,IAAY,OAAY,MAAM,MAAM,IAAM,EAAI,EAAgB,EAAe,EAAI,eAAe,UAAU,YAAY,GAAG,GAAS,GAAI,EAAI,WAAW,GAAA,CAAI,YAAY,EAAQ,EAAU,mBAAmB,KAAK,CAAE,GAAG,EAAe,SAAS,KAAK,GAAG,EAAe,SAAS,QAAQ,GAAG,EAAe,SAAS,MAAM,EAAQ,GAAc,EAAI,UAAU,GAAA,CAAI,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,OAAO,EAAI,gBAAiB,UAAU,EAAI,eAAe,EAAiJ,OAA5I,GAAW,EAAmB,MAAsB,EAAe,SAAS,SAAS,GAAG,EAAG,SAAS,SAAS,EAAqB,UAAgB,KAAM,CAAC,SAAgB,EAAyB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,IAAM,EAAQA,EAAO,IAAI,EAAQ,EAAgBA,EAAO,IAAI,EAAQ,EAAmBA,EAAO,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