{"version":3,"file":"ProjectImageGrid.C2d6-IOQ.mjs","names":["React.useRef","React.useState","React.useEffect","React.useLayoutEffect"],"sources":["https:/framerusercontent.com/modules/KlxAfzN7mjRAaCipDPGW/yWyR1hWQQVdVsN1itRw5/ProjectImageGrid.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/** Complete rows, in source order. Their widths follow the original image ratios. */function buildRows(items,columns){const rows=[];let cursor=0;while(cursor<items.length){const wide=items[cursor].ratio>=1.4;let end=cursor+1;while(end<items.length&&items[end].ratio>=1.4===wide)end++;let remaining=end-cursor;if(wide){// Full-width frames alternate with pairs, with every row filled.\nlet row=0;while(remaining){const count=row%2===0&&remaining!==2?1:Math.min(2,remaining);rows.push(items.slice(cursor,cursor+count));cursor+=count;remaining-=count;row++;}}else{while(remaining){// Four images become two pairs, never a triptych and an isolated cell.\nconst count=columns===3?remaining===4?2:Math.min(3,remaining):Math.min(2,remaining);rows.push(items.slice(cursor,cursor+count));cursor+=count;remaining-=count;}}}// An isolated portrait can share a row with an adjacent landscape frame.\nfor(let index=0;index<rows.length;index++){const row=rows[index];if(row.length!==1||row[0].ratio>=1.4)continue;const previous=rows[index-1];const next=rows[index+1];if(previous?.every(item=>item.ratio>=1.4)){row.unshift(previous.pop());if(!previous.length){rows.splice(index-1,1);index--;}}else if(next?.every(item=>item.ratio>=1.4)){row.push(next.shift());if(!next.length)rows.splice(index+1,1);}}return rows;}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ProjectImageGrid(props){const{images=[],project=\"Project\",start=0,count=0,style}=props;const root=React.useRef(null);const[columns,setColumns]=React.useState(2);const useMeasure=typeof window===\"undefined\"?React.useEffect:React.useLayoutEffect;useMeasure(()=>{const element=root.current;if(!element)return;const measure=width=>{// Use the gallery's available width, including changes to the sidebar.\nconst next=width>=880?3:2;setColumns(current=>current===next?current:next);};measure(element.getBoundingClientRect().width);const observer=new ResizeObserver(entries=>{const entry=entries[0];if(entry)measure(entry.contentRect.width);});observer.observe(element);return()=>observer.disconnect();},[images,start,count]);const first=Math.max(0,Math.floor(start));const source=Array.isArray(images)?images:[];const selection=source.slice(first,count>0?first+Math.floor(count):undefined);const items=selection.map((entry,index)=>{const item=typeof entry.image===\"string\"?{src:entry.image}:entry.image;let width=item?.width||0;let height=item?.height||0;try{const url=new URL(item?.src||\"\");width=width||Number(url.searchParams.get(\"width\"));height=height||Number(url.searchParams.get(\"height\"));}catch{}return{...item,width,height,ratio:width&&height?width/height:1.5,index:first+index};});if(!items.length)return null;const rows=buildRows(items,columns);return /*#__PURE__*/_jsxs(\"div\",{ref:root,className:\"ic-project-image-grid\",style:{...style,position:\"relative\",width:\"100%\",height:\"auto\"},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                .ic-project-image-grid { --gallery-gap: 4px; display: flex; flex-direction: column; gap: var(--gallery-gap); }\n                .ic-project-image-row { display: flex; align-items: start; gap: var(--gallery-gap); width: 100%; }\n                .ic-project-image-grid figure { margin: 0; min-width: 0; overflow: hidden; border-radius: 8px; }\n                .ic-project-image-grid img { display: block; width: 100%; height: auto; }\n                @media (max-width: 809.98px) { .ic-project-image-grid { --gallery-gap: 4px; } }\n            `}),rows.map(row=>{const totalRatio=row.reduce((sum,item)=>sum+item.ratio,0);return /*#__PURE__*/_jsx(\"div\",{className:\"ic-project-image-row\",children:row.map(item=>/*#__PURE__*/_jsx(\"figure\",{\"data-image-index\":item.index,style:{flex:`${100*item.ratio/totalRatio} 1 0%`},children:/*#__PURE__*/_jsx(\"img\",{src:item.src,srcSet:item.srcSet,width:item.width||undefined,height:item.height||undefined,sizes:row.length===1?\"(max-width: 809px) calc(100vw - 32px), 1440px\":\"(max-width: 809px) calc((100vw - 36px) / 2), 960px\",alt:item.alt||`${project} — project image ${item.index+1}`,loading:\"lazy\",decoding:\"async\"})},`${item.src||\"image\"}-${item.index}`))},row[0].index);})]});}addPropertyControls(ProjectImageGrid,{images:{type:ControlType.Array,title:\"Images\",control:{type:ControlType.Object,controls:{image:{type:ControlType.ResponsiveImage,title:\"Image\"}}},defaultValue:[{image:{src:\"https://framerusercontent.com/images/y3ErjJFUIETkYwNLhWkhbDmPCA.jpg\"}}]},project:{type:ControlType.String,title:\"Project\",defaultValue:\"Project\"},start:{type:ControlType.Number,title:\"Start\",min:0,step:1,defaultValue:0},count:{type:ControlType.Number,title:\"Count\",min:0,step:1,defaultValue:0}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProjectImageGrid\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProjectImageGrid.map"],"mappings":"+MAA8N,SAAS,EAAU,EAAM,EAAQ,CAAC,IAAM,EAAK,CAAC,EAAM,EAAO,EAAE,KAAM,EAAO,EAAM,QAAO,CAAC,IAAM,EAAK,EAAM,EAAO,CAAC,OAAO,IAAQ,EAAI,EAAO,EAAE,KAAM,EAAI,EAAM,QAAQ,EAAM,EAAI,CAAC,OAAO,MAAM,GAAK,IAAM,IAAI,EAAU,EAAI,EAAO,GAAG,EAAK,CACvc,IAAI,EAAI,EAAE,KAAM,GAAU,CAAC,IAAM,EAAM,EAAI,GAAI,GAAG,IAAY,EAAE,EAAE,KAAK,IAAI,EAAE,CAAS,EAAE,EAAK,KAAK,EAAM,MAAM,EAAO,EAAO,CAAK,CAAC,EAAE,GAAQ,EAAM,GAAW,EAAM,GAAM,CAAC,MAAM,KAAM,GAAU,CAChM,IAAM,EAAM,IAAU,EAAE,IAAY,EAAE,EAAE,KAAK,IAAI,EAAE,CAAS,EAAE,KAAK,IAAI,EAAE,CAAS,EAAE,EAAK,KAAK,EAAM,MAAM,EAAO,EAAO,CAAK,CAAC,EAAE,GAAQ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