{"version":3,"file":"CMSRandomizeNestedCollection.D1C5VDV0.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/o0DMUi0wfXbp0aduEzuQ/osGVX0D6ku0Ju4zBZQJa/CMSRandomizeNestedCollection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function CMSRandomizeNestedCollection(props){const{breakpoint,collectionListDesktop,hasMobileLayout,collectionListMobile,randomize,shouldLimit,limit}=props;/* Checks */const currentTarget=RenderTarget.current();const isCanvas=currentTarget===RenderTarget.canvas||currentTarget===RenderTarget.export;const collectionList=hasMobileLayout?breakpoint===\"mobile\"?collectionListMobile?.[0]:collectionListDesktop?.[0]:collectionListDesktop?.[0];const[items,setItems]=useState([]);useEffect(()=>{if(isCanvas)return;// console.log(\"collectionList\", collectionList)\nlet finalItems=collectionList.props.children;if(randomize){finalItems=shuffleArray(finalItems);}if(shouldLimit&&limit>0){finalItems=finalItems.slice(0,limit);}setItems(finalItems);},[]);return /*#__PURE__*/_jsx(\"div\",{className:collectionList?.props?.className,style:{width:\"100%\"},children:!isCanvas?items:collectionList});}addPropertyControls(CMSRandomizeNestedCollection,{breakpoint:{type:ControlType.Enum,title:\"Breakpoint\",options:[\"desktop\",\"tablet\",\"mobile\"],optionTitles:[\"Desktop\",\"Tablet\",\"Mobile\"],defaultValue:\"desktop\"},collectionListDesktop:{type:ControlType.ComponentInstance,title:\"CMS Collection Big Layout\"},hasMobileLayout:{type:ControlType.Boolean,title:\"Has Mobile Layout\",defaultValue:false},collectionListMobile:{type:ControlType.ComponentInstance,title:\"CMS Collection Mobile Layout\",hidden(props){return!props.hasMobileLayout;}},randomize:{type:ControlType.Boolean,title:\"Randomize\",defaultValue:false},shouldLimit:{type:ControlType.Boolean,title:\"Limit\",defaultValue:false},limit:{type:ControlType.Number,title:\"Max\",defaultValue:20,min:0,hidden(props){return!props.shouldLimit;}}});function shuffleArray(array){return array.map(value=>({value,sort:Math.random()})).sort((a,b)=>a.sort-b.sort).map(({value})=>value);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSRandomizeNestedCollection\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSRandomizeNestedCollection.map"],"mappings":"yLAGG,SAAwB,EAA6B,EAAM,CAAC,GAAK,CAAC,aAAW,wBAAsB,kBAAgB,uBAAqB,YAAU,cAAY,SAAO,EAAwB,EAAc,EAAa,QAAQ,EAAQ,EAAS,IAAgB,EAAa,QAAQ,IAAgB,EAAa,OAAa,EAAe,GAAgB,IAAa,SAAS,IAAuB,GAAG,IAAwB,GAAmC,CAAC,EAAM,GAAUA,EAAS,CAAC,CAAC,EAC/S,OADiT,MAAc,CAAC,GAAG,EAAS,OACtgB,IAAI,EAAW,EAAe,MAAM,SAAY,IAAW,EAAW,EAAa,CAAU,GAAM,GAAa,EAAM,IAAG,EAAW,EAAW,MAAM,EAAE,CAAK,GAAG,EAAS,CAAU,CAAE,EAAE,CAAC,CAAC,EAAsB,EAAK,MAAM,CAAC,UAAU,GAAgB,OAAO,UAAU,MAAM,CAAC,MAAM,MAAM,EAAE,SAAU,EAAe,EAAN,CAAoB,CAAC,CAAE,CAAixB,SAAS,EAAa,EAAM,CAAC,OAAO,EAAM,IAAI,IAAQ,CAAC,QAAM,KAAK,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,WAAS,CAAK,CAAE,iBAJ/qC,IAAsC,IAAiE,EAIoL,EAAoB,EAA6B,CAAC,WAAW,CAAC,KAAK,EAAY,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