{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/O4iBWQrDmGKDGXcsKcK7/aP2sKnxV17IM6zzgzDKx/Pagination.js"],
  "sourcesContent": ["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useLayoutEffect,startTransition}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const LIMIT=12;const OFFSET=0;const SCROLL_THRESHOLD=200;const PREVIOUS_CLASS=\"Previous\";const PREVIOUS_DISABLED_CLASS=\"Previous Disabled\";const NEXT_CLASS=\"Next\";const NEXT_DISABLED_CLASS=\"Next Disabled\";const PAGE_NUMBER_CLASS=\"Page Number\";const PAGE_NUMBER_ACTIVE_CLASS=\"Page Number Active\";const useStore=createStore({limit:LIMIT,offset:OFFSET,totalItems:null,currentPage:1});export const withCollectionList=Component=>{return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useEffect(()=>{if(store.totalItems===null){const queryTotalItems=document.querySelector(`.${props.className}none .${props.className}`).children.length;const newTotalItems=queryTotalItems-OFFSET;setStore({totalItems:Math.max(newTotalItems,0)});}},[props,store]);useLayoutEffect(()=>{setNewProps({...props,children:{...props.children,props:{...props.children.props,query:{...props.children.props.query,limit:{type:\"LiteralValue\",value:store.limit},offset:{type:\"LiteralValue\",value:store.offset}}}}});},[store.offset,store.limit,props]);return /*#__PURE__*/_jsxs(_Fragment,{children:[store.totalItems===null&&/*#__PURE__*/_jsx(\"div\",{className:`${props.className}none`,style:{display:\"none\"},children:/*#__PURE__*/_jsx(Component,{...props})}),/*#__PURE__*/_jsx(Component,{...newProps})]});};};const onToggle=()=>{startTransition(()=>{originalOnToggle();});};export const withLoadMore=Component=>{return props=>{const[store,setStore]=useStore();useEffect(()=>{setStore({offset:OFFSET,totalItems:null,currentPage:1,limit:LIMIT});},[]);const handleLoadMore=()=>{setStore({limit:store.limit+LIMIT});};// Ensure the component renders only if store.totalItems is not null\nif(store.totalItems===null){return null// or return a loading indicator\n;}return /*#__PURE__*/_jsx(_Fragment,{children:store.limit<store.totalItems&&/*#__PURE__*/_jsx(Component,{...props,onClick:handleLoadMore})});};};export const withInfiniteScroll=Component=>{return props=>{const[store,setStore]=useStore();useEffect(()=>{setStore({offset:OFFSET,totalItems:null,currentPage:1});},[]);useEffect(()=>{window.addEventListener(\"scroll\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[store,store.limit,store.totalItems]);const handleScroll=()=>{if(store.totalItems&&store.limit<store.totalItems&&window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-SCROLL_THRESHOLD){setStore({limit:store.limit+LIMIT});}};return /*#__PURE__*/_jsx(Component,{...props});};};export const withPrevious=Component=>{return props=>{const[store,setStore]=useStore();useEffect(()=>{setStore({totalItems:null,limit:LIMIT});},[]);const handlePreviousPage=()=>{if(store.currentPage>1){const newPage=store.currentPage-1;const newOffset=(newPage-1)*LIMIT;setStore({offset:newOffset,currentPage:newPage});window.scrollTo(0,0);}};return /*#__PURE__*/_jsx(Component,{...props,onClick:handlePreviousPage,variant:store.currentPage!==1?PREVIOUS_CLASS:PREVIOUS_DISABLED_CLASS});};};export const withNext=Component=>{return props=>{const[store,setStore]=useStore();useEffect(()=>{setStore({totalItems:null,limit:LIMIT});},[]);const handleNextPage=()=>{if(store.currentPage*LIMIT<store.totalItems){const newPage=store.currentPage+1;const newOffset=(newPage-1)*LIMIT;setStore({offset:newOffset,currentPage:newPage});window.scrollTo(0,0);}};return /*#__PURE__*/_jsx(Component,{...props,onClick:handleNextPage,variant:store.currentPage*LIMIT<store.totalItems?NEXT_CLASS:NEXT_DISABLED_CLASS});};};export const withCurrentPage=Component=>{return props=>{const[store,setStore]=useStore();useEffect(()=>{setStore({totalItems:null,limit:LIMIT});},[]);const[currentPage,setCurrentPage]=useState(()=>store.currentPage.toString());const[totalPages,setTotalPages]=useState(()=>Math.ceil(store.totalItems/LIMIT));useEffect(()=>{setCurrentPage(store.currentPage.toString());setTotalPages(Math.ceil(store.totalItems/LIMIT));},[store.currentPage,store.totalItems]);return /*#__PURE__*/_jsx(Component,{...props,page:`${currentPage}/${totalPages}`});};};export const withPageSelector=Component=>{return props=>{const[store,setStore]=useStore();const[pages,setPages]=useState([]);useEffect(()=>{setStore({totalItems:null,limit:LIMIT});},[]);useEffect(()=>{const generatePages=()=>{const totalPages=Math.ceil(store.totalItems/LIMIT);const newPages=Array.from({length:totalPages},(_,index)=>index+1);setPages(newPages);};generatePages();},[store.totalItems]);const handleNewPage=newPage=>{const newOffset=(newPage-1)*LIMIT;setStore({offset:newOffset,currentPage:newPage});window.scrollTo(0,0);};return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"row\"},children:pages.map((item,index)=>{return /*#__PURE__*/_jsx(Component,{...props,page:item.toString(),onClick:()=>handleNewPage(item),variant:store.currentPage===item?PAGE_NUMBER_ACTIVE_CLASS:PAGE_NUMBER_CLASS},index);})});};};export const withTablePagination=Component=>{return props=>{const[store,setStore]=useStore();const[pages,setPages]=useState([]);useEffect(()=>{setStore({totalItems:null,limit:LIMIT});},[]);useEffect(()=>{const generatePages=()=>{const totalPages=Math.ceil(store.totalItems/LIMIT);const adjacentPages=store.currentPage===1||store.currentPage===totalPages?2:1;const pages=[];for(let i=1;i<=totalPages;i++){const isWithinRange=i>=store.currentPage-adjacentPages&&i<=store.currentPage+adjacentPages;if(i===1||i===totalPages||isWithinRange){pages.push(i);}else if(i===store.currentPage-adjacentPages-1&&i!==1||i===store.currentPage+adjacentPages+1&&i!==totalPages){pages.push(\"...\");}}setPages(pages);};generatePages();},[store.totalItems,store.currentPage]);const handleNewPage=newPage=>{const newOffset=(newPage-1)*LIMIT;setStore({offset:newOffset,currentPage:newPage});window.scrollTo(0,0);};return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"row\"},children:pages.map((item,index,array)=>{const isEllipsis=item===\"...\";return /*#__PURE__*/_jsx(Component,{...props,page:item.toString(),onClick:()=>!isEllipsis&&handleNewPage(item),variant:store.currentPage===item||isEllipsis?PAGE_NUMBER_ACTIVE_CLASS:PAGE_NUMBER_CLASS},index);})});};};export const withClear=Component=>{return props=>{const[store,setStore]=useStore();const handleClick=()=>{setStore({offset:OFFSET,totalItems:null,currentPage:1,limit:LIMIT});};return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};};function originalOnToggle(){throw new Error(\"Function not implemented.\");}\nexport const __FramerMetadata__ = {\"exports\":{\"withClear\":{\"type\":\"reactHoc\",\"name\":\"withClear\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPageSelector\":{\"type\":\"reactHoc\",\"name\":\"withPageSelector\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCurrentPage\":{\"type\":\"reactHoc\",\"name\":\"withCurrentPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPrevious\":{\"type\":\"reactHoc\",\"name\":\"withPrevious\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCollectionList\":{\"type\":\"reactHoc\",\"name\":\"withCollectionList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withInfiniteScroll\":{\"type\":\"reactHoc\",\"name\":\"withInfiniteScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoadMore\":{\"type\":\"reactHoc\",\"name\":\"withLoadMore\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withNext\":{\"type\":\"reactHoc\",\"name\":\"withNext\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTablePagination\":{\"type\":\"reactHoc\",\"name\":\"withTablePagination\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Pagination.map"],
  "mappings": "uJAA0N,IAAMA,EAAM,GAASC,EAAO,EAA2Q,IAAMC,EAASC,EAAY,CAAC,MAAMC,EAAM,OAAOC,EAAO,WAAW,KAAK,YAAY,CAAC,CAAC,EAAeC,EAAmBC,GAAmBC,GAAO,CAAC,GAAK,CAACC,EAAMC,CAAQ,EAAER,EAAS,EAAO,CAACS,EAASC,CAAW,EAAEC,EAASL,CAAK,EAAE,OAAAM,EAAU,IAAI,CAAC,GAAGL,EAAM,aAAa,KAAK,CAA6G,IAAMM,EAA5F,SAAS,cAAc,IAAIP,EAAM,kBAAkBA,EAAM,WAAW,EAAE,SAAS,OAA2CH,EAAOK,EAAS,CAAC,WAAW,KAAK,IAAIK,EAAc,CAAC,CAAC,CAAC,EAAG,EAAE,CAACP,EAAMC,CAAK,CAAC,EAAEO,EAAgB,IAAI,CAACJ,EAAY,CAAC,GAAGJ,EAAM,SAAS,CAAC,GAAGA,EAAM,SAAS,MAAM,CAAC,GAAGA,EAAM,SAAS,MAAM,MAAM,CAAC,GAAGA,EAAM,SAAS,MAAM,MAAM,MAAM,CAAC,KAAK,eAAe,MAAMC,EAAM,KAAK,EAAE,OAAO,CAAC,KAAK,eAAe,MAAMA,EAAM,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,CAACA,EAAM,OAAOA,EAAM,MAAMD,CAAK,CAAC,EAAsBS,EAAM,EAAU,CAAC,SAAS,CAACR,EAAM,aAAa,MAAmBS,EAAK,MAAM,CAAC,UAAU,GAAGV,EAAM,gBAAgB,MAAM,CAAC,QAAQ,MAAM,EAAE,SAAsBU,EAAKX,EAAU,CAAC,GAAGC,CAAK,CAAC,CAAC,CAAC,EAAeU,EAAKX,EAAU,CAAC,GAAGI,CAAQ,CAAC,CAAC,CAAC,CAAC,CAAE",
  "names": ["LIMIT", "OFFSET", "useStore", "createStore", "LIMIT", "OFFSET", "withCollectionList", "Component", "props", "store", "setStore", "newProps", "setNewProps", "ye", "ue", "newTotalItems", "fe", "u", "p"]
}
