{"version":3,"file":"CMSBookmarkList.CpDIcanP.mjs","names":["useState"],"sources":["https:/framer.com/m/SuperfieldsShared-hv54.js","https:/framerusercontent.com/modules/zRbm1HyT3eOdKGvsSmRe/JP5ojFQws0RU9D9OhF1P/CMSBookmarkList.js"],"sourcesContent":["/*\n * SuperfieldsShared\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/FZjYlw33eNo8pxLbSFLX/9cz7ek89fMdNfYUyPOlg/SuperfieldsShared.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useState,useEffect,createContext}from\"react\";import{EmptyState}from\"https://framer.com/m/SuperfieldsShared-hv54.js\";import{fetchUserData}from\"https://framer.com/m/ThentyHelpers-I0Oh.js\";export const FavouriteContext=/*#__PURE__*/createContext(false);const slugFieldName=\"Slug\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CMSBookmarkList(props){const{cmsCollectionName,collectionList}=props;const{userData}=fetchUserData();const isCanvas=RenderTarget.current()===RenderTarget.canvas;const cl=collectionList?.[0];const emptyState=props.emptyState?.[0]// Empty state is never used\n;const[favouriteState,setFavouriteState]=useState([]);useEffect(()=>{setFavouriteState(userData?.bookmarks);},[userData?.bookmarks]);const query=cl?.props?.children?.props?.children?.props?.query;const collectionData=query?.from?.data;const propertyControlsById=collectionData?.propertyControls||{};const data=query?useQueryData(query):[];let slugFieldId=\"\";// Get favorite and slug field IDs\nfor(const id in propertyControlsById){const control=propertyControlsById[id];if(control.title==slugFieldName){slugFieldId=id;break;}}const newData=[];if(!isCanvas){for(const index in data){const cmsItem=data[index];const slug=cmsItem[slugFieldId];if(!isNaN(Number(index))){const isFavourite=(favouriteState??[]).includes(`/${cmsCollectionName}/${slug}`.toLowerCase());if(isFavourite){const newObject=Object.assign({},cmsItem);newData.push(newObject);}}else{newData[index]=cmsItem;}}}// Empty states\nif(isCanvas&&!cl){return /*#__PURE__*/_jsx(EmptyState,{title:\"Connect a Collection List\",subtitle:\"Connect a CMS Collection List layer using the handle on the right side of the component.\"});}let children=[];if(!isCanvas&&cl&&query){children=cl?.props?.children?.props?.children?.props?.children(newData);}return /*#__PURE__*/_jsx(FavouriteContext.Provider,{value:true,children:isCanvas?cl?/*#__PURE__*/cloneElement(cl,{style:{...props.style,...cl.props?.style}}):null:(children?.props?.children??[]).length>0?/*#__PURE__*/_jsx(\"div\",{...cl.props,style:{...cl.props?.style,...props.style},children:children}):emptyState?/*#__PURE__*/cloneElement(emptyState,{style:{...emptyState.props.style,...props.style}}):null});}CMSBookmarkList.displayName=\"CMS Bookmark List\";addPropertyControls(CMSBookmarkList,{collectionList:{type:ControlType.ComponentInstance},emptyState:{type:ControlType.ComponentInstance},cmsCollectionName:{type:ControlType.String,defaultValue:\"\",title:\"CMS Collection Name\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSBookmarkList\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"FavouriteContext\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSBookmarkList.map"],"mappings":"mVCIG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,oBAAkB,kBAAgB,EAAW,CAAC,YAAU,EAAc,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAa,EAAG,IAAiB,GAAS,EAAW,EAAM,aAAa,GACvP,CAAC,EAAe,GAAmBA,EAAS,CAAC,CAAC,EAAE,MAAc,CAAC,EAAkB,GAAU,SAAS,CAAE,EAAE,CAAC,GAAU,SAAS,CAAC,EAAE,IAAM,EAAM,GAAI,OAAO,UAAU,OAAO,UAAU,OAAO,MAAmD,EAAxB,GAAO,M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