{"version":3,"file":"Confetti_Prod.B0ltppOZ.mjs","names":["UtilsComponentMessage","React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/aej5zpwxBpkMdzOteBwy/DWeAZ5wauvGM5oFwVdgS/Utils.js","https:/framerusercontent.com/modules/1bV9DraQN5thDCL4JgRU/kh5Shcmz7wW9EWn33o1D/Confetti_Prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{cloneElement}from\"react\";import UtilsComponentMessage from\"https://framer.com/m/Utils-Component-Message-ZVoG.js@cRfVFRl0izzBulKFjOAe\";export const ComponentMessage=({title,subtitle,style})=>{return /*#__PURE__*/_jsx(UtilsComponentMessage,{yeAnKbEUZ:title,WuF2iG84P:subtitle,style:{width:\"100%\",height:\"100%\",...style}});};/* \n    This function is also used many times to make sure components work even if we set a color style like \"Accent\" on their color properties. We can make this into a utility function.\n*/export const extractRGBColorFromString=str=>{const rgbRegex=/(rgba|rgb)\\(.*?\\)/g;const match=str.match(rgbRegex);return match?match[0]:str;};/*\n    This function makes a connected layer use the sizing of the component it is inside,\n    preventing it from being larger or smaller than the component's size.\n    Use this on layers connected with ControlType.ComponentInstance.\n*/export function styleLayer(layer,style={}){layer=Array.isArray(layer)?layer[0]:layer;let newLayer=layer;const{width,height,...otherStyle}=style;if(layer&&layer.props&&style&&(width||height)){if(typeof layer.type===\"function\"&&typeof layer.props.children===\"object\"){newLayer=/*#__PURE__*/cloneElement(layer,{children:{...layer.props.children,props:{...layer.props.children.props,style:{...layer.props.children.props.style,...width&&{width},...height&&{height},...otherStyle}}}});}else{newLayer=/*#__PURE__*/cloneElement(layer,{style:{...layer.props.style,...width&&{width},...height&&{height},...otherStyle}});}}return newLayer;}\nexport const __FramerMetadata__ = {\"exports\":{\"ComponentMessage\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"extractRGBColorFromString\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"styleLayer\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utils.map","import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";import confetti from\"canvas-confetti\";import{useIsOnFramerCanvas}from\"framer\";import{ComponentMessage}from\"https://framerusercontent.com/modules/aej5zpwxBpkMdzOteBwy/DWeAZ5wauvGM5oFwVdgS/Utils.js\";function extractRGBColorFromString(str){const rgbRegex=/(rgba|rgb)\\(.*?\\)/g;const match=str.match(rgbRegex);return match?match[0]:str;}function rgbToHex(rgb){if(rgb.startsWith(\"#\")){return rgb;}let[r,g,b]=rgb.match(/\\d+/g).map(Number);return\"#\"+[r,g,b].map(x=>{const hex=x.toString(16);return hex.length===1?\"0\"+hex:hex;}).join(\"\");}/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function Confetti({delayInSeconds,amount,coverArea,explosion,color}){const frameRef=React.useRef(null);const[hasTriggered,setHasTriggered]=React.useState(false);const isOnCanvas=useIsOnFramerCanvas();React.useEffect(()=>{if(!hasTriggered&&!isOnCanvas){const timer=setTimeout(()=>{triggerConfetti();setHasTriggered(true);},delayInSeconds*1e3);return()=>clearTimeout(timer);}},[delayInSeconds,hasTriggered,isOnCanvas]);const triggerConfetti=()=>{if(!frameRef.current)return;const explosionSettings={S:{velocity:5,decay:.95},M:{velocity:15,decay:.95},L:{velocity:35,decay:.95},XL:{velocity:60,decay:.95}}[explosion];const rect=frameRef.current.getBoundingClientRect();const origin={x:(rect.left+rect.width/2)/window.innerWidth,y:(rect.top+rect.height/2)/window.innerHeight};confetti({particleCount:Math.floor(200*(amount/100)),spread:coverArea,startVelocity:explosionSettings.velocity,decay:explosionSettings.decay,scalar:1,origin:origin,shapes:[\"circle\",\"square\"],colors:getColorConfig(color)});};function getColorConfig({mode,singleColor,colors}){if(mode===\"Random\")return undefined;if(mode===\"Single\"){const formattedColor=extractRGBColorFromString(singleColor);return[rgbToHex(formattedColor)];}return colors.map(color=>rgbToHex(extractRGBColorFromString(color)));}if(isOnCanvas){return /*#__PURE__*/_jsx(ComponentMessage,{title:\"Confetti Component\",subtitle:\"Preview the website and the confetti will appear here.\"});}return /*#__PURE__*/_jsx(Frame,{ref:frameRef,style:{width:\"100%\",height:\"100%\",overflow:\"visible\",position:\"relative\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",boxSizing:\"border-box\",background:\"none\"}});}Confetti.displayName=\"Confetti\";Confetti.defaultProps={delayInSeconds:0,amount:30,coverArea:360,explosion:\"M\",color:{mode:\"Random\",singleColor:\"#2060DF\",colors:[\"#2060DF\",\"#986BEF\"]}};addPropertyControls(Confetti,{amount:{type:ControlType.Number,title:\"Amount\",min:1,max:200,defaultValue:30,step:1},coverArea:{type:ControlType.Number,title:\"Cover Area\",min:20,max:360,defaultValue:360,step:1,unit:\"\\xb0\"},explosion:{type:ControlType.Enum,title:\"Explosion\",options:[\"S\",\"M\",\"L\",\"XL\"],displaySegmentedControl:true,segmentedControlDirection:\"horizontal\"},color:{type:ControlType.Object,title:\"Color\",controls:{mode:{type:ControlType.Enum,title:\"Color Mode\",options:[\"Random\",\"Single\",\"Multi\"],defaultValue:\"Random\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},singleColor:{type:ControlType.Color,title:\"Single Color\",hidden:({mode})=>mode!==\"Single\"},colors:{type:ControlType.Array,title:\"Colors\",propertyControl:{type:ControlType.Color},hidden:({mode})=>mode!==\"Multi\"}}},delayInSeconds:{type:ControlType.Number,title:\"Delay\",min:0,max:10,step:.1,displayStepper:true,description:\"More components at [Framer University](https://frameruni.link/cc).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Confetti\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"200\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Confetti_Prod.map"],"mappings":"4TAA0C,IAAgC,IAA6G,EAAc,GAAkB,CAAC,QAAM,WAAS,WAA8B,EAAKA,EAAsB,CAAC,UAAU,EAAM,UAAU,EAAS,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,GAAG,CAAK,CAAC,CAAC,KCA1C,SAAS,EAA0B,EAAI,CAAqC,IAAM,EAAM,EAAI,MAAM,oBAAQ,EAAE,OAAO,EAAM,EAAM,GAAG,CAAI,CAAC,SAAS,EAAS,EAAI,CAAC,GAAG,EAAI,WAAW,GAAG,EAAG,OAAO,EAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAI,MAAM,MAAM,CAAC,CAAC,IAAI,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAM,EAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAI,SAAS,EAAE,IAAI,EAAI,CAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAE,CAQ/oB,SAAwB,EAAS,CAAC,iBAAe,SAAO,YAAU,YAAU,SAAO,CAAC,IAAM,EAASC,EAAa,IAAI,EAAO,CAAC,EAAa,GAAiBC,EAAe,EAAK,EAAQ,EAAW,EAAoB,EAAE,MAAoB,CAAC,GAAG,CAAC,GAAc,CAAC,EAAW,CAAC,IAAM,EAAM,eAAe,CAAC,EAAgB,EAAE,EAAgB,EAAI,CAAE,EAAE,EAAe,GAAG,EAAE,UAAU,aAAa,CAAK,CAAE,CAAC,EAAE,CAAC,EAAe,EAAa,CAAU,CAAC,EAAE,IAAM,MAAoB,CAAC,GAAG,CAAC,EAAS,QAAQ,OAAO,IAAM,EAAkB,CAAC,EAAE,CAAC,SAAS,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