{"version":3,"file":"RandomItemSelector.BlIXsSTQ.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/n9cR4gFLy0DjoxfkLrIe/eDj1MxSfupkYrrIeXQ6b/Shared.js","https:/framer.com/m/Shared-8iGD.js","https:/framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js","https:/framer.com/m/CMSLibrary-09eo.js","https:/framerusercontent.com/modules/WG7j109B8jRxLbUu4MYP/9yuYOCT4C0U3pR7BApyA/RandomItemSelector.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{ControlType}from\"framer\";import{motion}from\"framer-motion\";export const borderPropertyControl=(hidden=null)=>({type:ControlType.Object,optional:true,hidden,controls:{color:{type:ControlType.Color,defaultValue:\"#222\"},width:{type:ControlType.FusedNumber,defaultValue:1,toggleKey:\"widthIsMixed\",toggleTitles:[\"All\",\"Individual\"],valueKeys:[\"widthTop\",\"widthRight\",\"widthBottom\",\"widthLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},style:{type:ControlType.Enum,defaultValue:\"solid\",options:[\"solid\",\"dashed\",\"dotted\",\"double\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\"]}}});export function Border({width,widthIsMixed,widthTop,widthRight,widthBottom,widthLeft,style,color,transition}){return /*#__PURE__*/_jsx(motion.div,{animate:{borderColor:color},style:{position:\"absolute\",inset:0,borderWidth:widthIsMixed?`${widthTop}px ${widthRight}px ${widthBottom}px ${widthLeft}px`:`${width}px`,borderStyle:style,borderRadius:\"inherit\",pointerEvents:\"none\"},initial:false,transition:transition});}export function EmptyState({title,subtitle,maxWidth=0}){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",width:\"100%\",height:\"100%\",placeContent:\"center\",placeItems:\"center\",flexDirection:\"column\",gap:16,backgroundColor:\"rgba(136, 85, 255, 0.1)\",borderRadius:6,border:\"1px dashed rgb(136, 85, 255)\",color:\"rgb(136, 85, 255)\",fontSize:16,padding:20,minHeight:200,maxWidth:maxWidth||undefined},children:[/*#__PURE__*/_jsx(\"p\",{style:{margin:0,fontWeight:600,textAlign:\"center\"},children:title}),/*#__PURE__*/_jsx(\"p\",{style:{margin:0,opacity:.7,// maxWidth: 500,\nlineHeight:1.5,textAlign:\"center\"},children:subtitle})]});}EmptyState.displayName=\"Empty State\";\nexport const __FramerMetadata__ = {\"exports\":{\"borderPropertyControl\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Border\":{\"type\":\"reactComponent\",\"name\":\"Border\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"EmptyState\":{\"type\":\"reactComponent\",\"name\":\"EmptyState\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Shared.map","/*\n * Shared\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/n9cR4gFLy0DjoxfkLrIe/eDj1MxSfupkYrrIeXQ6b/Shared.js\"\n","export function getCollectionData(collectionList){var _collectionList_props,_collectionList_props_children_props,_collectionList_props_children,_collectionList_props1,_collectionList_props_children_props_children_props,_collectionList_props_children_props_children,_collectionList_props_children_props1,_collectionList_props_children1,_collectionList_props2,_queryParent_props;let queryParent=null;if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props=collectionList.props)===null||_collectionList_props===void 0?void 0:_collectionList_props.query){queryParent=collectionList;}else if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props1=collectionList.props)===null||_collectionList_props1===void 0?void 0:(_collectionList_props_children=_collectionList_props1.children)===null||_collectionList_props_children===void 0?void 0:(_collectionList_props_children_props=_collectionList_props_children.props)===null||_collectionList_props_children_props===void 0?void 0:_collectionList_props_children_props.query){queryParent=collectionList.props.children;}else if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props2=collectionList.props)===null||_collectionList_props2===void 0?void 0:(_collectionList_props_children1=_collectionList_props2.children)===null||_collectionList_props_children1===void 0?void 0:(_collectionList_props_children_props1=_collectionList_props_children1.props)===null||_collectionList_props_children_props1===void 0?void 0:(_collectionList_props_children_props_children=_collectionList_props_children_props1.children)===null||_collectionList_props_children_props_children===void 0?void 0:(_collectionList_props_children_props_children_props=_collectionList_props_children_props_children.props)===null||_collectionList_props_children_props_children_props===void 0?void 0:_collectionList_props_children_props_children_props.query){queryParent=collectionList.props.children.props.children;}const query=queryParent===null||queryParent===void 0?void 0:(_queryParent_props=queryParent.props)===null||_queryParent_props===void 0?void 0:_queryParent_props.query;let queryData=null;if(query===null||query===void 0?void 0:query.from){if(query.from.data){queryData=query.from.data;}else if(query.from.left){let left=query.from.left;for(let i=0;i<100;i++){if(left.type==\"Collection\"){queryData=left.data;break;}else if(left.left){left=left.left;}else{break;}}}}// Get property controls\nconst propertyControlsById=(queryData===null||queryData===void 0?void 0:queryData.propertyControls)||{};const propertyControlsByName={};for(const id in propertyControlsById){const control=propertyControlsById[id];propertyControlsByName[control.title]={id,...control};}// Get children function\nlet childrenFunction=null;if(collectionList){var _collectionList_props3,_clpc_props,_clpc_props_children_props,_clpc_props_children,_clpc_props1;const clpc=(_collectionList_props3=collectionList.props)===null||_collectionList_props3===void 0?void 0:_collectionList_props3.children;if(typeof clpc==\"function\"){childrenFunction=clpc;}else if(typeof(clpc===null||clpc===void 0?void 0:(_clpc_props=clpc.props)===null||_clpc_props===void 0?void 0:_clpc_props.children)==\"function\"){childrenFunction=clpc.props.children;}else if(typeof(clpc===null||clpc===void 0?void 0:(_clpc_props1=clpc.props)===null||_clpc_props1===void 0?void 0:(_clpc_props_children=_clpc_props1.children)===null||_clpc_props_children===void 0?void 0:(_clpc_props_children_props=_clpc_props_children.props)===null||_clpc_props_children_props===void 0?void 0:_clpc_props_children_props.children)==\"function\"){childrenFunction=clpc.props.children.props.children;}}return{query,queryParent,queryData,propertyControlsById,propertyControlsByName,childrenFunction};}export function addFieldsToSelect(fields,query,propertyControlsByName){const alias=query.alias;const select=Array.isArray(query===null||query===void 0?void 0:query.select)?[...query.select]:[];for(const fieldName of fields){var _propertyControlsByName_fieldName;const fieldId=(_propertyControlsByName_fieldName=propertyControlsByName[fieldName])===null||_propertyControlsByName_fieldName===void 0?void 0:_propertyControlsByName_fieldName.id;if(!fieldId){continue;}let matchFound=false;for(const item of select){if(item.name===fieldId&&item.type===\"Identifier\"&&item.collection===alias){matchFound=true;continue;}}if(matchFound){continue;}select.push({collection:alias,name:fieldId,type:\"Identifier\"});}return select;}\nexport const __FramerMetadata__ = {\"exports\":{\"getCollectionData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"addFieldsToSelect\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSLibrary.map","/*\n * CMSLibrary\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useEffect,useState}from\"react\";import{EmptyState}from\"https://framer.com/m/Shared-8iGD.js\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function RandomItemSelector(props){var _props_collectionList;const{type,layers}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const collectionList=(_props_collectionList=props.collectionList)===null||_props_collectionList===void 0?void 0:_props_collectionList[0];const{query,childrenFunction}=getCollectionData(collectionList);const data=query?useQueryData(query):null;const[layer,setLayer]=useState(null);useEffect(()=>{let randomLayer=null;switch(type){case\"array\":randomLayer=random(layers);break;case\"cms\":if(data){var _children_props;const children=childrenFunction(data);if(Array.isArray(children)){randomLayer=random(children);}else if(Array.isArray(children===null||children===void 0?void 0:(_children_props=children.props)===null||_children_props===void 0?void 0:_children_props.children)){randomLayer=random(children.props.children);}}break;}if(randomLayer){var _randomLayer_props;setLayer(/*#__PURE__*/cloneElement(randomLayer,{style:{...(_randomLayer_props=randomLayer.props)===null||_randomLayer_props===void 0?void 0:_randomLayer_props.style,...props.style}}));}else{setLayer(null);}},isCanvas?[type,layers,data]:[]);switch(type){case\"array\":if(!(layers===null||layers===void 0?void 0:layers.length)){return /*#__PURE__*/_jsx(EmptyState,{title:\"Connect layers\",subtitle:'Use the handle on the right side of the component or the \"Layers\" menu in the properties panel to connect layers.',maxWidth:400});}break;case\"cms\":if(!collectionList){return /*#__PURE__*/_jsx(EmptyState,{title:\"Connect a CMS Collection List\",subtitle:'Use the handle on the right side of the component or the \"Collection List\" dropdown in the properties panel to a Collection List layer.',maxWidth:400});}else if(isCanvas){return /*#__PURE__*/_jsx(EmptyState,{title:\"Preview site to see random item.\",subtitle:\"The Collection List's children are not accessible to code components in the editor, so you need to run the project in the preview or published site to see it.\",maxWidth:400});}break;}return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,...!layer?{minWidth:40,minHeight:40}:{}},children:layer});}RandomItemSelector.displayName=\"Random Item Selector\";addPropertyControls(RandomItemSelector,{type:{type:ControlType.Enum,defaultValue:\"array\",options:[\"array\",\"cms\"],optionTitles:[\"Array\",\"CMS Collection\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},layers:{type:ControlType.Array,control:{type:ControlType.ComponentInstance},description:\"A random layer from this list will be displayed.\",hidden:props=>props.type!=\"array\"},collectionList:{type:ControlType.ComponentInstance,description:\"A random item from this CMS Collection List will be displayed.\",hidden:props=>props.type!=\"cms\"}});function random(array){if(!array||array.length==0){return null;}return array[Math.floor(Math.random()*array.length)];}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RandomItemSelector\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RandomItemSelector.map"],"mappings":"mPAA6hC,SAAgB,EAAW,CAAC,QAAM,WAAS,WAAS,GAAG,CAAC,OAAoB,EAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,OAAO,MAAM,OAAO,OAAO,OAAO,aAAa,SAAS,WAAW,SAAS,cAAc,SAAS,IAAI,GAAG,gBAAgB,0BAA0B,aAAa,EAAE,OAAO,+BAA+B,MAAM,oBAAoB,SAAS,GAAG,QAAQ,GAAG,UAAU,IAAI,SAAS,GAAU,IAAA,GAAU,CAAC,SAAS,CAAc,EAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,IAAI,UAAU,SAAS,CAAC,SAAS,EAAM,CAAC,CAAc,EAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAC/jD,WAAW,IAAI,UAAU,SAAS,CAAC,SAAS,EAAS,CAAC,CAAC,CAAC,CAAC,kBADA,IAAgC,IAAkC,CAChE,EAAW,YAAY,kCEDlF,SAAgB,EAAkB,EAAe,CAAC,IAA+D,EAA+B,EAA2E,EAA8C,EAAsC,EAAgC,EAA0C,IAAI,EAAY,KAAQ,GAAiB,MAA4D,EAAe,OAA2E,MAAO,EAAY,EAAwB,KAAiB,OAAsC,EAAuB,EAAe,QAAS,OAA8C,EAA+B,EAAuB,WAAY,OAA2F,EAA+B,OAAyG,MAAO,EAAY,EAAe,MAAM,SAAkB,KAAiB,OAAsC,EAAuB,EAAe,QAAS,OAA8C,EAAgC,EAAuB,WAAY,OAAuD,EAAsC,EAAgC,QAAS,OAA6D,EAA8C,EAAsC,WAAY,OAAyH,EAA8C,OAAuI,QAAO,EAAY,EAAe,MAAM,SAAS,MAAM,UAAU,IAAM,EAAM,GAAgF,OAAqE,MAAU,EAAU,KAAK,GAAG,GA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