{"version":3,"sources":["../../elements/pagination/Pagination.tsx","../../util/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Pagination as PaginationPrimitive } from \"react-headless-pagination\";\n\nimport { cn } from \"@util/index\";\n\nimport { DirectionType } from \"../../types/commonTypes\";\n\ntype PaginationProps = {\n  direction?: DirectionType;\n  totalPages: number;\n  currentPage?: number;\n};\n\nexport const Pagination: React.FC<PaginationProps> = ({\n  direction,\n  totalPages,\n  currentPage,\n}) => {\n  const [page, setPage] = React.useState<number>(currentPage || 0);\n  const handlePageChange = (page: number) => {\n    setPage(page);\n  };\n  return (\n    <PaginationPrimitive\n      totalPages={totalPages}\n      edgePageCount={2}\n      middlePagesSiblingCount={1}\n      currentPage={page}\n      setCurrentPage={handlePageChange}\n      className=\"hawa-flex hawa-h-9 hawa-w-full hawa-select-none hawa-items-center hawa-text-sm hawa-transition-all\"\n      truncableText=\"...\"\n      truncableClassName=\"hawa-w-10 hawa-px-0.5 hawa-text-center\"\n    >\n      <PaginationPrimitive.PrevButton\n        as={\n          <button\n            aria-label=\"Previous Table Page\"\n            className={cn(\n              \"hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card\",\n              direction === \"rtl\" && \"hawa-rotate-180\",\n            )}\n            style={{ minWidth: 36 }}\n          >\n            <svg\n              xmlns=\"http://www.w3.org/2000/svg\"\n              width=\"24\"\n              height=\"24\"\n              viewBox=\"0 0 24 24\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              strokeWidth=\"2\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n            >\n              <path d=\"m15 18-6-6 6-6\" />\n            </svg>\n          </button>\n        }\n        className={cn(\n          \"hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200\",\n          {\n            \"hawa-cursor-pointer\": page !== 0,\n            \"hawa-opacity-50\": page === 0,\n          },\n        )}\n      >\n        Previous\n      </PaginationPrimitive.PrevButton>\n\n      <nav className=\"hawa-flex hawa-flex-grow hawa-justify-center\">\n        <ul className=\"hawa-flex hawa-items-center hawa-gap-1\">\n          <PaginationPrimitive.PageButton\n            className={\n              \"hawa-tap-highlight-transparent hawa-text-default-foreground data-[focus-visible=true]:hawa-outline-focus data-[disabled=true]:hawa-text-default-300 hawa-min-w-9 hawa-text-small hawa-box-border hawa-flex hawa-h-9 hawa-w-9 hawa-cursor-pointer hawa-touch-none hawa-select-none hawa-flex-wrap hawa-items-center hawa-justify-center hawa-truncate hawa-rounded hawa-border hawa-bg-card hawa-outline-none hawa-transition-all hover:hawa-scale-[1.1] data-[disabled=true]:hawa-pointer-events-none data-[focus-visible=true]:hawa-z-10 data-[pressed=true]:hawa-scale-[0.97] data-[focus-visible=true]:hawa-outline-2 data-[focus-visible=true]:hawa-outline-offset-2\"\n            }\n            activeClassName=\"hawa-bg-primary hawa-text-primary-foreground hawa-transition-all\"\n            // activeClassName=\"hawa-bg-primary/80  hawa-text-primary-foreground hawa-font-extrabold\"\n            // inactiveClassName=\"hawa-text-gray-500\"\n            // className={\n            //   \"hawa-flex hawa-bg-muted hawa-rounded hawa-items-center hawa-justify-center hover:hawa-text-primary-600 focus:hawa-font-bold focus:hawa-text-primary-600 focus:hawa-outline-none hawa-h-7 hawa-w-7 hawa-cursor-pointer\"\n            // }\n          />\n        </ul>\n      </nav>\n\n      <PaginationPrimitive.NextButton\n        as={\n          <button\n            aria-label=\"Previous Table Page\"\n            className={cn(\n              \"hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card\",\n              direction === \"ltr\" && \"hawa-rotate-180\",\n            )}\n            style={{ minWidth: 36 }}\n          >\n            <svg\n              xmlns=\"http://www.w3.org/2000/svg\"\n              width=\"24\"\n              height=\"24\"\n              viewBox=\"0 0 24 24\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              strokeWidth=\"2\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n            >\n              <path d=\"m15 18-6-6 6-6\" />\n            </svg>\n          </button>\n        }\n        className={cn(\n          \"hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200\",\n          {\n            \"hawa-cursor-pointer\": page !== totalPages - 1,\n            \"hawa-opacity-50\": page === totalPages - 1,\n          },\n        )}\n      >\n        Next\n        {/* <FiArrowRight size={20} className=\"ml-3\" /> */}\n      </PaginationPrimitive.NextButton>\n    </PaginationPrimitive>\n  );\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n  name: string;\n  colors: {\n    [key: number]: string;\n  };\n};\ntype Rgb = {\n  r: number;\n  g: number;\n  b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n  const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n  const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n    sanitizedHex\n  );\n\n  if (!colorParts) {\n    return null;\n  }\n\n  const [, r, g, b] = colorParts;\n\n  return {\n    r: parseInt(r, 16),\n    g: parseInt(g, 16),\n    b: parseInt(b, 16)\n  } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n  const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n  return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n  const rgbColor = hexToRgb(color);\n\n  if (!rgbColor) {\n    return \"#333\";\n  }\n\n  const { r, g, b } = rgbColor;\n  const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n  return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n  const color = hexToRgb(`#${hex}`);\n\n  if (!color) {\n    return \"\";\n  }\n\n  const r = Math.round(color.r + (255 - color.r) * intensity);\n  const g = Math.round(color.g + (255 - color.g) * intensity);\n  const b = Math.round(color.b + (255 - color.b) * intensity);\n\n  return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n  const color = hexToRgb(hex);\n\n  if (!color) {\n    return \"\";\n  }\n\n  const r = Math.round(color.r * intensity);\n  const g = Math.round(color.g * intensity);\n  const b = Math.round(color.b * intensity);\n\n  return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n  if (color.startsWith(\"#\")) {\n    // Convert hex to RGB\n    let r = parseInt(color.slice(1, 3), 16);\n    let g = parseInt(color.slice(3, 5), 16);\n    let b = parseInt(color.slice(5, 7), 16);\n    return [r, g, b];\n  } else if (color.startsWith(\"rgb\")) {\n    // Extract RGB values from rgb() format\n    return color.match(/\\d+/g).map(Number);\n  }\n  // Default to white if format is unrecognized\n  return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n  const [r, g, b] = parseColor(color)?.map((c: any) => {\n    c /= 255;\n    return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n  });\n  return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n  const name = baseColor;\n\n  const response: Palette = {\n    name,\n    colors: {\n      500: `#${baseColor}`.replace(\"##\", \"#\")\n    }\n  };\n\n  const intensityMap: {\n    [key: number]: number;\n  } = {\n    50: 0.95,\n    100: 0.9,\n    200: 0.75,\n    300: 0.6,\n    400: 0.3,\n    600: 0.9,\n    700: 0.75,\n    800: 0.6,\n    900: 0.49\n  };\n\n  [50, 100, 200, 300, 400].forEach((level) => {\n    response.colors[level] = lighten(baseColor, intensityMap[level]);\n  });\n  [600, 700, 800, 900].forEach((level) => {\n    response.colors[level] = darken(baseColor, intensityMap[level]);\n  });\n\n  return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n//   let d = hex?.split(\"#\")[1];\n//   var aRgbHex = d?.match(/.{1,2}/g);\n//   var aRgb = [\n//     parseInt(aRgbHex[0], 16),\n//     parseInt(aRgbHex[1], 16),\n//     parseInt(aRgbHex[2], 16)\n//   ];\n//   return aRgb;\n// };\n// const getTextColor = (backColor) => {\n//   let rgbArray = hexToRgb(backColor);\n//   if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n//     return \"#000000\";\n//   } else {\n//     return \"#ffffff\";\n//   }\n// };\n// const replaceAt = function (string, index, replacement) {\n//   // if (replacement == \"\" || replacement == \" \") {\n//   //   return (\n//   //     string.substring(0, index) +\n//   //     string.substring(index + replacement.length )\n//   //   );\n//   // }\n//   const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n//   return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n"],"mappings":";;;AAAA,OAAO,WAAW;AAClB,SAAS,cAAc,2BAA2B;;;ACDlD,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADQO,IAAM,aAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAiB,eAAe,CAAC;AAC/D,QAAM,mBAAmB,CAACA,UAAiB;AACzC,YAAQA,KAAI;AAAA,EACd;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAe;AAAA,MACf,yBAAyB;AAAA,MACzB,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,WAAU;AAAA,MACV,eAAc;AAAA,MACd,oBAAmB;AAAA;AAAA,IAEnB;AAAA,MAAC,oBAAoB;AAAA,MAApB;AAAA,QACC,IACE;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW;AAAA,cACT;AAAA,cACA,cAAc,SAAS;AAAA,YACzB;AAAA,YACA,OAAO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