@edrlab/thorium-web 1.0.0-beta.2 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +1 -1
  2. package/dist/{ThSettingsWrapper-De4qvjsh.d.mts → ThSettingsWrapper-CA2_0nQz.d.mts} +1 -1
  3. package/dist/{actionsReducer-e808e6V_.d.mts → actionsReducer-D4Mphfuv.d.mts} +1 -1
  4. package/dist/chunk-BNPR6V7V.mjs.map +1 -1
  5. package/dist/chunk-IEYR7QV7.mjs.map +1 -1
  6. package/dist/chunk-MLEYTQGK.mjs.map +1 -1
  7. package/dist/chunk-NA3KMUS4.mjs +417 -0
  8. package/dist/chunk-NA3KMUS4.mjs.map +1 -0
  9. package/dist/{chunk-GHEGQBCW.mjs → chunk-NOV43IG4.mjs} +4 -18
  10. package/dist/chunk-NOV43IG4.mjs.map +1 -0
  11. package/dist/chunk-NQ2ZSGCX.mjs.map +1 -1
  12. package/dist/{chunk-O4MBY6P4.mjs → chunk-OCASVHBV.mjs} +91 -36
  13. package/dist/chunk-OCASVHBV.mjs.map +1 -0
  14. package/dist/{chunk-TWGRY5SW.mjs → chunk-RQFPGXWN.mjs} +29 -22
  15. package/dist/chunk-RQFPGXWN.mjs.map +1 -0
  16. package/dist/{chunk-BVSROK7Z.mjs → chunk-SDVDRPT5.mjs} +116 -6
  17. package/dist/chunk-SDVDRPT5.mjs.map +1 -0
  18. package/dist/chunk-TTGURRX3.mjs.map +1 -1
  19. package/dist/{chunk-PGZF5NO2.mjs → chunk-TXILKP4F.mjs} +16 -12
  20. package/dist/chunk-TXILKP4F.mjs.map +1 -0
  21. package/dist/components/Epub/index.d.mts +48 -25
  22. package/dist/components/Epub/index.mjs +878 -408
  23. package/dist/components/Epub/index.mjs.map +1 -1
  24. package/dist/{const-DGYvRLhk.d.mts → const-IAfi9t_g.d.mts} +14 -11
  25. package/dist/core/Components/index.d.mts +52 -6
  26. package/dist/core/Components/index.mjs +2 -2
  27. package/dist/core/Helpers/index.d.mts +3 -9
  28. package/dist/core/Helpers/index.mjs +2 -3
  29. package/dist/core/Hooks/index.d.mts +15 -5
  30. package/dist/core/Hooks/index.mjs +2 -3
  31. package/dist/{enums-DxbWWvn7.d.mts → enums-DqGQ66r1.d.mts} +1 -23
  32. package/dist/lib/index.d.mts +355 -11
  33. package/dist/lib/index.mjs +2 -3
  34. package/dist/{overflowMenu.module-XQRI7RJJ.module.css → overflowMenu.module-FO27A2A3.module.css} +12 -0
  35. package/dist/preferences/index.d.mts +6 -6
  36. package/dist/preferences/index.mjs +2 -3
  37. package/dist/publicationGrid.module-T6ISNRGM.module.css +70 -0
  38. package/dist/{reader-QFK7DGLX.css → reader-NGCQJKLX.css} +74 -36
  39. package/dist/{readerArrowButton.module-NHAUIQXS.module.css → readerArrowButton.module-EFLOIADG.module.css} +4 -0
  40. package/dist/{readerHeader.module-OBKZATSW.module.css → readerHeader.module-K7OLOIJP.module.css} +2 -7
  41. package/dist/{readerLoader.module-U6LLXOVQ.module.css → readerLoader.module-KDBPCQZJ.module.css} +1 -1
  42. package/dist/readerPagination.module-W4IAEOSH.module.css +73 -0
  43. package/dist/readerProgression.module-7PU7L74S.module.css +5 -0
  44. package/dist/{readerSharedUI.module-MCLGNG22.module.css → readerSharedUI.module-Y2VDWFS5.module.css} +1 -5
  45. package/dist/{settings.module-5WB3OOEF.module.css → settings.module-O2SOKTIN.module.css} +4 -0
  46. package/dist/{sheets.module-DDN7GPMG.module.css → sheets.module-NA32WOSZ.module.css} +4 -4
  47. package/dist/{toc.module-XJLXQM7G.module.css → toc.module-KNW5CKIY.module.css} +1 -0
  48. package/dist/{useBreakpoints-I7vHrywa.d.mts → useBreakpoints-BQaiwecQ.d.mts} +1 -1
  49. package/dist/{useEpubNavigator-BrV4MYJy.d.mts → useEpubNavigator-DFRJ_tHa.d.mts} +9 -10
  50. package/dist/{usePreferences-B55XqFto.d.mts → usePreferences-BMyBhq7F.d.mts} +1 -1
  51. package/dist/useTimeline-Bid5B7AQ.d.mts +39 -0
  52. package/package.json +31 -22
  53. package/dist/bookUrlConverter.module-J46O27CR.module.css +0 -63
  54. package/dist/chunk-3QS3WKRC.mjs +0 -29
  55. package/dist/chunk-3QS3WKRC.mjs.map +0 -1
  56. package/dist/chunk-BVSROK7Z.mjs.map +0 -1
  57. package/dist/chunk-GHEGQBCW.mjs.map +0 -1
  58. package/dist/chunk-JS5WI5D4.mjs +0 -600
  59. package/dist/chunk-JS5WI5D4.mjs.map +0 -1
  60. package/dist/chunk-O4MBY6P4.mjs.map +0 -1
  61. package/dist/chunk-PGZF5NO2.mjs.map +0 -1
  62. package/dist/chunk-TWGRY5SW.mjs.map +0 -1
  63. package/dist/index-ClB-1iNN.d.mts +0 -356
  64. package/dist/readerProgression.module-S5R3Y6JI.module.css +0 -11
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2024, Readium
3
+ Copyright (c) 2024, EDRLab (European Digital Reading Lab)
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
6
6
  modification, are permitted provided that the following conditions are met:
