{"version":3,"file":"Examples.DZ6x1SY_.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/28rXvpPsrum7FH6cMELS/1jCAazZw1EGHjrG5Nu5D/Utils.js","https:/framer.com/m/framer/utils.js@^0.9.0","https:/framerusercontent.com/modules/SJvyKaMd2Ojdm7dWwEon/AEhN75coYKjm0CX6vW4p/Examples.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","export const centerContent = {\n    display: \"flex\",\n    justifyContent: \"center\",\n    alignItems: \"center\"\n};\nexport const autoSizingText = {\n    width: \"max-content\",\n    wordBreak: \"break-word\",\n    overflowWrap: \"break-word\",\n    overflow: \"hidden\",\n    whiteSpace: \"pre-wrap\",\n    flexShrink: 0\n};\nexport const defaultContainerStyles = {\n    ...centerContent,\n    overflow: \"hidden\"\n};\nexport const containerStyles = defaultContainerStyles;\nexport const randomColor = ()=>\"#\" + Math.floor(Math.random() * 16777215).toString(16)\n;\n\nexport const __FramerMetadata__ = {\"exports\":{\"centerContent\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"containerStyles\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autoSizingText\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"defaultContainerStyles\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"randomColor\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}}}}\n//# sourceMappingURL=./Utils.map","/*\n * Utils (framer/utils@0.9.0)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/28rXvpPsrum7FH6cMELS/1jCAazZw1EGHjrG5Nu5D/Utils.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{randomColor}from\"https://framer.com/m/framer/utils.js@^0.9.0\";// Learn more: https://www.framer.com/developers/overrides/\nconst useStore=createStore({background:\"#0099FF\"});export function withRotate(Component){return /*#__PURE__*/forwardRef((props,ref)=>{return /*#__PURE__*/_jsx(Component,{ref:ref,...props,animate:{rotate:90},transition:{duration:2}});});}export function withHover(Component){return /*#__PURE__*/forwardRef((props,ref)=>{return /*#__PURE__*/_jsx(Component,{ref:ref,...props,whileHover:{scale:1.05}});});}export function withRandomColor(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,animate:{background:store.background},onClick:()=>{setStore({background:randomColor()});}});});}function getFormFieldByExactName(form,targetName){const elements=Array.from(form.elements);return elements.find(element=>{return element instanceof HTMLInputElement||element instanceof HTMLTextAreaElement||element instanceof HTMLSelectElement?element.name===targetName:false;});}export function AtLeastOneContactRequired(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{onSubmit,...restProps}=props;return /*#__PURE__*/_jsx(Component,{ref:ref,...restProps,onSubmit:event=>{const form=event?.currentTarget;if(!form){onSubmit?.(event);return;}const phoneField=getFormFieldByExactName(form,\"電話 / WhatsApp\");const emailField=getFormFieldByExactName(form,\"電郵\");const phoneValue=phoneField?.value?.trim()??\"\";const emailValue=emailField?.value?.trim()??\"\";const message=\"請至少填寫電話或電郵其中一項。\";if(!phoneValue&&!emailValue){event.preventDefault();if(phoneField)phoneField.setCustomValidity(message);if(emailField)emailField.setCustomValidity(message);if(phoneField){phoneField.focus();phoneField.reportValidity();}else if(emailField){emailField.focus();emailField.reportValidity();}else{form.reportValidity();}return;}if(phoneField)phoneField.setCustomValidity(\"\");if(emailField)emailField.setCustomValidity(\"\");onSubmit?.(event);}});});}function isScrollableY(element){const style=window.getComputedStyle(element);const overflowY=style.overflowY;const canScroll=overflowY===\"auto\"||overflowY===\"scroll\"||overflowY===\"overlay\";return canScroll&&element.scrollHeight>element.clientHeight+1;}function findNearestScrollableContainer(start){let current=start;while(current){if(isScrollableY(current))return current;current=current.parentElement;}let walker=start.parentElement;while(walker){const descendants=Array.from(walker.querySelectorAll(\"*\"));const candidate=descendants.find(node=>isScrollableY(node));if(candidate)return candidate;walker=walker.parentElement;}return null;}export function ScrollNearestProductMenuDown(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{onClick,onTap,...restProps}=props;const blockNavigation=event=>{event?.preventDefault?.();event?.stopPropagation?.();event?.nativeEvent?.stopImmediatePropagation?.();};const handleScroll=event=>{const source=(event?.currentTarget)||null;if(!source||typeof window===\"undefined\")return;const target=findNearestScrollableContainer(source);if(!target)return;target.scrollBy({top:target.clientHeight*.9,behavior:\"smooth\"});};return /*#__PURE__*/_jsx(Component,{ref:ref,...restProps,onClick:event=>{blockNavigation(event);handleScroll(event);onClick?.(event);},onTap:event=>{blockNavigation(event);handleScroll(event);onTap?.(event);}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"ScrollNearestProductMenuDown\":{\"type\":\"reactHoc\",\"name\":\"ScrollNearestProductMenuDown\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRotate\":{\"type\":\"reactHoc\",\"name\":\"withRotate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRandomColor\":{\"type\":\"reactHoc\",\"name\":\"withRandomColor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"AtLeastOneContactRequired\":{\"type\":\"reactHoc\",\"name\":\"AtLeastOneContactRequired\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHover\":{\"type\":\"reactHoc\",\"name\":\"withHover\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"uMAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,CAAM,CAAC,CAAC,CAAC,EACjD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,KAAK,GAAG,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,CAAQ,CAAC,CAAE,EACjI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,G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