{"version":3,"file":"sync.oGFO8BVf.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/fr5rlBeqfsI3t1cSDhs5/Zd8vHWG8XAmeoAXNr1QA/config.js","https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js","https:/framerusercontent.com/modules/7iKm8o7FSl4LLCe2yci5/NyTgBDGsMlNq96AKCQZc/sync.js"],"sourcesContent":["// config.ts\n// Shared Airtable API key\nexport const AIRTABLE_API_KEY=\"patOXxxgan7LzwY7C.8f38e2453445c657425eda063fca1a241c6eded08801a29211376493f90847db\";// Main Airtable configuration\nexport const MAIN_AIRTABLE_CONFIG={baseId:\"app9cLl0fkF9K5GcL\",tableId:\"tblTFjxHLXTOKz5fn\",viewId:\"viwCBLx9U5M8jq2jZ\"};//airtable.com/app9cLl0fkF9K5GcL/tblTFjxHLXTOKz5fn/viwCBLx9U5M8jq2jZ?blocks=hide\n// NEW: Events Airtable configuration (Type = \"Event\" will be applied via filterByFormula in the hook)\nexport const EVENTS_AIRTABLE_CONFIG={baseId:\"app9cLl0fkF9K5GcL\",tableId:\"tblLf10McRkL13tml\",viewId:\"viw6qm10kPXvkWTXv\"};//airtable.com/app9cLl0fkF9K5GcL/tblLf10McRkL13tml/viw6qm10kPXvkWTXv?blocks=hide\n// FAQ Airtable configuration\nexport const FAQ_AIRTABLE_CONFIG={baseId:\"appd7EFJwRVxkFX22\",tableId:\"tbljD9QME5HLICy7w\",viewId:\"viwjRJCmBhWcLZbsw\"};// Field IDs and names from main Airtable table\nexport const MAIN_FIELD_IDS={avatar:{id:\"fldpYlZeOnaYpmJwc\",name:\"Avatar\"},firstName:{id:\"fldVOk6BPXWMw7itx\",name:\"First name\"},lastModified:{id:\"fld23FNxccgTnQnz6\",name:\"Last Modified\"}};// Field IDs and names from FAQ Airtable table\nexport const FAQ_FIELD_IDS={question:{name:\"Question\"},answer:{name:\"Answer\"},category:{name:\"Category\"},topAsked:{name:\"TopAsked\"},lastModified:{name:\"Last Modified\"}};// Optional: centralize categories\nexport const FAQ_CATEGORIES=[\"All\",\"Contracting\",\"Community\",\"Fees\",\"Location\",\"Beliefs\"];// Helper function to get the appropriate config based on the type\nexport const getAirtableConfig=type=>{const config=type===\"main\"?MAIN_AIRTABLE_CONFIG:type===\"faq\"?FAQ_AIRTABLE_CONFIG:EVENTS_AIRTABLE_CONFIG;return{...config,apiKey:AIRTABLE_API_KEY};};// Single implementation (required)\nexport function getFieldIds(type){return type===\"main\"?MAIN_FIELD_IDS:FAQ_FIELD_IDS;}\nexport const __FramerMetadata__ = {\"exports\":{\"MAIN_FIELD_IDS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FAQ_FIELD_IDS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getFieldIds\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"EVENTS_AIRTABLE_CONFIG\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"MAIN_AIRTABLE_CONFIG\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FAQ_CATEGORIES\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getAirtableConfig\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"AIRTABLE_API_KEY\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FAQ_AIRTABLE_CONFIG\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./config.map","import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","// sync.ts\nimport{createStore}from\"https://framer.com/m/framer/store.js\";import React from\"react\";// Create a store for page states\n// This store holds the state for different pages, identified by their pageId\nconst usePageStore=createStore({});// Hook to manage page-specific category selections\n// This allows components on the same page to share their category selection state\nexport function usePageCategories(){const[store,setStore]=usePageStore();const[pageId,setPageId]=React.useState(\"default\");// Get the current page ID from Framer's Page component\n// Only run this on the client side\nReact.useEffect(()=>{// Find the closest parent Page component\nconst pageElement=document.querySelector('[data-framer-component-type=\"Page\"]');if(pageElement?.id){setPageId(pageElement.id);}},[]);// Initialize page state if it doesn't exist\n// This ensures we always have a valid state object for the page\nif(!store[pageId]){setStore({...store,[pageId]:{selectedCategories:[],categoryOrder:[]}});}// Function to update categories for this page\n// This will be called by the FAQAccordion when categories are selected\nconst updateCategories=(categories,order)=>{setStore({...store,[pageId]:{...store[pageId],selectedCategories:categories,categoryOrder:order}});};// Return the current categories and the update function\n// Components can use this to read and write category selections\nreturn{selectedCategories:store[pageId]?.selectedCategories||[],categoryOrder:store[pageId]?.categoryOrder||[],updateCategories};}export function createAirtableSync(options){const{key,baseId,tableId,viewId,apiKey,transformRecord,filterByFormula}=options;const useStore=createStore({records:[]});let isFetching=false;async function fetchAllRecordsWithPagination(url){let allRecords=[];let offset;do{const fullUrl=offset?`${url}&offset=${offset}`:url;const response=await fetch(fullUrl,{headers:{Authorization:`Bearer ${apiKey}`}});if(!response.ok)throw new Error(`Airtable fetch failed: ${response.statusText}`);const data=await response.json();allRecords=allRecords.concat(data.records);offset=data.offset;}while(offset)return allRecords;}async function fetchAndSync(setStore){if(isFetching)return;isFetching=true;const url=new URL(`https://api.airtable.com/v0/${baseId}/${tableId}`);url.searchParams.set(\"view\",viewId);url.searchParams.set(\"pageSize\",\"100\");// NEW: Server-side filtering using Airtable formulas\nif(filterByFormula){url.searchParams.set(\"filterByFormula\",filterByFormula);}try{const records=await fetchAllRecordsWithPagination(url.toString());const transformed=records.map(transformRecord).filter(r=>r!=null);setStore({records:transformed});}catch(err){console.error(`[AirtableSync] Error fetching ${key}:`,err);setStore({records:[]});}isFetching=false;}function useAirtableRecords(){const[store,setStore]=useStore();React.useEffect(()=>{fetchAndSync(setStore);},[]);return store.records??[];}return useAirtableRecords;}\nexport const __FramerMetadata__ = {\"exports\":{\"usePageCategories\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createAirtableSync\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingUR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