{"version":3,"file":"BackgroundBoxes_prod.DmZwDo4-.mjs","names":["useRef","useState","useMemo","useCallback","__esmMin","le","init_ssg_sandbox_shims","ne","window","_e","de","init_jsx_runtime","pe","c","init_npm_react_18_3_1","useReducedMotion","init_framer_motion_DhsWWWsN","init_framer_CaDWdxiz","addPropertyControls","ControlType","resolveCssColor","color","getGridDimensions","safeBoxSize","boxSize","radians","radX","rotateX","radY","rotateY","radZ","rotateZ","diagonal","width","height","cosZ","sinZ","rotatedWidth","rotatedHeight","compensateX","compensateY","safetyMargin","BackgroundBoxes","colorsProp","DEFAULT_COLORS","containerRef","prefersReducedMotion","grid","setGrid","colors","validColors","calculateGrid","container","next","current","observer","resolvedBorderColor","borderColor","cells","borderWidth","index","handlePointerOver","target","event","cell","handlePointerOut","outDuration","rootStyle","backgroundColor","style","init_BackgroundBoxes_prod"],"sources":["https:/framerusercontent.com/modules/ooqkSD3rGXzWpV96qhGd/plkgAZUTBRu2m6Ywm247/BackgroundBoxes_prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useLayoutEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useReducedMotion}from\"framer-motion\";const DEFAULT_COLORS=[\"rgb(125 211 252)\",\"rgb(249 168 212)\",\"rgb(134 239 172)\",\"rgb(253 224 71)\",\"rgb(252 165 165)\",\"rgb(216 180 254)\",\"rgb(147 197 253)\",\"rgb(165 180 252)\",\"rgb(196 181 253)\"];function resolveCssColor(color){if(typeof color===\"string\")return color;if(!color||typeof color!==\"object\")return undefined;return color.value;}function getGridDimensions(width,height,boxSize,rotateX,rotateY,rotateZ,safetyMargin){const safeBoxSize=Math.max(1,boxSize);const radians=Math.PI/180;const radX=Math.abs(rotateX)*radians;const radY=Math.abs(rotateY)*radians;const radZ=Math.abs(rotateZ)*radians;const diagonal=Math.hypot(width,height);const cosZ=Math.abs(Math.cos(radZ));const sinZ=Math.abs(Math.sin(radZ));const rotatedWidth=width*cosZ+height*sinZ;const rotatedHeight=width*sinZ+height*cosZ;const compensateX=1/Math.max(Math.abs(Math.cos(radX)),.2);const compensateY=1/Math.max(Math.abs(Math.cos(radY)),.2);return{cols:Math.max(10,Math.ceil(Math.max(rotatedWidth*compensateY,diagonal)*safetyMargin/safeBoxSize)),rows:Math.max(10,Math.ceil(Math.max(rotatedHeight*compensateX,diagonal)*safetyMargin/safeBoxSize))};}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 300\n * @framerDisableUnlink\n */export default function BackgroundBoxes({backgroundColor,boxSize=36,borderWidth=1,borderColor,rotateX=45,rotateY=0,rotateZ=45,safetyMargin=1.2,colors:colorsProp=DEFAULT_COLORS,outDuration=.5,style}){const containerRef=useRef(null);const prefersReducedMotion=useReducedMotion();const[grid,setGrid]=useState(()=>getGridDimensions(400,300,boxSize,rotateX,rotateY,rotateZ,safetyMargin));const colors=useMemo(()=>{const validColors=colorsProp?.map(resolveCssColor).filter(color=>typeof color===\"string\"&&color.trim().length>0).map(color=>color.trim());return validColors?.length?validColors:DEFAULT_COLORS;},[colorsProp]);const calculateGrid=useCallback(()=>{const container=containerRef.current?.isConnected?containerRef.current:document.documentElement;if(container===document.documentElement)return;const next=getGridDimensions(container.clientWidth||container.offsetWidth||1,container.clientHeight||container.offsetHeight||1,boxSize,rotateX,rotateY,rotateZ,safetyMargin);setGrid(current=>current.rows===next.rows&&current.cols===next.cols?current:next);},[boxSize,rotateX,rotateY,rotateZ,safetyMargin]);useLayoutEffect(()=>{if(typeof window===\"undefined\")return;calculateGrid();const container=containerRef.current;if(!container||typeof ResizeObserver===\"undefined\"){window.addEventListener(\"resize\",calculateGrid);return()=>window.removeEventListener(\"resize\",calculateGrid);}const observer=new ResizeObserver(calculateGrid);observer.observe(container);return()=>observer.disconnect();},[calculateGrid]);const resolvedBorderColor=resolveCssColor(borderColor);const cells=useMemo(()=>Array.from({length:grid.rows*grid.cols},(_,index)=>/*#__PURE__*/_jsx(\"div\",{\"data-background-box\":\"\",style:{width:boxSize,height:boxSize,borderRight:borderWidth?`${borderWidth}px solid ${resolvedBorderColor}`:undefined,borderTop:borderWidth?`${borderWidth}px solid ${resolvedBorderColor}`:undefined,transition:\"none\"}},index)),[grid.rows,grid.cols,boxSize,borderWidth,resolvedBorderColor]);const handlePointerOver=useCallback(event=>{const target=event.target;if(!(target instanceof HTMLElement))return;const cell=target.closest(\"[data-background-box]\");if(!cell||!event.currentTarget.contains(cell))return;cell.style.transition=\"none\";cell.style.setProperty(\"background-color\",colors[Math.floor(Math.random()*colors.length)]||DEFAULT_COLORS[0]);},[colors]);const handlePointerOut=useCallback(event=>{const target=event.target;if(!(target instanceof HTMLElement))return;const cell=target.closest(\"[data-background-box]\");if(!cell||!event.currentTarget.contains(cell))return;cell.style.transition=prefersReducedMotion?\"none\":`background-color ${Math.max(0,outDuration)}s`;cell.style.removeProperty(\"background-color\");},[outDuration,prefersReducedMotion]);const rootStyle={position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",backgroundColor:resolveCssColor(backgroundColor),perspective:\"10000px\",perspectiveOrigin:\"center center\",transformStyle:\"preserve-3d\",...style};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:rootStyle,children:/*#__PURE__*/_jsx(\"div\",{onPointerOver:handlePointerOver,onPointerOut:handlePointerOut,style:{position:\"absolute\",left:\"50%\",top:\"50%\",display:\"grid\",gridTemplateColumns:`repeat(${grid.cols}, ${boxSize}px)`,width:grid.cols*boxSize,height:grid.rows*boxSize,borderLeft:borderWidth?`${borderWidth}px solid ${resolveCssColor(borderColor)}`:undefined,transform:`translate(-50%, -50%) rotateX(${rotateX}deg) rotateY(${rotateY}deg) rotateZ(${rotateZ}deg)`,transformOrigin:\"center center\",transformStyle:\"preserve-3d\"},children:cells})});}addPropertyControls(BackgroundBoxes,{backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0,0,0,1)\",optional:true},boxSize:{type:ControlType.Number,title:\"Box Size\",min:4,max:64,step:2,defaultValue:36,unit:\"px\"},borderWidth:{type:ControlType.Number,title:\"Width\",min:0,max:10,step:1,defaultValue:1,unit:\"px\"},rotateX:{type:ControlType.Number,title:\"Rotate X\",min:-45,max:45,step:1,defaultValue:45,unit:\"\\xb0\"},rotateY:{type:ControlType.Number,title:\"Rotate Y\",min:-45,max:45,step:1,defaultValue:0,unit:\"\\xb0\"},rotateZ:{type:ControlType.Number,title:\"Rotate Z\",min:-45,max:45,step:1,defaultValue:45,unit:\"\\xb0\"},outDuration:{type:ControlType.Number,title:\"Fade Time\",min:0,max:10,step:.1,defaultValue:.5,unit:\"s\"},borderColor:{type:ControlType.Color,title:\"Line Color\",defaultValue:\"rgba(255,255,255,0.2)\",optional:true},safetyMargin:{type:ControlType.Number,title:\"Fill Grid\",min:1,max:2,step:.1,defaultValue:1.2,description:\"Add rows and columns. Increase for high rotations.\"},colors:{type:ControlType.Array,title:\"Colors\",defaultValue:DEFAULT_COLORS,control:{type:ControlType.Color,title:\"Color\"},description:\"More components at [Framer University](https://frameruni.link/cc).\"}});BackgroundBoxes.displayName=\"Background Boxes\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BackgroundBoxes\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"300\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BackgroundBoxes_prod.map"],"mappings":"A,qQAAmZ,SAASoB,EAAgB,EAAM,CAAC,GAAG,OAAOC,GAAQ,SAAS,OAAOA,EAAM,GAAIA,GAAO,OAAOA,GAAQ,SAA0B,OAAOA,EAAM,KAAM,CAAC,SAASC,EAAkB,EAA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