@nulib/clover 0.0.0-stage → 4.0.0-beta.0

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 (410) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +120 -2
  3. package/dist/components/Annotations/Annotations.mjs +674 -0
  4. package/dist/components/Annotations/EntryBodies.mjs +52 -0
  5. package/dist/components/Annotations/languages.mjs +43 -0
  6. package/dist/components/Body/Body.mjs +51 -0
  7. package/dist/components/Body/BodyAlert.mjs +25 -0
  8. package/dist/components/Body/Caption.mjs +90 -0
  9. package/dist/components/Body/CaptionDetails.mjs +50 -0
  10. package/dist/components/Body/Pending.mjs +9 -0
  11. package/dist/components/Body/glyphs.mjs +66 -0
  12. package/dist/components/Body/renderers.mjs +30 -0
  13. package/dist/components/Body/useControlsVisibility.mjs +204 -0
  14. package/dist/components/Body/useNearViewport.mjs +27 -0
  15. package/dist/components/Canvas/AnnotationMenu.mjs +128 -0
  16. package/dist/components/Canvas/AnnotationState.mjs +338 -0
  17. package/dist/components/Canvas/Annotations.mjs +497 -0
  18. package/dist/components/Canvas/CanvasView.mjs +669 -0
  19. package/dist/components/Canvas/ChoiceMenu.mjs +77 -0
  20. package/dist/components/Canvas/Connected.mjs +228 -0
  21. package/dist/components/Canvas/ControlMenu.mjs +67 -0
  22. package/dist/components/Canvas/Controls.mjs +233 -0
  23. package/dist/components/Canvas/FrameAnimation.mjs +344 -0
  24. package/dist/components/Canvas/LoadedCanvas.mjs +177 -0
  25. package/dist/components/Canvas/Placeholder.mjs +105 -0
  26. package/dist/components/Canvas/fromManifest.mjs +44 -0
  27. package/dist/components/Canvas/index.mjs +19 -0
  28. package/dist/components/Canvas/layout.mjs +369 -0
  29. package/dist/components/Canvas/media/MediaBody.mjs +285 -0
  30. package/dist/components/Canvas/media/Player.mjs +193 -0
  31. package/dist/components/Canvas/media/Transport.mjs +511 -0
  32. package/dist/components/Canvas/media/TransportButton.mjs +39 -0
  33. package/dist/components/Canvas/media/useBarHeight.mjs +28 -0
  34. package/dist/components/Canvas/media/useCaptionTracks.mjs +131 -0
  35. package/dist/components/Canvas/media/useMediaController.mjs +77 -0
  36. package/dist/components/Canvas/media/useMediaElement.mjs +100 -0
  37. package/dist/components/Canvas/panClearOfControls.mjs +92 -0
  38. package/dist/components/Canvas/rendererSurface.mjs +6 -0
  39. package/dist/components/Canvas/surface.mjs +5 -0
  40. package/dist/components/Canvas/track.mjs +43 -0
  41. package/dist/components/Canvas/useSvgReader.mjs +23 -0
  42. package/dist/components/Collection/Collection.mjs +76 -0
  43. package/dist/components/CollectionSelect/CollectionSelect.mjs +114 -0
  44. package/dist/components/Contents/Contents.mjs +120 -0
  45. package/dist/components/Download/Download.mjs +105 -0
  46. package/dist/components/Items/Item.mjs +184 -0
  47. package/dist/components/Items/Items.mjs +455 -0
  48. package/dist/components/Items/Pager.mjs +190 -0
  49. package/dist/components/Items/StandaloneItems.mjs +80 -0
  50. package/dist/components/Items/clamped.mjs +90 -0
  51. package/dist/components/Label/Label.mjs +39 -0
  52. package/dist/components/Map/LoadedMap.mjs +26 -0
  53. package/dist/components/Map/Map.mjs +38 -0
  54. package/dist/components/Map/MapView.mjs +538 -0
  55. package/dist/components/Map/basemap.mjs +50 -0
  56. package/dist/components/Map/overlayImage.mjs +17 -0
  57. package/dist/components/Panel/About.mjs +143 -0
  58. package/dist/components/Panel/Panel.mjs +259 -0
  59. package/dist/components/Panel/PanelToggle.mjs +43 -0
  60. package/dist/components/Panel/PartOfManifest.mjs +52 -0
  61. package/dist/components/Primitives/Primitives.mjs +263 -0
  62. package/dist/components/Primitives/resource.mjs +11 -0
  63. package/dist/components/Provider/Provider.mjs +174 -0
  64. package/dist/components/Root/Announcer.mjs +58 -0
  65. package/dist/components/Root/Root.mjs +29 -0
  66. package/dist/components/Root/useRootState.mjs +188 -0
  67. package/dist/components/Scene/Connected.mjs +48 -0
  68. package/dist/components/Scene/Loaded.mjs +56 -0
  69. package/dist/components/Scene/RotatePad.mjs +204 -0
  70. package/dist/components/Scene/Scene.mjs +20 -0
  71. package/dist/components/Scene/SceneView.mjs +539 -0
  72. package/dist/components/Scene/cloverEngine.mjs +105 -0
  73. package/dist/components/Scene/engine.mjs +141 -0
  74. package/dist/components/Scene/engines.mjs +23 -0
  75. package/dist/components/Scene/gestures.mjs +74 -0
  76. package/dist/components/Scene/models.mjs +78 -0
  77. package/dist/components/Scene/orbit.mjs +60 -0
  78. package/dist/components/Search/Search.mjs +246 -0
  79. package/dist/components/Split/Split.mjs +203 -0
  80. package/dist/components/Split/splitting.mjs +203 -0
  81. package/dist/components/Status/Status.mjs +47 -0
  82. package/dist/components/Timeline/Connected.mjs +25 -0
  83. package/dist/components/Timeline/Timeline.mjs +40 -0
  84. package/dist/components/Timeline/playerSurface.mjs +84 -0
  85. package/dist/components/Transcript/Transcript.mjs +377 -0
  86. package/dist/components/Viewer/Viewer.mjs +19 -0
  87. package/dist/core/annotation-bodies.mjs +29 -0
  88. package/dist/core/annotation-collection.mjs +55 -0
  89. package/dist/core/annotation-name.mjs +31 -0
  90. package/dist/core/annotation-sets.mjs +155 -0
  91. package/dist/core/annotations-content.mjs +27 -0
  92. package/dist/core/annotations.mjs +73 -0
  93. package/dist/core/clover.mjs +393 -0
  94. package/dist/core/content-state-reader.mjs +82 -0
  95. package/dist/core/content-state.mjs +43 -0
  96. package/dist/core/direction.mjs +12 -0
  97. package/dist/core/geo-detect.mjs +30 -0
  98. package/dist/core/geo.mjs +283 -0
  99. package/dist/core/items.mjs +74 -0
  100. package/dist/core/keep-fragments.mjs +40 -0
  101. package/dist/core/link.mjs +28 -0
  102. package/dist/core/load.mjs +176 -0
  103. package/dist/core/map-config.mjs +12 -0
  104. package/dist/core/markdown.mjs +139 -0
  105. package/dist/core/pages.mjs +51 -0
  106. package/dist/core/painted-bodies.mjs +20 -0
  107. package/dist/core/painting.mjs +17 -0
  108. package/dist/core/presentation.mjs +27 -0
  109. package/dist/core/ranges.mjs +133 -0
  110. package/dist/core/region.mjs +32 -0
  111. package/dist/core/request.mjs +40 -0
  112. package/dist/core/sanitize.mjs +72 -0
  113. package/dist/core/search-service.mjs +22 -0
  114. package/dist/core/search.mjs +154 -0
  115. package/dist/core/selectors.mjs +94 -0
  116. package/dist/core/sequence.mjs +70 -0
  117. package/dist/core/show-link.mjs +16 -0
  118. package/dist/core/store.mjs +40 -0
  119. package/dist/core/svg-shape.mjs +183 -0
  120. package/dist/core/text.mjs +36 -0
  121. package/dist/core/thumbnail.mjs +55 -0
  122. package/dist/core/value.mjs +39 -0
  123. package/dist/core/vtt.mjs +111 -0
  124. package/dist/hooks/useFullscreen.mjs +21 -0
  125. package/dist/hooks/useFullscreenSupported.mjs +11 -0
  126. package/dist/hooks/useLoaded.mjs +27 -0
  127. package/dist/hooks/useWithinFullscreen.mjs +24 -0
  128. package/dist/i18n/config.mjs +170 -0
  129. package/dist/i18n/hostLanguage.mjs +6 -0
  130. package/dist/i18n/locales/en.json.mjs +5 -0
  131. package/dist/i18n/locales/es.json.mjs +5 -0
  132. package/dist/i18n/locales/fi.json.mjs +5 -0
  133. package/dist/i18n/locales/fr.json.mjs +5 -0
  134. package/dist/i18n/locales/index.mjs +13 -0
  135. package/dist/i18n/locales/nb.json.mjs +5 -0
  136. package/dist/i18n/locales/nn.json.mjs +5 -0
  137. package/dist/i18n/locales/no.json.mjs +5 -0
  138. package/dist/i18n/locales/pt.json.mjs +5 -0
  139. package/dist/i18n/reader.mjs +13 -0
  140. package/dist/i18n/useCloverTranslation.mjs +28 -0
  141. package/dist/index.d.mts +2204 -0
  142. package/dist/index.mjs +133 -0
  143. package/dist/lib/asArray.mjs +5 -0
  144. package/dist/lib/classnames.mjs +5 -0
  145. package/dist/lib/fullscreen.mjs +65 -0
  146. package/dist/lib/gltf/bounds.mjs +44 -0
  147. package/dist/lib/gltf/load.mjs +156 -0
  148. package/dist/lib/gltf/mat4.mjs +150 -0
  149. package/dist/lib/gltf/renderer.mjs +342 -0
  150. package/dist/lib/gltf/shaders.mjs +192 -0
  151. package/dist/lib/hls.mjs +6 -0
  152. package/dist/lib/pointer.mjs +38 -0
  153. package/dist/lib/renderer/CanvasRenderer.mjs +857 -0
  154. package/dist/lib/renderer/backends/backend.mjs +21 -0
  155. package/dist/lib/renderer/backends/canvas2d/Canvas2DBackend.mjs +91 -0
  156. package/dist/lib/renderer/backends/contexts.mjs +27 -0
  157. package/dist/lib/renderer/backends/dom/DomLayers.mjs +91 -0
  158. package/dist/lib/renderer/backends/webgl2/WebGL2Backend.mjs +248 -0
  159. package/dist/lib/renderer/backends/webgl2/shaders.mjs +28 -0
  160. package/dist/lib/renderer/camera/Camera.mjs +64 -0
  161. package/dist/lib/renderer/camera/CameraAnimator.mjs +90 -0
  162. package/dist/lib/renderer/input/GestureController.mjs +252 -0
  163. package/dist/lib/renderer/io/TileCache.mjs +207 -0
  164. package/dist/lib/renderer/io/decode.mjs +156 -0
  165. package/dist/lib/renderer/loop/FrameLoop.mjs +50 -0
  166. package/dist/lib/renderer/math/affine.mjs +68 -0
  167. package/dist/lib/renderer/math/rect.mjs +45 -0
  168. package/dist/lib/renderer/overlays/Navigator.mjs +141 -0
  169. package/dist/lib/renderer/overlays/OverlayLayer.mjs +94 -0
  170. package/dist/lib/renderer/scene/planFrame.mjs +168 -0
  171. package/dist/lib/renderer/scene/regions.mjs +30 -0
  172. package/dist/lib/renderer/scene/sceneItem.mjs +114 -0
  173. package/dist/lib/renderer/scene/uploadBudget.mjs +30 -0
  174. package/dist/lib/renderer/sources/imageService.mjs +160 -0
  175. package/dist/lib/renderer/sources/sizedImage.mjs +38 -0
  176. package/dist/lib/renderer/sources/tilePyramid.mjs +172 -0
  177. package/dist/lib/time.mjs +21 -0
  178. package/dist/map/index.d.mts +184 -0
  179. package/dist/map/index.mjs +16 -0
  180. package/dist/react/context.mjs +46 -0
  181. package/dist/react/hooks.mjs +69 -0
  182. package/dist/react/language.mjs +30 -0
  183. package/dist/styles.css +1 -0
  184. package/dist/templates/default/Default.mjs +229 -0
  185. package/dist/templates/document/Document.mjs +286 -0
  186. package/dist/templates/document/DocumentPanel.mjs +9 -0
  187. package/dist/templates/document/Sheets.mjs +360 -0
  188. package/dist/templates/gallery/Gallery.mjs +62 -0
  189. package/dist/templates/index.d.mts +273 -0
  190. package/dist/templates/index.mjs +11 -0
  191. package/dist/templates/shared/Lightbox.mjs +111 -0
  192. package/dist/templates/shared/LightboxBody.mjs +9 -0
  193. package/dist/templates/shared/dragToClose.mjs +129 -0
  194. package/dist/templates/shared/useDragToClose.mjs +35 -0
  195. package/dist/templates/shared/useDrawer.mjs +113 -0
  196. package/dist/templates/shared/useFollowFocus.mjs +24 -0
  197. package/dist/templates/shared/useSlide.mjs +52 -0
  198. package/dist/templates/shared/useSpine.mjs +26 -0
  199. package/dist/templates.css +1 -0
  200. package/dist/three/index.d.mts +6 -0
  201. package/dist/three/index.mjs +8 -0
  202. package/dist/ui/Button.mjs +53 -0
  203. package/dist/ui/ControlCluster.mjs +87 -0
  204. package/dist/ui/Cue.mjs +13 -0
  205. package/dist/ui/ErrorBoundary.mjs +26 -0
  206. package/dist/ui/ExitFullscreen.mjs +46 -0
  207. package/dist/ui/FieldPill.mjs +153 -0
  208. package/dist/ui/HideToggle.mjs +57 -0
  209. package/dist/ui/Loading.mjs +20 -0
  210. package/dist/ui/Markup.mjs +95 -0
  211. package/dist/ui/ReadMore.mjs +84 -0
  212. package/dist/ui/Sections.mjs +448 -0
  213. package/dist/ui/Steps.mjs +84 -0
  214. package/dist/ui/Tip.mjs +196 -0
  215. package/dist/ui/bringIntoView.mjs +27 -0
  216. package/dist/ui/controlGlyphs.mjs +120 -0
  217. package/dist/ui/heading.mjs +19 -0
  218. package/dist/ui/languageCode.mjs +8 -0
  219. package/dist/ui/mediaIcons.mjs +104 -0
  220. package/dist/ui/useClusterReach.mjs +50 -0
  221. package/dist/ui/useContainerName.mjs +19 -0
  222. package/dist/ui/useOneOpen.mjs +22 -0
  223. package/dist/ui/useRovingFocus.mjs +64 -0
  224. package/dist/ui/useScrollTrack.mjs +150 -0
  225. package/dist/ui/useUniqueId.mjs +10 -0
  226. package/dist/ui/visuallyHidden.mjs +15 -0
  227. package/dist/web-components/About-uKa1wfDr.mjs +1 -0
  228. package/dist/web-components/AnnotationMenu-BGIYRXW6.mjs +1 -0
  229. package/dist/web-components/AnnotationState-D2UIgIEC.mjs +1 -0
  230. package/dist/web-components/Annotations-BhwAv3ah.mjs +1 -0
  231. package/dist/web-components/Annotations-C_tBJHo3.mjs +2 -0
  232. package/dist/web-components/Body-DMEERFuB.mjs +1 -0
  233. package/dist/web-components/BodyAlert-BP8voSLv.mjs +1 -0
  234. package/dist/web-components/Button-Cl02BFDd.mjs +1 -0
  235. package/dist/web-components/Camera-Dw51CAfF.mjs +1 -0
  236. package/dist/web-components/Canvas2DBackend-RRN2bEkc.mjs +1 -0
  237. package/dist/web-components/CanvasView-B8lMMSou.mjs +1 -0
  238. package/dist/web-components/CaptionDetails-KLMDv-ec.mjs +1 -0
  239. package/dist/web-components/ChoiceMenu-CXrVOmJl.mjs +1 -0
  240. package/dist/web-components/Collection-DL4Ui4hF.mjs +1 -0
  241. package/dist/web-components/CollectionSelect-DL-bbpwJ.mjs +1 -0
  242. package/dist/web-components/Connected-B0S1HXQb.mjs +1 -0
  243. package/dist/web-components/Connected-BcjRA5si.mjs +1 -0
  244. package/dist/web-components/Connected-Q7iizBb8.mjs +1 -0
  245. package/dist/web-components/Contents-ZC8TiGaW.mjs +1 -0
  246. package/dist/web-components/ControlMenu-DIoU797-.mjs +1 -0
  247. package/dist/web-components/Cue-CJxnDMEy.mjs +1 -0
  248. package/dist/web-components/Document-DHBRAFEK.mjs +1 -0
  249. package/dist/web-components/DocumentPanel-CqvE2pu9.mjs +1 -0
  250. package/dist/web-components/DomLayers-BsR2AOy-.mjs +1 -0
  251. package/dist/web-components/Download-DBksL1C0.mjs +1 -0
  252. package/dist/web-components/EntryBodies-VwEkTVrw.mjs +1 -0
  253. package/dist/web-components/ErrorBoundary-Cy9PGoZv.mjs +1 -0
  254. package/dist/web-components/FieldPill-DCJBz6Vj.mjs +1 -0
  255. package/dist/web-components/FrameAnimation-DRbmgGpF.mjs +1 -0
  256. package/dist/web-components/Gallery-BM7-VJkB.mjs +1 -0
  257. package/dist/web-components/HideToggle-BdYgG7us.mjs +1 -0
  258. package/dist/web-components/Items-_1Jz3FMs.mjs +1 -0
  259. package/dist/web-components/Label-CAiJ49eA.mjs +1 -0
  260. package/dist/web-components/LightboxBody-DyhUZiDf.mjs +1 -0
  261. package/dist/web-components/Loaded-wQurAeJz.mjs +1 -0
  262. package/dist/web-components/LoadedCanvas-DWz5IK5m.mjs +1 -0
  263. package/dist/web-components/LoadedMap-DIeW313M.mjs +1 -0
  264. package/dist/web-components/Loading-BmA--pzr.mjs +1 -0
  265. package/dist/web-components/Map-DzVGblIS.mjs +1 -0
  266. package/dist/web-components/MapView-BJaN7VBI.mjs +1 -0
  267. package/dist/web-components/Markup-D91DbxLk.mjs +2 -0
  268. package/dist/web-components/MediaBody-BYcVPo2X.mjs +1 -0
  269. package/dist/web-components/MediaBody-FEzH8VVw.mjs +1 -0
  270. package/dist/web-components/Navigator-CIJFA3q1.mjs +1 -0
  271. package/dist/web-components/Pager-BGwCurxE.mjs +1 -0
  272. package/dist/web-components/Panel-B-GXOkzF.mjs +1 -0
  273. package/dist/web-components/PanelToggle-BYjV2t1j.mjs +1 -0
  274. package/dist/web-components/PartOfManifest-ClbGepVM.mjs +1 -0
  275. package/dist/web-components/Pending-BspZajh5.mjs +1 -0
  276. package/dist/web-components/Primitives-CTh59wvs.mjs +1 -0
  277. package/dist/web-components/Provider-C6rIiDXH.mjs +1 -0
  278. package/dist/web-components/ReadMore-BJ2i-0uN.mjs +1 -0
  279. package/dist/web-components/Root-DkkYDtur.mjs +1 -0
  280. package/dist/web-components/Scene-B_PU_TiX.mjs +1 -0
  281. package/dist/web-components/SceneView-qcW_sT3j.mjs +1 -0
  282. package/dist/web-components/Search-UOneIUcP.mjs +1 -0
  283. package/dist/web-components/Sections-we9U9fXq.mjs +2 -0
  284. package/dist/web-components/StandaloneItems-DU8oCFc_.mjs +1 -0
  285. package/dist/web-components/Status-Cs5ZvFvL.mjs +1 -0
  286. package/dist/web-components/Timeline-WtYZ1bIJ.mjs +1 -0
  287. package/dist/web-components/Tip-C8J3qsIK.mjs +1 -0
  288. package/dist/web-components/Transcript-CRL2zToL.mjs +1 -0
  289. package/dist/web-components/annotation-collection-ZPyvpLFc.mjs +1 -0
  290. package/dist/web-components/annotations-content-BZChKhJZ.mjs +1 -0
  291. package/dist/web-components/assets/maplibre-gl-worker-kTz9OPxr.js +13831 -0
  292. package/dist/web-components/body-UntgrmoV.mjs +1 -0
  293. package/dist/web-components/bringIntoView-CQH5ZgMM.mjs +1 -0
  294. package/dist/web-components/canvas-d_U4v_mh.mjs +1 -0
  295. package/dist/web-components/classnames-DukgfdpI.mjs +1 -0
  296. package/dist/web-components/cloverEngine-Dbv-26NP.mjs +164 -0
  297. package/dist/web-components/content-state-reader-DjdKWjit.mjs +1 -0
  298. package/dist/web-components/contexts-ByL3eA_T.mjs +1 -0
  299. package/dist/web-components/controls-qRYf2jO2.mjs +1 -0
  300. package/dist/web-components/custom-elements.json +2739 -0
  301. package/dist/web-components/dragToClose-C-Pf1IeO.mjs +1 -0
  302. package/dist/web-components/engine-D8JLgzqq.mjs +4228 -0
  303. package/dist/web-components/engines-BwVb9R_A.mjs +1 -0
  304. package/dist/web-components/es-BwMkoRod.mjs +1 -0
  305. package/dist/web-components/fi-gPFOn9RK.mjs +1 -0
  306. package/dist/web-components/fr-DUHmgdJo.mjs +1 -0
  307. package/dist/web-components/fromManifest-UrMJgktp.mjs +1 -0
  308. package/dist/web-components/glyphs-BoX0a88P.mjs +1 -0
  309. package/dist/web-components/heading-Cjt0f-Eu.mjs +1 -0
  310. package/dist/web-components/hls-CdKrthkC.mjs +40 -0
  311. package/dist/web-components/hooks-Dp8pjU8l.mjs +1 -0
  312. package/dist/web-components/imageService-C3yg9DxB.mjs +1 -0
  313. package/dist/web-components/index-DWxMuwDL.mjs +1 -0
  314. package/dist/web-components/index.d.mts +604 -0
  315. package/dist/web-components/index.mjs +1 -0
  316. package/dist/web-components/index.umd.js +18 -0
  317. package/dist/web-components/items--Tu7ZM3L.mjs +1 -0
  318. package/dist/web-components/items-W2vrwArM.mjs +1 -0
  319. package/dist/web-components/keep-fragments-B5nlv2ck.mjs +1 -0
  320. package/dist/web-components/label-CYQ7tVl6.mjs +1 -0
  321. package/dist/web-components/languageCode-cCpiU0b0.mjs +1 -0
  322. package/dist/web-components/layout-KL0V-iJu.mjs +1 -0
  323. package/dist/web-components/link-DRRTY4lY.mjs +1 -0
  324. package/dist/web-components/logo-CnQUCB3Y.mjs +1 -0
  325. package/dist/web-components/maplibre-gl-CQ4OueXY.mjs +823 -0
  326. package/dist/web-components/markdown-CCYJwzFn.mjs +5 -0
  327. package/dist/web-components/models-BP2qp9nT.mjs +1 -0
  328. package/dist/web-components/nb-BSvnQ6jd.mjs +1 -0
  329. package/dist/web-components/nn-Dg2_HdZu.mjs +1 -0
  330. package/dist/web-components/no-BSvnQ6jd.mjs +1 -0
  331. package/dist/web-components/nodes-Bf-Fb7e5.mjs +1 -0
  332. package/dist/web-components/overlayImage-DdPs2EGY.mjs +1 -0
  333. package/dist/web-components/panClearOfControls-ac9uf-Qs.mjs +1 -0
  334. package/dist/web-components/panel-CiqEFDzv.mjs +1 -0
  335. package/dist/web-components/part-CUBY90_b.mjs +1 -0
  336. package/dist/web-components/playerSurface-i2TJz-F4.mjs +1 -0
  337. package/dist/web-components/provider-LUmAQSoP.mjs +1 -0
  338. package/dist/web-components/pt-B3J80JgO.mjs +1 -0
  339. package/dist/web-components/read-more-BaaO77el.mjs +1 -0
  340. package/dist/web-components/rendererSurface-DAvatpMF.mjs +22 -0
  341. package/dist/web-components/renderers-Bg4QqawN.mjs +1 -0
  342. package/dist/web-components/resource-DzIvB_4m.mjs +1 -0
  343. package/dist/web-components/sanitize-Dc7nOsgO.mjs +3 -0
  344. package/dist/web-components/search-DgcgsI3I.mjs +1 -0
  345. package/dist/web-components/shared-J3w3gnXD.mjs +1 -0
  346. package/dist/web-components/show-link-DWRRXSBy.mjs +1 -0
  347. package/dist/web-components/sizedImage-DfjlV2-i.mjs +1 -0
  348. package/dist/web-components/split-m-_XivaW.mjs +1 -0
  349. package/dist/web-components/splitting-BnQUxxgH.mjs +1 -0
  350. package/dist/web-components/status-DDS7jLNd.mjs +1 -0
  351. package/dist/web-components/styles-Ypl9KrSK.mjs +1 -0
  352. package/dist/web-components/svg-shape-DLY3g7oq.mjs +1 -0
  353. package/dist/web-components/text-BTAkxEfQ.mjs +5 -0
  354. package/dist/web-components/three.mjs +1 -0
  355. package/dist/web-components/thumbnail-BZvLSwWW.mjs +1 -0
  356. package/dist/web-components/time-B9GZoYcm.mjs +1 -0
  357. package/dist/web-components/tip-BXByhOJ9.mjs +1 -0
  358. package/dist/web-components/toggle-AS72kq6v.mjs +1 -0
  359. package/dist/web-components/upgrader-XNxI-5jo.mjs +1 -0
  360. package/dist/web-components/useContainerName-DCbE5JXi.mjs +1 -0
  361. package/dist/web-components/useNearViewport-CyoK3l8W.mjs +1 -0
  362. package/dist/web-components/useScrollTrack-dLFWnT8N.mjs +1 -0
  363. package/dist/web-components/viewer/AnnotationMenu-Dd4tnzNV.mjs +1 -0
  364. package/dist/web-components/viewer/AnnotationState-DZaSy5lH.mjs +1 -0
  365. package/dist/web-components/viewer/Annotations-D1h-Yi5J.mjs +1 -0
  366. package/dist/web-components/viewer/Annotations-sj79EMen.mjs +2 -0
  367. package/dist/web-components/viewer/Canvas2DBackend-CkvI0wUT.mjs +1 -0
  368. package/dist/web-components/viewer/CaptionDetails-B_JdNjJ7.mjs +1 -0
  369. package/dist/web-components/viewer/ChoiceMenu-xa51a1DV.mjs +1 -0
  370. package/dist/web-components/viewer/Collection-CxuLCspj.mjs +1 -0
  371. package/dist/web-components/viewer/Connected-BSUBc3Ci.mjs +1 -0
  372. package/dist/web-components/viewer/Connected-CPIxNjF2.mjs +1 -0
  373. package/dist/web-components/viewer/Contents-DNh9mnsF.mjs +1 -0
  374. package/dist/web-components/viewer/ControlMenu-DdgIvBdf.mjs +1 -0
  375. package/dist/web-components/viewer/Cue-90H9_dXz.mjs +1 -0
  376. package/dist/web-components/viewer/Document-CNCpzkiN.mjs +1 -0
  377. package/dist/web-components/viewer/DocumentPanel-BdG4TVLE.mjs +1 -0
  378. package/dist/web-components/viewer/DomLayers-Dybz_aJv.mjs +1 -0
  379. package/dist/web-components/viewer/EntryBodies-DGXjFP3N.mjs +1 -0
  380. package/dist/web-components/viewer/FieldPill-Icmd98OY.mjs +1 -0
  381. package/dist/web-components/viewer/FrameAnimation-DJZN3Rd4.mjs +1 -0
  382. package/dist/web-components/viewer/Gallery-CEp3-bh2.mjs +1 -0
  383. package/dist/web-components/viewer/HideToggle-DB6HTmAO.mjs +1 -0
  384. package/dist/web-components/viewer/LightboxBody-ClQ4yrTh.mjs +1 -0
  385. package/dist/web-components/viewer/MapView-BVSdybIC.mjs +1 -0
  386. package/dist/web-components/viewer/MediaBody-BBbSMT1i.mjs +1 -0
  387. package/dist/web-components/viewer/MediaBody-BzMXMHIF.mjs +1 -0
  388. package/dist/web-components/viewer/Navigator-Duc69Yes.mjs +1 -0
  389. package/dist/web-components/viewer/PartOfManifest-X9_q-2t6.mjs +1 -0
  390. package/dist/web-components/viewer/Search-S4N5QU4R.mjs +1 -0
  391. package/dist/web-components/viewer/StandaloneItems-BO4VyWRW.mjs +1 -0
  392. package/dist/web-components/viewer/Transcript-BbDaS064.mjs +1 -0
  393. package/dist/web-components/viewer/annotation-collection-BjZ1DAHq.mjs +1 -0
  394. package/dist/web-components/viewer/annotations-content-jn3n5Y2-.mjs +1 -0
  395. package/dist/web-components/viewer/cloverEngine-CjuYjUhI.mjs +164 -0
  396. package/dist/web-components/viewer/content-state-reader-CPiShIjP.mjs +1 -0
  397. package/dist/web-components/viewer/host-yWi4R1bP.mjs +1 -0
  398. package/dist/web-components/viewer/index.d.mts +7 -0
  399. package/dist/web-components/viewer/index.mjs +1 -0
  400. package/dist/web-components/viewer/index.umd.js +18 -0
  401. package/dist/web-components/viewer/link-CwE-fg5G.mjs +1 -0
  402. package/dist/web-components/viewer/overlayImage-BpOgqsZ0.mjs +1 -0
  403. package/dist/web-components/viewer/renderers-L-IlGI1r.mjs +1 -0
  404. package/dist/web-components/viewer/search-DWkwRPo_.mjs +1 -0
  405. package/dist/web-components/viewer/styles-BRCkEU3w.mjs +1 -0
  406. package/dist/web-components/viewer/viewer--TreVlJ_.mjs +28 -0
  407. package/dist/web-components/viewer/vtt-1ZJwtElI.mjs +5 -0
  408. package/dist/web-components/viewer-DyV864Qe.mjs +1 -0
  409. package/dist/web-components/vtt-GFssZH8Y.mjs +5 -0
  410. package/package.json +110 -4
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { GROUPS } from "./painting.mjs";
3
+ import { bodiesOf } from "./painting.mjs";
4
+ import { asArray } from "../lib/asArray.mjs";
5
+ function readFragment(id, fragment) {
6
+ const time = /(?:^|[#&])t=([^&]+)/.exec(fragment);
7
+ const t = time && { t: time[1] };
8
+ const xywh = /(?:^|[#&])xywh=(?:pixel:)?([^&]+)/.exec(fragment);
9
+ if (xywh) {
10
+ const [x, y, w, h] = xywh[1].split(",").map(Number);
11
+ if ([x, y, w, h].every(Number.isFinite)) {
12
+ return { id, rect: { x, y, w, h }, ...t };
13
+ }
14
+ }
15
+ return t && { id, ...t };
16
+ }
17
+ function readUri(uri) {
18
+ const hash = uri.indexOf("#");
19
+ if (hash >= 0) {
20
+ const id = uri.slice(0, hash);
21
+ return readFragment(id, uri.slice(hash)) ?? { id };
22
+ }
23
+ const query = uri.indexOf("&t=");
24
+ if (query >= 0) return { id: uri.slice(0, query), t: uri.slice(query + 3) };
25
+ return { id: uri };
26
+ }
27
+ const first = (target) => {
28
+ var _a;
29
+ return Array.isArray(target) ? first(target[0]) : GROUPS.includes(target == null ? void 0 : target.type) ? first((_a = target.items) == null ? void 0 : _a[0]) : target;
30
+ };
31
+ function parseAnnotationTarget(target) {
32
+ return readTarget(first(target));
33
+ }
34
+ function readTarget(target) {
35
+ var _a;
36
+ if (typeof target === "string") return readUri(target);
37
+ if (!target || typeof target !== "object") return { id: "" };
38
+ if (target.type !== "SpecificResource" || target.source === void 0) {
39
+ return readUri(target.id ?? "");
40
+ }
41
+ const source = typeof target.source === "string" ? readUri(target.source) : readUri(((_a = target.source) == null ? void 0 : _a.id) ?? "");
42
+ for (const raw of asArray(target.selector)) {
43
+ const selector = raw;
44
+ if ((selector == null ? void 0 : selector.type) === "PointSelector") {
45
+ return {
46
+ id: source.id,
47
+ point: { x: Number(selector.x), y: Number(selector.y) }
48
+ };
49
+ }
50
+ if ((selector == null ? void 0 : selector.type) === "SvgSelector" && selector.value) {
51
+ return { id: source.id, svg: String(selector.value) };
52
+ }
53
+ if ((selector == null ? void 0 : selector.type) === "FragmentSelector" && selector.value) {
54
+ const parsed = readFragment(source.id, String(selector.value));
55
+ if (parsed) return parsed;
56
+ }
57
+ }
58
+ return source;
59
+ }
60
+ const isSound = (type) => type === "Audio" || type === "Sound";
61
+ const supplementsOnly = (motivation) => {
62
+ const motivations = asArray(motivation);
63
+ return motivations.length > 0 && motivations.every((each) => each === "supplementing");
64
+ };
65
+ const isRegionText = (motivation, target) => supplementsOnly(motivation) && Boolean(target.rect || target.svg || target.point) && !target.t;
66
+ export {
67
+ GROUPS,
68
+ bodiesOf,
69
+ isRegionText,
70
+ isSound,
71
+ parseAnnotationTarget,
72
+ supplementsOnly
73
+ };
@@ -0,0 +1,393 @@
1
+ "use client";
2
+ import { findEntry, selectDrawnSets, selectHiddenSets, manifestOfAnnotation, readPage } from "./annotation-sets.mjs";
3
+ import { buildContentState } from "./content-state.mjs";
4
+ import { fetchResource, loadContent, loadManifest } from "./load.mjs";
5
+ import { referencedPages, fetchPage, embedPage } from "./pages.mjs";
6
+ import { selectVisibleCanvases, selectCanvas, selectSequence, canvasOfView, selectPosition, selectStart } from "./selectors.mjs";
7
+ import { searchServiceOf, SEARCH_SET_ID } from "./search-service.mjs";
8
+ import { createStore, createChannel } from "./store.mjs";
9
+ function navigationOf(clover, position, total) {
10
+ return {
11
+ position,
12
+ total,
13
+ hasPrevious: position > 0,
14
+ hasNext: position + 1 < total,
15
+ previous: () => clover.previous(),
16
+ next: () => clover.next(),
17
+ first: () => clover.first(),
18
+ last: () => clover.last(),
19
+ goTo: (canvasId) => clover.goTo(canvasId)
20
+ };
21
+ }
22
+ const NO_SEARCH = {
23
+ query: "",
24
+ status: "idle",
25
+ hits: [],
26
+ set: null
27
+ };
28
+ const INITIAL = {
29
+ status: "idle",
30
+ error: null,
31
+ manifest: null,
32
+ collection: null,
33
+ canvasId: null,
34
+ target: null,
35
+ annotationId: null,
36
+ hiddenSets: [],
37
+ shownSets: [],
38
+ addedSets: [],
39
+ search: NO_SEARCH
40
+ };
41
+ function createClover(options = {}) {
42
+ const store = createStore(INITIAL);
43
+ const viewport = createChannel(null);
44
+ const media = createChannel(null);
45
+ const captions = createChannel(null);
46
+ const highlight = createChannel(null);
47
+ const chapter = createChannel(null);
48
+ let annotating = null;
49
+ let searching = null;
50
+ let hostSets = [];
51
+ let stateSets = [];
52
+ let pending = null;
53
+ const added = () => hostSets.length || stateSets.length ? [...hostSets, ...stateSets] : INITIAL.addedSets;
54
+ let request = options.request;
55
+ let loading = null;
56
+ const requested = /* @__PURE__ */ new Set();
57
+ let pageScope = "view";
58
+ let allHeld = 0;
59
+ const embedVisiblePages = () => {
60
+ const { manifest, canvasId } = store.get();
61
+ if (!manifest) return;
62
+ const signal = loading == null ? void 0 : loading.signal;
63
+ for (const [canvas, list, pageId] of referencedPages(
64
+ pageScope === "all" || allHeld > 0 ? selectSequence(manifest).canvases : selectVisibleCanvases(manifest, canvasId)
65
+ )) {
66
+ if (requested.has(pageId)) continue;
67
+ requested.add(pageId);
68
+ fetchPage(pageId, canvas, request, signal).then((page) => {
69
+ if (signal == null ? void 0 : signal.aborted) return;
70
+ store.set(
71
+ (state) => state.manifest ? { manifest: embedPage(state.manifest, canvas, list, page) } : {}
72
+ );
73
+ }).catch(() => requested.delete(pageId));
74
+ }
75
+ };
76
+ store.subscribe(embedVisiblePages);
77
+ const arrive = (manifest, collection, deepLink, initial, pick) => {
78
+ var _a, _b, _c;
79
+ const { canvases } = selectSequence(manifest);
80
+ const has = (id) => Boolean(id) && canvases.some((canvas) => canvas.id === id);
81
+ const start = selectStart(manifest);
82
+ const target = has(deepLink == null ? void 0 : deepLink.canvasId) ? deepLink : has(start == null ? void 0 : start.canvasId) ? start : null;
83
+ const canvasId = has(initial.canvasId) ? initial.canvasId : (target == null ? void 0 : target.canvasId) ?? (has(initial.defaultCanvasId) ? initial.defaultCanvasId : null) ?? ((_a = canvases[0]) == null ? void 0 : _a.id) ?? null;
84
+ searching == null ? void 0 : searching.abort();
85
+ const picked = pick && ((_b = findEntry(stateSets, pick)) == null ? void 0 : _b.canvasId) === canvasId ? pick : null;
86
+ const arrival = target && picked ? { ...target, region: void 0 } : target;
87
+ store.set({
88
+ status: "ready",
89
+ search: NO_SEARCH,
90
+ manifest,
91
+ collection,
92
+ canvasId,
93
+ target: arrival && arrival.canvasId === canvasId ? arrival : null,
94
+ addedSets: added(),
95
+ annotationId: picked
96
+ });
97
+ if (canvasId && canvasId !== initial.canvasId) {
98
+ (_c = options.onCanvasChange) == null ? void 0 : _c.call(options, canvasId);
99
+ }
100
+ };
101
+ const setVisible = (setId, visible) => store.set((state) => {
102
+ const hidden = state.hiddenSets.filter((id) => id !== setId);
103
+ const shown = state.shownSets.filter((id) => id !== setId);
104
+ return visible ? { hiddenSets: hidden, shownSets: [...shown, setId] } : { hiddenSets: [...hidden, setId], shownSets: shown };
105
+ });
106
+ const navigate = (canvasId, target) => {
107
+ var _a, _b, _c;
108
+ if (!canvasId) return;
109
+ if ((_a = options.isControlled) == null ? void 0 : _a.call(options)) {
110
+ if (target) store.set({ target });
111
+ (_b = options.onCanvasChange) == null ? void 0 : _b.call(options, canvasId);
112
+ return;
113
+ }
114
+ const changed = store.get().canvasId !== canvasId;
115
+ store.set({ canvasId, target });
116
+ if (changed) (_c = options.onCanvasChange) == null ? void 0 : _c.call(options, canvasId);
117
+ };
118
+ const stepTo = (view, autoplay = false) => {
119
+ const { manifest } = store.get();
120
+ const canvasId = canvasOfView(manifest, view);
121
+ navigate(canvasId, canvasId && autoplay ? { canvasId, autoplay } : null);
122
+ };
123
+ const position = () => {
124
+ const { manifest, canvasId } = store.get();
125
+ return {
126
+ at: selectPosition(manifest, canvasId),
127
+ total: selectSequence(manifest).views.length
128
+ };
129
+ };
130
+ const begin = () => {
131
+ loading == null ? void 0 : loading.abort();
132
+ const controller = new AbortController();
133
+ loading = controller;
134
+ requested.clear();
135
+ store.set({ status: "loading", error: null, annotationId: null });
136
+ return controller.signal;
137
+ };
138
+ const fail = (error) => store.set({
139
+ status: "error",
140
+ error: error instanceof Error ? error : new Error(String(error))
141
+ });
142
+ async function load(content, initial = {}) {
143
+ var _a;
144
+ const signal = begin();
145
+ try {
146
+ const loaded = await loadContent(content, {
147
+ request,
148
+ signal,
149
+ manifestId: initial.manifestId ?? void 0
150
+ });
151
+ if (signal.aborted) return;
152
+ const note = loaded.annotation;
153
+ const noted = note ? readPage({ items: [note] }, `${note.id}#content-state`) : [];
154
+ stateSets = noted.length ? [{ id: `${note.id}#content-state`, source: "added", entries: noted }] : loaded.annotationSets ?? [];
155
+ const pick = pending ?? ((_a = noted[0]) == null ? void 0 : _a.id) ?? loaded.pick;
156
+ pending = null;
157
+ arrive(
158
+ loaded.manifest,
159
+ loaded.collection ?? null,
160
+ loaded.target,
161
+ initial,
162
+ pick
163
+ );
164
+ } catch (error) {
165
+ if (!signal.aborted) fail(error);
166
+ }
167
+ }
168
+ const isShown = (id) => {
169
+ const { manifest, collection } = store.get();
170
+ return (manifest == null ? void 0 : manifest.id) === id || (collection == null ? void 0 : collection.id) === id;
171
+ };
172
+ const memberOf = (id) => {
173
+ var _a;
174
+ return (((_a = store.get().collection) == null ? void 0 : _a.items) ?? []).find(
175
+ (item) => item.id === id
176
+ ) ?? { id, type: "Manifest" };
177
+ };
178
+ const openAnnotation = (manifestId, id) => {
179
+ var _a, _b;
180
+ pending = id;
181
+ if ((_a = options.isManifestControlled) == null ? void 0 : _a.call(options)) {
182
+ (_b = options.onManifestChange) == null ? void 0 : _b.call(options, manifestId);
183
+ return;
184
+ }
185
+ void show({ id: manifestId, type: "Manifest" }).then(
186
+ (shown) => {
187
+ var _a2;
188
+ return shown && ((_a2 = options.onManifestChange) == null ? void 0 : _a2.call(options, manifestId));
189
+ }
190
+ );
191
+ };
192
+ const show = async (member, canvasId) => {
193
+ if (member.type === "Collection") {
194
+ await load(member.id);
195
+ return store.get().status === "ready";
196
+ }
197
+ const { collection } = store.get();
198
+ const signal = begin();
199
+ const pick = pending;
200
+ pending = null;
201
+ const waiting = pick ? findEntry(stateSets, pick) : null;
202
+ try {
203
+ const next = await loadManifest(member, { request, signal });
204
+ if (signal.aborted) return false;
205
+ arrive(
206
+ next,
207
+ collection,
208
+ waiting ? { canvasId: waiting.canvasId } : canvasId ? { canvasId } : void 0,
209
+ {},
210
+ pick
211
+ );
212
+ return true;
213
+ } catch (error) {
214
+ if (!signal.aborted) fail(error);
215
+ return false;
216
+ }
217
+ };
218
+ return {
219
+ store,
220
+ viewport,
221
+ media,
222
+ captions,
223
+ highlight,
224
+ chapter,
225
+ get request() {
226
+ return request;
227
+ },
228
+ setRequest(next) {
229
+ request = next;
230
+ },
231
+ load,
232
+ async openCollection(id) {
233
+ var _a;
234
+ const shown = store.get().manifest;
235
+ if (!shown || ((_a = store.get().collection) == null ? void 0 : _a.id) === id) return;
236
+ try {
237
+ const collection = await fetchResource(id, { request });
238
+ if (collection.type !== "Collection") return;
239
+ if (store.get().manifest !== shown) return;
240
+ store.set({ collection });
241
+ } catch {
242
+ }
243
+ },
244
+ async goToManifest(id, canvasId) {
245
+ var _a, _b, _c;
246
+ if (isShown(id)) return;
247
+ const member = memberOf(id);
248
+ if (member.type !== "Collection" && ((_a = options.isManifestControlled) == null ? void 0 : _a.call(options))) {
249
+ (_b = options.onManifestChange) == null ? void 0 : _b.call(options, id);
250
+ return;
251
+ }
252
+ if (await show(member, canvasId)) {
253
+ (_c = options.onManifestChange) == null ? void 0 : _c.call(options, store.get().manifest.id);
254
+ }
255
+ },
256
+ async syncManifest(id) {
257
+ if (!id || isShown(id) || store.get().status !== "ready") return;
258
+ await show(memberOf(id));
259
+ },
260
+ goTo(canvasId, target) {
261
+ navigate(canvasId, target ? { ...target, canvasId } : null);
262
+ },
263
+ next({ autoplay = false, wrap = false } = {}) {
264
+ const { at, total } = position();
265
+ if (at + 1 < total) stepTo(at + 1, autoplay);
266
+ else if (wrap && total > 1) stepTo(0, autoplay);
267
+ },
268
+ previous() {
269
+ const { at } = position();
270
+ if (at > 0) stepTo(at - 1);
271
+ },
272
+ first() {
273
+ stepTo(0);
274
+ },
275
+ last() {
276
+ stepTo(position().total - 1);
277
+ },
278
+ consumeTarget() {
279
+ store.set({ target: null });
280
+ },
281
+ syncCanvas(canvasId) {
282
+ if (canvasId) store.set({ canvasId });
283
+ },
284
+ selectAnnotation(id) {
285
+ const { manifest, addedSets, canvasId, search } = store.get();
286
+ const entry = findEntry(
287
+ selectDrawnSets(manifest, addedSets, search.set),
288
+ id
289
+ );
290
+ store.set({ annotationId: entry ? id : null });
291
+ if (!entry) return;
292
+ const { hiddenSets, shownSets } = store.get();
293
+ if (entry.setId !== SEARCH_SET_ID && selectHiddenSets(manifest, addedSets, hiddenSets, shownSets).includes(
294
+ entry.setId
295
+ ))
296
+ setVisible(entry.setId, true);
297
+ const shown = selectVisibleCanvases(manifest, canvasId).some(
298
+ (canvas) => canvas.id === entry.canvasId
299
+ );
300
+ const exists = selectCanvas(manifest, entry.canvasId) !== null;
301
+ if (!shown && exists) navigate(entry.canvasId, null);
302
+ const elsewhere = exists ? void 0 : manifestOfAnnotation(entry.annotation);
303
+ if (elsewhere) openAnnotation(elsewhere, entry.id);
304
+ },
305
+ async search(query) {
306
+ searching == null ? void 0 : searching.abort();
307
+ const service = searchServiceOf(store.get().manifest);
308
+ const q = query.trim();
309
+ if (!q || !service) {
310
+ searching = null;
311
+ store.set({ search: NO_SEARCH, annotationId: null });
312
+ return;
313
+ }
314
+ const controller = new AbortController();
315
+ searching = controller;
316
+ store.set((state) => ({
317
+ search: { ...state.search, query: q, status: "loading" }
318
+ }));
319
+ try {
320
+ const { searchInto } = await import("./search.mjs");
321
+ await searchInto(store, service, q, request, controller.signal);
322
+ } catch {
323
+ store.set({
324
+ search: { query: q, status: "error", hits: [], set: null }
325
+ });
326
+ }
327
+ },
328
+ setSetVisible(setId, visible) {
329
+ setVisible(setId, visible);
330
+ },
331
+ async loadAnnotations(input) {
332
+ annotating == null ? void 0 : annotating.abort();
333
+ if (!input) {
334
+ hostSets = [];
335
+ store.set({ addedSets: added() });
336
+ return;
337
+ }
338
+ const controller = new AbortController();
339
+ annotating = controller;
340
+ try {
341
+ const { loadAnnotationSets } = await import("./annotation-collection.mjs");
342
+ const sets = await loadAnnotationSets(input, {
343
+ request,
344
+ signal: controller.signal
345
+ });
346
+ if (controller.signal.aborted) return;
347
+ hostSets = sets;
348
+ store.set({ addedSets: added() });
349
+ } catch {
350
+ }
351
+ },
352
+ getContentState() {
353
+ const { manifest, canvasId } = store.get();
354
+ if (!manifest || !canvasId) return null;
355
+ const view = viewport.get();
356
+ const element = media.get();
357
+ const time = element && element.currentTime > 0 ? element.currentTime : null;
358
+ const current = view && selectVisibleCanvases(manifest, canvasId).some(
359
+ (canvas) => canvas.id === view.canvasId
360
+ );
361
+ const onView = current && !time ? view : null;
362
+ return buildContentState({
363
+ manifestId: manifest.id,
364
+ canvasId: (onView == null ? void 0 : onView.canvasId) ?? canvasId,
365
+ region: onView == null ? void 0 : onView.region,
366
+ time
367
+ });
368
+ },
369
+ setAnnotationPages(scope) {
370
+ if (scope === pageScope) return;
371
+ pageScope = scope;
372
+ embedVisiblePages();
373
+ },
374
+ holdAllAnnotationPages() {
375
+ allHeld++;
376
+ embedVisiblePages();
377
+ let held = true;
378
+ return () => {
379
+ if (held) allHeld--;
380
+ held = false;
381
+ };
382
+ },
383
+ dispose() {
384
+ loading == null ? void 0 : loading.abort();
385
+ annotating == null ? void 0 : annotating.abort();
386
+ searching == null ? void 0 : searching.abort();
387
+ }
388
+ };
389
+ }
390
+ export {
391
+ createClover,
392
+ navigationOf
393
+ };
@@ -0,0 +1,82 @@
1
+ "use client";
2
+ import { parseAnnotationTarget } from "./annotations.mjs";
3
+ import { asArray } from "../lib/asArray.mjs";
4
+ function decodeBase64Url(encoded) {
5
+ const base64 = encoded.replace(/-/g, "+").replace(/_/g, "/");
6
+ const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
7
+ const binary = atob(padded);
8
+ try {
9
+ return decodeURIComponent(binary);
10
+ } catch {
11
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
12
+ return new TextDecoder().decode(bytes);
13
+ }
14
+ }
15
+ function decodeContentState(value) {
16
+ const trimmed = value.trim();
17
+ for (const read of [
18
+ () => JSON.parse(trimmed),
19
+ () => JSON.parse(decodeBase64Url(trimmed))
20
+ ]) {
21
+ try {
22
+ const json = read();
23
+ if (json && typeof json === "object") return json;
24
+ } catch {
25
+ }
26
+ }
27
+ return null;
28
+ }
29
+ function startTime(t) {
30
+ if (!t) return void 0;
31
+ const seconds = Number(t.split(",")[0]);
32
+ return Number.isFinite(seconds) ? seconds : void 0;
33
+ }
34
+ const collectionOf = (resource) => asArray(resource == null ? void 0 : resource.partOf).find(
35
+ (part) => (part == null ? void 0 : part.id) && part.type === "Collection"
36
+ );
37
+ function resolveContentState(json) {
38
+ const target = json.type === "Annotation" ? asArray(json.target)[0] : json;
39
+ if (!target) return null;
40
+ const parsed = parseAnnotationTarget(target);
41
+ const resource = typeof target === "string" ? { id: parsed.id } : target.type === "SpecificResource" ? typeof target.source === "string" ? { id: target.source } : target.source ?? {} : target;
42
+ const type = resource.type;
43
+ if (type === "Manifest" || type === "Collection") {
44
+ const collection2 = type === "Manifest" ? collectionOf(resource) : void 0;
45
+ return collection2 ? { id: collection2.id, type: "Collection", manifestId: parsed.id } : { id: parsed.id, type };
46
+ }
47
+ const pointTime = asArray(target.selector).find(
48
+ (selector) => (selector == null ? void 0 : selector.type) === "PointSelector" && selector.t != null
49
+ );
50
+ const canvasTarget = { canvasId: parsed.id };
51
+ if (parsed.rect) canvasTarget.region = parsed.rect;
52
+ const time = (pointTime == null ? void 0 : pointTime.t) ?? startTime(parsed.t);
53
+ if (time !== void 0) canvasTarget.time = Number(time);
54
+ const partOf = asArray(resource.partOf).find(
55
+ (part) => (part == null ? void 0 : part.id) && (!part.type || part.type === "Manifest")
56
+ );
57
+ const collection = collectionOf(partOf);
58
+ const annotation = json.type === "Annotation" && asArray(json.body).length ? {
59
+ id: json.id ?? `${parsed.id}#content-state`,
60
+ type: "Annotation",
61
+ motivation: asArray(json.motivation),
62
+ body: json.body,
63
+ target
64
+ } : void 0;
65
+ const shared = annotation ? { annotation } : {};
66
+ return collection && partOf ? {
67
+ id: collection.id,
68
+ type: "Collection",
69
+ manifestId: partOf.id,
70
+ target: canvasTarget,
71
+ ...shared
72
+ } : partOf ? { id: partOf.id, type: "Manifest", target: canvasTarget, ...shared } : {
73
+ id: parsed.id,
74
+ type: type ?? "Canvas",
75
+ target: canvasTarget,
76
+ ...shared
77
+ };
78
+ }
79
+ export {
80
+ decodeContentState,
81
+ resolveContentState
82
+ };
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { asArray } from "../lib/asArray.mjs";
3
+ function isContentState(json) {
4
+ const value = json;
5
+ if (!value || typeof value !== "object") return false;
6
+ if (value.type === "Annotation") {
7
+ return asArray(value.motivation).includes("contentState");
8
+ }
9
+ return value.type === "SpecificResource";
10
+ }
11
+ function encodeContentState(json) {
12
+ return btoa(encodeURIComponent(JSON.stringify(json))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
13
+ }
14
+ function buildContentState({
15
+ manifestId,
16
+ canvasId,
17
+ region,
18
+ time
19
+ }) {
20
+ const source = {
21
+ id: canvasId,
22
+ type: "Canvas",
23
+ partOf: [{ id: manifestId, type: "Manifest" }]
24
+ };
25
+ const fragment = time != null && time > 0 ? `t=${Math.round(time * 100) / 100}` : region ? `xywh=${[region.x, region.y, region.w, region.h].map(Math.round).join(",")}` : null;
26
+ const json = {
27
+ "@context": "http://iiif.io/api/presentation/3/context.json",
28
+ id: `${canvasId}#content-state`,
29
+ type: "Annotation",
30
+ motivation: ["contentState"],
31
+ target: fragment ? {
32
+ type: "SpecificResource",
33
+ source,
34
+ selector: { type: "FragmentSelector", value: fragment }
35
+ } : source
36
+ };
37
+ return { json, encoded: encodeContentState(json) };
38
+ }
39
+ export {
40
+ buildContentState,
41
+ encodeContentState,
42
+ isContentState
43
+ };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ const RTL_LANGUAGE = /^(ar|arc|ckb|dv|fa|he|iw|ks|ps|sd|syr|ug|ur|yi)$/;
3
+ const RTL_SCRIPT = /^(adlm|arab|hebr|nkoo|rohg|syrc|thaa)$/;
4
+ function directionOf(lang) {
5
+ if (!lang) return void 0;
6
+ const [primary, ...subtags] = lang.toLowerCase().split(/[-_]/);
7
+ const script = subtags.find((subtag) => subtag.length === 4);
8
+ return (script ? RTL_SCRIPT.test(script) : RTL_LANGUAGE.test(primary)) ? "rtl" : void 0;
9
+ }
10
+ export {
11
+ directionOf
12
+ };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { selectSequence } from "./selectors.mjs";
3
+ import { asArray } from "../lib/asArray.mjs";
4
+ function hasMapData(manifest, collection = null) {
5
+ if (!manifest) return false;
6
+ if ((collection == null ? void 0 : collection.navPlace) || manifest.navPlace) {
7
+ return true;
8
+ }
9
+ for (const canvas of selectSequence(manifest).canvases) {
10
+ if (canvas.navPlace) return true;
11
+ for (const page of asArray(canvas.annotations)) {
12
+ for (const annotation of asArray(page == null ? void 0 : page.items)) {
13
+ if (annotation == null ? void 0 : annotation.navPlace) return true;
14
+ if (asArray(annotation == null ? void 0 : annotation.motivation).includes("georeferencing")) {
15
+ return true;
16
+ }
17
+ const bodies = asArray(annotation == null ? void 0 : annotation.body);
18
+ if (bodies.some(
19
+ (body) => (body == null ? void 0 : body.type) === "Feature" || (body == null ? void 0 : body.type) === "FeatureCollection"
20
+ )) {
21
+ return true;
22
+ }
23
+ }
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+ export {
29
+ hasMapData
30
+ };