@@ -67,7 +67,7 @@ interface ThCollapsibleActionsBarProps extends ThActionsBarProps {
67
67
  declare const ThCollapsibleActionsBar: ({ ref, id, items, prefs, breakpoint, compounds, ...props }: ThCollapsibleActionsBarProps) => react_jsx_runtime.JSX.Element;
68
68
 
69
69
  interface ThMenuItemProps extends MenuItemProps {
70
- ref?: React__default.Ref<HTMLLIElement>;
70
+ ref?: React__default.Ref<HTMLDivElement>;
71
71
  id: string;
72
72
  SVGIcon?: React__default.ComponentType<React__default.SVGProps<SVGElement>>;
73
73
  label: string;
@@ -1,5 +1,5 @@
1
1
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
2
- import { c as ThDockingKeys } from './enums-DxbWWvn7.mjs';
2
+ import { a as ThDockingKeys } from './enums-DqGQ66r1.mjs';
3
3
 
4
4
  type PrimitiveType = number | string | boolean;
5
5
  /** Object types that should never be mapped */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/Hooks/useBreakpoints.ts","../src/core/Hooks/useReducedMotion.ts","../src/core/Hooks/useReducedTransparency.ts","../src/core/Hooks/useForcedColors.ts","../src/core/Hooks/useMonochrome.ts"],"names":["useState","useEffect"],"mappings":";;;AAqBa,IAAA,cAAA,GAAiB,CAAC,GAAA,EAAoC,QAA+E,KAAA;AAChJ,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,SAA+B,IAAI,CAAA;AAErF,EAAM,MAAA,eAAA,GAAkB,CAAC,KAAoC,KAAA;AAC3D,IAAI,IAAA,CAAC,SAAU,CAAC,KAAA,CAAM,OAAO,CAAC,KAAA,CAAM,KAAa,OAAA,IAAA;AAEjD,IAAA,IAAI,WAAc,GAAA,QAAA;AAClB,IAAA,IAAI,MAAM,GAAK,EAAA;AACb,MAAe,WAAA,IAAA,CAAA,iBAAA,EAAqB,MAAM,GAAI,CAAA,GAAA,CAAA;AAAA;AAEhD,IAAA,IAAI,MAAM,GAAK,EAAA;AACb,MAAe,WAAA,IAAA,CAAA,iBAAA,EAAqB,MAAM,GAAI,CAAA,GAAA,CAAA;AAAA;AAEhD,IAAO,OAAA,WAAA;AAAA,GACT;AAEA,EAAM,MAAA,UAAA,GAAa,CAAC,KAAyC,KAAA;AAC3D,IAAA,MAAM,gBAAuC,GAAA;AAAA,MAC3C,2BAAyB,IAAA;AAAA,MACzB,yBAAwB,IAAA;AAAA,MACxB,6BAA0B,IAAA;AAAA,MAC1B,uBAAuB,IAAA;AAAA,MACvB,yBAAwB;AAAA,KAC1B;AAEA,IAAA,IAAI,IAAsB,GAAA,IAAA;AAE1B,IAAO,MAAA,CAAA,OAAA,CAAQ,KAAK,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAE,GAAA,EAAK,KAAM,CAAM,KAAA;AAChD,MAAA,IAAI,KAAS,IAAA,CAAC,KAAM,CAAA,KAAK,CAA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C,QAAsD,KAAA;AAC3F,EAAA,MAAM,CAAC,mBAAA,EAAqB,sBAAsB,CAAA,GAAID,SAAS,KAAK,CAAA;AAEpE,EAAM,MAAA,0BAAA,GAA6B,cAAc,wCAAwC,CAAA;AAEzF,EAAAC,UAAU,MAAM;AACd,IAAA,sBAAA,CAAuB,0BAA0B,CAAA;AACjD,IAAA,QAAA,IAAY,SAAS,0BAA0B,CAAA;AAAA,GAC9C,EAAA,CAAC,0BAA4B,EAAA,QAAQ,CAAC,CAAA;AAEzC,EAAO,OAAA,mBAAA;AACT;ACXa,IAAA,eAAA,GAAkB,CAAC,QAA+C,KAAA;AAC7E,EAAA,MAAM,CAAC,MAAA,EAAQ,eAAe,CAAA,GAAID,SAAS,KAAK,CAAA;AAEhD,EAAM,MAAA,YAAA,GAAe,cAAc,yBAAyB,CAAA;AAE5D,EAAAC,UAAU,MAAM;AACd,IAAA,eAAA,CAAgB,YAAY,CAAA;AAC5B,IAAA,QAAA,IAAY,SAAS,YAAY,CAAA;AAAA,GAChC,EAAA,CAAC,YAAc,EAAA,QAAQ,CAAC,CAAA;AAE3B,EAAO,OAAA,MAAA;AACT;ACXa,IAAA,aAAA,GAAgB,CAAC,QAA+C,KAAA;AAC3E,EAAA,MAAM,CAAC,YAAA,EAAc,aAAa,CAAA,GAAID,SAAS,KAAK,CAAA;AAEpD,EAAM,MAAA,UAAA,GAAa,cAAc,cAAc,CAAA;AAE/C,EAAAC,UAAU,MAAM;AACd,IAAA,aAAA,CAAc,UAAU,CAAA;AACxB,IAAA,QAAA,IAAY,SAAS,UAAU,CAAA;AAAA,GAC9B,EAAA,CAAC,UAAY,EAAA,QAAQ,CAAC,CAAA;AAEzB,EAAO,OAAA,YAAA;AACT","file":"chunk-BNPR6V7V.mjs","sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { ThBreakpoints } from \"@/preferences/models/enums\";\n\nimport { useMediaQuery } from \"./useMediaQuery\";\n\ntype ThBreakpointRange = {\n min: number | null,\n max: number | null\n}\n\ntype ThBreakpointRanges = { [key in ThBreakpoints]: ThBreakpointRange | null; }\n\nexport type BreakpointsMap<T> = {\n [key in ThBreakpoints]?: T\n};\n\nexport type ThBreakpointsObject = { [key in ThBreakpoints]: boolean | null } & { current: string | null } & { ranges: ThBreakpointRanges }\n\nexport const useBreakpoints = (map: BreakpointsMap<number | null>, onChange?: (breakpoint: ThBreakpoints | null) => void): ThBreakpointsObject => {\n const [currentBreakpoint, setCurrentBreakpoint] = useState<ThBreakpoints | null>(null);\n\n const makeMediaString = (range: ThBreakpointRange | null) => {\n if (!range || (!range.min && !range.max)) return null;\n \n let mediaString = \"screen\"\n if (range.min) {\n mediaString += ` and (min-width: ${ range.min }px)`;\n }\n if (range.max) {\n mediaString += ` and (max-width: ${ range.max }px)`\n }\n return mediaString;\n };\n\n const initRanges = (prefs: BreakpointsMap<number | null>) => {\n const breakpointRanges: ThBreakpointRanges = {\n [ThBreakpoints.compact]: null,\n [ThBreakpoints.medium]: null,\n [ThBreakpoints.expanded]: null,\n [ThBreakpoints.large]: null,\n [ThBreakpoints.xLarge]: null\n };\n \n let prev: null | number = null;\n \n Object.entries(prefs).forEach(([ key, value ]) => {\n if (value && !isNaN(value)) {\n const max = value;\n const min = prev ? prev + 1 : null;\n Object.defineProperty(breakpointRanges, key, {\n value: {\n min: min,\n max: max\n }\n });\n prev = value;\n } else if (!value && key === ThBreakpoints.xLarge && prev) {\n Object.defineProperty(breakpointRanges, key, {\n value: {\n min: prev + 1,\n max: null\n }\n });\n }\n });\n\n return breakpointRanges;\n };\n\n const ranges = useMemo(() => initRanges(map), [map]);\n\n const compactMedia = makeMediaString(ranges[ThBreakpoints.compact]);\n const mediumMedia = makeMediaString(ranges[ThBreakpoints.medium]);\n const expandedMedia = makeMediaString(ranges[ThBreakpoints.expanded]);\n const largeMedia = makeMediaString(ranges[ThBreakpoints.large]);\n const xLargeMedia = makeMediaString(ranges[ThBreakpoints.xLarge]);\n\n const compactMatches = useMediaQuery(compactMedia);\n const mediumMatches = useMediaQuery(mediumMedia);\n const expandedMatches = useMediaQuery(expandedMedia);\n const largeMatches = useMediaQuery(largeMedia);\n const xLargeMatches = useMediaQuery(xLargeMedia);\n\n useEffect(() => {\n let newBreakpoint = currentBreakpoint;\n\n if (compactMatches) {\n newBreakpoint = ThBreakpoints.compact;\n } else if (mediumMatches) {\n newBreakpoint = ThBreakpoints.medium;\n } else if (expandedMatches) {\n newBreakpoint = ThBreakpoints.expanded;\n } else if (largeMatches) {\n newBreakpoint = ThBreakpoints.large;\n } else if (xLargeMatches) {\n newBreakpoint = ThBreakpoints.xLarge;\n }\n\n setCurrentBreakpoint(newBreakpoint);\n onChange && onChange(newBreakpoint);\n }, [currentBreakpoint, compactMatches, mediumMatches, expandedMatches, largeMatches, xLargeMatches, onChange]);\n\n return {\n [ThBreakpoints.compact]: compactMatches,\n [ThBreakpoints.medium]: mediumMatches,\n [ThBreakpoints.expanded]: expandedMatches,\n [ThBreakpoints.large]: largeMatches,\n [ThBreakpoints.xLarge]: xLargeMatches,\n current: currentBreakpoint,\n ranges: ranges\n };\n};","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useReducedMotion = (onChange?: (reducedMotion: boolean) => void) => {\n const [reducedMotion, setReducedMotion] = useState(false);\n\n const prefersReducedMotion = useMediaQuery(\"(prefers-reduced-motion: reduce)\");\n\n useEffect(() => {\n setReducedMotion(prefersReducedMotion);\n onChange && onChange(prefersReducedMotion);\n }, [prefersReducedMotion, onChange]);\n\n return reducedMotion;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useReducedTransparency = (onChange?: (reducedTransparency: boolean) => void) => {\n const [reducedTransparency, setReducedTransparency] = useState(false);\n\n const prefersReducedTransparency = useMediaQuery(\"(prefers-reduced-transparency: reduce)\");\n\n useEffect(() => {\n setReducedTransparency(prefersReducedTransparency);\n onChange && onChange(prefersReducedTransparency);\n }, [prefersReducedTransparency, onChange]);\n\n return reducedTransparency;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useForcedColors = (onChange?: (forcedColors: boolean) => void) => {\n const [colors, setForcedColors] = useState(false);\n\n const forcedColors = useMediaQuery(\"(forced-colors: active)\");\n\n useEffect(() => {\n setForcedColors(forcedColors);\n onChange && onChange(forcedColors);\n }, [forcedColors, onChange]);\n\n return colors;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useMonochrome = (onChange?: (isMonochrome: boolean) => void) => {\n const [isMonochrome, setMonochrome] = useState(false);\n\n const monochrome = useMediaQuery(\"(monochrome)\");\n\n useEffect(() => {\n setMonochrome(monochrome);\n onChange && onChange(monochrome);\n }, [monochrome, onChange]);\n\n return isMonochrome;\n}"]}
