{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/o0DMUi0wfXbp0aduEzuQ/9bJSB40FTdCWVWmLkvRL/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;let 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\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSRandomizeNestedCollection.map"],
  "mappings": "8GAGkB,SAARA,EAA8CC,EAAM,CAAC,GAAK,CAAC,WAAAC,EAAW,sBAAAC,EAAsB,gBAAAC,EAAgB,qBAAAC,EAAqB,UAAAC,EAAU,YAAAC,EAAY,MAAAC,CAAK,EAAEP,EAAwBQ,EAAcC,EAAa,QAAQ,EAAQC,EAASF,IAAgBC,EAAa,QAAQD,IAAgBC,EAAa,OAAaE,EAAeR,GAAgBF,IAAa,SAASG,IAAuB,CAAC,EAA6BF,IAAwB,CAAC,EAAO,CAACU,EAAMC,CAAQ,EAAEC,EAAS,CAAC,CAAC,EAAE,OAAAC,EAAU,IAAI,CAAC,GAAGL,EAAS,OAAO,IAAIM,EAAWL,EAAe,MAAM,SAAYN,IAAWW,EAAWC,EAAaD,CAAU,GAAMV,GAAaC,EAAM,IAAGS,EAAWA,EAAW,MAAM,EAAET,CAAK,GAAGM,EAASG,CAAU,CAAE,EAAE,CAAC,CAAC,EAAsBE,EAAK,MAAM,CAAC,UAAUP,GAAgB,OAAO,UAAU,MAAM,CAAC,MAAM,MAAM,EAAE,SAAUD,EAAeC,EAANC,CAAoB,CAAC,CAAE,CAACO,EAAoBpB,EAA6B,CAAC,WAAW,CAAC,KAAKqB,EAAY,KAAK,MAAM,aAAa,QAAQ,CAAC,UAAU,SAAS,QAAQ,EAAE,aAAa,CAAC,UAAU,SAAS,QAAQ,EAAE,aAAa,SAAS,EAAE,sBAAsB,CAAC,KAAKA,EAAY,kBAAkB,MAAM,2BAA2B,EAAE,gBAAgB,CAAC,KAAKA,EAAY,QAAQ,MAAM,oBAAoB,aAAa,EAAK,EAAE,qBAAqB,CAAC,KAAKA,EAAY,kBAAkB,MAAM,+BAA+B,OAAOpB,EAAM,CAAC,MAAM,CAACA,EAAM,eAAgB,CAAC,EAAE,UAAU,CAAC,KAAKoB,EAAY,QAAQ,MAAM,YAAY,aAAa,EAAK,EAAE,YAAY,CAAC,KAAKA,EAAY,QAAQ,MAAM,QAAQ,aAAa,EAAK,EAAE,MAAM,CAAC,KAAKA,EAAY,OAAO,MAAM,MAAM,aAAa,GAAG,IAAI,EAAE,OAAOpB,EAAM,CAAC,MAAM,CAACA,EAAM,WAAY,CAAC,CAAC,CAAC,EAAE,SAASiB,EAAaI,EAAM,CAAC,OAAOA,EAAM,IAAIC,IAAQ,CAAC,MAAAA,EAAM,KAAK,KAAK,OAAO,CAAC,EAAE,EAAE,KAAK,CAACC,EAAEC,IAAID,EAAE,KAAKC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,MAAAF,CAAK,IAAIA,CAAK,CAAE",
  "names": ["CMSRandomizeNestedCollection", "props", "breakpoint", "collectionListDesktop", "hasMobileLayout", "collectionListMobile", "randomize", "shouldLimit", "limit", "currentTarget", "RenderTarget", "isCanvas", "collectionList", "items", "setItems", "ye", "ue", "finalItems", "shuffleArray", "p", "addPropertyControls", "ControlType", "array", "value", "a", "b"]
}
