{"version":3,"file":"Count_Plus.DFbaSDhq.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/ubQzYMGMKNc26KTaalF2/tJuXeqBbQQFnEYkTlWWT/Count_Plus.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,// @ts-ignore\ngetPropertyControls,ControlType,useIsOnFramerCanvas}from\"framer\";import{useEffect,useState}from\"react\";import{useStore}from\"https://framerusercontent.com/modules/oaAH7umUjUOTeKmykfom/4GSr51yWhuxjuWu6QpOf/Stores.js\";import CollectionIDControl from\"https://framerusercontent.com/modules/Hxho9sUnioBkMjGbLBed/csoxszrftuhmv2NyuE1c/collectionID.js\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */export default function Count_Plus(props){const cmsPlusComponentName=\"Count+\";const{counters,countOption,interactionAboveZero,interactionOnZero,selectedCollections,fontStyles,fontColor}=props;const[store]=useStore();const[count,setCount]=useState(0);const isOnFramerCanvas=useIsOnFramerCanvas();const pStyles={margin:0};// as the collections' filters are changed in store, total the search results or selected active filters\nuseEffect(()=>{if(!isOnFramerCanvas){let tally=0;const selections=countOption===\"searchResults\"?selectedCollections:counters;for(let index=0;index<selections.length;index++){// tally up search results if selected\nif(countOption===\"searchResults\"){const collectionID=selections[index];const collection=store[collectionID];if(!collection)continue;tally+=collection.searchResults.length;}// tally up active filters if selected\nif(countOption===\"activeFilters\"){const{countAllActiveFilters,cmsFields,collectionID}=selections[index];const collection=store[collectionID];if(!collection)continue;for(const[fieldName,{filters}]of Object.entries(collection.fields)){// skit if filters are undefined\nif(!filters)continue;if(countAllActiveFilters||cmsFields.includes(fieldName)){// for each active filter, tally up\nfilters.forEach(filter=>{if(filter.isActive)tally++;});}}}}setCount(tally);// trigger the interactions if they're set, they are optional\ntally<1?interactionOnZero?.():interactionAboveZero?.();}},[isOnFramerCanvas,store]);return /*#__PURE__*/_jsx(\"p\",{style:{...pStyles,...fontStyles,color:fontColor},children:count});}Count_Plus.displayName=\"Count+\";addPropertyControls(Count_Plus,{interactionOnZero:{type:ControlType.EventHandler,title:\"Zero\",defaultValue:null},interactionAboveZero:{type:ControlType.EventHandler,title:\"Above Zero\",defaultValue:null},countOption:{type:ControlType.Enum,title:\"Count\",description:`Explore its [documentation](https://framercms.plus/documentation/component-count-plus).`,options:[\"searchResults\",\"activeFilters\"],optionTitles:[\"Search Results\",\"Active Filters\"]},selectedCollections:{type:ControlType.Array,title:\"Collection+ IDs\",defaultValue:[],control:{type:ControlType.Number,defaultValue:0,min:0,displayStepper:true,step:1},hidden:props=>props.countOption!==\"searchResults\"},counters:{type:ControlType.Array,title:\"Filters\",defaultValue:[],control:{type:ControlType.Object,title:\"Collection+ IDs & Fields\",controls:{...getPropertyControls(CollectionIDControl),countAllActiveFilters:{type:ControlType.Boolean,title:\"All Active Filters\",defaultValue:true},cmsFields:{type:ControlType.Array,title:\"Fields\",defaultValue:[],description:\"Must match exactly as the field is named in its collection.\",control:{type:ControlType.String,title:\"Field\",defaultValue:\"\"},hidden:props=>props.countAllActiveFilters}}},hidden:props=>props.countOption!==\"activeFilters\"},fontStyles:{type:ControlType.Font,controls:\"extended\",title:\"Font\"},fontColor:{type:ControlType.Color,title:\"Color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Count_Plus\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"sdAMG,SAAwB,EAAW,EAAM,CAAqC,GAAK,CAAC,WAAS,cAAY,uBAAqB,oBAAkB,sBAAoB,aAAW,aAAW,EAAW,CAAC,GAAO,GAAU,CAAM,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAO,EAAiB,GAAqB,CAMrN,OALpF,MAAc,CAAC,GAAG,CAAC,EAAiB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