1
+ {"version":3,"sources":["../src/core/Hooks/useBreakpoints.ts","../src/core/Hooks/useReducedMotion.ts","../src/core/Hooks/useReducedTransparency.ts","../src/core/Hooks/useForcedColors.ts","../src/core/Hooks/useMonochrome.ts"],"names":["useState","useEffect"],"mappings":";;;AAqBO,IAAM,cAAA,GAAiB,CAAC,GAAA,EAAoC,QAAA,KAA+E;AAChJ,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,SAA+B,IAAI,CAAA;AAErF,EAAA,MAAM,eAAA,GAAkB,CAAC,KAAA,KAAoC;AAC3D,IAAA,IAAI,CAAC,SAAU,CAAC,KAAA,CAAM,OAAO,CAAC,KAAA,CAAM,KAAM,OAAO,IAAA;AAEjD,IAAA,IAAI,WAAA,GAAc,QAAA;AAClB,IAAA,IAAI,MAAM,GAAA,EAAK;AACb,MAAA,WAAA,IAAe,CAAA,iBAAA,EAAqB,MAAM,GAAI,CAAA,GAAA,CAAA;AAAA,IAChD;AACA,IAAA,IAAI,MAAM,GAAA,EAAK;AACb,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AS,YAAY,CAAA;AAAA,EACnC,CAAA,EAAG,CAAC,YAAA,EAAc,QAAQ,CAAC,CAAA;AAE3B,EAAA,OAAO,MAAA;AACT;ACXO,IAAM,aAAA,GAAgB,CAAC,QAAA,KAA+C;AAC3E,EAAA,MAAM,CAAC,YAAA,EAAc,aAAa,CAAA,GAAID,SAAS,KAAK,CAAA;AAEpD,EAAA,MAAM,UAAA,GAAa,cAAc,cAAc,CAAA;AAE/C,EAAAC,UAAU,MAAM;AACd,IAAA,aAAA,CAAc,UAAU,CAAA;AACxB,IAAA,QAAA,IAAY,SAAS,UAAU,CAAA;AAAA,EACjC,CAAA,EAAG,CAAC,UAAA,EAAY,QAAQ,CAAC,CAAA;AAEzB,EAAA,OAAO,YAAA;AACT","file":"chunk-BNPR6V7V.mjs","sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { ThBreakpoints } from \"@/preferences/models/enums\";\n\nimport { useMediaQuery } from \"./useMediaQuery\";\n\ntype ThBreakpointRange = {\n min: number | null,\n max: number | null\n}\n\ntype ThBreakpointRanges = { [key in ThBreakpoints]: ThBreakpointRange | null; }\n\nexport type BreakpointsMap<T> = {\n [key in ThBreakpoints]?: T\n};\n\nexport type ThBreakpointsObject = { [key in ThBreakpoints]: boolean | null } & { current: string | null } & { ranges: ThBreakpointRanges }\n\nexport const useBreakpoints = (map: BreakpointsMap<number | null>, onChange?: (breakpoint: ThBreakpoints | null) => void): ThBreakpointsObject => {\n const [currentBreakpoint, setCurrentBreakpoint] = useState<ThBreakpoints | null>(null);\n\n const makeMediaString = (range: ThBreakpointRange | null) => {\n if (!range || (!range.min && !range.max)) return null;\n \n let mediaString = \"screen\"\n if (range.min) {\n mediaString += ` and (min-width: ${ range.min }px)`;\n }\n if (range.max) {\n mediaString += ` and (max-width: ${ range.max }px)`\n }\n return mediaString;\n };\n\n const initRanges = (prefs: BreakpointsMap<number | null>) => {\n const breakpointRanges: ThBreakpointRanges = {\n [ThBreakpoints.compact]: null,\n [ThBreakpoints.medium]: null,\n [ThBreakpoints.expanded]: null,\n [ThBreakpoints.large]: null,\n [ThBreakpoints.xLarge]: null\n };\n \n let prev: null | number = null;\n \n Object.entries(prefs).forEach(([ key, value ]) => {\n if (value && !isNaN(value)) {\n const max = value;\n const min = prev ? prev + 1 : null;\n Object.defineProperty(breakpointRanges, key, {\n value: {\n min: min,\n max: max\n }\n });\n prev = value;\n } else if (!value && key === ThBreakpoints.xLarge && prev) {\n Object.defineProperty(breakpointRanges, key, {\n value: {\n min: prev + 1,\n max: null\n }\n });\n }\n });\n\n return breakpointRanges;\n };\n\n const ranges = useMemo(() => initRanges(map), [map]);\n\n const compactMedia = makeMediaString(ranges[ThBreakpoints.compact]);\n const mediumMedia = makeMediaString(ranges[ThBreakpoints.medium]);\n const expandedMedia = makeMediaString(ranges[ThBreakpoints.expanded]);\n const largeMedia = makeMediaString(ranges[ThBreakpoints.large]);\n const xLargeMedia = makeMediaString(ranges[ThBreakpoints.xLarge]);\n\n const compactMatches = useMediaQuery(compactMedia);\n const mediumMatches = useMediaQuery(mediumMedia);\n const expandedMatches = useMediaQuery(expandedMedia);\n const largeMatches = useMediaQuery(largeMedia);\n const xLargeMatches = useMediaQuery(xLargeMedia);\n\n useEffect(() => {\n let newBreakpoint = currentBreakpoint;\n\n if (compactMatches) {\n newBreakpoint = ThBreakpoints.compact;\n } else if (mediumMatches) {\n newBreakpoint = ThBreakpoints.medium;\n } else if (expandedMatches) {\n newBreakpoint = ThBreakpoints.expanded;\n } else if (largeMatches) {\n newBreakpoint = ThBreakpoints.large;\n } else if (xLargeMatches) {\n newBreakpoint = ThBreakpoints.xLarge;\n }\n\n setCurrentBreakpoint(newBreakpoint);\n onChange && onChange(newBreakpoint);\n }, [currentBreakpoint, compactMatches, mediumMatches, expandedMatches, largeMatches, xLargeMatches, onChange]);\n\n return {\n [ThBreakpoints.compact]: compactMatches,\n [ThBreakpoints.medium]: mediumMatches,\n [ThBreakpoints.expanded]: expandedMatches,\n [ThBreakpoints.large]: largeMatches,\n [ThBreakpoints.xLarge]: xLargeMatches,\n current: currentBreakpoint,\n ranges: ranges\n };\n};","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useReducedMotion = (onChange?: (reducedMotion: boolean) => void) => {\n const [reducedMotion, setReducedMotion] = useState(false);\n\n const prefersReducedMotion = useMediaQuery(\"(prefers-reduced-motion: reduce)\");\n\n useEffect(() => {\n setReducedMotion(prefersReducedMotion);\n onChange && onChange(prefersReducedMotion);\n }, [prefersReducedMotion, onChange]);\n\n return reducedMotion;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useReducedTransparency = (onChange?: (reducedTransparency: boolean) => void) => {\n const [reducedTransparency, setReducedTransparency] = useState(false);\n\n const prefersReducedTransparency = useMediaQuery(\"(prefers-reduced-transparency: reduce)\");\n\n useEffect(() => {\n setReducedTransparency(prefersReducedTransparency);\n onChange && onChange(prefersReducedTransparency);\n }, [prefersReducedTransparency, onChange]);\n\n return reducedTransparency;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useForcedColors = (onChange?: (forcedColors: boolean) => void) => {\n const [colors, setForcedColors] = useState(false);\n\n const forcedColors = useMediaQuery(\"(forced-colors: active)\");\n\n useEffect(() => {\n setForcedColors(forcedColors);\n onChange && onChange(forcedColors);\n }, [forcedColors, onChange]);\n\n return colors;\n}","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useMediaQuery } from \"./useMediaQuery\";\n\nexport const useMonochrome = (onChange?: (isMonochrome: boolean) => void) => {\n const [isMonochrome, setMonochrome] = useState(false);\n\n const monochrome = useMediaQuery(\"(monochrome)\");\n\n useEffect(() => {\n setMonochrome(monochrome);\n onChange && onChange(monochrome);\n }, [monochrome, onChange]);\n\n return isMonochrome;\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/Helpers/getPlatform.ts","../src/core/Helpers/keyboardUtilities.ts"],"names":["UnstableShortcutMetaKeywords","UnstableShortcutRepresentation"],"mappings":";AAeO,IAAM,cAAc,MAAM;AAC/B,EAAI,IAAA,OAAO,WAAW,WAAa,EAAA;AACjC,IAAA,MAAM,MAAoB,MAAO,CAAA,SAAA;AAEjC,IAAA,IAAI,OAAO,GAAI,CAAA,aAAA,KAAkB,eAAe,OAAO,GAAA,CAAI,iBAAiB,IAAM,EAAA;AAChF,MAAO,OAAA,GAAA,CAAI,aAAc,CAAA,QAAA,CAAS,WAAY,EAAA;AAAA;AAIhD,IAAI,IAAA,OAAO,GAAI,CAAA,QAAA,KAAa,WAAa,EAAA;AAEvC,MAAI,IAAA,OAAO,GAAI,CAAA,SAAA,KAAc,WAAe,IAAA,SAAA,CAAU,KAAK,GAAI,CAAA,SAAA,CAAU,WAAY,EAAC,CAAG,EAAA;AACvF,QAAO,OAAA,SAAA;AAAA;AAET,MAAO,OAAA,GAAA,CAAI,SAAS,WAAY,EAAA;AAAA;AAClC;AAEF,EAAO,OAAA,SAAA;AACT;AAEO,IAAM,WAAW,MAAM;AAC5B,EAAA,MAAM,YAAe,GAAA,uBAAA;AACrB,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAO,OAAA,YAAA,CAAa,KAAK,QAAQ,CAAA;AACnC;AAGO,IAAM,WAAW,MAAM;AAC5B,EAAO,OAAA,CAAC,EAAE,SAAA,CAAU,cACX,IAAA,SAAA,CAAU,iBAAiB,CAC3B,IAAA,SAAA,CAAU,SAAU,CAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AAC/C;AAGO,IAAM,WAAW,MAAM;AAC5B,EAAA,MAAM,kBAAqB,GAAA,mBAAA;AAC3B,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAI,IAAA,kBAAA,CAAmB,IAAK,CAAA,QAAQ,CAAG,EAAA;AACrC,IAAO,OAAA,IAAA;AAAA,GACF,M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AAA,EAAA,GAAA,CAAI,IAAK,EAAA,CAAE,aAAc,CAAA,CAAA;AAAA;AACpD,GACD,CAAA;AAED,EAAO,OAAA,WAAA,CAAY,MAAM,WAAc,GAAA,IAAA;AACzC","file":"chunk-IEYR7QV7.mjs","sourcesContent":["\"use client\";\n\n// Not caring about instance methods there, only properties\n// See https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData\ninterface ExtNavigatorUAData {\n brands: string[];\n mobile: boolean;\n platform: string;\n}\n\ninterface ExtNavigator extends Navigator {\n userAgentData: ExtNavigatorUAData;\n}\n\n// See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData\nexport const getPlatform = () => {\n if (typeof window !== \"undefined\") {\n const nav: ExtNavigator = window.navigator as ExtNavigator;\n\n if (typeof nav.userAgentData !== \"undefined\" && typeof nav.userAgentData != null) {\n return nav.userAgentData.platform.toLowerCase();\n }\n\n // Deprecated but userAgentData still experimental…\n if (typeof nav.platform !== \"undefined\") {\n // android navigator.platform is often set as \"linux\", so we have to check userAgent\n if (typeof nav.userAgent !== \"undefined\" && /android/.test(nav.userAgent.toLowerCase())) {\n return \"android\";\n }\n return nav.platform.toLowerCase();\n }\n }\n return \"unknown\";\n}\n\nexport const isMacish = () => {\n const MacOSPattern = /mac|ipod|iphone|ipad/i;\n const platform = getPlatform();\n return MacOSPattern.test(platform);\n}\n\n// “Desktop-class” iPadOS\nexport const isIpadOS = () => {\n return !!(navigator.maxTouchPoints \n && navigator.maxTouchPoints > 2 \n && navigator.userAgent.includes(\"Intel\"));\n}\n\n// Stopgap measure for fullscreen on iPadOS, do not use elsewhere\nexport const isIOSish = () => {\n const AppleMobilePattern = /ipod|iphone|ipad/i;\n const platform = getPlatform();\n if (AppleMobilePattern.test(platform)) {\n return true;\n } else {\n return isIpadOS();\n }\n}","\"use client\";\n\nimport { isMacish } from \"./getPlatform\";\n\nexport interface UnstableKey {\n [key: string]: string;\n longform: string;\n shortform: string;\n}\n\nexport interface UnstableMetaKey extends UnstableKey {\n modifier: \"altKey\" | \"ctrlKey\" | \"metaKey\" | \"shiftKey\";\n symbol: \"⌥\" | \"^\" | \"⌘\" | \"⊞\" | \"⇧\";\n}\n\nexport interface UnstablePlatformModifier extends UnstableKey {\n modifier: \"ctrlKey\" | \"metaKey\";\n symbol: \"^\" | \"⌘\";\n}\n\nexport interface UnstableMetaKeys {\n [key: string]: UnstableMetaKey;\n altKey: UnstableMetaKey;\n ctrlKey: UnstableMetaKey;\n metaKey: UnstableMetaKey;\n shiftKey: UnstableMetaKey;\n}\n\nexport enum UnstableShortcutMetaKeywords {\n alt = \"altKey\",\n ctrl = \"ctrlKey\",\n meta = \"metaKey\",\n platform = \"platformKey\",\n shift = \"shiftKey\"\n}\n\nexport enum UnstableShortcutRepresentation {\n symbol = \"symbol\",\n short = \"shortform\",\n long = \"longform\"\n};\n\nexport interface UnstableShortcut {\n className?: string;\n rawForm: string;\n representation?: UnstableShortcutRepresentation; \n joiner?: string;\n}\n\nexport interface UnstablePShortcut {\n key?: string;\n char?: string;\n modifiers: {\n [key: string]: boolean;\n altKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n platformKey: boolean;\n shiftKey: boolean;\n }\n}\n\nconst altModifier: UnstableMetaKey = {\n longform: \"Option\",\n shortform: \"Alt\",\n modifier: \"altKey\",\n symbol: \"⌥\"\n}\n\nconst ctrlModifier: UnstableMetaKey & UnstablePlatformModifier = {\n longform: \"Control\",\n shortform: \"Ctrl\",\n modifier: \"ctrlKey\",\n symbol: \"^\"\n}\n\nconst metaModifierMac: UnstableMetaKey & UnstablePlatformModifier = {\n longform: \"Command\",\n shortform: \"Cmd\",\n modifier: \"metaKey\",\n symbol: \"⌘\" \n}\n\nconst metaModifierWin: UnstableMetaKey = {\n longform: \"Windows\",\n shortform: \"Win\",\n modifier: \"metaKey\",\n symbol: \"⊞\"\n}\n\nconst shiftModifier: UnstableMetaKey = {\n longform: \"Shift\",\n shortform: \"Shift\",\n modifier: \"shiftKey\",\n symbol: \"⇧\"\n}\n\nexport const metaKeys: UnstableMetaKeys = {\n altKey: altModifier,\n ctrlKey: ctrlModifier,\n metaKey: isMacish() ? metaModifierMac : metaModifierWin,\n shiftKey: shiftModifier\n}\n\n// Platform modifier differs from Mac to Windows so we have to get it dynamically\n\nexport const defaultPlatformModifier = ctrlModifier;\n\nexport const getPlatformModifier = (): UnstablePlatformModifier => {\n if (isMacish()) {\n return metaModifierMac;\n } else {\n return ctrlModifier;\n }\n}\n\nexport const buildShortcut = (str: string) => {\n let shortcutObj: UnstablePShortcut = {\n key: \"\",\n char: \"\",\n modifiers: {\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n platformKey: false,\n shiftKey: false\n }\n }\n \n const shortcutArray = str.split(/\\s*?[+-]\\s*?/);\n\n shortcutArray.filter((val) => {\n if ((Object.values(UnstableShortcutMetaKeywords) as string[]).includes(val)) {\n const trimmedKey = val.trim();\n shortcutObj.modifiers[trimmedKey] = true;\n } else {\n shortcutObj.char = val.trim().toUpperCase();\n shortcutObj.key = `Key${ val.trim().toUpperCase() }`;\n }\n });\n\n return shortcutObj.key ? shortcutObj : null;\n}"]}
1
+ {"version":3,"sources":["../src/core/Helpers/getPlatform.ts","../src/core/Helpers/keyboardUtilities.ts"],"names":["UnstableShortcutMetaKeywords","UnstableShortcutRepresentation"],"mappings":";AAeO,IAAM,cAAc,MAAM;AAC/B,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,MAAM,MAAoB,MAAA,CAAO,SAAA;AAEjC,IAAA,IAAI,OAAO,GAAA,CAAI,aAAA,KAAkB,eAAe,OAAO,GAAA,CAAI,iBAAiB,IAAA,EAAM;AAChF,MAAA,OAAO,GAAA,CAAI,aAAA,CAAc,QAAA,CAAS,WAAA,EAAY;AAAA,IAChD;AAGA,IAAA,IAAI,OAAO,GAAA,CAAI,QAAA,KAAa,WAAA,EAAa;AAEvC,MAAA,IAAI,OAAO,GAAA,CAAI,SAAA,KAAc,WAAA,IAAe,SAAA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AC,GAAA,KAAgB;AAC5C,EAAA,IAAI,WAAA,GAAiC;AAAA,IACnC,GAAA,EAAK,EAAA;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,SAAA,EAAW;AAAA,MACT,MAAA,EAAQ,KAAA;AAAA,MACR,OAAA,EAAS,KAAA;AAAA,MACT,OAAA,EAAS,KAAA;AAAA,MACT,WAAA,EAAa,KAAA;AAAA,MACb,QAAA,EAAU;AAAA;AACZ,GACF;AAEA,EAAA,MAAM,aAAA,GAAgB,GAAA,CAAI,KAAA,CAAM,cAAc,CAAA;AAE9C,EAAA,aAAA,CAAc,MAAA,CAAO,CAAC,GAAA,KAAQ;AAC5B,IAAA,IAAK,OAAO,MAAA,CAAO,4BAA4B,CAAA,CAAe,QAAA,CAAS,GAAG,CAAA,EAAG;AAC3E,MAAA,MAAM,UAAA,GAAa,IAAI,IAAA,EAAK;AAC5B,MAAA,WAAA,CAAY,SAAA,CAAU,UAAU,CAAA,GAAI,IAAA;AAAA,IACtC,CAAA,MAAO;AACL,MAAA,WAAA,CAAY,IAAA,GAAO,GAAA,CAAI,IAAA,EAAK,CAAE,WAAA,EAAY;AAC1C,MAAA,WAAA,CAAY,MAAM,CAAA,GAAA,EAAO,GAAA,CAAI,IAAA,EAAK,CAAE,aAAc,CAAA,CAAA;AAAA,IACpD;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,WAAA,CAAY,MAAM,WAAA,GAAc,IAAA;AACzC","file":"chunk-IEYR7QV7.mjs","sourcesContent":["\"use client\";\n\n// Not caring about instance methods there, only properties\n// See https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData\ninterface ExtNavigatorUAData {\n brands: string[];\n mobile: boolean;\n platform: string;\n}\n\ninterface ExtNavigator extends Navigator {\n userAgentData: ExtNavigatorUAData;\n}\n\n// See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData\nexport const getPlatform = () => {\n if (typeof window !== \"undefined\") {\n const nav: ExtNavigator = window.navigator as ExtNavigator;\n\n if (typeof nav.userAgentData !== \"undefined\" && typeof nav.userAgentData != null) {\n return nav.userAgentData.platform.toLowerCase();\n }\n\n // Deprecated but userAgentData still experimental…\n if (typeof nav.platform !== \"undefined\") {\n // android navigator.platform is often set as \"linux\", so we have to check userAgent\n if (typeof nav.userAgent !== \"undefined\" && /android/.test(nav.userAgent.toLowerCase())) {\n return \"android\";\n }\n return nav.platform.toLowerCase();\n }\n }\n return \"unknown\";\n}\n\nexport const isMacish = () => {\n const MacOSPattern = /mac|ipod|iphone|ipad/i;\n const platform = getPlatform();\n return MacOSPattern.test(platform);\n}\n\n// “Desktop-class” iPadOS\nexport const isIpadOS = () => {\n return !!(navigator.maxTouchPoints \n && navigator.maxTouchPoints > 2 \n && navigator.userAgent.includes(\"Intel\"));\n}\n\n// Stopgap measure for fullscreen on iPadOS, do not use elsewhere\nexport const isIOSish = () => {\n const AppleMobilePattern = /ipod|iphone|ipad/i;\n const platform = getPlatform();\n if (AppleMobilePattern.test(platform)) {\n return true;\n } else {\n return isIpadOS();\n }\n}","\"use client\";\n\nimport { isMacish } from \"./getPlatform\";\n\nexport interface UnstableKey {\n [key: string]: string;\n longform: string;\n shortform: string;\n}\n\nexport interface UnstableMetaKey extends UnstableKey {\n modifier: \"altKey\" | \"ctrlKey\" | \"metaKey\" | \"shiftKey\";\n symbol: \"⌥\" | \"^\" | \"⌘\" | \"⊞\" | \"⇧\";\n}\n\nexport interface UnstablePlatformModifier extends UnstableKey {\n modifier: \"ctrlKey\" | \"metaKey\";\n symbol: \"^\" | \"⌘\";\n}\n\nexport interface UnstableMetaKeys {\n [key: string]: UnstableMetaKey;\n altKey: UnstableMetaKey;\n ctrlKey: UnstableMetaKey;\n metaKey: UnstableMetaKey;\n shiftKey: UnstableMetaKey;\n}\n\nexport enum UnstableShortcutMetaKeywords {\n alt = \"altKey\",\n ctrl = \"ctrlKey\",\n meta = \"metaKey\",\n platform = \"platformKey\",\n shift = \"shiftKey\"\n}\n\nexport enum UnstableShortcutRepresentation {\n symbol = \"symbol\",\n short = \"shortform\",\n long = \"longform\"\n};\n\nexport interface UnstableShortcut {\n className?: string;\n rawForm: string;\n representation?: UnstableShortcutRepresentation; \n joiner?: string;\n}\n\nexport interface UnstablePShortcut {\n key?: string;\n char?: string;\n modifiers: {\n [key: string]: boolean;\n altKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n platformKey: boolean;\n shiftKey: boolean;\n }\n}\n\nconst altModifier: UnstableMetaKey = {\n longform: \"Option\",\n shortform: \"Alt\",\n modifier: \"altKey\",\n symbol: \"⌥\"\n}\n\nconst ctrlModifier: UnstableMetaKey & UnstablePlatformModifier = {\n longform: \"Control\",\n shortform: \"Ctrl\",\n modifier: \"ctrlKey\",\n symbol: \"^\"\n}\n\nconst metaModifierMac: UnstableMetaKey & UnstablePlatformModifier = {\n longform: \"Command\",\n shortform: \"Cmd\",\n modifier: \"metaKey\",\n symbol: \"⌘\" \n}\n\nconst metaModifierWin: UnstableMetaKey = {\n longform: \"Windows\",\n shortform: \"Win\",\n modifier: \"metaKey\",\n symbol: \"⊞\"\n}\n\nconst shiftModifier: UnstableMetaKey = {\n longform: \"Shift\",\n shortform: \"Shift\",\n modifier: \"shiftKey\",\n symbol: \"⇧\"\n}\n\nexport const metaKeys: UnstableMetaKeys = {\n altKey: altModifier,\n ctrlKey: ctrlModifier,\n metaKey: isMacish() ? metaModifierMac : metaModifierWin,\n shiftKey: shiftModifier\n}\n\n// Platform modifier differs from Mac to Windows so we have to get it dynamically\n\nexport const defaultPlatformModifier = ctrlModifier;\n\nexport const getPlatformModifier = (): UnstablePlatformModifier => {\n if (isMacish()) {\n return metaModifierMac;\n } else {\n return ctrlModifier;\n }\n}\n\nexport const buildShortcut = (str: string) => {\n let shortcutObj: UnstablePShortcut = {\n key: \"\",\n char: \"\",\n modifiers: {\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n platformKey: false,\n shiftKey: false\n }\n }\n \n const shortcutArray = str.split(/\\s*?[+-]\\s*?/);\n\n shortcutArray.filter((val) => {\n if ((Object.values(UnstableShortcutMetaKeywords) as string[]).includes(val)) {\n const trimmedKey = val.trim();\n shortcutObj.modifiers[trimmedKey] = true;\n } else {\n shortcutObj.char = val.trim().toUpperCase();\n shortcutObj.key = `Key${ val.trim().toUpperCase() }`;\n }\n });\n\n return shortcutObj.key ? shortcutObj : null;\n}"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/Components/Actions/hooks/useCollapsibility.ts"],"names":["ThCollapsibilityVisibility","actionIcons","menuItems"],"mappings":";;;AAQY,IAAA,0BAAA,qBAAAA,2BAAL,KAAA;AACL,EAAAA,4BAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,4BAAA,WAAY,CAAA,GAAA,WAAA;AACZ,EAAAA,4BAAA,UAAW,CAAA,GAAA,UAAA;AAHD,EAAAA,OAAAA,2BAAAA;AAAA,CAAA,EAAA,0BAAA,IAAA,EAAA;AAiBL,IAAM,iBAAoB,GAAA,CAAC,KAAgC,EAAA,KAAA,EAAwB,UAAwB,KAAA;AAChH,EAAA,MAAM,CAAC,WAAA,EAAa,SAAS,CAAA,GAAI,QAAQ,MAAM;AAC7C,IAAA,MAAMC,eAAuC,EAAC;AAC9C,IAAA,MAAMC,aAAqC,EAAC;AAE5C,IAAA,IAAI,SAAoB,GAAA,CAAA;AAExB,IAAA,IAAI,MAAM,QAAU,EAAA;AAElB,MAAA,IAAI,OAAO,KAAM,CAAA,QAAA,KAAa,YAAY,EAAE,KAAA,CAAM,oBAAoB,OAAU,CAAA,EAAA;AAC9E,QAAA,IAAI,UAAY,EAAA;AACd,UAAM,MAAA,iBAAA,GAAoB,KAAM,CAAA,QAAA,CAAS,UAAU,CAAA;AACnD,UAAA,IAAI,iBAAmB,EAAA;AACrB,YAAA,IAAI,sBAAsB,KAAO,EAAA;AAC/B,cAAY,SAAA,GAAA,CAAA;AAAA,aACH,MAAA,IAAA,CAAC,KAAM,CAAA,iBAAiB,CAAG,EAAA;AACpC,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\";\n\nimport { useMemo } from \"react\";\n\nimport { ThActionEntry } from \"../ThActionsBar\";\n\nexport type ThCollapsibility = boolean | Record<string, number | \"all\">;\n\nexport enum ThCollapsibilityVisibility {\n always = \"always\",\n partially = \"partially\",\n overflow = \"overflow\"\n}\n\nexport interface CollapsiblePref {\n displayOrder: string[];\n collapse: ThCollapsibility;\n keys: {\n [key: string]: {\n [key: string]: any;\n visibility: ThCollapsibilityVisibility;\n };\n }\n}\n\nexport const useCollapsibility = (items: ThActionEntry<string>[], prefs: CollapsiblePref, breakpoint?: string) => {\n const [actionIcons, menuItems] = useMemo(() => {\n const actionIcons: ThActionEntry<string>[] = [];\n const menuItems: ThActionEntry<string>[] = [];\n\n let countdown: number = 0;\n\n if (prefs.collapse) {\n // Handling number of items to collapse\n if (typeof prefs.collapse === \"object\" && !(prefs.collapse instanceof Boolean)) {\n if (breakpoint) {\n const prefForBreakpoint = prefs.collapse[breakpoint];\n if (prefForBreakpoint) {\n if (prefForBreakpoint === \"all\") {\n countdown = 0;\n } else if (!isNaN(prefForBreakpoint)) {\n if (prefForBreakpoint === items.length) {\n countdown = 0;\n } else if (prefForBreakpoint < items.length) {\n // We must take the overflow icon into account so that\n // it doesn’t contain only one partially visible item \n countdown = items.length - (prefForBreakpoint - 1);\n }\n }\n }\n }\n }\n\n // Creating a shallow copy so that actionsOrder doesn’t mutate between rerenders\n [...items].slice().reverse().map((item) => {\n const actionPref = prefs.keys[item.key];\n if (actionPref.visibility === ThCollapsibilityVisibility.overflow) {\n menuItems.unshift(item);\n --countdown;\n } else if (actionPref.visibility === ThCollapsibilityVisibility.partially) {\n if (countdown > 0) {\n menuItems.unshift(item);\n --countdown;\n } else {\n actionIcons.unshift(item);\n }\n } else {\n actionIcons.unshift(item);\n }\n });\n } else {\n // collapse set to false so we ignore visibility and don’t triage\n items.map((item) => {\n actionIcons.push(item);\n });\n }\n\n return [actionIcons, menuItems];\n }, [items, prefs, breakpoint]);\n\n return { ActionIcons: actionIcons, MenuItems: menuItems };\n}"]}
1
+ {"version":3,"sources":["../src/core/Components/Actions/hooks/useCollapsibility.ts"],"names":["ThCollapsibilityVisibility","actionIcons","menuItems"],"mappings":";;;AAQO,IAAK,0BAAA,qBAAAA,2BAAAA,KAAL;AACL,EAAAA,4BAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,4BAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,4BAAA,UAAA,CAAA,GAAW,UAAA;AAHD,EAAA,OAAAA,2BAAAA;AAAA,CAAA,EAAA,0BAAA,IAAA,EAAA;AAiBL,IAAM,iBAAA,GAAoB,CAAC,KAAA,EAAgC,KAAA,EAAwB,UAAA,KAAwB;AAChH,EAAA,MAAM,CAAC,WAAA,EAAa,SAAS,CAAA,GAAI,QAAQ,MAAM;AAC7C,IAAA,MAAMC,eAAuC,EAAC;AAC9C,IAAA,MAAMC,aAAqC,EAAC;AAE5C,IAAA,IAAI,SAAA,GAAoB,CAAA;AAExB,IAAA,IAAI,MAAM,QAAA,EAAU;AAElB,MAAA,IAAI,OAAO,KAAA,CAAM,QAAA,KAAa,YAAY,EAAE,KAAA,CAAM,oBAAoB,OAAA,CAAA,EAAU;AAC9E,QAAA,IAAI,UAAA,EAAY;AACd,UAAA,MAAM,iBAAA,GAAoB,KAAA,CAAM,QAAA,CAAS,UAAU,CAAA;AACnD,UAAA,IAAI,iBAAA,EAAmB;AACrB,YAAA,IAAI,sBAAsB,KAAA,EAAO;AAC/B,cAAA,SAAA,GAAY,CAAA;AAAA,YACd,CAAA,MAAA,IAAW,CAAC,KAAA,CAAM,iBAAiB,CAAA,EAAG;AACpC,cAAA,IAAI,iBAAA,KAAsB,MAAM,MAAA,EAAQ;AACtC,gBAAA,SAAA,GAAY,CAAA;AAAA,cACd,CAAA,MAAA,IAAW,iBAAA,GAAoB,KAAA,CAAM,MAAA,EAAQ;AAG3C,gBAAA,SAAA,GAAY,KAAA,CAAM,UAAU,iBAAA,GAAoB,CAAA,CAAA;AAAA,cAClD;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAGA,MAAA,CAAC,GAAG,KAAK,CAAA,CAAE,KAAA,GAAQ,OAAA,EAAQ,CAAE,GAAA,CAAI,CAAC,IAAA,KAAS;AACzC,QAAA,MAAM,UAAA,GAAa,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA;AACtC,QAAA,IAAI,UAAA,CAAW,eAAe,UAAA,iBAAqC;AACjE,UAAAA,UAAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,UAAA,EAAE,SAAA;AAAA,QACJ,CAAA,MAAA,IAAW,UAAA,CAAW,UAAA,KAAe,WAAA,kBAAsC;AACzE,UAAA,IAAI,YAAY,CAAA,EAAG;AACjB,YAAAA,UAAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,YAAA,EAAE,SAAA;AAAA,UACJ,CAAA,MAAO;AACL,YAAAD,YAAAA,CAAY,QAAQ,IAAI,CAAA;AAAA,UAC1B;AAAA,QACF,CAAA,MAAO;AACL,UAAAA,YAAAA,CAAY,QAAQ,IAAI,CAAA;AAAA,QAC1B;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA,MAAO;AAEL,MAAA,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAS;AAClB,QAAAA,YAAAA,CAAY,KAAK,IAAI,CAAA;AAAA,MACvB,CAAC,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,CAACA,cAAaC,UAAS,CAAA;AAAA,EAChC,CAAA,EAAG,CAAC,KAAA,EAAO,KAAA,EAAO,UAAU,CAAC,CAAA;AAE7B,EAAA,OAAO,EAAE,WAAA,EAAa,WAAA,EAAa,SAAA,EAAW,SAAA,EAAU;AAC1D","file":"chunk-MLEYTQGK.mjs","sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\n\nimport { ThActionEntry } from \"../ThActionsBar\";\n\nexport type ThCollapsibility = boolean | Record<string, number | \"all\">;\n\nexport enum ThCollapsibilityVisibility {\n always = \"always\",\n partially = \"partially\",\n overflow = \"overflow\"\n}\n\nexport interface CollapsiblePref {\n displayOrder: string[];\n collapse: ThCollapsibility;\n keys: {\n [key: string]: {\n [key: string]: any;\n visibility: ThCollapsibilityVisibility;\n };\n }\n}\n\nexport const useCollapsibility = (items: ThActionEntry<string>[], prefs: CollapsiblePref, breakpoint?: string) => {\n const [actionIcons, menuItems] = useMemo(() => {\n const actionIcons: ThActionEntry<string>[] = [];\n const menuItems: ThActionEntry<string>[] = [];\n\n let countdown: number = 0;\n\n if (prefs.collapse) {\n // Handling number of items to collapse\n if (typeof prefs.collapse === \"object\" && !(prefs.collapse instanceof Boolean)) {\n if (breakpoint) {\n const prefForBreakpoint = prefs.collapse[breakpoint];\n if (prefForBreakpoint) {\n if (prefForBreakpoint === \"all\") {\n countdown = 0;\n } else if (!isNaN(prefForBreakpoint)) {\n if (prefForBreakpoint === items.length) {\n countdown = 0;\n } else if (prefForBreakpoint < items.length) {\n // We must take the overflow icon into account so that\n // it doesn’t contain only one partially visible item \n countdown = items.length - (prefForBreakpoint - 1);\n }\n }\n }\n }\n }\n\n // Creating a shallow copy so that actionsOrder doesn’t mutate between rerenders\n [...items].slice().reverse().map((item) => {\n const actionPref = prefs.keys[item.key];\n if (actionPref.visibility === ThCollapsibilityVisibility.overflow) {\n menuItems.unshift(item);\n --countdown;\n } else if (actionPref.visibility === ThCollapsibilityVisibility.partially) {\n if (countdown > 0) {\n menuItems.unshift(item);\n --countdown;\n } else {\n actionIcons.unshift(item);\n }\n } else {\n actionIcons.unshift(item);\n }\n });\n } else {\n // collapse set to false so we ignore visibility and don’t triage\n items.map((item) => {\n actionIcons.push(item);\n });\n }\n\n return [actionIcons, menuItems];\n }, [items, prefs, breakpoint]);\n\n return { ActionIcons: actionIcons, MenuItems: menuItems };\n}"]}
@@ -0,0 +1,417 @@
1
+ import { useState, useLayoutEffect, useCallback, useEffect, useRef, useMemo } from 'react';
2
+ import { EPUBLayout, Link, Locator } from '@readium/shared';
3
+ import { EpubPreferences, EpubNavigator } from '@readium/navigator';
4
+
5
+ // src/core/Hooks/useFullscreen.ts
6
+ var useIsClient = () => {
7
+ const [isClient, setIsClient] = useState(false);
8
+ useLayoutEffect(() => {
9
+ if (typeof window !== "undefined") setIsClient(true);
10
+ }, []);
11
+ return isClient;
12
+ };
13
+
14
+ // src/core/Hooks/useFullscreen.ts
15
+ var useFullscreen = (onChange) => {
16
+ const [isFullscreen, setIsFullscreen] = useState(false);
17
+ const isClient = useIsClient();
18
+ const handleFullscreen = useCallback(() => {
19
+ if (!isClient) return;
20
+ if (!document.fullscreenElement) {
21
+ document.documentElement.requestFullscreen();
22
+ } else if (document.exitFullscreen) {
23
+ document.exitFullscreen();
24
+ }
25
+ }, [isClient]);
26
+ useEffect(() => {
27
+ const onFSchange = () => {
28
+ const isFs = Boolean(document.fullscreenElement);
29
+ setIsFullscreen(isFs);
30
+ onChange && onChange(isFs);
31
+ };
32
+ document.addEventListener("fullscreenchange", onFSchange);
33
+ return () => {
34
+ document.removeEventListener("fullscreenchange", onFSchange);
35
+ };
36
+ }, [onChange]);
37
+ return {
38
+ isFullscreen,
39
+ handleFullscreen
40
+ };
41
+ };
42
+ var useLocalStorage = (key) => {
43
+ const [localData, setLocalData] = useState(null);
44
+ const cachedLocalData = useRef(null);
45
+ const setValue = (newValue) => {
46
+ setLocalData(newValue);
47
+ localStorage.setItem(key, JSON.stringify(newValue));
48
+ };
49
+ const getValue = () => {
50
+ if (localData !== null) return localData;
51
+ const value = localStorage.getItem(key);
52
+ return value ? JSON.parse(value) : null;
53
+ };
54
+ const clearValue = () => {
55
+ setLocalData(null);
56
+ localStorage.removeItem(key);
57
+ };
58
+ useEffect(() => {
59
+ cachedLocalData.current = localData;
60
+ }, [localData]);
61
+ return {
62
+ setLocalData: setValue,
63
+ getLocalData: getValue,
64
+ clearLocalData: clearValue,
65
+ localData,
66
+ cachedLocalData
67
+ };
68
+ };
69
+ var usePrevious = (value) => {
70
+ const ref = useRef(null);
71
+ useEffect(() => {
72
+ ref.current = value;
73
+ }, [value]);
74
+ return ref.current;
75
+ };
76
+ var useTimeline = ({
77
+ publication,
78
+ currentLocation,
79
+ currentPositions,
80
+ positionsList,
81
+ onChange
82
+ }) => {
83
+ const layout = publication?.metadata.getPresentation()?.layout || EPUBLayout.reflowable;
84
+ const [timelineItems, setTimelineItems] = useState({});
85
+ const [tocTree, setTocTree] = useState([]);
86
+ const [currentTocEntry, setCurrentTocEntry] = useState(null);
87
+ const [currentItem, setCurrentItem] = useState(null);
88
+ const [previousItem, setPreviousItem] = useState(null);
89
+ const [nextItem, setNextItem] = useState(null);
90
+ const idCounterRef = useRef(0);
91
+ const buildTocTree = useCallback((links, idGenerator, positionsList2) => {
92
+ return links.map((link) => {
93
+ const newId = idGenerator();
94
+ let href = link.href;
95
+ const fragmentIndex = href.indexOf("#");
96
+ if (fragmentIndex !== -1) {
97
+ const baseHref = href.substring(0, fragmentIndex);
98
+ const duplicateLink = links.find((l) => l.href.startsWith(baseHref) && l.href !== href);
99
+ if (!duplicateLink) {
100
+ href = baseHref;
101
+ }
102
+ }
103
+ const treeNode = {
104
+ id: newId,
105
+ href,
106
+ title: link.title,
107
+ position: positionsList2?.find((position) => position.href === href)?.locations.position
108
+ };
109
+ if (link.children) {
110
+ treeNode.children = buildTocTree(link.children.items, idGenerator, positionsList2);
111
+ }
112
+ return treeNode;
113
+ });
114
+ }, []);
115
+ const handleTocEntryOnNav = useCallback((locator) => {
116
+ if (!locator || !tocTree.length) return;
117
+ const findMatch = (items, link) => {
118
+ for (const item of items) {
119
+ if (item.href === link?.href) {
120
+ return item;
121
+ }
122
+ if (item.children) {
123
+ const match = findMatch(item.children, link);
124
+ if (match) return match;
125
+ }
126
+ }
127
+ return void 0;
128
+ };
129
+ const currentMatch = findMatch(tocTree, new Link(locator));
130
+ if (currentMatch) {
131
+ setCurrentTocEntry(currentMatch.id);
132
+ return;
133
+ }
134
+ if (layout === EPUBLayout.fixed) {
135
+ const positions = currentPositions;
136
+ if (positions && positions.length === 2) {
137
+ const otherPosition = positions[0] === locator.locations.position ? positions[1] : positions[0];
138
+ const otherPositionInList = positionsList.find((pos) => pos.locations.position === otherPosition);
139
+ if (otherPositionInList) {
140
+ const match = findMatch(tocTree, new Link(otherPositionInList));
141
+ if (match) {
142
+ setCurrentTocEntry(match.id);
143
+ return;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ const otherPositions = currentPositions.filter((pos) => pos !== locator.locations.position);
149
+ for (const otherPosition of otherPositions) {
150
+ const otherPositionInList = positionsList.find((pos) => pos.locations.position === otherPosition);
151
+ if (otherPositionInList) {
152
+ const match = findMatch(tocTree, new Link(otherPositionInList));
153
+ if (match) {
154
+ setCurrentTocEntry(match.id);
155
+ return;
156
+ }
157
+ }
158
+ }
159
+ }, [tocTree, currentPositions, positionsList, layout]);
160
+ const buildTimelineItems = useCallback(() => {
161
+ const timelineItems2 = {};
162
+ const readingOrder = publication?.readingOrder?.items || [];
163
+ const getBaseUrl = (url) => {
164
+ const [base] = url.split("#");
165
+ const [path] = base.split("?");
166
+ return path;
167
+ };
168
+ for (const item of readingOrder) {
169
+ const toc = publication?.toc?.items || [];
170
+ const flatToc = toc.flatMap((t) => [t, ...t.children?.items || []]);
171
+ const matchingTocItems = flatToc.filter((t) => {
172
+ const baseHref = getBaseUrl(t.href);
173
+ const baseItemHref = getBaseUrl(item.href);
174
+ return baseHref === baseItemHref;
175
+ });
176
+ const timelineItem = {
177
+ href: item.href,
178
+ title: matchingTocItems[0]?.title || "",
179
+ fragments: matchingTocItems.map((t) => t.href.split("#")[1]).filter(Boolean),
180
+ children: matchingTocItems[0]?.children?.items?.map((child) => ({
181
+ title: child.title,
182
+ href: child.href
183
+ })) || []
184
+ };
185
+ timelineItems2[item.href] = timelineItem;
186
+ }
187
+ for (const item of readingOrder) {
188
+ const timelineItem = timelineItems2[item.href];
189
+ if (!timelineItem) continue;
190
+ const positions = positionsList.filter((p) => p.href === item.href).sort((a, b) => (a.locations.position || 0) - (b.locations.position || 0));
191
+ if (positions.length > 0) {
192
+ const start = positions[0].locations;
193
+ const end = positions.length > 1 ? positions[positions.length - 1].locations : void 0;
194
+ timelineItem.positionRange = start.position !== void 0 ? [start.position, end?.position] : void 0;
195
+ timelineItem.progressionRange = start.progression !== void 0 ? [start.progression, end?.progression] : void 0;
196
+ timelineItem.totalProgressionRange = start.totalProgression !== void 0 ? [start.totalProgression, end?.totalProgression] : void 0;
197
+ }
198
+ }
199
+ return timelineItems2;
200
+ }, [publication?.readingOrder?.items, publication?.toc?.items, positionsList]);
201
+ const updateTimelineItems = useCallback(() => {
202
+ if (!currentLocation || !timelineItems) {
203
+ setPreviousItem(null);
204
+ setNextItem(null);
205
+ setCurrentItem(null);
206
+ return;
207
+ }
208
+ const currentItem2 = timelineItems[currentLocation.href];
209
+ if (!currentItem2) {
210
+ setPreviousItem(null);
211
+ setNextItem(null);
212
+ setCurrentItem(null);
213
+ return;
214
+ }
215
+ setCurrentItem(currentItem2);
216
+ const timelineItemsArray = Object.values(timelineItems);
217
+ const currentIndex = timelineItemsArray.findIndex((item) => item.href === currentLocation.href);
218
+ if (currentIndex === -1) {
219
+ setPreviousItem(null);
220
+ setNextItem(null);
221
+ } else {
222
+ setPreviousItem(currentIndex > 0 ? timelineItemsArray[currentIndex - 1] : null);
223
+ setNextItem(currentIndex < timelineItemsArray.length - 1 ? timelineItemsArray[currentIndex + 1] : null);
224
+ }
225
+ }, [currentLocation, timelineItems]);
226
+ useEffect(() => {
227
+ if (!publication) return;
228
+ const idGenerator = () => `toc-${++idCounterRef.current}`;
229
+ setTocTree(buildTocTree(publication.toc?.items || [], idGenerator, positionsList));
230
+ setTimelineItems(buildTimelineItems());
231
+ }, [publication, positionsList, buildTocTree, buildTimelineItems]);
232
+ useEffect(() => {
233
+ if (!tocTree.length || !timelineItems) return;
234
+ if (currentLocation) {
235
+ handleTocEntryOnNav(currentLocation);
236
+ } else if (tocTree.length > 0) {
237
+ handleTocEntryOnNav(new Locator({ href: tocTree[0].href, type: "" }));
238
+ }
239
+ updateTimelineItems();
240
+ }, [currentLocation, tocTree, timelineItems, handleTocEntryOnNav, updateTimelineItems]);
241
+ useEffect(() => {
242
+ if (!onChange) return;
243
+ const timeline = {
244
+ items: timelineItems,
245
+ toc: {
246
+ tree: tocTree,
247
+ currentEntry: currentTocEntry
248
+ },
249
+ currentItem,
250
+ previousItem,
251
+ nextItem
252
+ };
253
+ onChange(timeline);
254
+ }, [timelineItems, currentItem, tocTree, currentTocEntry, previousItem, nextItem, onChange]);
255
+ return {
256
+ items: timelineItems,
257
+ toc: {
258
+ tree: tocTree,
259
+ currentEntry: currentTocEntry
260
+ },
261
+ currentItem,
262
+ previousItem,
263
+ nextItem
264
+ };
265
+ };
266
+ var navigatorInstance = null;
267
+ var useEpubNavigator = () => {
268
+ const container = useRef(null);
269
+ const containerParent = useRef(null);
270
+ const publication = useRef(null);
271
+ const submitPreferences = useCallback(async (preferences) => {
272
+ await navigatorInstance?.submitPreferences(new EpubPreferences(preferences));
273
+ }, []);
274
+ const getSetting = useCallback((settingKey) => {
275
+ return navigatorInstance?.settings[settingKey];
276
+ }, []);
277
+ let FXLPositionChangedCallback;
278
+ const FXLPositionChanged = useMemo(() => {
279
+ return new MutationObserver((mutationsList) => {
280
+ for (const mutation of mutationsList) {
281
+ const re = /translate3d\(([^)]+)\)/;
282
+ const newVal = mutation.target.getAttribute(mutation.attributeName);
283
+ const oldVal = mutation.oldValue;
284
+ if (newVal?.split(re)[1] !== oldVal?.split(re)[1]) {
285
+ const locator = navigatorInstance?.currentLocator;
286
+ if (locator) {
287
+ FXLPositionChangedCallback?.(locator);
288
+ }
289
+ }
290
+ }
291
+ });
292
+ }, [FXLPositionChangedCallback]);
293
+ const EpubNavigatorLoad = useCallback((config, cb) => {
294
+ if (config.container) {
295
+ container.current = config.container;
296
+ containerParent.current = container.current ? container.current.parentElement : null;
297
+ publication.current = config.publication;
298
+ navigatorInstance = new EpubNavigator(
299
+ config.container,
300
+ config.publication,
301
+ config.listeners,
302
+ config.positionsList,
303
+ config.initialPosition,
304
+ { preferences: config.preferences || {}, defaults: config.defaults || {} }
305
+ );
306
+ navigatorInstance.load().then(() => {
307
+ cb();
308
+ if (navigatorInstance?.layout === EPUBLayout.fixed) {
309
+ FXLPositionChanged.observe(navigatorInstance?.pool.spineElement, {
310
+ attributeFilter: ["style"],
311
+ attributeOldValue: true
312
+ });
313
+ }
314
+ });
315
+ }
316
+ }, [FXLPositionChanged]);
317
+ const EpubNavigatorDestroy = useCallback((cb) => {
318
+ cb();
319
+ if (navigatorInstance?.layout === EPUBLayout.fixed) {
320
+ FXLPositionChanged.disconnect();
321
+ }
322
+ navigatorInstance?.destroy;
323
+ }, [FXLPositionChanged]);
324
+ const goRight = useCallback((animated, callback) => {
325
+ navigatorInstance?.goRight(animated, callback);
326
+ }, []);
327
+ const goLeft = useCallback((animated, callback) => {
328
+ navigatorInstance?.goLeft(animated, callback);
329
+ }, []);
330
+ const goBackward = useCallback((animated, callback) => {
331
+ navigatorInstance?.goBackward(animated, callback);
332
+ }, []);
333
+ const goForward = useCallback((animated, callback) => {
334
+ navigatorInstance?.goForward(animated, callback);
335
+ }, []);
336
+ const goLink = useCallback((link, animated, callback) => {
337
+ navigatorInstance?.goLink(link, animated, callback);
338
+ }, []);
339
+ const go = useCallback((locator, animated, callback) => {
340
+ navigatorInstance?.go(locator, animated, callback);
341
+ }, []);
342
+ const navLayout = useCallback(() => {
343
+ return navigatorInstance?.layout;
344
+ }, []);
345
+ const currentLocator = useCallback(() => {
346
+ return navigatorInstance?.currentLocator;
347
+ }, []);
348
+ const getLocatorAtOffset = useCallback((offset) => {
349
+ const readingOrder = navigatorInstance?.publication?.readingOrder;
350
+ if (!readingOrder) return null;
351
+ const currentLocator2 = navigatorInstance?.currentLocator;
352
+ if (!currentLocator2) return null;
353
+ const currentLocatorIndex = readingOrder.findIndexWithHref(currentLocator2.href);
354
+ if (currentLocatorIndex === -1) return null;
355
+ const newIndex = currentLocatorIndex + offset;
356
+ if (newIndex < 0 || newIndex >= readingOrder.items.length) return null;
357
+ return readingOrder.items[newIndex];
358
+ }, []);
359
+ const previousLocator = useCallback(() => {
360
+ const link = getLocatorAtOffset(-1);
361
+ if (!link) return null;
362
+ return navigatorInstance?.publication?.manifest?.locatorFromLink(link);
363
+ }, [getLocatorAtOffset]);
364
+ const nextLocator = useCallback(() => {
365
+ const link = getLocatorAtOffset(1);
366
+ if (!link) return null;
367
+ return navigatorInstance?.publication?.manifest?.locatorFromLink(link);
368
+ }, [getLocatorAtOffset]);
369
+ const currentPositions = useCallback(() => {
370
+ return navigatorInstance?.viewport?.positions;
371
+ }, []);
372
+ const canGoBackward = useCallback(() => {
373
+ return navigatorInstance?.canGoBackward;
374
+ }, []);
375
+ const canGoForward = useCallback(() => {
376
+ return navigatorInstance?.canGoForward;
377
+ }, []);
378
+ const isScrollStart = useCallback(() => {
379
+ return navigatorInstance?.isScrollStart;
380
+ }, []);
381
+ const isScrollEnd = useCallback(() => {
382
+ return navigatorInstance?.isScrollEnd;
383
+ }, []);
384
+ const getCframes = useCallback(() => {
385
+ return navigatorInstance?._cframes;
386
+ }, []);
387
+ return {
388
+ EpubNavigatorLoad,
389
+ EpubNavigatorDestroy,
390
+ goRight,
391
+ goLeft,
392
+ goBackward,
393
+ goForward,
394
+ goLink,
395
+ go,
396
+ navLayout,
397
+ currentLocator,
398
+ previousLocator,
399
+ nextLocator,
400
+ currentPositions,
401
+ canGoBackward,
402
+ canGoForward,
403
+ isScrollStart,
404
+ isScrollEnd,
405
+ preferencesEditor: navigatorInstance?.preferencesEditor,
406
+ getSetting,
407
+ submitPreferences,
408
+ getCframes,
409
+ onFXLPositionChange: (cb) => {
410
+ FXLPositionChangedCallback = cb;
411
+ }
412
+ };
413
+ };
414
+
415
+ export { useEpubNavigator, useFullscreen, useIsClient, useLocalStorage, usePrevious, useTimeline };
416
+ //# sourceMappingURL=chunk-NA3KMUS4.mjs.map
417
+ //# sourceMappingURL=chunk-NA3KMUS4.mjs.map