{"version":3,"file":"CMSCounter.SuA4RGp0.mjs","names":["__esmMin","p","init_jsx_runtime","init_framer_CaDWdxiz","useQueryData","addPropertyControls","RenderTarget","getCollectionData","_collectionList_props_children","_collectionList_props1","_collectionList_props_children_props_children","_collectionList_props_children_props1","_collectionList_props_children1","_collectionList_props2","queryParent","collectionList","query","queryData","left","i","propertyControlsById","propertyControlsByName","id","control","childrenFunction","_clpc_props_children","_clpc_props1","clpc","init_CMSLibrary","formatNumber","numberString","value","commas","CMSCounter","props","isCanvas","items","prefix","suffix","transform","init_CMSCounter","ControlType"],"sources":["https:/framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js","https:/framerusercontent.com/modules/BBUAbGx22zVBT9dNUfhp/EloIiNVxyGmTu7IVoOOS/CMSCounter.js"],"sourcesContent":["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","import{jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";function formatNumber(value,commas){let numberString=value.toFixed(0);if(commas){numberString=numberString.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");}return numberString;}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CMSCounter(props){var _props_collectionList,_props_style;const{transform}=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}=getCollectionData(collectionList);let items=props.placeholder;// Only display number of CMS items in the preview and live website.\nif(query&&!isCanvas){items=useQueryData(query).length;}let prefix=\"\";let suffix=\"\";if(transform){if(transform.plural){prefix=items==1?transform.singularPrefix:transform.pluralPrefix;suffix=items==1?transform.singularSuffix:transform.pluralSuffix;}else{prefix=transform.prefix;suffix=transform.suffix;}}return /*#__PURE__*/_jsxs(\"div\",{style:{color:props.fontColor,userSelect:props.textSelect?\"auto\":\"none\",margin:0,whiteSpace:((_props_style=props.style)===null||_props_style===void 0?void 0:_props_style.width)?undefined:\"nowrap\",...props.font,...props.style},children:[prefix,formatNumber(items,props.commas),suffix]});}CMSCounter.displayName=\"CMS Item Counter\";addPropertyControls(CMSCounter,{collectionList:{type:ControlType.ComponentInstance},placeholder:{type:ControlType.Number,defaultValue:10,min:0,step:1,description:\"Placeholder number is shown in the editor.\"},commas:{type:ControlType.Boolean,defaultValue:true},fontColor:{type:ControlType.Color,defaultValue:\"#000\"},font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1}},transform:{type:ControlType.Object,optional:true,controls:{plural:{type:ControlType.Boolean,defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,hidden(props){return props.plural;}},suffix:{type:ControlType.String,hidden(props){return props.plural;}},singularPrefix:{type:ControlType.String,placeholder:\"Singular Prefix\",hidden(props){return!props.plural;}},singularSuffix:{type:ControlType.String,placeholder:\"Singular Suffix\",hidden(props){return!props.plural;}},pluralPrefix:{type:ControlType.String,placeholder:\"Plural Prefix\",hidden(props){return!props.plural;}},pluralSuffix:{type:ControlType.String,placeholder:\"Plural Suffix\",hidden(props){return!props.plural;}}}},textSelect:{type:ControlType.Boolean,defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSCounter.map"],"mappings":"A,uKAAA,SAAgBO,EAAkB,EAAe,CAAC,IAA+DC,EAA+BC,EAA2EC,EAA8CC,EAAsCC,EAAgCC,EAA0C,IAAIC,EAAY,KAAQC,GAAiB,MAA4DA,EAAe,OAA2E,MAAO,EAAYA,EAAwBA,GAAiB,OAAsC,EAAuBA,EAAe,QAAS,OAA8C,EAA+BN,EAAuB,WAAY,MAA2FD,EAA+B,OAAyG,MAAO,EAAYO,EAAe,MAAM,SAAkBA,GAAiB,OAAsC,EAAuBA,EAAe,QAAS,OAA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