lightgallery 2.9.0 → 3.0.0-beta.2

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 (595) hide show
  1. package/LICENSE +690 -0
  2. package/README.md +31 -21
  3. package/dist/README.md +229 -0
  4. package/{css → dist/css}/lg-autoplay.css +7 -4
  5. package/{css → dist/css}/lg-autoplay.css.map +1 -1
  6. package/{css → dist/css}/lg-comments.css +0 -6
  7. package/{css → dist/css}/lg-comments.css.map +1 -1
  8. package/dist/css/lg-fullscreen.css +11 -0
  9. package/dist/css/lg-fullscreen.css.map +1 -0
  10. package/dist/css/lg-justified.css +37 -0
  11. package/dist/css/lg-justified.css.map +1 -0
  12. package/{css → dist/css}/lg-pager.css.map +1 -1
  13. package/{css → dist/css}/lg-rotate.css +0 -16
  14. package/{css → dist/css}/lg-rotate.css.map +1 -1
  15. package/dist/css/lg-rtl.css +94 -0
  16. package/dist/css/lg-rtl.css.map +1 -0
  17. package/{css → dist/css}/lg-share.css +4 -32
  18. package/dist/css/lg-share.css.map +1 -0
  19. package/{css → dist/css}/lg-thumbnail.css +7 -3
  20. package/dist/css/lg-thumbnail.css.map +1 -0
  21. package/{css → dist/css}/lg-transitions.css +10 -0
  22. package/dist/css/lg-transitions.css.map +1 -0
  23. package/{css → dist/css}/lg-zoom.css +20 -9
  24. package/dist/css/lg-zoom.css.map +1 -0
  25. package/{css → dist/css}/lightgallery-bundle.css +150 -118
  26. package/dist/css/lightgallery-bundle.css.map +1 -0
  27. package/dist/css/lightgallery-bundle.min.css +1 -0
  28. package/{css → dist/css}/lightgallery-core.css +49 -7
  29. package/dist/css/lightgallery-core.css.map +1 -0
  30. package/{css → dist/css}/lightgallery.css +105 -44
  31. package/dist/css/lightgallery.css.map +1 -0
  32. package/dist/lightgallery.es5.js +3848 -0
  33. package/dist/lightgallery.es5.js.map +1 -0
  34. package/dist/lightgallery.min.js +1 -0
  35. package/dist/lightgallery.umd.js +3851 -0
  36. package/dist/lightgallery.umd.js.map +1 -0
  37. package/dist/package.json +33 -0
  38. package/dist/plugins/autoplay/lg-autoplay.es5.js +193 -0
  39. package/dist/plugins/autoplay/lg-autoplay.es5.js.map +1 -0
  40. package/dist/plugins/autoplay/lg-autoplay.min.js +1 -0
  41. package/dist/plugins/autoplay/lg-autoplay.umd.js +196 -0
  42. package/dist/plugins/autoplay/lg-autoplay.umd.js.map +1 -0
  43. package/dist/plugins/autoplay/package.json +7 -0
  44. package/dist/plugins/comment/lg-comment.es5.js +136 -0
  45. package/dist/plugins/comment/lg-comment.es5.js.map +1 -0
  46. package/dist/plugins/comment/lg-comment.min.js +1 -0
  47. package/dist/plugins/comment/lg-comment.umd.js +139 -0
  48. package/dist/plugins/comment/lg-comment.umd.js.map +1 -0
  49. package/dist/plugins/comment/package.json +7 -0
  50. package/dist/plugins/fullscreen/lg-fullscreen.es5.js +114 -0
  51. package/dist/plugins/fullscreen/lg-fullscreen.es5.js.map +1 -0
  52. package/dist/plugins/fullscreen/lg-fullscreen.min.js +1 -0
  53. package/dist/plugins/fullscreen/lg-fullscreen.umd.js +117 -0
  54. package/dist/plugins/fullscreen/lg-fullscreen.umd.js.map +1 -0
  55. package/dist/plugins/fullscreen/package.json +7 -0
  56. package/dist/plugins/hash/lg-hash.es5.js +207 -0
  57. package/dist/plugins/hash/lg-hash.es5.js.map +1 -0
  58. package/dist/plugins/hash/lg-hash.min.js +1 -0
  59. package/dist/plugins/hash/lg-hash.umd.js +210 -0
  60. package/dist/plugins/hash/lg-hash.umd.js.map +1 -0
  61. package/dist/plugins/hash/package.json +7 -0
  62. package/dist/plugins/justified/lg-justified.es5.js +415 -0
  63. package/dist/plugins/justified/lg-justified.es5.js.map +1 -0
  64. package/dist/plugins/justified/lg-justified.min.js +1 -0
  65. package/dist/plugins/justified/lg-justified.umd.js +418 -0
  66. package/dist/plugins/justified/lg-justified.umd.js.map +1 -0
  67. package/dist/plugins/justified/package.json +7 -0
  68. package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js +95 -0
  69. package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js.map +1 -0
  70. package/dist/plugins/mediumZoom/lg-medium-zoom.min.js +1 -0
  71. package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js +98 -0
  72. package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js.map +1 -0
  73. package/dist/plugins/mediumZoom/package.json +7 -0
  74. package/dist/plugins/originCrop/lg-origin-crop.es5.js +622 -0
  75. package/dist/plugins/originCrop/lg-origin-crop.es5.js.map +1 -0
  76. package/dist/plugins/originCrop/lg-origin-crop.min.js +1 -0
  77. package/dist/plugins/originCrop/lg-origin-crop.umd.js +625 -0
  78. package/dist/plugins/originCrop/lg-origin-crop.umd.js.map +1 -0
  79. package/dist/plugins/pager/lg-pager.es5.js +96 -0
  80. package/dist/plugins/pager/lg-pager.es5.js.map +1 -0
  81. package/dist/plugins/pager/lg-pager.min.js +1 -0
  82. package/dist/plugins/pager/lg-pager.umd.js +99 -0
  83. package/dist/plugins/pager/lg-pager.umd.js.map +1 -0
  84. package/dist/plugins/pager/package.json +7 -0
  85. package/dist/plugins/relativeCaption/lg-relative-caption.es5.js +98 -0
  86. package/dist/plugins/relativeCaption/lg-relative-caption.es5.js.map +1 -0
  87. package/dist/plugins/relativeCaption/lg-relative-caption.min.js +1 -0
  88. package/dist/plugins/relativeCaption/lg-relative-caption.umd.js +101 -0
  89. package/dist/plugins/relativeCaption/lg-relative-caption.umd.js.map +1 -0
  90. package/dist/plugins/relativeCaption/package.json +7 -0
  91. package/dist/plugins/rotate/lg-rotate.es5.js +226 -0
  92. package/dist/plugins/rotate/lg-rotate.es5.js.map +1 -0
  93. package/dist/plugins/rotate/lg-rotate.min.js +1 -0
  94. package/dist/plugins/rotate/lg-rotate.umd.js +229 -0
  95. package/dist/plugins/rotate/lg-rotate.umd.js.map +1 -0
  96. package/dist/plugins/rotate/package.json +7 -0
  97. package/dist/plugins/share/lg-share.es5.js +309 -0
  98. package/dist/plugins/share/lg-share.es5.js.map +1 -0
  99. package/dist/plugins/share/lg-share.min.js +1 -0
  100. package/dist/plugins/share/lg-share.umd.js +312 -0
  101. package/dist/plugins/share/lg-share.umd.js.map +1 -0
  102. package/dist/plugins/share/package.json +7 -0
  103. package/dist/plugins/thumbnail/lg-thumbnail.es5.js +792 -0
  104. package/dist/plugins/thumbnail/lg-thumbnail.es5.js.map +1 -0
  105. package/dist/plugins/thumbnail/lg-thumbnail.min.js +1 -0
  106. package/dist/plugins/thumbnail/lg-thumbnail.umd.js +795 -0
  107. package/dist/plugins/thumbnail/lg-thumbnail.umd.js.map +1 -0
  108. package/dist/plugins/thumbnail/package.json +7 -0
  109. package/dist/plugins/video/lg-video.es5.js +518 -0
  110. package/dist/plugins/video/lg-video.es5.js.map +1 -0
  111. package/dist/plugins/video/lg-video.min.js +1 -0
  112. package/dist/plugins/video/lg-video.umd.js +521 -0
  113. package/dist/plugins/video/lg-video.umd.js.map +1 -0
  114. package/dist/plugins/video/package.json +7 -0
  115. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +72 -0
  116. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +1 -0
  117. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -0
  118. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +75 -0
  119. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +1 -0
  120. package/dist/plugins/vimeoThumbnail/package.json +7 -0
  121. package/dist/plugins/zoom/lg-zoom.es5.js +1412 -0
  122. package/dist/plugins/zoom/lg-zoom.es5.js.map +1 -0
  123. package/dist/plugins/zoom/lg-zoom.min.js +1 -0
  124. package/dist/plugins/zoom/lg-zoom.umd.js +1415 -0
  125. package/dist/plugins/zoom/lg-zoom.umd.js.map +1 -0
  126. package/dist/plugins/zoom/package.json +7 -0
  127. package/{scss → dist/scss}/_lg-theme-default.scss +68 -18
  128. package/{scss → dist/scss}/_lg-variables.scss +0 -1
  129. package/{scss → dist/scss}/lg-autoplay.scss +10 -4
  130. package/{scss → dist/scss}/lg-comments.scss +0 -8
  131. package/dist/scss/lg-fullscreen.scss +15 -0
  132. package/dist/scss/lg-justified.scss +63 -0
  133. package/{scss → dist/scss}/lg-rotate.scss +0 -24
  134. package/dist/scss/lg-rtl.scss +145 -0
  135. package/{scss → dist/scss}/lg-share.scss +6 -33
  136. package/{scss → dist/scss}/lg-thumbnail.scss +16 -5
  137. package/{scss → dist/scss}/lg-zoom.scss +46 -9
  138. package/{scss → dist/scss}/lightgallery-bundle.scss +0 -1
  139. package/{scss → dist/scss}/lightgallery-core.scss +73 -6
  140. package/{scss → dist/scss}/lightgallery.scss +0 -1
  141. package/{scss → dist/scss}/transitions/_lg-scale-up.scss +6 -0
  142. package/{scss → dist/scss}/transitions/_lg-slide-circular-vertical.scss +6 -0
  143. package/{scss → dist/scss}/transitions/_lg-slide-circular.scss +6 -0
  144. package/{scss → dist/scss}/transitions/_lg-soft-zoom.scss +6 -0
  145. package/{scss → dist/scss}/transitions/_lg-zoom-in-big.scss +6 -0
  146. package/{scss → dist/scss}/transitions/_lg-zoom-in-out.scss +6 -0
  147. package/{scss → dist/scss}/transitions/_lg-zoom-in.scss +6 -0
  148. package/{scss → dist/scss}/transitions/_lg-zoom-out-big.scss +6 -0
  149. package/{scss → dist/scss}/transitions/_lg-zoom-out-in.scss +6 -0
  150. package/{scss → dist/scss}/transitions/_lg-zoom-out.scss +6 -0
  151. package/{index.d.ts → dist/types/index.d.ts} +8 -4
  152. package/{lg-events.d.ts → dist/types/lg-events.d.ts} +300 -300
  153. package/dist/types/lg-icons.d.ts +27 -0
  154. package/{lg-plugin.d.ts → dist/types/lg-plugin.d.ts} +7 -7
  155. package/{lg-settings.d.ts → dist/types/lg-settings.d.ts} +555 -425
  156. package/dist/types/lg-spring-runner.d.ts +14 -0
  157. package/dist/types/lg-toolbar-overflow.d.ts +36 -0
  158. package/{lg-utils.d.ts → dist/types/lg-utils.d.ts} +236 -228
  159. package/{lgQuery.d.ts → dist/types/lgQuery.d.ts} +56 -56
  160. package/{lightgallery.d.ts → dist/types/lightgallery.d.ts} +385 -305
  161. package/{plugins → dist/types/plugins}/autoplay/lg-autoplay-settings.d.ts +41 -38
  162. package/{plugins → dist/types/plugins}/autoplay/lg-autoplay.d.ts +22 -22
  163. package/{plugins → dist/types/plugins}/comment/lg-comment-settings.d.ts +36 -33
  164. package/{plugins → dist/types/plugins}/comment/lg-comment.d.ts +25 -25
  165. package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen-settings.d.ts +17 -14
  166. package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen.d.ts +16 -16
  167. package/dist/types/plugins/hash/lg-hash-settings.d.ts +28 -0
  168. package/{plugins → dist/types/plugins}/hash/lg-hash.d.ts +25 -23
  169. package/dist/types/plugins/justified/lg-justified-settings.d.ts +42 -0
  170. package/dist/types/plugins/justified/lg-justified.d.ts +55 -0
  171. package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom-settings.d.ts +16 -16
  172. package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom.d.ts +12 -12
  173. package/dist/types/plugins/originCrop/lg-origin-crop-settings.d.ts +12 -0
  174. package/dist/types/plugins/originCrop/lg-origin-crop.d.ts +79 -0
  175. package/{plugins → dist/types/plugins}/pager/lg-pager-settings.d.ts +7 -7
  176. package/{plugins → dist/types/plugins}/pager/lg-pager.d.ts +13 -13
  177. package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption-settings.d.ts +7 -7
  178. package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption.d.ts +14 -14
  179. package/{plugins → dist/types/plugins}/rotate/lg-rotate-settings.d.ts +47 -45
  180. package/{plugins → dist/types/plugins}/rotate/lg-rotate.d.ts +25 -24
  181. package/{plugins → dist/types/plugins}/share/lg-fb-share-utils.d.ts +2 -2
  182. package/{plugins → dist/types/plugins}/share/lg-pinterest-share-utils.d.ts +2 -2
  183. package/{plugins → dist/types/plugins}/share/lg-share-settings.d.ts +71 -56
  184. package/dist/types/plugins/share/lg-share.d.ts +33 -0
  185. package/dist/types/plugins/share/lg-twitter-share-utils.d.ts +4 -0
  186. package/{plugins → dist/types/plugins}/share/types.d.ts +6 -6
  187. package/{plugins → dist/types/plugins}/thumbnail/lg-thumbnail-settings.d.ts +85 -70
  188. package/dist/types/plugins/thumbnail/lg-thumbnail.d.ts +88 -0
  189. package/{plugins → dist/types/plugins}/video/lg-video-settings.d.ts +94 -71
  190. package/{plugins → dist/types/plugins}/video/lg-video.d.ts +116 -104
  191. package/{plugins → dist/types/plugins}/video/types.d.ts +8 -8
  192. package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail-settings.d.ts +11 -11
  193. package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail.d.ts +14 -14
  194. package/{plugins → dist/types/plugins}/zoom/lg-zoom-settings.d.ts +54 -51
  195. package/{plugins → dist/types/plugins}/zoom/lg-zoom.d.ts +145 -108
  196. package/{types.d.ts → dist/types/types.d.ts} +40 -40
  197. package/package.json +237 -8
  198. package/angular/10/README.md +0 -24
  199. package/angular/10/bundles/lightgallery-angular-10.umd.js +0 -289
  200. package/angular/10/bundles/lightgallery-angular-10.umd.js.map +0 -1
  201. package/angular/10/bundles/lightgallery-angular-10.umd.min.js +0 -2
  202. package/angular/10/bundles/lightgallery-angular-10.umd.min.js.map +0 -1
  203. package/angular/10/esm2015/lib/lightgallery-angular.component.js +0 -225
  204. package/angular/10/esm2015/lib/lightgallery-angular.module.js +0 -17
  205. package/angular/10/esm2015/lib/lightgallery-angular.service.js +0 -14
  206. package/angular/10/esm2015/lightgallery-angular-10.js +0 -5
  207. package/angular/10/esm2015/public-api.js +0 -7
  208. package/angular/10/fesm2015/lightgallery-angular-10.js +0 -261
  209. package/angular/10/fesm2015/lightgallery-angular-10.js.map +0 -1
  210. package/angular/10/lib/lightgallery-angular.component.d.ts +0 -39
  211. package/angular/10/lib/lightgallery-angular.component.d.ts.map +0 -1
  212. package/angular/10/lib/lightgallery-angular.module.d.ts +0 -7
  213. package/angular/10/lib/lightgallery-angular.module.d.ts.map +0 -1
  214. package/angular/10/lib/lightgallery-angular.service.d.ts +0 -7
  215. package/angular/10/lib/lightgallery-angular.service.d.ts.map +0 -1
  216. package/angular/10/lightgallery-angular-10.d.ts +0 -6
  217. package/angular/10/lightgallery-angular-10.d.ts.map +0 -1
  218. package/angular/10/package.json +0 -21
  219. package/angular/10/public-api.d.ts +0 -4
  220. package/angular/10/public-api.d.ts.map +0 -1
  221. package/angular/11/README.md +0 -24
  222. package/angular/11/bundles/lightgallery-angular-11.umd.js +0 -290
  223. package/angular/11/bundles/lightgallery-angular-11.umd.js.map +0 -1
  224. package/angular/11/bundles/lightgallery-angular-11.umd.min.js +0 -2
  225. package/angular/11/bundles/lightgallery-angular-11.umd.min.js.map +0 -1
  226. package/angular/11/esm2015/lib/lightgallery-angular.component.js +0 -225
  227. package/angular/11/esm2015/lib/lightgallery-angular.module.js +0 -18
  228. package/angular/11/esm2015/lib/lightgallery-angular.service.js +0 -14
  229. package/angular/11/esm2015/lightgallery-angular-11.js +0 -5
  230. package/angular/11/esm2015/public-api.js +0 -7
  231. package/angular/11/fesm2015/lightgallery-angular-11.js +0 -262
  232. package/angular/11/fesm2015/lightgallery-angular-11.js.map +0 -1
  233. package/angular/11/lib/lightgallery-angular.component.d.ts +0 -39
  234. package/angular/11/lib/lightgallery-angular.component.d.ts.map +0 -1
  235. package/angular/11/lib/lightgallery-angular.module.d.ts +0 -8
  236. package/angular/11/lib/lightgallery-angular.module.d.ts.map +0 -1
  237. package/angular/11/lib/lightgallery-angular.service.d.ts +0 -7
  238. package/angular/11/lib/lightgallery-angular.service.d.ts.map +0 -1
  239. package/angular/11/lightgallery-angular-11.d.ts +0 -6
  240. package/angular/11/lightgallery-angular-11.d.ts.map +0 -1
  241. package/angular/11/package.json +0 -21
  242. package/angular/11/public-api.d.ts +0 -4
  243. package/angular/11/public-api.d.ts.map +0 -1
  244. package/angular/12/README.md +0 -24
  245. package/angular/12/bundles/lightgallery-angular-12.umd.js +0 -296
  246. package/angular/12/bundles/lightgallery-angular-12.umd.js.map +0 -1
  247. package/angular/12/esm2015/lib/lightgallery-angular.component.js +0 -221
  248. package/angular/12/esm2015/lib/lightgallery-angular.module.js +0 -17
  249. package/angular/12/esm2015/lib/lightgallery-angular.service.js +0 -14
  250. package/angular/12/esm2015/lightgallery-angular-12.js +0 -5
  251. package/angular/12/esm2015/public-api.js +0 -7
  252. package/angular/12/fesm2015/lightgallery-angular-12.js +0 -258
  253. package/angular/12/fesm2015/lightgallery-angular-12.js.map +0 -1
  254. package/angular/12/lib/lightgallery-angular.component.d.ts +0 -38
  255. package/angular/12/lib/lightgallery-angular.module.d.ts +0 -7
  256. package/angular/12/lib/lightgallery-angular.service.d.ts +0 -6
  257. package/angular/12/lightgallery-angular-12.d.ts +0 -5
  258. package/angular/12/package.json +0 -18
  259. package/angular/12/public-api.d.ts +0 -3
  260. package/angular/13/README.md +0 -24
  261. package/angular/13/esm2020/lib/lightgallery-angular.component.mjs +0 -221
  262. package/angular/13/esm2020/lib/lightgallery-angular.module.mjs +0 -17
  263. package/angular/13/esm2020/lib/lightgallery-angular.service.mjs +0 -14
  264. package/angular/13/esm2020/lightgallery-angular-13.mjs +0 -5
  265. package/angular/13/esm2020/public-api.mjs +0 -7
  266. package/angular/13/fesm2015/lightgallery-angular-13.mjs +0 -258
  267. package/angular/13/fesm2015/lightgallery-angular-13.mjs.map +0 -1
  268. package/angular/13/fesm2020/lightgallery-angular-13.mjs +0 -258
  269. package/angular/13/fesm2020/lightgallery-angular-13.mjs.map +0 -1
  270. package/angular/13/lib/lightgallery-angular.component.d.ts +0 -38
  271. package/angular/13/lib/lightgallery-angular.module.d.ts +0 -7
  272. package/angular/13/lib/lightgallery-angular.service.d.ts +0 -6
  273. package/angular/13/lightgallery-angular-13.d.ts +0 -5
  274. package/angular/13/package.json +0 -31
  275. package/angular/13/public-api.d.ts +0 -3
  276. package/angular/14/README.md +0 -24
  277. package/angular/14/esm2020/lib/lightgallery-angular.component.mjs +0 -217
  278. package/angular/14/esm2020/lib/lightgallery-angular.module.mjs +0 -17
  279. package/angular/14/esm2020/lib/lightgallery-angular.service.mjs +0 -14
  280. package/angular/14/esm2020/lightgallery-angular-14.mjs +0 -5
  281. package/angular/14/esm2020/public-api.mjs +0 -7
  282. package/angular/14/fesm2015/lightgallery-angular-14.mjs +0 -254
  283. package/angular/14/fesm2015/lightgallery-angular-14.mjs.map +0 -1
  284. package/angular/14/fesm2020/lightgallery-angular-14.mjs +0 -254
  285. package/angular/14/fesm2020/lightgallery-angular-14.mjs.map +0 -1
  286. package/angular/14/index.d.ts +0 -5
  287. package/angular/14/lib/lightgallery-angular.component.d.ts +0 -38
  288. package/angular/14/lib/lightgallery-angular.module.d.ts +0 -7
  289. package/angular/14/lib/lightgallery-angular.service.d.ts +0 -6
  290. package/angular/14/package.json +0 -31
  291. package/angular/14/public-api.d.ts +0 -3
  292. package/angular/15/README.md +0 -24
  293. package/angular/15/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  294. package/angular/15/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  295. package/angular/15/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  296. package/angular/15/esm2022/lightgallery-angular-15.mjs +0 -5
  297. package/angular/15/esm2022/public-api.mjs +0 -7
  298. package/angular/15/fesm2022/lightgallery-angular-15.mjs +0 -254
  299. package/angular/15/fesm2022/lightgallery-angular-15.mjs.map +0 -1
  300. package/angular/15/index.d.ts +0 -5
  301. package/angular/15/lib/lightgallery-angular.component.d.ts +0 -38
  302. package/angular/15/lib/lightgallery-angular.module.d.ts +0 -7
  303. package/angular/15/lib/lightgallery-angular.service.d.ts +0 -6
  304. package/angular/15/package.json +0 -25
  305. package/angular/15/public-api.d.ts +0 -3
  306. package/angular/16/README.md +0 -24
  307. package/angular/16/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  308. package/angular/16/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  309. package/angular/16/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  310. package/angular/16/esm2022/lightgallery-angular-16.mjs +0 -5
  311. package/angular/16/esm2022/public-api.mjs +0 -7
  312. package/angular/16/fesm2022/lightgallery-angular-16.mjs +0 -254
  313. package/angular/16/fesm2022/lightgallery-angular-16.mjs.map +0 -1
  314. package/angular/16/index.d.ts +0 -5
  315. package/angular/16/lib/lightgallery-angular.component.d.ts +0 -38
  316. package/angular/16/lib/lightgallery-angular.module.d.ts +0 -7
  317. package/angular/16/lib/lightgallery-angular.service.d.ts +0 -6
  318. package/angular/16/package.json +0 -25
  319. package/angular/16/public-api.d.ts +0 -3
  320. package/angular/9/README.md +0 -24
  321. package/angular/9/bundles/lightgallery-angular-9.umd.js +0 -271
  322. package/angular/9/bundles/lightgallery-angular-9.umd.js.map +0 -1
  323. package/angular/9/bundles/lightgallery-angular-9.umd.min.js +0 -2
  324. package/angular/9/bundles/lightgallery-angular-9.umd.min.js.map +0 -1
  325. package/angular/9/esm2015/lib/lightgallery-angular.component.js +0 -225
  326. package/angular/9/esm2015/lib/lightgallery-angular.module.js +0 -17
  327. package/angular/9/esm2015/lib/lightgallery-angular.service.js +0 -14
  328. package/angular/9/esm2015/lightgallery-angular-9.js +0 -5
  329. package/angular/9/esm2015/public-api.js +0 -7
  330. package/angular/9/esm5/lib/lightgallery-angular.component.js +0 -228
  331. package/angular/9/esm5/lib/lightgallery-angular.module.js +0 -21
  332. package/angular/9/esm5/lib/lightgallery-angular.service.js +0 -17
  333. package/angular/9/esm5/lightgallery-angular-9.js +0 -5
  334. package/angular/9/esm5/public-api.js +0 -7
  335. package/angular/9/fesm2015/lightgallery-angular-9.js +0 -261
  336. package/angular/9/fesm2015/lightgallery-angular-9.js.map +0 -1
  337. package/angular/9/fesm5/lightgallery-angular-9.js +0 -268
  338. package/angular/9/fesm5/lightgallery-angular-9.js.map +0 -1
  339. package/angular/9/lib/lightgallery-angular.component.d.ts +0 -38
  340. package/angular/9/lib/lightgallery-angular.module.d.ts +0 -6
  341. package/angular/9/lib/lightgallery-angular.service.d.ts +0 -6
  342. package/angular/9/lightgallery-angular-9.d.ts +0 -5
  343. package/angular/9/package.json +0 -23
  344. package/angular/9/public-api.d.ts +0 -3
  345. package/angular/README.md +0 -24
  346. package/angular/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  347. package/angular/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  348. package/angular/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  349. package/angular/esm2022/lightgallery-angular.mjs +0 -5
  350. package/angular/esm2022/public-api.mjs +0 -7
  351. package/angular/fesm2022/lightgallery-angular.mjs +0 -254
  352. package/angular/fesm2022/lightgallery-angular.mjs.map +0 -1
  353. package/angular/index.d.ts +0 -5
  354. package/angular/lib/lightgallery-angular.component.d.ts +0 -38
  355. package/angular/lib/lightgallery-angular.module.d.ts +0 -7
  356. package/angular/lib/lightgallery-angular.service.d.ts +0 -6
  357. package/angular/package.json +0 -25
  358. package/angular/public-api.d.ts +0 -3
  359. package/css/lg-fullscreen.css +0 -8
  360. package/css/lg-fullscreen.css.map +0 -1
  361. package/css/lg-share.css.map +0 -1
  362. package/css/lg-thumbnail.css.map +0 -1
  363. package/css/lg-transitions.css.map +0 -1
  364. package/css/lg-zoom.css.map +0 -1
  365. package/css/lightgallery-bundle.css.map +0 -1
  366. package/css/lightgallery-bundle.min.css +0 -1
  367. package/css/lightgallery-core.css.map +0 -1
  368. package/css/lightgallery.css.map +0 -1
  369. package/fonts/lg.svg +0 -54
  370. package/fonts/lg.ttf +0 -0
  371. package/fonts/lg.woff +0 -0
  372. package/fonts/lg.woff2 +0 -0
  373. package/lib/index.js +0 -8
  374. package/lib/index.js.map +0 -1
  375. package/lib/lg-events.js +0 -37
  376. package/lib/lg-events.js.map +0 -1
  377. package/lib/lg-plugin.js +0 -13
  378. package/lib/lg-plugin.js.map +0 -1
  379. package/lib/lg-settings.js +0 -83
  380. package/lib/lg-settings.js.map +0 -1
  381. package/lib/lg-utils.js +0 -328
  382. package/lib/lg-utils.js.map +0 -1
  383. package/lib/lgQuery.js +0 -385
  384. package/lib/lgQuery.js.map +0 -1
  385. package/lib/lightgallery.js +0 -1949
  386. package/lib/lightgallery.js.map +0 -1
  387. package/lib/plugins/autoplay/lg-autoplay-settings.js +0 -16
  388. package/lib/plugins/autoplay/lg-autoplay-settings.js.map +0 -1
  389. package/lib/plugins/autoplay/lg-autoplay.js +0 -184
  390. package/lib/plugins/autoplay/lg-autoplay.js.map +0 -1
  391. package/lib/plugins/comment/lg-comment-settings.js +0 -17
  392. package/lib/plugins/comment/lg-comment-settings.js.map +0 -1
  393. package/lib/plugins/comment/lg-comment.js +0 -140
  394. package/lib/plugins/comment/lg-comment.js.map +0 -1
  395. package/lib/plugins/fullscreen/lg-fullscreen-settings.js +0 -10
  396. package/lib/plugins/fullscreen/lg-fullscreen-settings.js.map +0 -1
  397. package/lib/plugins/fullscreen/lg-fullscreen.js +0 -108
  398. package/lib/plugins/fullscreen/lg-fullscreen.js.map +0 -1
  399. package/lib/plugins/hash/lg-hash-settings.js +0 -9
  400. package/lib/plugins/hash/lg-hash-settings.js.map +0 -1
  401. package/lib/plugins/hash/lg-hash.js +0 -139
  402. package/lib/plugins/hash/lg-hash.js.map +0 -1
  403. package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js +0 -9
  404. package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js.map +0 -1
  405. package/lib/plugins/mediumZoom/lg-medium-zoom.js +0 -73
  406. package/lib/plugins/mediumZoom/lg-medium-zoom.js.map +0 -1
  407. package/lib/plugins/pager/lg-pager-settings.js +0 -7
  408. package/lib/plugins/pager/lg-pager-settings.js.map +0 -1
  409. package/lib/plugins/pager/lg-pager.js +0 -82
  410. package/lib/plugins/pager/lg-pager.js.map +0 -1
  411. package/lib/plugins/relativeCaption/lg-relative-caption-settings.js +0 -7
  412. package/lib/plugins/relativeCaption/lg-relative-caption-settings.js.map +0 -1
  413. package/lib/plugins/relativeCaption/lg-relative-caption.js +0 -97
  414. package/lib/plugins/relativeCaption/lg-relative-caption.js.map +0 -1
  415. package/lib/plugins/rotate/lg-rotate-settings.js +0 -18
  416. package/lib/plugins/rotate/lg-rotate-settings.js.map +0 -1
  417. package/lib/plugins/rotate/lg-rotate.js +0 -206
  418. package/lib/plugins/rotate/lg-rotate.js.map +0 -1
  419. package/lib/plugins/share/lg-fb-share-utils.js +0 -10
  420. package/lib/plugins/share/lg-fb-share-utils.js.map +0 -1
  421. package/lib/plugins/share/lg-pinterest-share-utils.js +0 -17
  422. package/lib/plugins/share/lg-pinterest-share-utils.js.map +0 -1
  423. package/lib/plugins/share/lg-share-settings.js +0 -15
  424. package/lib/plugins/share/lg-share-settings.js.map +0 -1
  425. package/lib/plugins/share/lg-share.js +0 -130
  426. package/lib/plugins/share/lg-share.js.map +0 -1
  427. package/lib/plugins/share/lg-twitter-share-utils.js +0 -11
  428. package/lib/plugins/share/lg-twitter-share-utils.js.map +0 -1
  429. package/lib/plugins/share/types.js +0 -3
  430. package/lib/plugins/share/types.js.map +0 -1
  431. package/lib/plugins/thumbnail/lg-thumbnail-settings.js +0 -23
  432. package/lib/plugins/thumbnail/lg-thumbnail-settings.js.map +0 -1
  433. package/lib/plugins/thumbnail/lg-thumbnail.js +0 -414
  434. package/lib/plugins/thumbnail/lg-thumbnail.js.map +0 -1
  435. package/lib/plugins/video/lg-video-settings.js +0 -15
  436. package/lib/plugins/video/lg-video-settings.js.map +0 -1
  437. package/lib/plugins/video/lg-video-utils.js +0 -84
  438. package/lib/plugins/video/lg-video-utils.js.map +0 -1
  439. package/lib/plugins/video/lg-video.js +0 -411
  440. package/lib/plugins/video/lg-video.js.map +0 -1
  441. package/lib/plugins/video/types.js +0 -3
  442. package/lib/plugins/video/types.js.map +0 -1
  443. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js +0 -8
  444. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js.map +0 -1
  445. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js +0 -122
  446. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js.map +0 -1
  447. package/lib/plugins/zoom/lg-zoom-settings.js +0 -21
  448. package/lib/plugins/zoom/lg-zoom-settings.js.map +0 -1
  449. package/lib/plugins/zoom/lg-zoom.js +0 -909
  450. package/lib/plugins/zoom/lg-zoom.js.map +0 -1
  451. package/lib/types.js +0 -3
  452. package/lib/types.js.map +0 -1
  453. package/lightgallery-2.9.0.tgz +0 -0
  454. package/lightgallery.es5.js +0 -2786
  455. package/lightgallery.es5.js.map +0 -1
  456. package/lightgallery.min.js +0 -8
  457. package/lightgallery.umd.js +0 -2794
  458. package/lightgallery.umd.js.map +0 -1
  459. package/lit/custom-elements.json +0 -82
  460. package/lit/lightgallery.esm.js +0 -59
  461. package/lit/lightgallery.umd.js +0 -37
  462. package/lit/package.json +0 -8
  463. package/plugins/autoplay/lg-autoplay.es5.js +0 -250
  464. package/plugins/autoplay/lg-autoplay.es5.js.map +0 -1
  465. package/plugins/autoplay/lg-autoplay.min.js +0 -8
  466. package/plugins/autoplay/lg-autoplay.umd.js +0 -258
  467. package/plugins/autoplay/lg-autoplay.umd.js.map +0 -1
  468. package/plugins/autoplay/package.json +0 -7
  469. package/plugins/comment/lg-comment.es5.js +0 -205
  470. package/plugins/comment/lg-comment.es5.js.map +0 -1
  471. package/plugins/comment/lg-comment.min.js +0 -8
  472. package/plugins/comment/lg-comment.umd.js +0 -213
  473. package/plugins/comment/lg-comment.umd.js.map +0 -1
  474. package/plugins/comment/package.json +0 -7
  475. package/plugins/fullscreen/lg-fullscreen.es5.js +0 -135
  476. package/plugins/fullscreen/lg-fullscreen.es5.js.map +0 -1
  477. package/plugins/fullscreen/lg-fullscreen.min.js +0 -8
  478. package/plugins/fullscreen/lg-fullscreen.umd.js +0 -143
  479. package/plugins/fullscreen/lg-fullscreen.umd.js.map +0 -1
  480. package/plugins/fullscreen/package.json +0 -7
  481. package/plugins/hash/lg-hash-settings.d.ts +0 -16
  482. package/plugins/hash/lg-hash.es5.js +0 -198
  483. package/plugins/hash/lg-hash.es5.js.map +0 -1
  484. package/plugins/hash/lg-hash.min.js +0 -8
  485. package/plugins/hash/lg-hash.umd.js +0 -206
  486. package/plugins/hash/lg-hash.umd.js.map +0 -1
  487. package/plugins/hash/package.json +0 -7
  488. package/plugins/mediumZoom/lg-medium-zoom.es5.js +0 -132
  489. package/plugins/mediumZoom/lg-medium-zoom.es5.js.map +0 -1
  490. package/plugins/mediumZoom/lg-medium-zoom.min.js +0 -8
  491. package/plugins/mediumZoom/lg-medium-zoom.umd.js +0 -140
  492. package/plugins/mediumZoom/lg-medium-zoom.umd.js.map +0 -1
  493. package/plugins/mediumZoom/package.json +0 -7
  494. package/plugins/pager/lg-pager.es5.js +0 -139
  495. package/plugins/pager/lg-pager.es5.js.map +0 -1
  496. package/plugins/pager/lg-pager.min.js +0 -8
  497. package/plugins/pager/lg-pager.umd.js +0 -147
  498. package/plugins/pager/lg-pager.umd.js.map +0 -1
  499. package/plugins/pager/package.json +0 -7
  500. package/plugins/relativeCaption/lg-relative-caption.es5.js +0 -154
  501. package/plugins/relativeCaption/lg-relative-caption.es5.js.map +0 -1
  502. package/plugins/relativeCaption/lg-relative-caption.min.js +0 -8
  503. package/plugins/relativeCaption/lg-relative-caption.umd.js +0 -162
  504. package/plugins/relativeCaption/lg-relative-caption.umd.js.map +0 -1
  505. package/plugins/relativeCaption/package.json +0 -7
  506. package/plugins/rotate/lg-rotate.es5.js +0 -274
  507. package/plugins/rotate/lg-rotate.es5.js.map +0 -1
  508. package/plugins/rotate/lg-rotate.min.js +0 -8
  509. package/plugins/rotate/lg-rotate.umd.js +0 -282
  510. package/plugins/rotate/lg-rotate.umd.js.map +0 -1
  511. package/plugins/rotate/package.json +0 -7
  512. package/plugins/share/lg-share.d.ts +0 -15
  513. package/plugins/share/lg-share.es5.js +0 -219
  514. package/plugins/share/lg-share.es5.js.map +0 -1
  515. package/plugins/share/lg-share.min.js +0 -8
  516. package/plugins/share/lg-share.umd.js +0 -227
  517. package/plugins/share/lg-share.umd.js.map +0 -1
  518. package/plugins/share/lg-twitter-share-utils.d.ts +0 -2
  519. package/plugins/share/package.json +0 -7
  520. package/plugins/thumbnail/lg-thumbnail.d.ts +0 -48
  521. package/plugins/thumbnail/lg-thumbnail.es5.js +0 -487
  522. package/plugins/thumbnail/lg-thumbnail.es5.js.map +0 -1
  523. package/plugins/thumbnail/lg-thumbnail.min.js +0 -8
  524. package/plugins/thumbnail/lg-thumbnail.umd.js +0 -495
  525. package/plugins/thumbnail/lg-thumbnail.umd.js.map +0 -1
  526. package/plugins/thumbnail/package.json +0 -7
  527. package/plugins/video/lg-video-utils.d.ts +0 -10
  528. package/plugins/video/lg-video.es5.js +0 -545
  529. package/plugins/video/lg-video.es5.js.map +0 -1
  530. package/plugins/video/lg-video.min.js +0 -8
  531. package/plugins/video/lg-video.umd.js +0 -553
  532. package/plugins/video/lg-video.umd.js.map +0 -1
  533. package/plugins/video/package.json +0 -7
  534. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +0 -182
  535. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +0 -1
  536. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +0 -8
  537. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +0 -190
  538. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +0 -1
  539. package/plugins/vimeoThumbnail/package.json +0 -7
  540. package/plugins/zoom/lg-zoom.es5.js +0 -980
  541. package/plugins/zoom/lg-zoom.es5.js.map +0 -1
  542. package/plugins/zoom/lg-zoom.min.js +0 -8
  543. package/plugins/zoom/lg-zoom.umd.js +0 -988
  544. package/plugins/zoom/lg-zoom.umd.js.map +0 -1
  545. package/plugins/zoom/package.json +0 -7
  546. package/react/Lightgallery.d.ts +0 -33
  547. package/react/Lightgallery.es5.js +0 -2988
  548. package/react/Lightgallery.es5.js.map +0 -1
  549. package/react/Lightgallery.umd.js +0 -2994
  550. package/react/Lightgallery.umd.js.map +0 -1
  551. package/react/package.json +0 -7
  552. package/scss/_lg-fonts.scss +0 -27
  553. package/scss/lg-fullscreen.scss +0 -9
  554. package/vue/LightGallery.vue.d.ts +0 -37
  555. package/vue/LightGalleryVue.common.js +0 -9343
  556. package/vue/LightGalleryVue.common.js.map +0 -1
  557. package/vue/LightGalleryVue.umd.js +0 -9353
  558. package/vue/LightGalleryVue.umd.js.map +0 -1
  559. package/vue/LightGalleryVue.umd.min.js +0 -8
  560. package/vue/LightGalleryVue.umd.min.js.map +0 -1
  561. package/vue/package.json +0 -7
  562. /package/{css → dist/css}/lg-medium-zoom.css +0 -0
  563. /package/{css → dist/css}/lg-medium-zoom.css.map +0 -0
  564. /package/{css → dist/css}/lg-pager.css +0 -0
  565. /package/{css → dist/css}/lg-relative-caption.css +0 -0
  566. /package/{css → dist/css}/lg-relative-caption.css.map +0 -0
  567. /package/{css → dist/css}/lg-video.css +0 -0
  568. /package/{css → dist/css}/lg-video.css.map +0 -0
  569. /package/{images → dist/images}/loading.gif +0 -0
  570. /package/{scss → dist/scss}/_lg-mixins.scss +0 -0
  571. /package/{scss → dist/scss}/lg-medium-zoom.scss +0 -0
  572. /package/{scss → dist/scss}/lg-pager.scss +0 -0
  573. /package/{scss → dist/scss}/lg-relative-caption.scss +0 -0
  574. /package/{scss → dist/scss}/lg-transitions.scss +0 -0
  575. /package/{scss → dist/scss}/lg-video.scss +0 -0
  576. /package/{scss → dist/scss}/transitions/_index.scss +0 -0
  577. /package/{scss → dist/scss}/transitions/_lg-lollipop-rev.scss +0 -0
  578. /package/{scss → dist/scss}/transitions/_lg-lollipop.scss +0 -0
  579. /package/{scss → dist/scss}/transitions/_lg-rotate-rev.scss +0 -0
  580. /package/{scss → dist/scss}/transitions/_lg-rotate.scss +0 -0
  581. /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross-rev.scss +0 -0
  582. /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross.scss +0 -0
  583. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-rev.scss +0 -0
  584. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y-rev.scss +0 -0
  585. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y.scss +0 -0
  586. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only.scss +0 -0
  587. /package/{scss → dist/scss}/transitions/_lg-slide-skew-rev.scss +0 -0
  588. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross-rev.scss +0 -0
  589. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross.scss +0 -0
  590. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-rev.scss +0 -0
  591. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver.scss +0 -0
  592. /package/{scss → dist/scss}/transitions/_lg-slide-skew.scss +0 -0
  593. /package/{scss → dist/scss}/transitions/_lg-slide-vertical-growth.scss +0 -0
  594. /package/{scss → dist/scss}/transitions/_lg-slide-vertical.scss +0 -0
  595. /package/{scss → dist/scss}/transitions/_lg-tube.scss +0 -0
@@ -0,0 +1,3848 @@
1
+ /*!
2
+ * lightgallery | 3.0.0-beta.2 | October 1st 2026
3
+ * http://www.lightgalleryjs.com/
4
+ * Copyright (c) 2020 Sachin Neravath;
5
+ * @license GPLv3
6
+ */
7
+ function getVideoInfo(src, hasHtml5Video) {
8
+ if (!src) {
9
+ return hasHtml5Video ? { html5: true } : void 0;
10
+ }
11
+ const youtube = src.match(
12
+ /\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-_%]+)([&|?][\S]*)*/i
13
+ );
14
+ if (youtube) {
15
+ return { youtube: [...youtube] };
16
+ }
17
+ const vimeo = src.match(
18
+ /\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i
19
+ );
20
+ if (vimeo) {
21
+ return { vimeo: [...vimeo] };
22
+ }
23
+ const wistia = src.match(
24
+ /https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/
25
+ );
26
+ if (wistia) {
27
+ return { wistia: [...wistia] };
28
+ }
29
+ return hasHtml5Video ? { html5: true } : void 0;
30
+ }
31
+ function getYouTubePosterUrl(videoInfo) {
32
+ if (!(videoInfo == null ? void 0 : videoInfo.youtube)) {
33
+ return void 0;
34
+ }
35
+ return `//img.youtube.com/vi/${videoInfo.youtube[1]}/maxresdefault.jpg`;
36
+ }
37
+ function getFacadePoster(item, videoInfo, loadYouTubePoster) {
38
+ if (!videoInfo || videoInfo.html5) {
39
+ return item.poster || void 0;
40
+ }
41
+ return item.poster || (loadYouTubePoster ? getYouTubePosterUrl(videoInfo) : void 0) || item.thumb || void 0;
42
+ }
43
+ const TESTING_LICENSE_KEY = "0000-0000-000-0000";
44
+ const LICENSE_KEY_PREFIX = "LIG";
45
+ const LICENSE_DOCS = "https://www.lightgalleryjs.com/docs/license/";
46
+ function checkLicenseKey(licenseKey) {
47
+ const key = (licenseKey != null ? licenseKey : "").trim();
48
+ if (!key) {
49
+ return {
50
+ level: "error",
51
+ message: `lightGallery: please provide a valid license key. See ${LICENSE_DOCS}`
52
+ };
53
+ }
54
+ if (key === TESTING_LICENSE_KEY) {
55
+ return {
56
+ level: "warn",
57
+ message: `lightGallery: ${key} license key is not valid for production use. See ${LICENSE_DOCS}`
58
+ };
59
+ }
60
+ if (!key.startsWith(LICENSE_KEY_PREFIX)) {
61
+ return {
62
+ level: "warn",
63
+ message: `lightGallery: this license key is for v1 or v2 and is not valid for v3. Please upgrade to a v3 license. See ${LICENSE_DOCS}`
64
+ };
65
+ }
66
+ return null;
67
+ }
68
+ let pageLicenseKey;
69
+ const loggedNotices = /* @__PURE__ */ new Set();
70
+ function setLicenseKey(licenseKey) {
71
+ pageLicenseKey = licenseKey;
72
+ }
73
+ function resolveLicenseKey(instanceKey) {
74
+ const own = (instanceKey != null ? instanceKey : "").trim();
75
+ if (pageLicenseKey !== void 0 && (!own || own === TESTING_LICENSE_KEY)) {
76
+ return pageLicenseKey;
77
+ }
78
+ return instanceKey != null ? instanceKey : TESTING_LICENSE_KEY;
79
+ }
80
+ function takeLicenseNotice(instanceKey) {
81
+ const notice = checkLicenseKey(resolveLicenseKey(instanceKey));
82
+ if (!notice || loggedNotices.has(notice.message)) return null;
83
+ loggedNotices.add(notice.message);
84
+ return notice;
85
+ }
86
+ function formatSlideAnnouncement(options) {
87
+ const base = options.template.replace("{index}", String(options.index)).replace("{total}", String(options.total));
88
+ const caption = (options.caption || "").replace(/\s+/g, " ").trim();
89
+ return caption ? `${base}, ${caption}` : base;
90
+ }
91
+ const SPRING_SETTLE_DAMPING = 1;
92
+ const SPRING_NATURAL_FREQUENCY = 12;
93
+ const DECELERATION_RATE = 0.995;
94
+ function project(velocity, decelerationRate = DECELERATION_RATE) {
95
+ return velocity * decelerationRate / (1 - decelerationRate);
96
+ }
97
+ function stepSpring(state, target, dtMs, {
98
+ dampingRatio = SPRING_SETTLE_DAMPING,
99
+ naturalFrequency = SPRING_NATURAL_FREQUENCY
100
+ } = {}) {
101
+ const t = dtMs / 1e3;
102
+ const w0 = naturalFrequency;
103
+ const zeta = Math.min(dampingRatio, 1);
104
+ const x0 = state.position - target;
105
+ const v0 = state.velocity * 1e3;
106
+ const decay = Math.exp(-zeta * w0 * t);
107
+ let x;
108
+ let v;
109
+ if (zeta < 1) {
110
+ const wd = w0 * Math.sqrt(1 - zeta * zeta);
111
+ const a = x0;
112
+ const b = (v0 + zeta * w0 * x0) / wd;
113
+ const cos = Math.cos(wd * t);
114
+ const sin = Math.sin(wd * t);
115
+ x = decay * (a * cos + b * sin);
116
+ v = decay * ((b * wd - zeta * w0 * a) * cos - (a * wd + zeta * w0 * b) * sin);
117
+ } else {
118
+ const b = v0 + w0 * x0;
119
+ x = decay * (x0 + b * t);
120
+ v = decay * (b - w0 * (x0 + b * t));
121
+ }
122
+ return { position: target + x, velocity: v / 1e3 };
123
+ }
124
+ function isSpringSettled(state, target, restDelta = 0.3, restVelocity = 0.012) {
125
+ return Math.abs(state.position - target) < restDelta && Math.abs(state.velocity) < restVelocity;
126
+ }
127
+ const SWIPE_AXIS_THRESHOLD = 10;
128
+ const FLICK_VELOCITY = 0.5;
129
+ const FLICK_MIN_DISTANCE = 20;
130
+ const VERTICAL_CLOSE_THRESHOLD = 100;
131
+ const VERTICAL_CLOSE_RATIO = 0.4;
132
+ const VERTICAL_CLOSE_MIN_DRAG = 40;
133
+ const SLIDE_EDGE_FRICTION = 0.35;
134
+ function getEdgeFrictionedDelta(deltaX, hasPrev, hasNext, direction = "ltr") {
135
+ const [towardPrev, towardNext] = direction === "rtl" ? [hasNext, hasPrev] : [hasPrev, hasNext];
136
+ if (deltaX > 0 && !towardPrev || deltaX < 0 && !towardNext) {
137
+ return deltaX * SLIDE_EDGE_FRICTION;
138
+ }
139
+ return deltaX;
140
+ }
141
+ function getSwipeAxis(deltaX, deltaY, current) {
142
+ if (current) {
143
+ return current;
144
+ }
145
+ if (Math.abs(deltaX) > SWIPE_AXIS_THRESHOLD) {
146
+ return "horizontal";
147
+ }
148
+ if (Math.abs(deltaY) > SWIPE_AXIS_THRESHOLD) {
149
+ return "vertical";
150
+ }
151
+ return void 0;
152
+ }
153
+ function getHorizontalDragTransforms(deltaX, slideWidth, direction = "ltr") {
154
+ const slideWidthAmount = slideWidth * 15 / 100;
155
+ const gutter = slideWidthAmount - Math.abs(deltaX * 10 / 100);
156
+ const before = `translate3d(${-slideWidth + deltaX - gutter}px, 0px, 0px)`;
157
+ const after = `translate3d(${slideWidth + deltaX + gutter}px, 0px, 0px)`;
158
+ return {
159
+ current: `translate3d(${deltaX}px, 0px, 0px)`,
160
+ // In RTL the prev slide rests to the physical right (lg-rtl.css
161
+ // flips the resting positions the same way).
162
+ prev: direction === "rtl" ? after : before,
163
+ next: direction === "rtl" ? before : after
164
+ };
165
+ }
166
+ function getVerticalDragEffects(deltaY, viewportWidth, viewportHeight) {
167
+ const distance = Math.abs(deltaY);
168
+ const scale = 1 - distance / (viewportWidth * 2);
169
+ return {
170
+ backdropOpacity: 1 - distance / viewportHeight,
171
+ transform: `translate3d(0px, ${deltaY}px, 0px) scale3d(${scale}, ${scale}, 1)`,
172
+ hideUi: distance > VERTICAL_CLOSE_THRESHOLD
173
+ };
174
+ }
175
+ function getSwipeReleaseVerdict({
176
+ deltaX,
177
+ velocityX,
178
+ threshold,
179
+ flickVelocity = FLICK_VELOCITY,
180
+ viewportWidth,
181
+ direction = "ltr"
182
+ }) {
183
+ const distance = Math.abs(deltaX);
184
+ const directionMatches = deltaX !== 0 && Math.sign(velocityX) === Math.sign(deltaX);
185
+ const projected = deltaX + project(velocityX);
186
+ const passes = distance > threshold || distance > FLICK_MIN_DISTANCE && directionMatches && Math.abs(velocityX) > flickVelocity || viewportWidth !== void 0 && distance > FLICK_MIN_DISTANCE && directionMatches && Math.abs(projected) > viewportWidth / 2;
187
+ if (!passes) {
188
+ return "stay";
189
+ }
190
+ const towardNext = direction === "rtl" ? deltaX > 0 : deltaX < 0;
191
+ return towardNext ? "next" : "prev";
192
+ }
193
+ function shouldCloseOnVerticalDrag(deltaY, velocityY, viewportHeight, options) {
194
+ if (!options.closable || !options.swipeToClose || deltaY === 0) {
195
+ return false;
196
+ }
197
+ if (Math.abs(deltaY) < VERTICAL_CLOSE_MIN_DRAG) {
198
+ return false;
199
+ }
200
+ const projected = deltaY + project(velocityY);
201
+ return Math.sign(projected) === Math.sign(deltaY) && Math.abs(projected) > VERTICAL_CLOSE_RATIO * viewportHeight;
202
+ }
203
+ function resolveSwipeTarget(verdict, currentIndex, slidesCount, loop) {
204
+ if (verdict === "stay") {
205
+ return null;
206
+ }
207
+ const touchLoop = loop && slidesCount >= 3;
208
+ if (verdict === "next") {
209
+ if (currentIndex + 1 < slidesCount) {
210
+ return currentIndex + 1;
211
+ }
212
+ return touchLoop ? 0 : null;
213
+ }
214
+ if (currentIndex > 0) {
215
+ return currentIndex - 1;
216
+ }
217
+ return touchLoop ? slidesCount - 1 : null;
218
+ }
219
+ function parseImageSize(lgSize, viewportWidth) {
220
+ if (!lgSize) {
221
+ return void 0;
222
+ }
223
+ let size = lgSize;
224
+ const responsiveSizes = lgSize.split(",");
225
+ if (responsiveSizes[1]) {
226
+ for (let i = 0; i < responsiveSizes.length; i++) {
227
+ const candidate = responsiveSizes[i].trim();
228
+ const responsiveWidth = parseInt(candidate.split("-")[2], 10);
229
+ if (responsiveWidth > viewportWidth) {
230
+ size = candidate;
231
+ break;
232
+ }
233
+ if (i === responsiveSizes.length - 1) {
234
+ size = candidate;
235
+ }
236
+ }
237
+ }
238
+ const parts = size.trim().split("-");
239
+ const width = parseInt(parts[0], 10);
240
+ const height = parseInt(parts[1], 10);
241
+ if (!Number.isFinite(width) || !Number.isFinite(height)) {
242
+ return void 0;
243
+ }
244
+ return { width, height };
245
+ }
246
+ function fitImageSize(size, containerWidth, containerHeight) {
247
+ const maxWidth = Math.min(containerWidth, size.width);
248
+ const maxHeight = Math.min(containerHeight, size.height);
249
+ const ratio = Math.min(maxWidth / size.width, maxHeight / size.height);
250
+ return { width: size.width * ratio, height: size.height * ratio };
251
+ }
252
+ function isUsableOriginRect(rect) {
253
+ return !!rect && Number.isFinite(rect.left) && Number.isFinite(rect.top) && rect.width > 0 && rect.height > 0;
254
+ }
255
+ const CENTER_CLOSE_SCALE = 0.5;
256
+ function getCenterCloseTransform(scale = CENTER_CLOSE_SCALE) {
257
+ return `translate3d(0, 0, 0) scale3d(${scale}, ${scale}, 1)`;
258
+ }
259
+ function getOriginTransform(input) {
260
+ const { triggerRect, containerRect, top, bottom, imageSize } = input;
261
+ const availableWidth = containerRect.width;
262
+ const availableHeight = containerRect.height - (top + bottom);
263
+ const x = (availableWidth - triggerRect.width) / 2 - triggerRect.left + containerRect.left;
264
+ const y = (availableHeight - triggerRect.height) / 2 - triggerRect.top + top;
265
+ const scaleX = triggerRect.width / imageSize.width;
266
+ const scaleY = triggerRect.height / imageSize.height;
267
+ return `translate3d(${-x}px, ${-y}px, 0) scale3d(${scaleX}, ${scaleY}, 1)`;
268
+ }
269
+ const coreDefaultIcons = {
270
+ close: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M810 664.667l-238-238 238-238-60-60-238 238-238-238-60 60 238 238-238 238 60 60 238-238 238 238z"/></svg>',
271
+ // Three dots for the toolbar's More options menu button.
272
+ more: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><circle cx="232" cy="512" r="80"/><circle cx="512" cy="512" r="80"/><circle cx="792" cy="512" r="80"/></svg>',
273
+ prev: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M426.667 768q17.667 0 30.167-12.5t12.5-30.167q0-18-12.667-30.333l-225.667-225.667h665q17.667 0 30.167-12.5t12.5-30.167-12.5-30.167-30.167-12.5h-665l225.667-225.667q12.667-12.333 12.667-30.333 0-17.667-12.5-30.167t-30.167-12.5q-18 0-30.333 12.333l-298.667 298.667q-12.333 13-12.333 30.333t12.333 30.333l298.667 298.667q12.667 12.333 30.333 12.333z"/></svg>',
274
+ next: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M597.333 768q18 0 30.333-12.333l298.667-298.667q12.333-12.333 12.333-30.333t-12.333-30.333l-298.667-298.667q-12.333-12.333-30.333-12.333-18.333 0-30.5 12.167t-12.167 30.5q0 18 12.333 30.333l226 225.667h-665q-17.667 0-30.167 12.5t-12.5 30.167 12.5 30.167 30.167 12.5h665l-226 225.667q-12.333 12.333-12.333 30.333 0 18.333 12.167 30.5t30.5 12.167z"/></svg>',
275
+ download: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M170 128.667h684v-86h-684v86zM682 384.667l-170-172-170 172h128v426h84v-426h128z"/></svg>',
276
+ maximize: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M793.003 768l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-3.925 3.925-8.619 7.083-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667zM230.997 85.334l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-23.552 19.115-42.667 42.667-42.667h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667z"/></svg>',
277
+ minimize: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M700.331 554.667l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-5.803 1.152-11.307 3.243-16.341s5.163-9.728 9.216-13.781c0.043-0.043 0.043-0.043 0.085-0.085 3.925-3.925 8.619-7.083 13.781-9.216 5.035-2.091 10.539-3.243 16.341-3.243h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667zM158.165 12.502l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-4.096 4.053-8.789 7.125-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667h153.003l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0z"/></svg>'
278
+ };
279
+ var __defProp$1 = Object.defineProperty;
280
+ var __defProps$1 = Object.defineProperties;
281
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
282
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
283
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
284
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
285
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
286
+ var __spreadValues$1 = (a, b) => {
287
+ for (var prop in b || (b = {}))
288
+ if (__hasOwnProp$1.call(b, prop))
289
+ __defNormalProp$1(a, prop, b[prop]);
290
+ if (__getOwnPropSymbols$1)
291
+ for (var prop of __getOwnPropSymbols$1(b)) {
292
+ if (__propIsEnum$1.call(b, prop))
293
+ __defNormalProp$1(a, prop, b[prop]);
294
+ }
295
+ return a;
296
+ };
297
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
298
+ const TOOLBAR_PINNED = Number.POSITIVE_INFINITY;
299
+ const TOOLBAR_DEFAULT_PRIORITY = 20;
300
+ const PRIORITY_BY_CLASS = [
301
+ ["lg-close", TOOLBAR_PINNED],
302
+ ["lg-share", 30],
303
+ ["lg-autoplay-button", 30],
304
+ ["lg-download", 30],
305
+ ["lg-fullscreen", 20],
306
+ ["lg-toggle-thumb", 20],
307
+ ["lg-comment-toggle", 20],
308
+ ["lg-maximize", 10],
309
+ ["lg-rotate-left", 10],
310
+ ["lg-rotate-right", 10],
311
+ ["lg-flip-hor", 10],
312
+ ["lg-flip-ver", 10],
313
+ // Gesture duplicates go first: pinch and double-tap do the same.
314
+ ["lg-zoom-in", 0],
315
+ ["lg-zoom-out", 0],
316
+ ["lg-actual-size", 0]
317
+ ];
318
+ function getToolbarItemPriority(classList) {
319
+ const classes = new Set(classList);
320
+ for (const [className, priority] of PRIORITY_BY_CLASS) {
321
+ if (classes.has(className)) {
322
+ return priority;
323
+ }
324
+ }
325
+ return TOOLBAR_DEFAULT_PRIORITY;
326
+ }
327
+ function getToolbarOverflow({
328
+ available,
329
+ reserved,
330
+ moreWidth,
331
+ items
332
+ }) {
333
+ if (available <= 0) {
334
+ return [];
335
+ }
336
+ const total = items.reduce((sum, item) => sum + item.width, 0);
337
+ if (reserved + total <= available) {
338
+ return [];
339
+ }
340
+ const candidates = items.map((item, index) => __spreadProps$1(__spreadValues$1({}, item), { index })).filter((item) => item.priority !== TOOLBAR_PINNED).sort((a, b) => a.priority - b.priority || b.index - a.index);
341
+ let used = reserved + moreWidth + total;
342
+ const moved = [];
343
+ for (const item of candidates) {
344
+ if (used <= available) {
345
+ break;
346
+ }
347
+ moved.push(item.index);
348
+ used -= item.width;
349
+ }
350
+ return moved.sort((a, b) => a - b);
351
+ }
352
+ const BACKDROP_CLASS_NAMES = [
353
+ "lg-outer",
354
+ "lg-item",
355
+ "lg-img-wrap",
356
+ "lg-img-rotate"
357
+ ];
358
+ function consumeBackdropPress(event) {
359
+ var _a;
360
+ const classList = (_a = event.target) == null ? void 0 : _a.classList;
361
+ if (!classList || !BACKDROP_CLASS_NAMES.some((name) => classList.contains(name))) {
362
+ return false;
363
+ }
364
+ event.preventDefault();
365
+ event.stopPropagation();
366
+ return true;
367
+ }
368
+ function onTransitionSettle(element, property, fallbackMs, callback) {
369
+ let settled = false;
370
+ let timer;
371
+ const isOwn = (event) => event.target === element && event.propertyName === property;
372
+ const dispose = () => {
373
+ clearTimeout(timer);
374
+ element.removeEventListener("transitionstart", onStart);
375
+ element.removeEventListener("transitionend", onEnd);
376
+ };
377
+ const settle = () => {
378
+ if (settled) {
379
+ return;
380
+ }
381
+ settled = true;
382
+ dispose();
383
+ callback();
384
+ };
385
+ const onStart = (event) => {
386
+ if (isOwn(event)) {
387
+ clearTimeout(timer);
388
+ timer = setTimeout(settle, fallbackMs);
389
+ }
390
+ };
391
+ const onEnd = (event) => {
392
+ if (isOwn(event)) {
393
+ settle();
394
+ }
395
+ };
396
+ element.addEventListener("transitionstart", onStart);
397
+ element.addEventListener("transitionend", onEnd);
398
+ timer = setTimeout(settle, fallbackMs);
399
+ return () => {
400
+ settled = true;
401
+ dispose();
402
+ };
403
+ }
404
+ const DECODE_TIMEOUT_MS = 500;
405
+ function awaitDecode(img, timeoutMs = DECODE_TIMEOUT_MS) {
406
+ if (typeof img.decode !== "function") {
407
+ return Promise.resolve();
408
+ }
409
+ return new Promise((resolve) => {
410
+ let done = false;
411
+ const finish = () => {
412
+ if (!done) {
413
+ done = true;
414
+ clearTimeout(timer);
415
+ resolve();
416
+ }
417
+ };
418
+ const timer = setTimeout(finish, timeoutMs);
419
+ img.decode().then(finish, finish);
420
+ });
421
+ }
422
+ const VELOCITY_WINDOW_MS = 100;
423
+ const MIN_DISPLACEMENT = 1;
424
+ const MIN_WINDOW_SPAN_MS = 5;
425
+ function pushVelocitySample(samples, sample, windowMs = VELOCITY_WINDOW_MS) {
426
+ return [...samples.filter((s) => sample.t - s.t <= windowMs), sample];
427
+ }
428
+ function getWindowedVelocity(samples, releaseTime, windowMs = VELOCITY_WINDOW_MS) {
429
+ const recent = samples.filter((s) => releaseTime - s.t <= windowMs);
430
+ if (recent.length < 2) {
431
+ return { x: 0, y: 0 };
432
+ }
433
+ const first = recent[0];
434
+ const last = recent[recent.length - 1];
435
+ const dt = last.t - first.t;
436
+ if (dt < MIN_WINDOW_SPAN_MS) {
437
+ return { x: 0, y: 0 };
438
+ }
439
+ const dx = last.x - first.x;
440
+ const dy = last.y - first.y;
441
+ return {
442
+ x: Math.abs(dx) > MIN_DISPLACEMENT ? dx / dt : 0,
443
+ y: Math.abs(dy) > MIN_DISPLACEMENT ? dy / dt : 0
444
+ };
445
+ }
446
+ const lGEvents = {
447
+ afterAppendSlide: "lgAfterAppendSlide",
448
+ init: "lgInit",
449
+ hasVideo: "lgHasVideo",
450
+ containerResize: "lgContainerResize",
451
+ updateSlides: "lgUpdateSlides",
452
+ afterAppendSubHtml: "lgAfterAppendSubHtml",
453
+ beforeOpen: "lgBeforeOpen",
454
+ afterOpen: "lgAfterOpen",
455
+ slideItemLoad: "lgSlideItemLoad",
456
+ beforeSlide: "lgBeforeSlide",
457
+ afterSlide: "lgAfterSlide",
458
+ posterClick: "lgPosterClick",
459
+ dragStart: "lgDragStart",
460
+ dragMove: "lgDragMove",
461
+ dragEnd: "lgDragEnd",
462
+ beforeNextSlide: "lgBeforeNextSlide",
463
+ beforePrevSlide: "lgBeforePrevSlide",
464
+ beforeClose: "lgBeforeClose",
465
+ afterClose: "lgAfterClose"
466
+ };
467
+ const lightGalleryCoreSettings = {
468
+ mode: "lg-slide",
469
+ easing: "ease",
470
+ speed: 400,
471
+ licenseKey: "0000-0000-000-0000",
472
+ height: "100%",
473
+ width: "100%",
474
+ addClass: "",
475
+ startClass: "lg-start-zoom",
476
+ backdropDuration: 300,
477
+ container: "",
478
+ startAnimationDuration: 400,
479
+ zoomFromOrigin: true,
480
+ hideBarsDelay: 0,
481
+ showBarsAfter: 1e4,
482
+ slideDelay: 0,
483
+ supportLegacyBrowser: true,
484
+ allowMediaOverlap: false,
485
+ videoMaxSize: "1280-720",
486
+ loadYouTubePoster: true,
487
+ defaultCaptionHeight: 0,
488
+ ariaLabelledby: "",
489
+ ariaDescribedby: "",
490
+ ariaAnnouncements: true,
491
+ resetScrollPosition: true,
492
+ hideScrollbar: false,
493
+ closable: true,
494
+ swipeToClose: true,
495
+ closeOnTap: true,
496
+ showCloseIcon: true,
497
+ showMaximizeIcon: false,
498
+ loop: true,
499
+ escKey: true,
500
+ keyPress: true,
501
+ trapFocus: true,
502
+ controls: true,
503
+ slideEndAnimation: true,
504
+ hideControlOnEnd: false,
505
+ mousewheel: false,
506
+ direction: "ltr",
507
+ getCaptionFromTitleOrAlt: true,
508
+ appendSubHtmlTo: ".lg-sub-html",
509
+ subHtmlSelectorRelative: false,
510
+ preload: 2,
511
+ numberOfSlideItemsInDom: 10,
512
+ selector: "",
513
+ selectWithin: "",
514
+ nextHtml: "",
515
+ prevHtml: "",
516
+ index: 0,
517
+ iframeWidth: "100%",
518
+ iframeHeight: "100%",
519
+ iframeMaxWidth: "100%",
520
+ iframeMaxHeight: "100%",
521
+ download: true,
522
+ counter: true,
523
+ appendCounterTo: ".lg-toolbar",
524
+ swipeThreshold: 50,
525
+ flickVelocity: 0.5,
526
+ pinchToClose: true,
527
+ enableSwipe: true,
528
+ enableDrag: true,
529
+ dynamic: false,
530
+ dynamicEl: [],
531
+ extraProps: [],
532
+ exThumbImage: "",
533
+ toolbarOverflow: true,
534
+ showGestureButtons: true,
535
+ isMobile: void 0,
536
+ mobileSettings: {
537
+ controls: false,
538
+ showCloseIcon: false,
539
+ download: false,
540
+ showGestureButtons: false
541
+ },
542
+ plugins: [],
543
+ strings: {
544
+ closeGallery: "Close gallery",
545
+ toggleMaximize: "Toggle maximize",
546
+ previousSlide: "Previous slide",
547
+ nextSlide: "Next slide",
548
+ download: "Download",
549
+ playVideo: "Play video",
550
+ mediaLoadingFailed: "Oops... Failed to load content...",
551
+ galleryLabel: "Gallery",
552
+ slideAnnouncement: "Image {index} of {total}",
553
+ moreOptions: "More options",
554
+ share: "Share",
555
+ toggleThumbnails: "Toggle thumbnails",
556
+ toggleAutoplay: "Toggle Autoplay",
557
+ toggleFullscreen: "Toggle Fullscreen",
558
+ zoomIn: "Zoom in",
559
+ zoomOut: "Zoom out",
560
+ viewActualSize: "View actual size",
561
+ rotateLeft: "Rotate left",
562
+ rotateRight: "Rotate right",
563
+ flipHorizontal: "Flip horizontal",
564
+ flipVertical: "Flip vertical",
565
+ toggleComments: "Toggle Comments"
566
+ },
567
+ icons: {}
568
+ };
569
+ const schedule = typeof requestAnimationFrame === "function" ? (callback) => requestAnimationFrame(callback) : (callback) => window.setTimeout(callback, 16);
570
+ const cancel = typeof cancelAnimationFrame === "function" ? (handle) => cancelAnimationFrame(handle) : (handle) => window.clearTimeout(handle);
571
+ function toolbarButtons(toolbar, more) {
572
+ return Array.from(toolbar.querySelectorAll(".lg-icon")).filter(
573
+ (button) => {
574
+ var _a;
575
+ return button !== more && !button.closest(".lg-toolbar-menu, .lg-dropdown") && !((_a = button.parentElement) == null ? void 0 : _a.closest(".lg-icon"));
576
+ }
577
+ );
578
+ }
579
+ function visibleIconMarkup(button) {
580
+ var _a, _b, _c;
581
+ const icons = Array.from(button.querySelectorAll(".lg-ci"));
582
+ if (!icons.length) {
583
+ return (_b = (_a = button.querySelector("svg")) == null ? void 0 : _a.outerHTML) != null ? _b : "";
584
+ }
585
+ const shown = (_c = icons.find(
586
+ (icon) => window.getComputedStyle(icon).display !== "none"
587
+ )) != null ? _c : icons[0];
588
+ return shown.outerHTML;
589
+ }
590
+ class ToolbarOverflow {
591
+ constructor(toolbar, options) {
592
+ this.toolbar = toolbar;
593
+ this.options = options;
594
+ this.menu = null;
595
+ this.frame = 0;
596
+ this.movedSignature = "";
597
+ this.widths = /* @__PURE__ */ new WeakMap();
598
+ this.requestUpdate = () => {
599
+ if (this.frame) {
600
+ return;
601
+ }
602
+ this.frame = schedule(() => {
603
+ this.frame = 0;
604
+ this.update();
605
+ });
606
+ };
607
+ this.onMoreClick = () => {
608
+ if (this.menu) {
609
+ this.close(true);
610
+ } else {
611
+ this.open();
612
+ }
613
+ };
614
+ this.onMenuKeydown = (event) => {
615
+ var _a, _b, _c, _d;
616
+ const items = this.items();
617
+ const index = items.indexOf(document.activeElement);
618
+ switch (event.key) {
619
+ case "Escape":
620
+ this.close(true);
621
+ break;
622
+ case "ArrowDown":
623
+ (_a = items[(index + 1) % items.length]) == null ? void 0 : _a.focus();
624
+ break;
625
+ case "ArrowUp":
626
+ (_b = items[(index - 1 + items.length) % items.length]) == null ? void 0 : _b.focus();
627
+ break;
628
+ case "Home":
629
+ (_c = items[0]) == null ? void 0 : _c.focus();
630
+ break;
631
+ case "End":
632
+ (_d = items[items.length - 1]) == null ? void 0 : _d.focus();
633
+ break;
634
+ case "ArrowLeft":
635
+ case "ArrowRight":
636
+ break;
637
+ case "Tab":
638
+ this.close(false);
639
+ return;
640
+ default:
641
+ return;
642
+ }
643
+ event.preventDefault();
644
+ event.stopPropagation();
645
+ };
646
+ this.onDocumentPointerDown = (event) => {
647
+ var _a;
648
+ const target = event.target;
649
+ if (target && (((_a = this.menu) == null ? void 0 : _a.contains(target)) || this.more.contains(target))) {
650
+ return;
651
+ }
652
+ consumeBackdropPress(event);
653
+ this.close(false);
654
+ };
655
+ const more = document.createElement("button");
656
+ more.type = "button";
657
+ more.id = options.id;
658
+ more.className = "lg-more lg-icon";
659
+ more.hidden = true;
660
+ more.setAttribute("aria-label", options.label);
661
+ more.setAttribute("aria-haspopup", "menu");
662
+ more.setAttribute("aria-expanded", "false");
663
+ more.addEventListener("click", this.onMoreClick);
664
+ const close = toolbar.querySelector(".lg-close");
665
+ if (close) {
666
+ close.insertAdjacentElement("afterend", more);
667
+ } else {
668
+ toolbar.insertBefore(more, toolbar.firstChild);
669
+ }
670
+ this.more = more;
671
+ if (typeof ResizeObserver === "function") {
672
+ this.resizeObserver = new ResizeObserver(this.requestUpdate);
673
+ this.resizeObserver.observe(toolbar);
674
+ }
675
+ if (typeof MutationObserver === "function") {
676
+ this.mutationObserver = new MutationObserver((records) => {
677
+ if (records.some(
678
+ (record) => {
679
+ var _a, _b;
680
+ return !((_b = (_a = record.target).closest) == null ? void 0 : _b.call(
681
+ _a,
682
+ ".lg-toolbar-menu"
683
+ ));
684
+ }
685
+ )) {
686
+ this.requestUpdate();
687
+ }
688
+ });
689
+ this.mutationObserver.observe(toolbar, {
690
+ childList: true,
691
+ subtree: true
692
+ });
693
+ }
694
+ }
695
+ /** Re-measure the row and move buttons in or out of the menu. */
696
+ update() {
697
+ var _a, _b;
698
+ const buttons = toolbarButtons(this.toolbar, this.more);
699
+ buttons.forEach((button) => {
700
+ if (!button.hasAttribute("data-lg-overflow")) {
701
+ const width = button.offsetWidth;
702
+ if (width) {
703
+ this.widths.set(button, width);
704
+ }
705
+ }
706
+ });
707
+ const fallback = (_a = buttons.map((button) => this.widths.get(button)).find((width) => !!width)) != null ? _a : 0;
708
+ const counter = this.toolbar.querySelector(".lg-counter");
709
+ const moved = getToolbarOverflow({
710
+ available: this.toolbar.clientWidth,
711
+ reserved: counter ? counter.offsetWidth : 0,
712
+ moreWidth: (_b = this.widths.get(this.more)) != null ? _b : fallback,
713
+ items: buttons.map((button) => {
714
+ var _a2;
715
+ return {
716
+ width: (_a2 = this.widths.get(button)) != null ? _a2 : fallback,
717
+ priority: getToolbarItemPriority(Array.from(button.classList))
718
+ };
719
+ })
720
+ });
721
+ const overflow = new Set(moved);
722
+ buttons.forEach((button, index) => {
723
+ if (overflow.has(index)) {
724
+ button.setAttribute("data-lg-overflow", "");
725
+ } else {
726
+ button.removeAttribute("data-lg-overflow");
727
+ }
728
+ });
729
+ this.more.hidden = overflow.size === 0;
730
+ if (!this.more.hidden && this.more.offsetWidth) {
731
+ this.widths.set(this.more, this.more.offsetWidth);
732
+ }
733
+ const signature = `${buttons.length}:${moved.join(",")}`;
734
+ const changed = signature !== this.movedSignature;
735
+ this.movedSignature = signature;
736
+ if (!overflow.size) {
737
+ this.close(false);
738
+ } else if (this.menu && changed) {
739
+ this.renderMenu();
740
+ }
741
+ }
742
+ /** Close the menu; optionally hand focus back to the More button. */
743
+ close(returnFocus) {
744
+ if (!this.menu) {
745
+ return;
746
+ }
747
+ this.menu.removeEventListener("keydown", this.onMenuKeydown);
748
+ this.menu.remove();
749
+ this.menu = null;
750
+ document.removeEventListener(
751
+ "pointerdown",
752
+ this.onDocumentPointerDown,
753
+ true
754
+ );
755
+ this.more.setAttribute("aria-expanded", "false");
756
+ this.more.removeAttribute("aria-controls");
757
+ if (returnFocus) {
758
+ this.more.focus();
759
+ }
760
+ }
761
+ destroy() {
762
+ var _a, _b;
763
+ this.close(false);
764
+ cancel(this.frame);
765
+ (_a = this.resizeObserver) == null ? void 0 : _a.disconnect();
766
+ (_b = this.mutationObserver) == null ? void 0 : _b.disconnect();
767
+ toolbarButtons(this.toolbar, this.more).forEach(
768
+ (button) => button.removeAttribute("data-lg-overflow")
769
+ );
770
+ this.more.remove();
771
+ }
772
+ open() {
773
+ var _a;
774
+ const menu = document.createElement("div");
775
+ menu.id = `${this.options.id}-menu`;
776
+ menu.className = "lg-toolbar-menu";
777
+ menu.setAttribute("role", "menu");
778
+ menu.setAttribute("aria-label", this.options.label);
779
+ menu.addEventListener("keydown", this.onMenuKeydown);
780
+ this.menu = menu;
781
+ this.renderMenu();
782
+ this.toolbar.appendChild(menu);
783
+ this.more.setAttribute("aria-expanded", "true");
784
+ this.more.setAttribute("aria-controls", menu.id);
785
+ document.addEventListener(
786
+ "pointerdown",
787
+ this.onDocumentPointerDown,
788
+ true
789
+ );
790
+ (_a = this.items()[0]) == null ? void 0 : _a.focus();
791
+ }
792
+ renderMenu() {
793
+ const menu = this.menu;
794
+ if (!menu) {
795
+ return;
796
+ }
797
+ menu.textContent = "";
798
+ toolbarButtons(this.toolbar, this.more).filter((button) => button.hasAttribute("data-lg-overflow")).forEach((button) => {
799
+ var _a;
800
+ const item = document.createElement("button");
801
+ item.type = "button";
802
+ item.className = "lg-toolbar-menu-item";
803
+ item.setAttribute("role", "menuitem");
804
+ const icon = document.createElement("span");
805
+ icon.className = "lg-toolbar-menu-icon";
806
+ icon.setAttribute("aria-hidden", "true");
807
+ icon.innerHTML = visibleIconMarkup(button);
808
+ const label = document.createElement("span");
809
+ label.textContent = (_a = button.getAttribute("aria-label")) != null ? _a : "";
810
+ item.append(icon, label);
811
+ item.addEventListener("click", () => {
812
+ this.close(true);
813
+ button.click();
814
+ });
815
+ menu.appendChild(item);
816
+ });
817
+ }
818
+ items() {
819
+ return this.menu ? Array.from(
820
+ this.menu.querySelectorAll('[role="menuitem"]')
821
+ ) : [];
822
+ }
823
+ }
824
+ const ICON_TARGETS = [
825
+ { selector: ".lg-close", names: ["close"] },
826
+ { selector: ".lg-prev", names: ["prev"] },
827
+ { selector: ".lg-next", names: ["next"] },
828
+ { selector: ".lg-download", names: ["download"] },
829
+ { selector: ".lg-more", names: ["more"] },
830
+ // Shown while `.lg-inline` (prompting maximize) / after maximizing.
831
+ { selector: ".lg-maximize", names: ["maximize", "minimize"] },
832
+ // The actual-size button's CLASS toggles between the two zoom
833
+ // classes as the zoom state changes (2.x swapped the glyph that
834
+ // way), it carries BOTH zoom icons and the class picks one in
835
+ // CSS. Listed before the class-based zoom targets so the id match
836
+ // claims it first (the pass skips already-processed elements).
837
+ { selector: '[id^="lg-actual-size-"]', names: ["zoomIn", "zoomOut"] },
838
+ { selector: ".lg-zoom-in", names: ["zoomIn"] },
839
+ { selector: ".lg-zoom-out", names: ["zoomOut"] },
840
+ // No '.lg-actual-size' target: vanilla's actual-size BUTTON never
841
+ // carries that class (it rides the zoom classes above; the outer
842
+ // gets `lg-actual-size` as a zoom-state class after build). The
843
+ // `actualSize` name serves the framework ports' static button.
844
+ { selector: ".lg-rotate-left", names: ["rotateLeft"] },
845
+ { selector: ".lg-rotate-right", names: ["rotateRight"] },
846
+ { selector: ".lg-flip-hor", names: ["flipHorizontal"] },
847
+ { selector: ".lg-flip-ver", names: ["flipVertical"] },
848
+ { selector: ".lg-share", names: ["share"] },
849
+ { selector: ".lg-share-facebook .lg-icon", names: ["shareFacebook"] },
850
+ { selector: ".lg-share-twitter .lg-icon", names: ["shareX"] },
851
+ { selector: ".lg-share-pinterest .lg-icon", names: ["sharePinterest"] },
852
+ // Shown while idle (prompting play) / while `.lg-show-autoplay`.
853
+ {
854
+ selector: ".lg-autoplay-button",
855
+ names: ["autoplayPlay", "autoplayPause"]
856
+ },
857
+ // Shown while windowed / while `.lg-fullscreen-on`.
858
+ { selector: ".lg-fullscreen", names: ["fullscreen", "fullscreenExit"] },
859
+ { selector: ".lg-comment-toggle", names: ["comment"] },
860
+ { selector: ".lg-comment-close", names: ["commentClose"] },
861
+ { selector: ".lg-toggle-thumb", names: ["toggleThumbnails"] }
862
+ ];
863
+ const toKebab = (name) => name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
864
+ function getCustomIconMarkup(icons, names) {
865
+ if (!names.every((name) => icons[name])) {
866
+ return "";
867
+ }
868
+ return names.map(
869
+ (name) => `<span class="lg-ci lg-ci-${toKebab(
870
+ name
871
+ )}" aria-hidden="true">${icons[name]}</span>`
872
+ ).join("");
873
+ }
874
+ function applyCustomIcons(container, defaults, overrides) {
875
+ ICON_TARGETS.forEach(({ selector, names }) => {
876
+ const source = overrides && names.every((name) => overrides[name]) ? overrides : defaults;
877
+ const markup = getCustomIconMarkup(source, names);
878
+ if (!markup) {
879
+ return;
880
+ }
881
+ container.querySelectorAll(selector).forEach((element) => {
882
+ if (element.classList.contains("lg-icon-custom")) {
883
+ return;
884
+ }
885
+ element.classList.add("lg-icon-custom");
886
+ element.insertAdjacentHTML("afterbegin", markup);
887
+ });
888
+ });
889
+ }
890
+ const MAX_FRAME_MS = 64;
891
+ function runSprings(tracks, onFrame, onDone) {
892
+ let raf = 0;
893
+ let last = Date.now();
894
+ const states = tracks.map((t) => ({
895
+ position: t.from,
896
+ velocity: t.velocity
897
+ }));
898
+ const frame = () => {
899
+ const now = Date.now();
900
+ const dt = Math.min(Math.max(now - last, 0), MAX_FRAME_MS);
901
+ last = now;
902
+ let settled = true;
903
+ tracks.forEach((t, i) => {
904
+ states[i] = stepSpring(states[i], t.target, dt, t);
905
+ if (!isSpringSettled(states[i], t.target)) {
906
+ settled = false;
907
+ }
908
+ });
909
+ if (settled) {
910
+ onFrame(tracks.map((t) => t.target));
911
+ onDone == null ? void 0 : onDone();
912
+ return;
913
+ }
914
+ onFrame(states.map((s) => s.position));
915
+ raf = requestAnimationFrame(frame);
916
+ };
917
+ raf = requestAnimationFrame(frame);
918
+ return () => cancelAnimationFrame(raf);
919
+ }
920
+ function initLgPolyfills() {
921
+ (function() {
922
+ if (typeof window.CustomEvent === "function") return false;
923
+ function CustomEvent2(event, params) {
924
+ params = params || {
925
+ bubbles: false,
926
+ cancelable: false,
927
+ detail: null
928
+ };
929
+ const evt = document.createEvent("CustomEvent");
930
+ evt.initCustomEvent(
931
+ event,
932
+ params.bubbles,
933
+ params.cancelable,
934
+ params.detail
935
+ );
936
+ return evt;
937
+ }
938
+ window.CustomEvent = CustomEvent2;
939
+ })();
940
+ (function() {
941
+ if (!Element.prototype.matches) {
942
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
943
+ }
944
+ })();
945
+ }
946
+ const _lgQuery = class _lgQuery2 {
947
+ constructor(selector) {
948
+ this.cssVenderPrefixes = [
949
+ "TransitionDuration",
950
+ "TransitionTimingFunction",
951
+ "Transform",
952
+ "Transition"
953
+ ];
954
+ this.selector = this._getSelector(selector);
955
+ this.firstElement = this._getFirstEl();
956
+ return this;
957
+ }
958
+ static generateUUID() {
959
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
960
+ /[xy]/g,
961
+ function(c) {
962
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
963
+ return v.toString(16);
964
+ }
965
+ );
966
+ }
967
+ _getSelector(selector, context = document) {
968
+ if (typeof selector !== "string") {
969
+ return selector;
970
+ }
971
+ context = context || document;
972
+ const fl = selector.substring(0, 1);
973
+ if (fl === "#") {
974
+ return context.querySelector(selector);
975
+ } else {
976
+ return context.querySelectorAll(selector);
977
+ }
978
+ }
979
+ _each(func) {
980
+ if (!this.selector) {
981
+ return this;
982
+ }
983
+ if (this.selector.length !== void 0) {
984
+ [].forEach.call(this.selector, func);
985
+ } else {
986
+ func(this.selector, 0);
987
+ }
988
+ return this;
989
+ }
990
+ _setCssVendorPrefix(el, cssProperty, value) {
991
+ if (cssProperty.startsWith("--")) {
992
+ el.style.setProperty(cssProperty, String(value));
993
+ return;
994
+ }
995
+ const property = cssProperty.replace(/-([a-z])/gi, function(s, group1) {
996
+ return group1.toUpperCase();
997
+ });
998
+ if (this.cssVenderPrefixes.indexOf(property) !== -1) {
999
+ el.style[property.charAt(0).toLowerCase() + property.slice(1)] = value;
1000
+ el.style["webkit" + property] = value;
1001
+ el.style["moz" + property] = value;
1002
+ el.style["ms" + property] = value;
1003
+ el.style["o" + property] = value;
1004
+ } else {
1005
+ el.style[property] = value;
1006
+ }
1007
+ }
1008
+ _getFirstEl() {
1009
+ if (this.selector && this.selector.length !== void 0) {
1010
+ return this.selector[0];
1011
+ } else {
1012
+ return this.selector;
1013
+ }
1014
+ }
1015
+ isEventMatched(event, eventName) {
1016
+ const eventNamespace = eventName.split(".");
1017
+ return event.split(".").filter((e) => e).every((e) => {
1018
+ return eventNamespace.indexOf(e) !== -1;
1019
+ });
1020
+ }
1021
+ attr(attr, value) {
1022
+ if (value === void 0) {
1023
+ if (!this.firstElement) {
1024
+ return "";
1025
+ }
1026
+ return this.firstElement.getAttribute(attr);
1027
+ }
1028
+ this._each((el) => {
1029
+ el.setAttribute(attr, value);
1030
+ });
1031
+ return this;
1032
+ }
1033
+ find(selector) {
1034
+ return $LG(this._getSelector(selector, this.selector));
1035
+ }
1036
+ first() {
1037
+ if (this.selector && this.selector.length !== void 0) {
1038
+ return $LG(this.selector[0]);
1039
+ } else {
1040
+ return $LG(this.selector);
1041
+ }
1042
+ }
1043
+ eq(index) {
1044
+ return $LG(this.selector[index]);
1045
+ }
1046
+ parent() {
1047
+ return $LG(this.selector.parentElement);
1048
+ }
1049
+ get() {
1050
+ return this._getFirstEl();
1051
+ }
1052
+ removeAttr(attributes) {
1053
+ const attrs = attributes.split(" ");
1054
+ this._each((el) => {
1055
+ attrs.forEach((attr) => el.removeAttribute(attr));
1056
+ });
1057
+ return this;
1058
+ }
1059
+ wrap(className) {
1060
+ if (!this.firstElement) {
1061
+ return this;
1062
+ }
1063
+ const wrapper = document.createElement("div");
1064
+ wrapper.className = className;
1065
+ this.firstElement.parentNode.insertBefore(wrapper, this.firstElement);
1066
+ this.firstElement.parentNode.removeChild(this.firstElement);
1067
+ wrapper.appendChild(this.firstElement);
1068
+ return this;
1069
+ }
1070
+ addClass(classNames = "") {
1071
+ this._each((el) => {
1072
+ classNames.split(" ").forEach((className) => {
1073
+ if (className) {
1074
+ el.classList.add(className);
1075
+ }
1076
+ });
1077
+ });
1078
+ return this;
1079
+ }
1080
+ removeClass(classNames) {
1081
+ this._each((el) => {
1082
+ classNames.split(" ").forEach((className) => {
1083
+ if (className) {
1084
+ el.classList.remove(className);
1085
+ }
1086
+ });
1087
+ });
1088
+ return this;
1089
+ }
1090
+ hasClass(className) {
1091
+ if (!this.firstElement) {
1092
+ return false;
1093
+ }
1094
+ return this.firstElement.classList.contains(className);
1095
+ }
1096
+ hasAttribute(attribute) {
1097
+ if (!this.firstElement) {
1098
+ return false;
1099
+ }
1100
+ return this.firstElement.hasAttribute(attribute);
1101
+ }
1102
+ toggleClass(className) {
1103
+ if (!this.firstElement) {
1104
+ return this;
1105
+ }
1106
+ if (this.hasClass(className)) {
1107
+ this.removeClass(className);
1108
+ } else {
1109
+ this.addClass(className);
1110
+ }
1111
+ return this;
1112
+ }
1113
+ css(property, value) {
1114
+ this._each((el) => {
1115
+ this._setCssVendorPrefix(el, property, value);
1116
+ });
1117
+ return this;
1118
+ }
1119
+ // Need to pass separate namespaces for separate elements
1120
+ on(events, listener) {
1121
+ if (!this.selector) {
1122
+ return this;
1123
+ }
1124
+ events.split(" ").forEach((event) => {
1125
+ if (!Array.isArray(_lgQuery2.eventListeners[event])) {
1126
+ _lgQuery2.eventListeners[event] = [];
1127
+ }
1128
+ _lgQuery2.eventListeners[event].push(listener);
1129
+ this.selector.addEventListener(event.split(".")[0], listener);
1130
+ });
1131
+ return this;
1132
+ }
1133
+ // @todo - test this
1134
+ once(event, listener) {
1135
+ this.on(event, () => {
1136
+ this.off(event);
1137
+ listener(event);
1138
+ });
1139
+ return this;
1140
+ }
1141
+ off(event) {
1142
+ if (!this.selector) {
1143
+ return this;
1144
+ }
1145
+ Object.keys(_lgQuery2.eventListeners).forEach((eventName) => {
1146
+ if (this.isEventMatched(event, eventName)) {
1147
+ _lgQuery2.eventListeners[eventName].forEach((listener) => {
1148
+ this.selector.removeEventListener(
1149
+ eventName.split(".")[0],
1150
+ listener
1151
+ );
1152
+ });
1153
+ _lgQuery2.eventListeners[eventName] = [];
1154
+ }
1155
+ });
1156
+ return this;
1157
+ }
1158
+ trigger(event, detail) {
1159
+ if (!this.firstElement) {
1160
+ return this;
1161
+ }
1162
+ const customEvent = new CustomEvent(event.split(".")[0], {
1163
+ detail: detail || null
1164
+ });
1165
+ this.firstElement.dispatchEvent(customEvent);
1166
+ return this;
1167
+ }
1168
+ // Does not support IE
1169
+ load(url) {
1170
+ fetch(url).then((res) => res.text()).then((html) => {
1171
+ this.selector.innerHTML = html;
1172
+ });
1173
+ return this;
1174
+ }
1175
+ html(html) {
1176
+ if (html === void 0) {
1177
+ if (!this.firstElement) {
1178
+ return "";
1179
+ }
1180
+ return this.firstElement.innerHTML;
1181
+ }
1182
+ this._each((el) => {
1183
+ el.innerHTML = html;
1184
+ });
1185
+ return this;
1186
+ }
1187
+ append(html) {
1188
+ this._each((el) => {
1189
+ if (typeof html === "string") {
1190
+ el.insertAdjacentHTML("beforeend", html);
1191
+ } else {
1192
+ el.appendChild(html);
1193
+ }
1194
+ });
1195
+ return this;
1196
+ }
1197
+ prepend(html) {
1198
+ this._each((el) => {
1199
+ if (typeof html === "string") {
1200
+ el.insertAdjacentHTML("afterbegin", html);
1201
+ } else if (html instanceof HTMLElement) {
1202
+ el.insertBefore(html.cloneNode(true), el.firstChild);
1203
+ }
1204
+ });
1205
+ return this;
1206
+ }
1207
+ remove() {
1208
+ this._each((el) => {
1209
+ el.parentNode.removeChild(el);
1210
+ });
1211
+ return this;
1212
+ }
1213
+ empty() {
1214
+ this._each((el) => {
1215
+ el.innerHTML = "";
1216
+ });
1217
+ return this;
1218
+ }
1219
+ scrollTop(scrollTop) {
1220
+ if (scrollTop !== void 0) {
1221
+ document.body.scrollTop = scrollTop;
1222
+ document.documentElement.scrollTop = scrollTop;
1223
+ return this;
1224
+ } else {
1225
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
1226
+ }
1227
+ }
1228
+ scrollLeft(scrollLeft) {
1229
+ if (scrollLeft !== void 0) {
1230
+ document.body.scrollLeft = scrollLeft;
1231
+ document.documentElement.scrollLeft = scrollLeft;
1232
+ return this;
1233
+ } else {
1234
+ return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
1235
+ }
1236
+ }
1237
+ offset() {
1238
+ if (!this.firstElement) {
1239
+ return {
1240
+ left: 0,
1241
+ top: 0
1242
+ };
1243
+ }
1244
+ const rect = this.firstElement.getBoundingClientRect();
1245
+ const bodyMarginLeft = $LG("body").style().marginLeft;
1246
+ return {
1247
+ left: rect.left - parseFloat(bodyMarginLeft) + this.scrollLeft(),
1248
+ top: rect.top + this.scrollTop()
1249
+ };
1250
+ }
1251
+ style() {
1252
+ if (!this.firstElement) {
1253
+ return {};
1254
+ }
1255
+ return this.firstElement.currentStyle || window.getComputedStyle(this.firstElement);
1256
+ }
1257
+ // Width without padding and border even if box-sizing is used.
1258
+ width() {
1259
+ const style = this.style();
1260
+ return this.firstElement.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
1261
+ }
1262
+ // Height without padding and border even if box-sizing is used.
1263
+ height() {
1264
+ const style = this.style();
1265
+ return this.firstElement.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);
1266
+ }
1267
+ };
1268
+ _lgQuery.eventListeners = {};
1269
+ let lgQuery = _lgQuery;
1270
+ function $LG(selector) {
1271
+ initLgPolyfills();
1272
+ return new lgQuery(selector);
1273
+ }
1274
+ const defaultDynamicOptions = [
1275
+ "src",
1276
+ "sources",
1277
+ "subHtml",
1278
+ "subHtmlUrl",
1279
+ "html",
1280
+ "video",
1281
+ "poster",
1282
+ "slideName",
1283
+ "responsive",
1284
+ "srcset",
1285
+ "sizes",
1286
+ "iframe",
1287
+ "downloadUrl",
1288
+ "download",
1289
+ "width",
1290
+ "shareUrl",
1291
+ "facebookShareUrl",
1292
+ "tweetText",
1293
+ "iframeTitle",
1294
+ "twitterShareUrl",
1295
+ "pinterestShareUrl",
1296
+ "pinterestText",
1297
+ "fbHtml",
1298
+ "disqusIdentifier",
1299
+ "disqusUrl"
1300
+ ];
1301
+ function convertToData(attr) {
1302
+ if (attr === "href") {
1303
+ return "src";
1304
+ }
1305
+ attr = attr.replace("data-", "");
1306
+ attr = attr.charAt(0).toLowerCase() + attr.slice(1);
1307
+ attr = attr.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
1308
+ return attr;
1309
+ }
1310
+ const utils = {
1311
+ /**
1312
+ * Fetches HTML content from a given URL and inserts it into a specified element.
1313
+ *
1314
+ * @param url - The URL to fetch the HTML content from.
1315
+ * @param element - The DOM element (jQuery object) to insert the HTML content into.
1316
+ * @param insertMethod - The method to insert the HTML ('append' or 'replace').
1317
+ */
1318
+ fetchCaptionFromUrl(url, element, insertMethod) {
1319
+ fetch(url).then((response) => response.text()).then((htmlContent) => {
1320
+ if (insertMethod === "append") {
1321
+ const contentDiv = `<div class="lg-sub-html">${htmlContent}</div>`;
1322
+ element.append(contentDiv);
1323
+ } else {
1324
+ element.html(htmlContent);
1325
+ }
1326
+ });
1327
+ },
1328
+ /**
1329
+ * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
1330
+ */
1331
+ getSize(el, container, spacing = 0, defaultLgSize) {
1332
+ const LGel = $LG(el);
1333
+ const lgSize = LGel.attr("data-lg-size") || defaultLgSize;
1334
+ const parsed = parseImageSize(lgSize, window.innerWidth);
1335
+ if (!parsed) {
1336
+ return;
1337
+ }
1338
+ return fitImageSize(
1339
+ parsed,
1340
+ container.width(),
1341
+ container.height() - spacing
1342
+ );
1343
+ },
1344
+ /**
1345
+ * @desc Get transform value based on the imageSize. Used for ZoomFromOrigin option
1346
+ * @param {jQuery Element}
1347
+ * @returns {String} Transform CSS string
1348
+ */
1349
+ getTransform(el, container, top, bottom, imageSize) {
1350
+ if (!imageSize || imageSize.width <= 0 || imageSize.height <= 0) {
1351
+ return;
1352
+ }
1353
+ const LGel = $LG(el).find("img").first();
1354
+ if (!LGel.get()) {
1355
+ return;
1356
+ }
1357
+ const containerRect = container.get().getBoundingClientRect();
1358
+ const rect = LGel.get().getBoundingClientRect();
1359
+ const triggerRect = {
1360
+ left: rect.left,
1361
+ top: rect.top,
1362
+ width: rect.width,
1363
+ height: rect.height
1364
+ };
1365
+ if (!isUsableOriginRect(triggerRect)) {
1366
+ return;
1367
+ }
1368
+ return getOriginTransform({
1369
+ triggerRect,
1370
+ containerRect: {
1371
+ left: containerRect.left,
1372
+ top: containerRect.top,
1373
+ width: containerRect.width,
1374
+ // Element height, not rect height, includes the mobile
1375
+ // safari bottom bar handling this always had.
1376
+ height: container.height()
1377
+ },
1378
+ top,
1379
+ bottom,
1380
+ imageSize
1381
+ });
1382
+ },
1383
+ getIframeMarkup(iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
1384
+ const title = iframeTitle ? 'title="' + iframeTitle + '"' : "";
1385
+ return `<div class="lg-media-cont lg-has-iframe" style="width:${iframeWidth}; max-width:${iframeMaxWidth}; height: ${iframeHeight}; max-height:${iframeMaxHeight}">
1386
+ <iframe class="lg-object" frameborder="0" ${title} src="${src}" allowfullscreen="true"></iframe>
1387
+ </div>`;
1388
+ },
1389
+ getImgMarkup(index, src, altAttr, srcset, sizes, sources) {
1390
+ const srcsetAttr = srcset ? `srcset="${srcset}"` : "";
1391
+ const sizesAttr = sizes ? `sizes="${sizes}"` : "";
1392
+ const imgMarkup = `<img ${altAttr} ${srcsetAttr} ${sizesAttr} class="lg-object lg-image" data-index="${index}" src="${src}" />`;
1393
+ let sourceTag = "";
1394
+ if (sources) {
1395
+ const sourceObj = typeof sources === "string" ? JSON.parse(sources) : sources;
1396
+ sourceTag = sourceObj.map((source) => {
1397
+ let attrs = "";
1398
+ Object.keys(source).forEach((key) => {
1399
+ attrs += ` ${key}="${source[key]}"`;
1400
+ });
1401
+ return `<source ${attrs}></source>`;
1402
+ });
1403
+ }
1404
+ return `${sourceTag}${imgMarkup}`;
1405
+ },
1406
+ // Get src from responsive src
1407
+ getResponsiveSrc(srcItms) {
1408
+ const rsWidth = [];
1409
+ const rsSrc = [];
1410
+ let src = "";
1411
+ for (let i = 0; i < srcItms.length; i++) {
1412
+ const _src = srcItms[i].split(" ");
1413
+ if (_src[0] === "") {
1414
+ _src.splice(0, 1);
1415
+ }
1416
+ rsSrc.push(_src[0]);
1417
+ rsWidth.push(_src[1]);
1418
+ }
1419
+ const wWidth = window.innerWidth;
1420
+ for (let j = 0; j < rsWidth.length; j++) {
1421
+ if (parseInt(rsWidth[j], 10) > wWidth) {
1422
+ src = rsSrc[j];
1423
+ break;
1424
+ }
1425
+ }
1426
+ return src;
1427
+ },
1428
+ isImageLoaded(img) {
1429
+ if (!img) return false;
1430
+ if (!img.complete) {
1431
+ return false;
1432
+ }
1433
+ if (img.naturalWidth === 0) {
1434
+ return false;
1435
+ }
1436
+ return true;
1437
+ },
1438
+ getVideoPosterMarkup(_poster, dummyImg, videoContStyle, playVideoString, _isVideo) {
1439
+ let videoClass = "";
1440
+ if (_isVideo && _isVideo.youtube) {
1441
+ videoClass = "lg-has-youtube";
1442
+ } else if (_isVideo && _isVideo.vimeo) {
1443
+ videoClass = "lg-has-vimeo";
1444
+ } else if (_isVideo && _isVideo.wistia) {
1445
+ videoClass = "lg-has-wistia";
1446
+ } else {
1447
+ videoClass = "lg-has-html5";
1448
+ }
1449
+ let _dummy = dummyImg;
1450
+ if (typeof dummyImg !== "string") {
1451
+ _dummy = dummyImg.outerHTML;
1452
+ }
1453
+ return `<div class="lg-video-cont ${videoClass}" style="${videoContStyle}">
1454
+ <div class="lg-video-play-button">
1455
+ <svg
1456
+ viewBox="0 0 20 20"
1457
+ preserveAspectRatio="xMidYMid"
1458
+ focusable="false"
1459
+ aria-labelledby="${playVideoString}"
1460
+ role="img"
1461
+ class="lg-video-play-icon"
1462
+ >
1463
+ <title>${playVideoString}</title>
1464
+ <polygon class="lg-video-play-icon-inner" points="1,0 20,10 1,20"></polygon>
1465
+ </svg>
1466
+ <svg class="lg-video-play-icon-bg" viewBox="0 0 50 50" focusable="false">
1467
+ <circle cx="50%" cy="50%" r="20"></circle></svg>
1468
+ <svg class="lg-video-play-icon-circle" viewBox="0 0 50 50" focusable="false">
1469
+ <circle cx="50%" cy="50%" r="20"></circle>
1470
+ </svg>
1471
+ </div>
1472
+ ${_dummy}
1473
+ <img class="lg-object lg-video-poster" src="${_poster}" />
1474
+ </div>`;
1475
+ },
1476
+ getFocusableElements(container) {
1477
+ const elements = container.querySelectorAll(
1478
+ 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'
1479
+ );
1480
+ const visibleElements = [].filter.call(
1481
+ elements,
1482
+ (element) => {
1483
+ const style = window.getComputedStyle(element);
1484
+ return style.display !== "none" && style.visibility !== "hidden" && // Hidden or moved into the toolbar's More menu, whatever
1485
+ // the stylesheet says about their display.
1486
+ !element.closest("[hidden], [data-lg-overflow]");
1487
+ }
1488
+ );
1489
+ return visibleElements;
1490
+ },
1491
+ /**
1492
+ * @desc Create dynamic elements array from gallery items when dynamic option is false
1493
+ * It helps to avoid frequent DOM interaction
1494
+ * and avoid multiple checks for dynamic elments
1495
+ *
1496
+ * @returns {Array} dynamicEl
1497
+ */
1498
+ getDynamicOptions(items, extraProps, getCaptionFromTitleOrAlt, exThumbImage) {
1499
+ const dynamicElements = [];
1500
+ const availableDynamicOptions = [
1501
+ ...defaultDynamicOptions,
1502
+ ...extraProps
1503
+ ];
1504
+ [].forEach.call(items, (item) => {
1505
+ const dynamicEl = {};
1506
+ for (let i = 0; i < item.attributes.length; i++) {
1507
+ const attr = item.attributes[i];
1508
+ if (attr.specified) {
1509
+ const dynamicAttr = convertToData(attr.name);
1510
+ let label = "";
1511
+ if (availableDynamicOptions.indexOf(dynamicAttr) > -1) {
1512
+ label = dynamicAttr;
1513
+ }
1514
+ if (label) {
1515
+ dynamicEl[label] = attr.value;
1516
+ }
1517
+ }
1518
+ }
1519
+ if (typeof dynamicEl.sources === "string") {
1520
+ try {
1521
+ dynamicEl.sources = JSON.parse(dynamicEl.sources);
1522
+ } catch (e) {
1523
+ console.warn(
1524
+ "lightGallery :- data-sources must be a JSON array of picture source objects. See https://www.lightgalleryjs.com/docs/responsive-loading/"
1525
+ );
1526
+ delete dynamicEl.sources;
1527
+ }
1528
+ }
1529
+ const currentItem = $LG(item);
1530
+ const alt = currentItem.find("img").first().attr("alt");
1531
+ const title = currentItem.attr("title");
1532
+ const thumb = exThumbImage ? currentItem.attr(exThumbImage) : currentItem.find("img").first().attr("src");
1533
+ dynamicEl.thumb = thumb;
1534
+ if (getCaptionFromTitleOrAlt && !dynamicEl.subHtml) {
1535
+ dynamicEl.subHtml = title || alt || "";
1536
+ }
1537
+ dynamicEl.alt = alt || title || "";
1538
+ dynamicElements.push(dynamicEl);
1539
+ });
1540
+ return dynamicElements;
1541
+ },
1542
+ isMobile() {
1543
+ return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
1544
+ },
1545
+ /**
1546
+ * @desc Check the given src is video
1547
+ * @param {String} src
1548
+ * @return {Object} video type
1549
+ * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
1550
+ *
1551
+ * @todo - this information can be moved to dynamicEl to avoid frequent calls
1552
+ */
1553
+ isVideo(src, isHTML5VIdeo, index) {
1554
+ if (!src) {
1555
+ if (isHTML5VIdeo) {
1556
+ return {
1557
+ html5: true
1558
+ };
1559
+ } else {
1560
+ console.error(
1561
+ "lightGallery :- data-src is not provided on slide item " + (index + 1) + ". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/"
1562
+ );
1563
+ return;
1564
+ }
1565
+ }
1566
+ return getVideoInfo(src, false);
1567
+ }
1568
+ };
1569
+ var __defProp = Object.defineProperty;
1570
+ var __defProps = Object.defineProperties;
1571
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1572
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1573
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1574
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1575
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1576
+ var __spreadValues = (a, b) => {
1577
+ for (var prop in b || (b = {}))
1578
+ if (__hasOwnProp.call(b, prop))
1579
+ __defNormalProp(a, prop, b[prop]);
1580
+ if (__getOwnPropSymbols)
1581
+ for (var prop of __getOwnPropSymbols(b)) {
1582
+ if (__propIsEnum.call(b, prop))
1583
+ __defNormalProp(a, prop, b[prop]);
1584
+ }
1585
+ return a;
1586
+ };
1587
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1588
+ let lgId = 0;
1589
+ class LightGallery {
1590
+ constructor(element, options) {
1591
+ this.lgOpened = false;
1592
+ this.index = 0;
1593
+ this.plugins = [];
1594
+ this.lGalleryOn = false;
1595
+ this.lgBusy = false;
1596
+ this.defaultIcons = __spreadValues({}, coreDefaultIcons);
1597
+ this.swipeSamples = [];
1598
+ this.currentItemsInDom = [];
1599
+ this.prevScrollTop = 0;
1600
+ this.bodyPaddingRight = 0;
1601
+ this.isDummyImageRemoved = false;
1602
+ this.dragOrSwipeEnabled = false;
1603
+ this.mediaContainerPosition = {
1604
+ top: 0,
1605
+ bottom: 0
1606
+ };
1607
+ if (!element) {
1608
+ return this;
1609
+ }
1610
+ lgId++;
1611
+ this.lgId = lgId;
1612
+ this.el = element;
1613
+ this.LGel = $LG(element);
1614
+ this.generateSettings(options);
1615
+ this.buildModules();
1616
+ if (this.settings.dynamic && this.settings.dynamicEl !== void 0 && !Array.isArray(this.settings.dynamicEl)) {
1617
+ throw "When using dynamic mode, you must also define dynamicEl as an Array.";
1618
+ }
1619
+ this.galleryItems = this.getItems();
1620
+ this.normalizeSettings();
1621
+ this.init();
1622
+ this.validateLicense();
1623
+ return this;
1624
+ }
1625
+ generateSettings(options) {
1626
+ var _a;
1627
+ this.settings = __spreadProps(__spreadValues(__spreadValues({}, lightGalleryCoreSettings), options), {
1628
+ // Strings merge per-key (headless resolveSettings parity), // a partial override keeps every other default.
1629
+ strings: __spreadValues(__spreadValues({}, lightGalleryCoreSettings.strings), (_a = options == null ? void 0 : options.strings) != null ? _a : {})
1630
+ });
1631
+ if (this.settings.isMobile && typeof this.settings.isMobile === "function" ? this.settings.isMobile() : utils.isMobile()) {
1632
+ const mobileSettings = __spreadValues({}, this.settings.mobileSettings);
1633
+ this.settings = __spreadValues(__spreadValues({}, this.settings), mobileSettings);
1634
+ }
1635
+ if (typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
1636
+ this.settings = __spreadProps(__spreadValues({}, this.settings), {
1637
+ speed: 0,
1638
+ backdropDuration: 0,
1639
+ startAnimationDuration: 0,
1640
+ zoomFromOrigin: false,
1641
+ slideEndAnimation: false
1642
+ });
1643
+ }
1644
+ }
1645
+ normalizeSettings() {
1646
+ if (this.settings.direction === "auto") {
1647
+ this.settings.direction = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(this.el).direction === "rtl" ? "rtl" : "ltr";
1648
+ }
1649
+ if (this.settings.slideEndAnimation) {
1650
+ this.settings.hideControlOnEnd = false;
1651
+ }
1652
+ if (!this.settings.closable) {
1653
+ this.settings.swipeToClose = false;
1654
+ }
1655
+ this.zoomFromOrigin = this.settings.zoomFromOrigin;
1656
+ if (this.settings.dynamic) {
1657
+ this.zoomFromOrigin = false;
1658
+ }
1659
+ if (this.settings.container) {
1660
+ const { container } = this.settings;
1661
+ if (typeof container === "function") {
1662
+ this.settings.container = container();
1663
+ } else if (typeof container === "string") {
1664
+ const el = document.querySelector(container);
1665
+ this.settings.container = el != null ? el : document.body;
1666
+ }
1667
+ } else {
1668
+ this.settings.container = document.body;
1669
+ }
1670
+ this.settings.preload = Math.min(
1671
+ this.settings.preload,
1672
+ this.galleryItems.length
1673
+ );
1674
+ }
1675
+ init() {
1676
+ this.addSlideVideoInfo(this.galleryItems);
1677
+ this.buildStructure();
1678
+ this.LGel.trigger(lGEvents.init, {
1679
+ instance: this
1680
+ });
1681
+ if (this.settings.keyPress) {
1682
+ this.keyPress();
1683
+ }
1684
+ setTimeout(() => {
1685
+ this.enableDrag();
1686
+ this.enableSwipe();
1687
+ this.triggerPosterClick();
1688
+ }, 50);
1689
+ this.arrow();
1690
+ if (this.settings.mousewheel) {
1691
+ this.mousewheel();
1692
+ }
1693
+ if (!this.settings.dynamic) {
1694
+ this.openGalleryOnItemClick();
1695
+ }
1696
+ }
1697
+ openGalleryOnItemClick() {
1698
+ for (let index = 0; index < this.items.length; index++) {
1699
+ const element = this.items[index];
1700
+ const $element = $LG(element);
1701
+ const uuid = lgQuery.generateUUID();
1702
+ $element.attr("data-lg-id", uuid).on(`click.lgcustom-item-${uuid}`, (e) => {
1703
+ e.preventDefault();
1704
+ const currentItemIndex = this.settings.index || index;
1705
+ this.openGallery(currentItemIndex, element);
1706
+ });
1707
+ }
1708
+ }
1709
+ /**
1710
+ * Module constructor
1711
+ * Modules are build incrementally.
1712
+ * Gallery should be opened only once all the modules are initialized.
1713
+ * use moduleBuildTimeout to make sure this
1714
+ */
1715
+ buildModules() {
1716
+ this.settings.plugins.forEach((plugin) => {
1717
+ this.plugins.push(new plugin(this, $LG));
1718
+ });
1719
+ }
1720
+ validateLicense() {
1721
+ const notice = takeLicenseNotice(this.settings.licenseKey);
1722
+ if (notice) console[notice.level](notice.message);
1723
+ }
1724
+ getSlideItem(index) {
1725
+ return $LG(this.getSlideItemId(index));
1726
+ }
1727
+ getSlideItemId(index) {
1728
+ return `#lg-item-${this.lgId}-${index}`;
1729
+ }
1730
+ getIdName(id) {
1731
+ return `${id}-${this.lgId}`;
1732
+ }
1733
+ getElementById(id) {
1734
+ return $LG(`#${this.getIdName(id)}`);
1735
+ }
1736
+ manageSingleSlideClassName() {
1737
+ if (this.galleryItems.length < 2) {
1738
+ this.outer.addClass("lg-single-item");
1739
+ } else {
1740
+ this.outer.removeClass("lg-single-item");
1741
+ }
1742
+ }
1743
+ buildStructure() {
1744
+ const container = this.$container && this.$container.get();
1745
+ if (container) {
1746
+ return;
1747
+ }
1748
+ let controls = "";
1749
+ let subHtmlCont = "";
1750
+ if (this.settings.controls) {
1751
+ controls = `<button type="button" id="${this.getIdName(
1752
+ "lg-prev"
1753
+ )}" aria-label="${this.settings.strings["previousSlide"]}" class="lg-prev lg-icon"> ${this.settings.prevHtml} </button>
1754
+ <button type="button" id="${this.getIdName(
1755
+ "lg-next"
1756
+ )}" aria-label="${this.settings.strings["nextSlide"]}" class="lg-next lg-icon"> ${this.settings.nextHtml} </button>`;
1757
+ }
1758
+ if (this.settings.appendSubHtmlTo !== ".lg-item") {
1759
+ subHtmlCont = this.settings.ariaAnnouncements ? '<div class="lg-sub-html"></div>' : '<div class="lg-sub-html" role="status" aria-live="polite"></div>';
1760
+ }
1761
+ let addClasses = "";
1762
+ if (this.settings.allowMediaOverlap) {
1763
+ addClasses += "lg-media-overlap ";
1764
+ }
1765
+ const ariaLabelledby = this.settings.ariaLabelledby ? 'aria-labelledby="' + this.settings.ariaLabelledby + '"' : `aria-label="${this.settings.strings["galleryLabel"]}"`;
1766
+ const ariaDescribedby = this.settings.ariaDescribedby ? 'aria-describedby="' + this.settings.ariaDescribedby + '"' : "";
1767
+ const containerClassName = `lg-container ${this.settings.addClass} ${document.body !== this.settings.container ? "lg-inline" : ""}`;
1768
+ const closeIcon = this.settings.closable && this.settings.showCloseIcon ? `<button type="button" aria-label="${this.settings.strings["closeGallery"]}" id="${this.getIdName(
1769
+ "lg-close"
1770
+ )}" class="lg-close lg-icon"></button>` : "";
1771
+ const maximizeIcon = this.settings.showMaximizeIcon ? `<button type="button" aria-label="${this.settings.strings["toggleMaximize"]}" id="${this.getIdName(
1772
+ "lg-maximize"
1773
+ )}" class="lg-maximize lg-icon"></button>` : "";
1774
+ const template = `
1775
+ <div class="${containerClassName}" id="${this.getIdName(
1776
+ "lg-container"
1777
+ )}" tabindex="-1" aria-modal="true" ${ariaLabelledby} ${ariaDescribedby} role="dialog" dir="${this.getDirection()}"
1778
+ >
1779
+ <div id="${this.getIdName(
1780
+ "lg-backdrop"
1781
+ )}" class="lg-backdrop"></div>
1782
+ ${this.settings.ariaAnnouncements ? `<div id="${this.getIdName(
1783
+ "lg-announcer"
1784
+ )}" class="lg-announcer" role="status" aria-live="polite"></div>` : ""}
1785
+
1786
+ <div id="${this.getIdName(
1787
+ "lg-outer"
1788
+ )}" class="lg-outer lg-use-css3 lg-css3 lg-hide-items ${addClasses} ">
1789
+
1790
+ <div id="${this.getIdName("lg-content")}" class="lg-content">
1791
+ <div id="${this.getIdName("lg-inner")}" class="lg-inner">
1792
+ </div>
1793
+ ${controls}
1794
+ </div>
1795
+ <div id="${this.getIdName(
1796
+ "lg-toolbar"
1797
+ )}" class="lg-toolbar lg-group">
1798
+ ${maximizeIcon}
1799
+ ${closeIcon}
1800
+ </div>
1801
+ ${this.settings.appendSubHtmlTo === ".lg-outer" ? subHtmlCont : ""}
1802
+ <div id="${this.getIdName(
1803
+ "lg-components"
1804
+ )}" class="lg-components">
1805
+ ${this.settings.appendSubHtmlTo === ".lg-sub-html" ? subHtmlCont : ""}
1806
+ </div>
1807
+ </div>
1808
+ </div>
1809
+ `;
1810
+ $LG(this.settings.container).append(template);
1811
+ if (document.body !== this.settings.container) {
1812
+ $LG(this.settings.container).css("position", "relative");
1813
+ }
1814
+ this.outer = this.getElementById("lg-outer");
1815
+ this.$lgComponents = this.getElementById("lg-components");
1816
+ this.$backdrop = this.getElementById("lg-backdrop");
1817
+ this.$container = this.getElementById("lg-container");
1818
+ this.$inner = this.getElementById("lg-inner");
1819
+ this.$content = this.getElementById("lg-content");
1820
+ this.$toolbar = this.getElementById("lg-toolbar");
1821
+ this.$backdrop.css(
1822
+ "transition-duration",
1823
+ this.settings.backdropDuration + "ms"
1824
+ );
1825
+ let outerClassNames = `${this.settings.mode} `;
1826
+ this.manageSingleSlideClassName();
1827
+ if (this.settings.enableDrag) {
1828
+ outerClassNames += "lg-grab ";
1829
+ }
1830
+ this.outer.addClass(outerClassNames);
1831
+ this.$inner.css("transition-timing-function", this.settings.easing);
1832
+ this.$inner.css("transition-duration", this.settings.speed + "ms");
1833
+ this.$inner.css("--lg-speed", this.settings.speed + "ms");
1834
+ if (this.settings.download) {
1835
+ this.$toolbar.append(
1836
+ `<a id="${this.getIdName(
1837
+ "lg-download"
1838
+ )}" target="_blank" rel="noopener" aria-label="${this.settings.strings["download"]}" download class="lg-download lg-icon"></a>`
1839
+ );
1840
+ }
1841
+ this.counter();
1842
+ $LG(window).on(
1843
+ `resize.lg.global${this.lgId} orientationchange.lg.global${this.lgId}`,
1844
+ () => {
1845
+ this.refreshOnResize();
1846
+ }
1847
+ );
1848
+ this.hideBars();
1849
+ this.manageCloseGallery();
1850
+ this.toggleMaximize();
1851
+ this.initModules();
1852
+ if (this.settings.toolbarOverflow) {
1853
+ this.toolbarOverflow = new ToolbarOverflow(this.$toolbar.get(), {
1854
+ id: this.getIdName("lg-more"),
1855
+ label: this.settings.strings.moreOptions
1856
+ });
1857
+ const update = () => {
1858
+ var _a;
1859
+ return (_a = this.toolbarOverflow) == null ? void 0 : _a.update();
1860
+ };
1861
+ this.LGel.on(`${lGEvents.afterOpen}.lg`, update);
1862
+ this.LGel.on(`${lGEvents.afterSlide}.lg`, update);
1863
+ this.LGel.on(`${lGEvents.containerResize}.lg`, update);
1864
+ this.LGel.on(
1865
+ `${lGEvents.beforeClose}.lg`,
1866
+ () => {
1867
+ var _a;
1868
+ return (_a = this.toolbarOverflow) == null ? void 0 : _a.close(false);
1869
+ }
1870
+ );
1871
+ }
1872
+ applyCustomIcons(
1873
+ this.$container.get(),
1874
+ this.defaultIcons,
1875
+ this.settings.icons
1876
+ );
1877
+ }
1878
+ /**
1879
+ * Merge a plugin's built-in icon SVGs into the default set (called
1880
+ * from plugin `init()`, before the icon pass runs). Consumer
1881
+ * `settings.icons` still win over anything registered here.
1882
+ */
1883
+ registerDefaultIcons(icons) {
1884
+ this.defaultIcons = __spreadValues(__spreadValues({}, this.defaultIcons), icons);
1885
+ }
1886
+ /**
1887
+ * Cache the fitted (contain) size of a slide's media. Every consumer
1888
+ * of `currentImageSize` measures against the CURRENT slide: the
1889
+ * actual-size zoom divides the natural width by it, and the
1890
+ * zoom-from-origin close flight positions against it. Recomputed on
1891
+ * every slide change, not just at open — one cached landscape size
1892
+ * makes a portrait slide zoom to the wrong scale and then snap to
1893
+ * its real size when the natural-px swap lands.
1894
+ */
1895
+ updateCurrentImageSize(index) {
1896
+ const { __slideVideoInfo } = this.galleryItems[index];
1897
+ const { top, bottom } = this.mediaContainerPosition;
1898
+ this.currentImageSize = utils.getSize(
1899
+ this.items[index],
1900
+ this.outer,
1901
+ top + bottom,
1902
+ __slideVideoInfo && this.settings.videoMaxSize
1903
+ );
1904
+ }
1905
+ refreshOnResize() {
1906
+ if (this.lgOpened) {
1907
+ const currentGalleryItem = this.galleryItems[this.index];
1908
+ const { __slideVideoInfo } = currentGalleryItem;
1909
+ this.mediaContainerPosition = this.getMediaContainerPosition();
1910
+ this.updateCurrentImageSize(this.index);
1911
+ if (__slideVideoInfo) {
1912
+ this.resizeVideoSlide(this.index, this.currentImageSize);
1913
+ }
1914
+ if (this.zoomFromOrigin && !this.isDummyImageRemoved) {
1915
+ const imgStyle = this.getDummyImgStyles(this.currentImageSize);
1916
+ this.outer.find(".lg-current .lg-dummy-img").first().attr("style", imgStyle);
1917
+ }
1918
+ this.LGel.trigger(lGEvents.containerResize);
1919
+ }
1920
+ }
1921
+ resizeVideoSlide(index, imageSize) {
1922
+ const lgVideoStyle = this.getVideoContStyle(imageSize);
1923
+ const currentSlide = this.getSlideItem(index);
1924
+ currentSlide.find(".lg-video-cont").attr("style", lgVideoStyle);
1925
+ }
1926
+ /**
1927
+ * Update slides dynamically.
1928
+ * Add, edit or delete slides dynamically when lightGallery is opened.
1929
+ * Modify the current gallery items and pass it via updateSlides method
1930
+ * @note
1931
+ * - Do not mutate existing lightGallery items directly.
1932
+ * - Always pass new list of gallery items
1933
+ * - You need to take care of thumbnails outside the gallery if any
1934
+ * - user this method only if you want to update slides when the gallery is opened. Otherwise, use `refresh()` method.
1935
+ * @param items Gallery items
1936
+ * @param index After the update operation, which slide gallery should navigate to
1937
+ * @category lGPublicMethods
1938
+ * @example
1939
+ * const plugin = lightGallery();
1940
+ *
1941
+ * // Adding slides dynamically
1942
+ * let galleryItems = [
1943
+ * // Access existing lightGallery items
1944
+ * // galleryItems are automatically generated internally from the gallery HTML markup
1945
+ * // or directly from galleryItems when dynamic gallery is used
1946
+ * ...plugin.galleryItems,
1947
+ * ...[
1948
+ * {
1949
+ * src: 'img/img-1.png',
1950
+ * thumb: 'img/thumb1.png',
1951
+ * },
1952
+ * ],
1953
+ * ];
1954
+ * plugin.updateSlides(
1955
+ * galleryItems,
1956
+ * plugin.index,
1957
+ * );
1958
+ *
1959
+ *
1960
+ * // Remove slides dynamically
1961
+ * galleryItems = JSON.parse(
1962
+ * JSON.stringify(updateSlideInstance.galleryItems),
1963
+ * );
1964
+ * galleryItems.shift();
1965
+ * updateSlideInstance.updateSlides(galleryItems, 1);
1966
+ * @see <a href="/demos/update-slides/">Demo</a>
1967
+ */
1968
+ updateSlides(items, index) {
1969
+ if (this.index > items.length - 1) {
1970
+ this.index = items.length - 1;
1971
+ }
1972
+ if (items.length === 1) {
1973
+ this.index = 0;
1974
+ }
1975
+ if (!items.length) {
1976
+ this.closeGallery();
1977
+ return;
1978
+ }
1979
+ const currentSrc = this.galleryItems[index].src;
1980
+ this.galleryItems = items;
1981
+ this.updateControls();
1982
+ this.$inner.empty();
1983
+ this.currentItemsInDom = [];
1984
+ let _index = 0;
1985
+ this.galleryItems.some((galleryItem, itemIndex) => {
1986
+ if (galleryItem.src === currentSrc) {
1987
+ _index = itemIndex;
1988
+ return true;
1989
+ }
1990
+ return false;
1991
+ });
1992
+ this.currentItemsInDom = this.organizeSlideItems(_index, -1);
1993
+ this.loadContent(_index, true);
1994
+ this.getSlideItem(_index).addClass("lg-current");
1995
+ this.index = _index;
1996
+ this.updateCurrentCounter(_index);
1997
+ this.LGel.trigger(lGEvents.updateSlides);
1998
+ }
1999
+ // Get gallery items based on multiple conditions
2000
+ getItems() {
2001
+ this.items = [];
2002
+ if (!this.settings.dynamic) {
2003
+ if (this.settings.selector === "this") {
2004
+ this.items.push(this.el);
2005
+ } else if (this.settings.selector) {
2006
+ if (typeof this.settings.selector === "string") {
2007
+ if (this.settings.selectWithin) {
2008
+ const selectWithin = $LG(this.settings.selectWithin);
2009
+ this.items = selectWithin.find(this.settings.selector).get();
2010
+ } else {
2011
+ this.items = this.el.querySelectorAll(
2012
+ this.settings.selector
2013
+ );
2014
+ }
2015
+ } else {
2016
+ this.items = this.settings.selector;
2017
+ }
2018
+ } else {
2019
+ this.items = this.el.children;
2020
+ }
2021
+ return utils.getDynamicOptions(
2022
+ this.items,
2023
+ this.settings.extraProps,
2024
+ this.settings.getCaptionFromTitleOrAlt,
2025
+ this.settings.exThumbImage
2026
+ );
2027
+ } else {
2028
+ return this.settings.dynamicEl || [];
2029
+ }
2030
+ }
2031
+ shouldHideScrollbar() {
2032
+ return this.settings.hideScrollbar && document.body === this.settings.container;
2033
+ }
2034
+ hideScrollbar() {
2035
+ if (!this.shouldHideScrollbar()) {
2036
+ return;
2037
+ }
2038
+ this.bodyPaddingRight = parseFloat($LG("body").style().paddingRight);
2039
+ const bodyRect = document.documentElement.getBoundingClientRect();
2040
+ const scrollbarWidth = window.innerWidth - bodyRect.width;
2041
+ $LG(document.body).css(
2042
+ "padding-right",
2043
+ scrollbarWidth + this.bodyPaddingRight + "px"
2044
+ );
2045
+ $LG(document.body).addClass("lg-overlay-open");
2046
+ }
2047
+ resetScrollBar() {
2048
+ if (!this.shouldHideScrollbar()) {
2049
+ return;
2050
+ }
2051
+ $LG(document.body).css("padding-right", this.bodyPaddingRight + "px");
2052
+ $LG(document.body).removeClass("lg-overlay-open");
2053
+ }
2054
+ /**
2055
+ * Open lightGallery.
2056
+ * Open gallery with specific slide by passing index of the slide as parameter.
2057
+ * @category lGPublicMethods
2058
+ * @param {Number} index - index of the slide
2059
+ * @param {HTMLElement} element - Which image lightGallery should zoom from
2060
+ *
2061
+ * @example
2062
+ * const $dynamicGallery = document.getElementById('dynamic-gallery-demo');
2063
+ * const dynamicGallery = lightGallery($dynamicGallery, {
2064
+ * dynamic: true,
2065
+ * dynamicEl: [
2066
+ * {
2067
+ * src: 'img/1.jpg',
2068
+ * thumb: 'img/thumb-1.jpg',
2069
+ * subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
2070
+ * },
2071
+ * ...
2072
+ * ],
2073
+ * });
2074
+ * $dynamicGallery.addEventListener('click', function () {
2075
+ * // Starts with third item.(Optional).
2076
+ * // This is useful if you want use dynamic mode with
2077
+ * // custom thumbnails (thumbnails outside gallery),
2078
+ * dynamicGallery.openGallery(2);
2079
+ * });
2080
+ *
2081
+ */
2082
+ openGallery(index = this.settings.index, element) {
2083
+ if (this.lgOpened) return;
2084
+ this.lgOpened = true;
2085
+ this.outer.removeClass("lg-hide-items");
2086
+ this.hideScrollbar();
2087
+ this.$container.addClass("lg-show");
2088
+ const itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(
2089
+ index,
2090
+ index
2091
+ );
2092
+ this.currentItemsInDom = itemsToBeInsertedToDom;
2093
+ let items = "";
2094
+ itemsToBeInsertedToDom.forEach((item) => {
2095
+ items = items + `<div id="${item}" class="lg-item"></div>`;
2096
+ });
2097
+ this.$inner.append(items);
2098
+ this.addHtml(index);
2099
+ let transform = "";
2100
+ this.mediaContainerPosition = this.getMediaContainerPosition();
2101
+ const { top, bottom } = this.mediaContainerPosition;
2102
+ if (!this.settings.allowMediaOverlap) {
2103
+ this.setMediaContainerPosition(top, bottom);
2104
+ }
2105
+ const { __slideVideoInfo } = this.galleryItems[index];
2106
+ if (this.zoomFromOrigin && element) {
2107
+ this.currentImageSize = utils.getSize(
2108
+ element,
2109
+ this.outer,
2110
+ top + bottom,
2111
+ __slideVideoInfo && this.settings.videoMaxSize
2112
+ );
2113
+ transform = this.getOriginTransform(element, this.currentImageSize);
2114
+ }
2115
+ if (!this.zoomFromOrigin || !transform) {
2116
+ this.outer.addClass(this.settings.startClass);
2117
+ this.getSlideItem(index).removeClass("lg-complete");
2118
+ }
2119
+ const timeout = this.settings.zoomFromOrigin ? 100 : this.settings.backdropDuration;
2120
+ setTimeout(() => {
2121
+ this.outer.addClass("lg-components-open");
2122
+ }, timeout);
2123
+ this.index = index;
2124
+ this.LGel.trigger(lGEvents.beforeOpen);
2125
+ this.getSlideItem(index).addClass("lg-current");
2126
+ this.lGalleryOn = false;
2127
+ this.prevScrollTop = $LG(window).scrollTop();
2128
+ if (this.settings.trapFocus && document.body === this.settings.container) {
2129
+ this.prevActiveElement = document.activeElement instanceof HTMLElement ? document.activeElement : void 0;
2130
+ }
2131
+ setTimeout(() => {
2132
+ if (this.zoomFromOrigin && transform) {
2133
+ const currentSlide = this.getSlideItem(index);
2134
+ currentSlide.css("transform", transform);
2135
+ setTimeout(() => {
2136
+ currentSlide.addClass("lg-start-progress lg-start-end-progress").css(
2137
+ "transition-duration",
2138
+ this.settings.startAnimationDuration + "ms"
2139
+ );
2140
+ this.outer.addClass("lg-zoom-from-image");
2141
+ });
2142
+ setTimeout(() => {
2143
+ currentSlide.css("transform", "translate3d(0, 0, 0)");
2144
+ }, 100);
2145
+ }
2146
+ setTimeout(() => {
2147
+ this.$backdrop.addClass("in");
2148
+ this.$container.addClass("lg-show-in");
2149
+ }, 10);
2150
+ setTimeout(() => {
2151
+ if (this.settings.trapFocus && document.body === this.settings.container) {
2152
+ this.trapFocus();
2153
+ }
2154
+ }, this.settings.backdropDuration + 50);
2155
+ if (!this.zoomFromOrigin || !transform) {
2156
+ setTimeout(() => {
2157
+ this.outer.addClass("lg-visible");
2158
+ }, this.settings.backdropDuration);
2159
+ }
2160
+ this.slide(index, false, false, false);
2161
+ this.LGel.trigger(lGEvents.afterOpen);
2162
+ });
2163
+ if (document.body === this.settings.container) {
2164
+ $LG("html").addClass("lg-on");
2165
+ }
2166
+ }
2167
+ /**
2168
+ * The zoom-from-origin transform for a trigger: it lands the slide on
2169
+ * the trigger's thumbnail, the start of the opening flight and the end
2170
+ * of the closing one. Undefined when the trigger cannot anchor a flight,
2171
+ * and the gallery opens or closes about the stage centre instead.
2172
+ * Plugins may replace it on the instance to fly differently.
2173
+ */
2174
+ getOriginTransform(element, imageSize) {
2175
+ const { top, bottom } = this.mediaContainerPosition;
2176
+ return utils.getTransform(element, this.outer, top, bottom, imageSize);
2177
+ }
2178
+ /**
2179
+ * Note - Changing the position of the media on every slide transition creates a flickering effect.
2180
+ * Therefore, The height of the caption is calculated dynamically, only once based on the first slide caption.
2181
+ * if you have dynamic captions for each media,
2182
+ * you can provide an appropriate height for the captions via allowMediaOverlap option
2183
+ */
2184
+ getMediaContainerPosition() {
2185
+ if (this.settings.allowMediaOverlap) {
2186
+ return {
2187
+ top: 0,
2188
+ bottom: 0
2189
+ };
2190
+ }
2191
+ const top = this.$toolbar.get().clientHeight || 0;
2192
+ const subHtml = this.outer.find(".lg-components .lg-sub-html").get();
2193
+ const captionHeight = this.settings.defaultCaptionHeight || subHtml && subHtml.clientHeight || 0;
2194
+ const thumbContainer = this.outer.find(".lg-thumb-outer").get();
2195
+ const thumbHeight = thumbContainer ? thumbContainer.clientHeight : 0;
2196
+ const bottom = thumbHeight + captionHeight;
2197
+ return {
2198
+ top,
2199
+ bottom
2200
+ };
2201
+ }
2202
+ setMediaContainerPosition(top = 0, bottom = 0) {
2203
+ this.$content.css("top", top + "px").css("bottom", bottom + "px");
2204
+ }
2205
+ hideBars() {
2206
+ setTimeout(() => {
2207
+ this.outer.removeClass("lg-hide-items");
2208
+ if (this.settings.hideBarsDelay > 0) {
2209
+ this.outer.on("mousemove.lg click.lg touchstart.lg", () => {
2210
+ this.outer.removeClass("lg-hide-items");
2211
+ clearTimeout(this.hideBarTimeout);
2212
+ this.hideBarTimeout = setTimeout(() => {
2213
+ this.outer.addClass("lg-hide-items");
2214
+ }, this.settings.hideBarsDelay);
2215
+ });
2216
+ this.outer.trigger("mousemove.lg");
2217
+ }
2218
+ }, this.settings.showBarsAfter);
2219
+ }
2220
+ initPictureFill($img) {
2221
+ if (this.settings.supportLegacyBrowser) {
2222
+ try {
2223
+ picturefill({
2224
+ elements: [$img.get()]
2225
+ });
2226
+ } catch (e) {
2227
+ console.warn(
2228
+ "lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document. See https://www.lightgalleryjs.com/docs/responsive-loading/"
2229
+ );
2230
+ }
2231
+ }
2232
+ }
2233
+ /**
2234
+ * @desc Create image counter
2235
+ * Ex: 1/10
2236
+ */
2237
+ counter() {
2238
+ if (this.settings.counter) {
2239
+ const counterA11yAttrs = this.settings.ariaAnnouncements ? 'aria-hidden="true"' : 'role="status" aria-live="polite"';
2240
+ const counterHtml = `<div class="lg-counter" ${counterA11yAttrs}>
2241
+ <span id="${this.getIdName(
2242
+ "lg-counter-current"
2243
+ )}" class="lg-counter-current">${this.index + 1} </span> /
2244
+ <span id="${this.getIdName(
2245
+ "lg-counter-all"
2246
+ )}" class="lg-counter-all">${this.galleryItems.length} </span></div>`;
2247
+ this.outer.find(this.settings.appendCounterTo).append(counterHtml);
2248
+ }
2249
+ }
2250
+ /**
2251
+ * @desc add sub-html into the slide
2252
+ * @param {Number} index - index of the slide
2253
+ */
2254
+ addHtml(index) {
2255
+ let subHtml;
2256
+ let subHtmlUrl;
2257
+ if (this.galleryItems[index].subHtmlUrl) {
2258
+ subHtmlUrl = this.galleryItems[index].subHtmlUrl;
2259
+ } else {
2260
+ subHtml = this.galleryItems[index].subHtml;
2261
+ }
2262
+ if (!subHtmlUrl) {
2263
+ if (subHtml) {
2264
+ const fL = subHtml.substring(0, 1);
2265
+ if (fL === "." || fL === "#") {
2266
+ try {
2267
+ if (this.settings.subHtmlSelectorRelative && !this.settings.dynamic) {
2268
+ subHtml = $LG(this.items).eq(index).find(subHtml).first().html();
2269
+ } else {
2270
+ subHtml = $LG(subHtml).first().html();
2271
+ }
2272
+ } catch (error) {
2273
+ console.warn(
2274
+ `lightGallery: error processing subHtml selector "${subHtml}". See https://www.lightgalleryjs.com/demos/captions/`
2275
+ );
2276
+ subHtml = "";
2277
+ }
2278
+ }
2279
+ } else {
2280
+ subHtml = "";
2281
+ }
2282
+ }
2283
+ if (this.settings.appendSubHtmlTo !== ".lg-item") {
2284
+ if (subHtmlUrl) {
2285
+ utils.fetchCaptionFromUrl(
2286
+ subHtmlUrl,
2287
+ this.outer.find(".lg-sub-html"),
2288
+ "replace"
2289
+ );
2290
+ } else {
2291
+ this.outer.find(".lg-sub-html").html(subHtml);
2292
+ }
2293
+ } else {
2294
+ const currentSlide = $LG(this.getSlideItemId(index));
2295
+ if (subHtmlUrl) {
2296
+ utils.fetchCaptionFromUrl(subHtmlUrl, currentSlide, "append");
2297
+ } else {
2298
+ currentSlide.append(
2299
+ `<div class="lg-sub-html">${subHtml}</div>`
2300
+ );
2301
+ }
2302
+ }
2303
+ if (typeof subHtml !== "undefined" && subHtml !== null) {
2304
+ if (subHtml === "") {
2305
+ this.outer.find(this.settings.appendSubHtmlTo).addClass("lg-empty-html");
2306
+ } else {
2307
+ this.outer.find(this.settings.appendSubHtmlTo).removeClass("lg-empty-html");
2308
+ }
2309
+ }
2310
+ this.LGel.trigger(
2311
+ lGEvents.afterAppendSubHtml,
2312
+ {
2313
+ index
2314
+ }
2315
+ );
2316
+ }
2317
+ /**
2318
+ * @desc Preload slides
2319
+ * @param {Number} index - index of the slide
2320
+ * @todo preload not working for the first slide, Also, should work for the first and last slide as well
2321
+ */
2322
+ preload(index) {
2323
+ for (let i = 1; i <= this.settings.preload; i++) {
2324
+ if (i >= this.galleryItems.length - index) {
2325
+ break;
2326
+ }
2327
+ this.loadContent(index + i, false);
2328
+ }
2329
+ for (let j = 1; j <= this.settings.preload; j++) {
2330
+ if (index - j < 0) {
2331
+ break;
2332
+ }
2333
+ this.loadContent(index - j, false);
2334
+ }
2335
+ }
2336
+ getDummyImgStyles(imageSize) {
2337
+ if (!imageSize) return "";
2338
+ return `width:${imageSize.width}px;
2339
+ margin-left: -${imageSize.width / 2}px;
2340
+ margin-top: -${imageSize.height / 2}px;
2341
+ height:${imageSize.height}px`;
2342
+ }
2343
+ getVideoContStyle(imageSize) {
2344
+ if (!imageSize) return "";
2345
+ return `width:${imageSize.width}px;
2346
+ height:${imageSize.height}px`;
2347
+ }
2348
+ getDummyImageContent($currentSlide, index, alt) {
2349
+ let $currentItem;
2350
+ if (!this.settings.dynamic) {
2351
+ $currentItem = $LG(this.items).eq(index);
2352
+ }
2353
+ if ($currentItem) {
2354
+ let _dummyImgSrc;
2355
+ if (!this.settings.exThumbImage) {
2356
+ _dummyImgSrc = $currentItem.find("img").first().attr("src");
2357
+ } else {
2358
+ _dummyImgSrc = $currentItem.attr(this.settings.exThumbImage);
2359
+ }
2360
+ if (!_dummyImgSrc) return "";
2361
+ const imgStyle = this.getDummyImgStyles(this.currentImageSize);
2362
+ const dummyImgContentImg = document.createElement("img");
2363
+ dummyImgContentImg.alt = alt || "";
2364
+ dummyImgContentImg.src = _dummyImgSrc;
2365
+ dummyImgContentImg.className = `lg-dummy-img`;
2366
+ dummyImgContentImg.style.cssText = imgStyle;
2367
+ $currentSlide.addClass("lg-first-slide");
2368
+ this.outer.addClass("lg-first-slide-loading");
2369
+ return dummyImgContentImg;
2370
+ }
2371
+ return "";
2372
+ }
2373
+ setImgMarkup(src, $currentSlide, index) {
2374
+ const currentGalleryItem = this.galleryItems[index];
2375
+ const { alt, srcset, sizes, sources } = currentGalleryItem;
2376
+ let imgContent = "";
2377
+ const altAttr = alt ? 'alt="' + alt + '"' : "";
2378
+ if (this.isFirstSlideWithZoomAnimation()) {
2379
+ imgContent = this.getDummyImageContent(
2380
+ $currentSlide,
2381
+ index,
2382
+ altAttr
2383
+ );
2384
+ } else {
2385
+ imgContent = utils.getImgMarkup(
2386
+ index,
2387
+ src,
2388
+ altAttr,
2389
+ srcset,
2390
+ sizes,
2391
+ sources
2392
+ );
2393
+ }
2394
+ const picture = document.createElement("picture");
2395
+ picture.className = "lg-img-wrap";
2396
+ $LG(picture).append(imgContent);
2397
+ $currentSlide.prepend(picture);
2398
+ }
2399
+ onSlideObjectLoad($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
2400
+ const mediaObject = $slide.find(".lg-object").first();
2401
+ const media = mediaObject.get();
2402
+ const gated = (handler) => {
2403
+ if (media instanceof HTMLImageElement && typeof media.decode === "function") {
2404
+ void awaitDecode(media).then(handler);
2405
+ } else {
2406
+ handler();
2407
+ }
2408
+ };
2409
+ if (utils.isImageLoaded(media) || isHTML5VideoWithoutPoster) {
2410
+ gated(onLoad);
2411
+ } else {
2412
+ mediaObject.on("load.lg error.lg", () => {
2413
+ gated(() => onLoad && onLoad());
2414
+ });
2415
+ mediaObject.on("error.lg", () => {
2416
+ onError && onError();
2417
+ });
2418
+ }
2419
+ }
2420
+ /**
2421
+ *
2422
+ * @param $el Current slide item
2423
+ * @param index
2424
+ * @param delay Delay is 0 except first time
2425
+ * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
2426
+ * @param isFirstSlide
2427
+ */
2428
+ onLgObjectLoad(currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
2429
+ this.onSlideObjectLoad(
2430
+ currentSlide,
2431
+ isHTML5VideoWithoutPoster,
2432
+ () => {
2433
+ this.triggerSlideItemLoad(
2434
+ currentSlide,
2435
+ index,
2436
+ delay,
2437
+ speed,
2438
+ isFirstSlide
2439
+ );
2440
+ },
2441
+ () => {
2442
+ currentSlide.addClass("lg-complete lg-complete_");
2443
+ currentSlide.html(
2444
+ '<span class="lg-error-msg">' + this.settings.strings["mediaLoadingFailed"] + "</span>"
2445
+ );
2446
+ }
2447
+ );
2448
+ }
2449
+ triggerSlideItemLoad($currentSlide, index, delay, speed, isFirstSlide) {
2450
+ const currentGalleryItem = this.galleryItems[index];
2451
+ const _speed = isFirstSlide && this.getSlideType(currentGalleryItem) === "video" && !currentGalleryItem.poster ? speed : 0;
2452
+ setTimeout(() => {
2453
+ $currentSlide.addClass("lg-complete lg-complete_");
2454
+ this.LGel.trigger(lGEvents.slideItemLoad, {
2455
+ index,
2456
+ delay: delay || 0,
2457
+ isFirstSlide
2458
+ });
2459
+ }, _speed);
2460
+ }
2461
+ isFirstSlideWithZoomAnimation() {
2462
+ return !!(!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize);
2463
+ }
2464
+ // Add video slideInfo
2465
+ addSlideVideoInfo(items) {
2466
+ items.forEach((element, index) => {
2467
+ element.__slideVideoInfo = utils.isVideo(
2468
+ element.src,
2469
+ !!element.video,
2470
+ index
2471
+ );
2472
+ const videoInfo = element.__slideVideoInfo;
2473
+ if (!videoInfo) {
2474
+ return;
2475
+ }
2476
+ if (this.settings.videoFacade !== false) {
2477
+ element.poster = getFacadePoster(
2478
+ element,
2479
+ videoInfo,
2480
+ this.settings.loadYouTubePoster
2481
+ );
2482
+ } else if (this.settings.loadYouTubePoster && !element.poster && videoInfo.youtube) {
2483
+ element.poster = getYouTubePosterUrl(videoInfo);
2484
+ }
2485
+ });
2486
+ }
2487
+ /**
2488
+ * Load slide content into slide.
2489
+ * This is used to load content into slides that is not visible too
2490
+ * @param {Number} index - index of the slide.
2491
+ * @param {Boolean} rec - if true call loadcontent() function again.
2492
+ */
2493
+ loadContent(index, rec) {
2494
+ const currentGalleryItem = this.galleryItems[index];
2495
+ const $currentSlide = $LG(this.getSlideItemId(index));
2496
+ const { poster, srcset, sizes, sources } = currentGalleryItem;
2497
+ let { src } = currentGalleryItem;
2498
+ const video = currentGalleryItem.video;
2499
+ const _html5Video = video && typeof video === "string" ? JSON.parse(video) : video;
2500
+ if (currentGalleryItem.responsive) {
2501
+ const srcDyItms = currentGalleryItem.responsive.split(",");
2502
+ src = utils.getResponsiveSrc(srcDyItms) || src;
2503
+ }
2504
+ const videoInfo = currentGalleryItem.__slideVideoInfo;
2505
+ let lgVideoStyle = "";
2506
+ const iframe = !!currentGalleryItem.iframe;
2507
+ const isFirstSlide = !this.lGalleryOn;
2508
+ let delay = 0;
2509
+ if (isFirstSlide) {
2510
+ if (this.zoomFromOrigin && this.currentImageSize) {
2511
+ delay = this.settings.startAnimationDuration + 10;
2512
+ } else {
2513
+ delay = this.settings.backdropDuration + 10;
2514
+ }
2515
+ }
2516
+ if (!$currentSlide.hasClass("lg-loaded")) {
2517
+ if (videoInfo) {
2518
+ const { top, bottom } = this.mediaContainerPosition;
2519
+ const videoSize = utils.getSize(
2520
+ this.items[index],
2521
+ this.outer,
2522
+ top + bottom,
2523
+ videoInfo && this.settings.videoMaxSize
2524
+ );
2525
+ lgVideoStyle = this.getVideoContStyle(videoSize);
2526
+ }
2527
+ if (iframe) {
2528
+ const markup = utils.getIframeMarkup(
2529
+ this.settings.iframeWidth,
2530
+ this.settings.iframeHeight,
2531
+ this.settings.iframeMaxWidth,
2532
+ this.settings.iframeMaxHeight,
2533
+ src,
2534
+ currentGalleryItem.iframeTitle
2535
+ );
2536
+ $currentSlide.prepend(markup);
2537
+ } else if (poster) {
2538
+ let dummyImg = "";
2539
+ const hasStartAnimation = isFirstSlide && this.zoomFromOrigin && this.currentImageSize;
2540
+ if (hasStartAnimation) {
2541
+ dummyImg = this.getDummyImageContent(
2542
+ $currentSlide,
2543
+ index,
2544
+ ""
2545
+ );
2546
+ }
2547
+ const markup = utils.getVideoPosterMarkup(
2548
+ poster,
2549
+ dummyImg || "",
2550
+ lgVideoStyle,
2551
+ this.settings.strings["playVideo"],
2552
+ videoInfo
2553
+ );
2554
+ $currentSlide.prepend(markup);
2555
+ } else if (videoInfo) {
2556
+ const markup = `<div class="lg-video-cont " style="${lgVideoStyle}"></div>`;
2557
+ $currentSlide.prepend(markup);
2558
+ } else {
2559
+ this.setImgMarkup(src, $currentSlide, index);
2560
+ if (srcset || sources) {
2561
+ const $img = $currentSlide.find(".lg-object");
2562
+ this.initPictureFill($img);
2563
+ }
2564
+ }
2565
+ if (poster || videoInfo) {
2566
+ this.LGel.trigger(lGEvents.hasVideo, {
2567
+ index,
2568
+ src,
2569
+ html5Video: _html5Video,
2570
+ hasPoster: !!poster
2571
+ });
2572
+ }
2573
+ this.LGel.trigger(
2574
+ lGEvents.afterAppendSlide,
2575
+ { index }
2576
+ );
2577
+ if (this.lGalleryOn && this.settings.appendSubHtmlTo === ".lg-item") {
2578
+ this.addHtml(index);
2579
+ }
2580
+ }
2581
+ let _speed = 0;
2582
+ if (delay && !$LG(document.body).hasClass("lg-from-hash")) {
2583
+ _speed = delay;
2584
+ }
2585
+ if (this.isFirstSlideWithZoomAnimation()) {
2586
+ const settleFlight = (onLanded) => onTransitionSettle(
2587
+ $currentSlide.get(),
2588
+ "transform",
2589
+ this.settings.startAnimationDuration + 100,
2590
+ onLanded
2591
+ );
2592
+ settleFlight(() => {
2593
+ $currentSlide.removeClass("lg-start-end-progress lg-start-progress").removeAttr("style");
2594
+ });
2595
+ if (!$currentSlide.hasClass("lg-loaded")) {
2596
+ settleFlight(() => {
2597
+ if (this.getSlideType(currentGalleryItem) === "image") {
2598
+ const { alt } = currentGalleryItem;
2599
+ const altAttr = alt ? 'alt="' + alt + '"' : "";
2600
+ $currentSlide.find(".lg-img-wrap").append(
2601
+ utils.getImgMarkup(
2602
+ index,
2603
+ src,
2604
+ altAttr,
2605
+ srcset,
2606
+ sizes,
2607
+ currentGalleryItem.sources
2608
+ )
2609
+ );
2610
+ if (srcset || sources) {
2611
+ const $img = $currentSlide.find(".lg-object");
2612
+ this.initPictureFill($img);
2613
+ }
2614
+ }
2615
+ if (this.getSlideType(currentGalleryItem) === "image" || this.getSlideType(currentGalleryItem) === "video" && poster) {
2616
+ this.onLgObjectLoad(
2617
+ $currentSlide,
2618
+ index,
2619
+ delay,
2620
+ _speed,
2621
+ true,
2622
+ false
2623
+ );
2624
+ this.onSlideObjectLoad(
2625
+ $currentSlide,
2626
+ !!(videoInfo && videoInfo.html5 && !poster),
2627
+ () => {
2628
+ this.loadContentOnFirstSlideLoad(
2629
+ index,
2630
+ $currentSlide,
2631
+ _speed
2632
+ );
2633
+ },
2634
+ () => {
2635
+ this.loadContentOnFirstSlideLoad(
2636
+ index,
2637
+ $currentSlide,
2638
+ _speed
2639
+ );
2640
+ }
2641
+ );
2642
+ }
2643
+ });
2644
+ }
2645
+ }
2646
+ $currentSlide.addClass("lg-loaded");
2647
+ if (!this.isFirstSlideWithZoomAnimation() || this.getSlideType(currentGalleryItem) === "video" && !poster) {
2648
+ this.onLgObjectLoad(
2649
+ $currentSlide,
2650
+ index,
2651
+ delay,
2652
+ _speed,
2653
+ isFirstSlide,
2654
+ !!(videoInfo && videoInfo.html5 && !poster)
2655
+ );
2656
+ }
2657
+ if ((!this.zoomFromOrigin || !this.currentImageSize) && $currentSlide.hasClass("lg-complete_") && !this.lGalleryOn) {
2658
+ setTimeout(() => {
2659
+ $currentSlide.addClass("lg-complete");
2660
+ }, this.settings.backdropDuration);
2661
+ }
2662
+ this.lGalleryOn = true;
2663
+ if (rec === true) {
2664
+ if (!$currentSlide.hasClass("lg-complete_")) {
2665
+ $currentSlide.find(".lg-object").first().on("load.lg error.lg", () => {
2666
+ this.preload(index);
2667
+ });
2668
+ } else {
2669
+ this.preload(index);
2670
+ }
2671
+ }
2672
+ }
2673
+ /**
2674
+ * @desc Remove dummy image content and load next slides
2675
+ * Called only for the first time if zoomFromOrigin animation is enabled
2676
+ * @param index
2677
+ * @param $currentSlide
2678
+ * @param speed
2679
+ */
2680
+ loadContentOnFirstSlideLoad(index, $currentSlide, speed) {
2681
+ setTimeout(() => {
2682
+ $currentSlide.find(".lg-dummy-img").remove();
2683
+ $currentSlide.removeClass("lg-first-slide");
2684
+ this.outer.removeClass("lg-first-slide-loading");
2685
+ this.isDummyImageRemoved = true;
2686
+ this.preload(index);
2687
+ }, speed + 300);
2688
+ }
2689
+ getItemsToBeInsertedToDom(index, prevIndex, numberOfItems = 0) {
2690
+ const itemsToBeInsertedToDom = [];
2691
+ let possibleNumberOfItems = Math.max(numberOfItems, 3);
2692
+ possibleNumberOfItems = Math.min(
2693
+ possibleNumberOfItems,
2694
+ this.galleryItems.length
2695
+ );
2696
+ const prevIndexItem = `lg-item-${this.lgId}-${prevIndex}`;
2697
+ if (this.galleryItems.length <= 3) {
2698
+ this.galleryItems.forEach((_element, index2) => {
2699
+ itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${index2}`);
2700
+ });
2701
+ return itemsToBeInsertedToDom;
2702
+ }
2703
+ if (index < (this.galleryItems.length - 1) / 2) {
2704
+ for (let idx = index; idx > index - possibleNumberOfItems / 2 && idx >= 0; idx--) {
2705
+ itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${idx}`);
2706
+ }
2707
+ const numberOfExistingItems = itemsToBeInsertedToDom.length;
2708
+ for (let idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
2709
+ itemsToBeInsertedToDom.push(
2710
+ `lg-item-${this.lgId}-${index + idx + 1}`
2711
+ );
2712
+ }
2713
+ } else {
2714
+ for (let idx = index; idx <= this.galleryItems.length - 1 && idx < index + possibleNumberOfItems / 2; idx++) {
2715
+ itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${idx}`);
2716
+ }
2717
+ const numberOfExistingItems = itemsToBeInsertedToDom.length;
2718
+ for (let idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
2719
+ itemsToBeInsertedToDom.push(
2720
+ `lg-item-${this.lgId}-${index - idx - 1}`
2721
+ );
2722
+ }
2723
+ }
2724
+ if (this.settings.loop) {
2725
+ if (index === this.galleryItems.length - 1) {
2726
+ itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${0}`);
2727
+ } else if (index === 0) {
2728
+ itemsToBeInsertedToDom.push(
2729
+ `lg-item-${this.lgId}-${this.galleryItems.length - 1}`
2730
+ );
2731
+ }
2732
+ }
2733
+ if (itemsToBeInsertedToDom.indexOf(prevIndexItem) === -1) {
2734
+ itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${prevIndex}`);
2735
+ }
2736
+ return itemsToBeInsertedToDom;
2737
+ }
2738
+ organizeSlideItems(index, prevIndex) {
2739
+ var _a, _b;
2740
+ const itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(
2741
+ index,
2742
+ prevIndex,
2743
+ (_b = (_a = this.settings.virtualization) == null ? void 0 : _a.slides) != null ? _b : this.settings.numberOfSlideItemsInDom
2744
+ );
2745
+ itemsToBeInsertedToDom.forEach((item) => {
2746
+ if (this.currentItemsInDom.indexOf(item) === -1) {
2747
+ this.$inner.append(`<div id="${item}" class="lg-item"></div>`);
2748
+ }
2749
+ });
2750
+ this.currentItemsInDom.forEach((item) => {
2751
+ if (itemsToBeInsertedToDom.indexOf(item) === -1) {
2752
+ $LG(`#${item}`).remove();
2753
+ }
2754
+ });
2755
+ return itemsToBeInsertedToDom;
2756
+ }
2757
+ /**
2758
+ * Get previous index of the slide
2759
+ */
2760
+ getPreviousSlideIndex() {
2761
+ let prevIndex = 0;
2762
+ try {
2763
+ const currentItemId = this.outer.find(".lg-current").first().attr("id");
2764
+ prevIndex = parseInt(currentItemId.split("-")[3]) || 0;
2765
+ } catch (error) {
2766
+ prevIndex = 0;
2767
+ }
2768
+ return prevIndex;
2769
+ }
2770
+ setDownloadValue(index) {
2771
+ if (this.settings.download) {
2772
+ const currentGalleryItem = this.galleryItems[index];
2773
+ const hideDownloadBtn = currentGalleryItem.downloadUrl === false || currentGalleryItem.downloadUrl === "false";
2774
+ if (hideDownloadBtn) {
2775
+ this.outer.addClass("lg-hide-download");
2776
+ } else {
2777
+ const $download = this.getElementById("lg-download");
2778
+ this.outer.removeClass("lg-hide-download");
2779
+ $download.attr(
2780
+ "href",
2781
+ currentGalleryItem.downloadUrl || currentGalleryItem.src
2782
+ );
2783
+ if (currentGalleryItem.download) {
2784
+ $download.attr("download", currentGalleryItem.download);
2785
+ }
2786
+ }
2787
+ }
2788
+ }
2789
+ makeSlideAnimation(direction, currentSlideItem, previousSlideItem) {
2790
+ if (this.lGalleryOn) {
2791
+ previousSlideItem.addClass("lg-slide-progress");
2792
+ }
2793
+ setTimeout(
2794
+ () => {
2795
+ this.outer.addClass("lg-no-trans");
2796
+ this.outer.find(".lg-item").removeClass("lg-prev-slide lg-next-slide");
2797
+ if (direction === "prev") {
2798
+ currentSlideItem.addClass("lg-prev-slide");
2799
+ previousSlideItem.addClass("lg-next-slide");
2800
+ } else {
2801
+ currentSlideItem.addClass("lg-next-slide");
2802
+ previousSlideItem.addClass("lg-prev-slide");
2803
+ }
2804
+ setTimeout(() => {
2805
+ this.outer.find(".lg-item").removeClass("lg-current");
2806
+ currentSlideItem.addClass("lg-current");
2807
+ this.outer.removeClass("lg-no-trans");
2808
+ }, 50);
2809
+ },
2810
+ this.lGalleryOn ? this.settings.slideDelay : 0
2811
+ );
2812
+ }
2813
+ /**
2814
+ * Goto a specific slide.
2815
+ * @param {Number} index - index of the slide
2816
+ * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
2817
+ * @param {Boolean} fromThumb - true if slide function called via thumbnail click
2818
+ * @param {String} direction - Direction of the slide(next/prev)
2819
+ * @category lGPublicMethods
2820
+ * @example
2821
+ * const plugin = lightGallery();
2822
+ * // to go to 3rd slide
2823
+ * plugin.slide(2);
2824
+ *
2825
+ */
2826
+ slide(index, fromTouch, fromThumb, direction) {
2827
+ const prevIndex = this.getPreviousSlideIndex();
2828
+ this.currentItemsInDom = this.organizeSlideItems(index, prevIndex);
2829
+ if (this.lGalleryOn && prevIndex === index) {
2830
+ return;
2831
+ }
2832
+ const numberOfGalleryItems = this.galleryItems.length;
2833
+ if (!this.lgBusy) {
2834
+ if (this.settings.counter) {
2835
+ this.updateCurrentCounter(index);
2836
+ }
2837
+ this.announceSlide(index);
2838
+ const currentSlideItem = this.getSlideItem(index);
2839
+ const previousSlideItem = this.getSlideItem(prevIndex);
2840
+ const currentGalleryItem = this.galleryItems[index];
2841
+ const videoInfo = currentGalleryItem.__slideVideoInfo;
2842
+ this.outer.attr(
2843
+ "data-lg-slide-type",
2844
+ this.getSlideType(currentGalleryItem)
2845
+ );
2846
+ this.setDownloadValue(index);
2847
+ this.updateCurrentImageSize(index);
2848
+ if (videoInfo) {
2849
+ const { top, bottom } = this.mediaContainerPosition;
2850
+ const videoSize = utils.getSize(
2851
+ this.items[index],
2852
+ this.outer,
2853
+ top + bottom,
2854
+ videoInfo && this.settings.videoMaxSize
2855
+ );
2856
+ this.resizeVideoSlide(index, videoSize);
2857
+ }
2858
+ this.LGel.trigger(lGEvents.beforeSlide, {
2859
+ prevIndex,
2860
+ index,
2861
+ fromTouch: !!fromTouch,
2862
+ fromThumb: !!fromThumb
2863
+ });
2864
+ this.lgBusy = true;
2865
+ clearTimeout(this.hideBarTimeout);
2866
+ this.arrowDisable(index);
2867
+ if (!direction) {
2868
+ if (index < prevIndex) {
2869
+ direction = "prev";
2870
+ } else if (index > prevIndex) {
2871
+ direction = "next";
2872
+ }
2873
+ }
2874
+ if (!fromTouch) {
2875
+ this.makeSlideAnimation(
2876
+ direction,
2877
+ currentSlideItem,
2878
+ previousSlideItem
2879
+ );
2880
+ } else {
2881
+ this.outer.find(".lg-item").removeClass("lg-prev-slide lg-current lg-next-slide");
2882
+ let touchPrev;
2883
+ let touchNext;
2884
+ if (numberOfGalleryItems > 2) {
2885
+ touchPrev = index - 1;
2886
+ touchNext = index + 1;
2887
+ if (index === 0 && prevIndex === numberOfGalleryItems - 1) {
2888
+ touchNext = 0;
2889
+ touchPrev = numberOfGalleryItems - 1;
2890
+ } else if (index === numberOfGalleryItems - 1 && prevIndex === 0) {
2891
+ touchNext = 0;
2892
+ touchPrev = numberOfGalleryItems - 1;
2893
+ }
2894
+ } else {
2895
+ touchPrev = 0;
2896
+ touchNext = 1;
2897
+ }
2898
+ if (direction === "prev") {
2899
+ this.getSlideItem(touchNext).addClass("lg-next-slide");
2900
+ } else {
2901
+ this.getSlideItem(touchPrev).addClass("lg-prev-slide");
2902
+ }
2903
+ currentSlideItem.addClass("lg-current");
2904
+ }
2905
+ if (!this.lGalleryOn) {
2906
+ this.loadContent(index, true);
2907
+ } else {
2908
+ setTimeout(() => {
2909
+ this.loadContent(index, true);
2910
+ if (this.settings.appendSubHtmlTo !== ".lg-item") {
2911
+ this.addHtml(index);
2912
+ }
2913
+ }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
2914
+ }
2915
+ setTimeout(() => {
2916
+ this.lgBusy = false;
2917
+ previousSlideItem.removeClass("lg-slide-progress");
2918
+ this.LGel.trigger(lGEvents.afterSlide, {
2919
+ prevIndex,
2920
+ index,
2921
+ fromTouch,
2922
+ fromThumb
2923
+ });
2924
+ }, (this.lGalleryOn ? this.settings.speed + 100 : 100) + (fromTouch ? 0 : this.settings.slideDelay));
2925
+ }
2926
+ this.index = index;
2927
+ }
2928
+ updateCurrentCounter(index) {
2929
+ this.getElementById("lg-counter-current").html(index + 1 + "");
2930
+ }
2931
+ /**
2932
+ * Plain-text caption of a slide for the aria-live announcer. Resolves
2933
+ * the same sources addHtml uses (inline subHtml markup or a selector)
2934
+ * and strips the markup down to readable text. Remote captions
2935
+ * (subHtmlUrl) are skipped, announcing can't wait on a fetch.
2936
+ */
2937
+ getSlideCaptionText(index) {
2938
+ const currentGalleryItem = this.galleryItems[index];
2939
+ if (!currentGalleryItem || currentGalleryItem.subHtmlUrl) {
2940
+ return "";
2941
+ }
2942
+ let subHtml = currentGalleryItem.subHtml || "";
2943
+ const firstLetter = subHtml.substring(0, 1);
2944
+ if (firstLetter === "." || firstLetter === "#") {
2945
+ try {
2946
+ if (this.settings.subHtmlSelectorRelative && !this.settings.dynamic) {
2947
+ subHtml = $LG(this.items).eq(index).find(subHtml).first().html();
2948
+ } else {
2949
+ subHtml = $LG(subHtml).first().html();
2950
+ }
2951
+ } catch (error) {
2952
+ subHtml = "";
2953
+ }
2954
+ }
2955
+ if (!subHtml) {
2956
+ return "";
2957
+ }
2958
+ const container = document.createElement("div");
2959
+ container.innerHTML = subHtml;
2960
+ return container.textContent || "";
2961
+ }
2962
+ /**
2963
+ * Update the polite live region with the shown slide's position and
2964
+ * caption ("Image X of Y, caption"). The single announcement source,
2965
+ * counter and caption bar are not live regions while this is enabled.
2966
+ */
2967
+ announceSlide(index) {
2968
+ if (!this.settings.ariaAnnouncements) {
2969
+ return;
2970
+ }
2971
+ const announcer = this.getElementById("lg-announcer").get();
2972
+ if (!announcer) {
2973
+ return;
2974
+ }
2975
+ announcer.textContent = formatSlideAnnouncement({
2976
+ template: this.settings.strings["slideAnnouncement"],
2977
+ index: index + 1,
2978
+ total: this.galleryItems.length,
2979
+ caption: this.getSlideCaptionText(index)
2980
+ });
2981
+ }
2982
+ updateCounterTotal() {
2983
+ this.getElementById("lg-counter-all").html(
2984
+ this.galleryItems.length + ""
2985
+ );
2986
+ }
2987
+ getSlideType(item) {
2988
+ if (item.__slideVideoInfo) {
2989
+ return "video";
2990
+ } else if (item.iframe) {
2991
+ return "iframe";
2992
+ } else {
2993
+ return "image";
2994
+ }
2995
+ }
2996
+ /** Stop a running release spring; visuals stay at the live frame. */
2997
+ stopSlideSpring() {
2998
+ if (this.cancelSlideSpring) {
2999
+ this.cancelSlideSpring();
3000
+ this.cancelSlideSpring = void 0;
3001
+ }
3002
+ }
3003
+ touchMove(startCoords, endCoords, e) {
3004
+ const distanceX = endCoords.pageX - startCoords.pageX;
3005
+ const distanceY = endCoords.pageY - startCoords.pageY;
3006
+ this.swipeSamples = pushVelocitySample(this.swipeSamples, {
3007
+ x: endCoords.pageX,
3008
+ y: endCoords.pageY,
3009
+ t: Date.now()
3010
+ });
3011
+ this.swipeDirection = getSwipeAxis(
3012
+ distanceX,
3013
+ distanceY,
3014
+ this.swipeDirection
3015
+ );
3016
+ if (!this.swipeDirection) {
3017
+ return;
3018
+ }
3019
+ const $currentSlide = this.getSlideItem(this.index);
3020
+ if (this.swipeDirection === "horizontal") {
3021
+ e == null ? void 0 : e.preventDefault();
3022
+ this.outer.addClass("lg-dragging");
3023
+ const transforms = getHorizontalDragTransforms(
3024
+ this.getEdgeDragDelta(distanceX),
3025
+ $currentSlide.get().offsetWidth,
3026
+ this.getDirection()
3027
+ );
3028
+ $currentSlide.css("transform", transforms.current);
3029
+ this.outer.find(".lg-prev-slide").first().css("transform", transforms.prev);
3030
+ this.outer.find(".lg-next-slide").first().css("transform", transforms.next);
3031
+ } else if (this.swipeDirection === "vertical") {
3032
+ if (this.settings.swipeToClose) {
3033
+ e == null ? void 0 : e.preventDefault();
3034
+ this.$container.addClass("lg-dragging-vertical");
3035
+ const effects = getVerticalDragEffects(
3036
+ distanceY,
3037
+ window.innerWidth,
3038
+ window.innerHeight
3039
+ );
3040
+ this.$backdrop.css("opacity", effects.backdropOpacity);
3041
+ $currentSlide.css("transform", effects.transform);
3042
+ if (effects.hideUi) {
3043
+ this.outer.addClass("lg-hide-items").removeClass("lg-components-open");
3044
+ }
3045
+ }
3046
+ }
3047
+ }
3048
+ /**
3049
+ * The horizontal delta as rendered: rubber-banded when the drag
3050
+ * points past the first/last slide with nothing there (loop counts).
3051
+ */
3052
+ getEdgeDragDelta(distanceX) {
3053
+ const count = this.galleryItems.length;
3054
+ return getEdgeFrictionedDelta(
3055
+ distanceX,
3056
+ resolveSwipeTarget(
3057
+ "prev",
3058
+ this.index,
3059
+ count,
3060
+ this.settings.loop
3061
+ ) !== null,
3062
+ resolveSwipeTarget(
3063
+ "next",
3064
+ this.index,
3065
+ count,
3066
+ this.settings.loop
3067
+ ) !== null,
3068
+ this.getDirection()
3069
+ );
3070
+ }
3071
+ /** Resolved reading direction ('auto' is resolved at init). */
3072
+ getDirection() {
3073
+ return this.settings.direction === "rtl" ? "rtl" : "ltr";
3074
+ }
3075
+ /**
3076
+ * Spring the dragged slides back to rest, seeded with the release
3077
+ * velocity. Returns false (no spring) for sub-pixel drags.
3078
+ */
3079
+ springSlidesBack(deltaX, velocityX) {
3080
+ if (Math.abs(deltaX) < 1) {
3081
+ return false;
3082
+ }
3083
+ const $currentSlide = this.getSlideItem(this.index);
3084
+ const $prev = this.outer.find(".lg-prev-slide").first();
3085
+ const $next = this.outer.find(".lg-next-slide").first();
3086
+ const width = $currentSlide.get().offsetWidth;
3087
+ this.stopSlideSpring();
3088
+ this.cancelSlideSpring = runSprings(
3089
+ [{ from: deltaX, velocity: velocityX, target: 0 }],
3090
+ ([x]) => {
3091
+ const transforms = getHorizontalDragTransforms(
3092
+ x,
3093
+ width,
3094
+ this.getDirection()
3095
+ );
3096
+ $currentSlide.css("transform", transforms.current);
3097
+ $prev.css("transform", transforms.prev);
3098
+ $next.css("transform", transforms.next);
3099
+ },
3100
+ () => {
3101
+ this.cancelSlideSpring = void 0;
3102
+ this.endDragVisuals();
3103
+ }
3104
+ );
3105
+ return true;
3106
+ }
3107
+ /**
3108
+ * Carry the release velocity into a gesture navigation: navigate
3109
+ * immediately (events, counter and busy-lock on time; fromTouch
3110
+ * classes flip underneath, inline transforms keep the visuals),
3111
+ * then spring the same drag geometry until the arriving slide lands
3112
+ * at rest. Falls back to a snap-back when navigation declines
3113
+ * (busy, or an edge without loop, the 2.x end animation plays).
3114
+ */
3115
+ springSlideNavigation(verdict, deltaX, velocityX) {
3116
+ const $current = this.getSlideItem(this.index);
3117
+ const $prev = this.outer.find(".lg-prev-slide").first();
3118
+ const $next = this.outer.find(".lg-next-slide").first();
3119
+ const width = $current.get().offsetWidth;
3120
+ if (!width) {
3121
+ return false;
3122
+ }
3123
+ const prevIndex = this.index;
3124
+ if (verdict === "next") {
3125
+ this.goToNextSlide(true);
3126
+ } else {
3127
+ this.goToPrevSlide(true);
3128
+ }
3129
+ if (this.index === prevIndex) {
3130
+ return this.springSlidesBack(deltaX, velocityX);
3131
+ }
3132
+ const target = (verdict === "next" ? -1 : 1) * (this.getDirection() === "rtl" ? -1 : 1) * (width * 115 / 110);
3133
+ this.stopSlideSpring();
3134
+ this.cancelSlideSpring = runSprings(
3135
+ [{ from: deltaX, velocity: velocityX, target }],
3136
+ ([x]) => {
3137
+ const transforms = getHorizontalDragTransforms(
3138
+ x,
3139
+ width,
3140
+ this.getDirection()
3141
+ );
3142
+ $current.css("transform", transforms.current);
3143
+ $prev.css("transform", transforms.prev);
3144
+ $next.css("transform", transforms.next);
3145
+ },
3146
+ () => {
3147
+ this.cancelSlideSpring = void 0;
3148
+ this.endDragVisuals();
3149
+ }
3150
+ );
3151
+ return true;
3152
+ }
3153
+ /**
3154
+ * Hand the slides back to CSS after a gesture. The inline transforms
3155
+ * go first, while lg-dragging still pins transition-duration to 0s,
3156
+ * so the snap from the released position to the slide's resting
3157
+ * place lands in a single frame. Dropping the class first animates
3158
+ * that snap instead, and the outgoing slide is seen travelling back
3159
+ * toward the centre while its fade is still running.
3160
+ */
3161
+ endDragVisuals() {
3162
+ this.outer.find(".lg-item").removeAttr("style");
3163
+ if (this.settings.mode !== "lg-slide") {
3164
+ this.outer.removeClass("lg-slide");
3165
+ }
3166
+ void this.outer.get().offsetHeight;
3167
+ this.outer.removeClass("lg-dragging");
3168
+ }
3169
+ /**
3170
+ * Spring a non-closing vertical drag back to rest, slide transform
3171
+ * and backdrop opacity together, seeded with the release velocity.
3172
+ */
3173
+ springVerticalRestore(deltaY, velocityY) {
3174
+ if (Math.abs(deltaY) < 1) {
3175
+ return false;
3176
+ }
3177
+ const $currentSlide = this.getSlideItem(this.index);
3178
+ this.stopSlideSpring();
3179
+ this.$container.addClass("lg-dragging-vertical");
3180
+ this.cancelSlideSpring = runSprings(
3181
+ [{ from: deltaY, velocity: velocityY, target: 0 }],
3182
+ ([y]) => {
3183
+ const effects = getVerticalDragEffects(
3184
+ y,
3185
+ window.innerWidth,
3186
+ window.innerHeight
3187
+ );
3188
+ this.$backdrop.css("opacity", effects.backdropOpacity);
3189
+ $currentSlide.css("transform", effects.transform);
3190
+ },
3191
+ () => {
3192
+ this.cancelSlideSpring = void 0;
3193
+ this.$container.removeClass("lg-dragging-vertical");
3194
+ this.endDragVisuals();
3195
+ this.$backdrop.css("opacity", 1);
3196
+ }
3197
+ );
3198
+ return true;
3199
+ }
3200
+ touchEnd(endCoords, startCoords, event) {
3201
+ const releaseVelocity = getWindowedVelocity(
3202
+ this.swipeSamples,
3203
+ Date.now()
3204
+ );
3205
+ if (this.settings.mode !== "lg-slide") {
3206
+ this.outer.addClass("lg-slide");
3207
+ }
3208
+ setTimeout(() => {
3209
+ this.$container.removeClass("lg-dragging-vertical");
3210
+ this.outer.removeClass("lg-hide-items").addClass("lg-components-open");
3211
+ let triggerClick = true;
3212
+ let springing = false;
3213
+ if (this.swipeDirection === "horizontal") {
3214
+ const verdict = getSwipeReleaseVerdict({
3215
+ deltaX: endCoords.pageX - startCoords.pageX,
3216
+ velocityX: releaseVelocity.x,
3217
+ threshold: this.settings.swipeThreshold,
3218
+ flickVelocity: this.settings.flickVelocity,
3219
+ viewportWidth: this.outer.get().offsetWidth,
3220
+ direction: this.getDirection()
3221
+ });
3222
+ const renderedDeltaX = this.getEdgeDragDelta(
3223
+ endCoords.pageX - startCoords.pageX
3224
+ );
3225
+ if (verdict === "next" || verdict === "prev") {
3226
+ triggerClick = false;
3227
+ springing = this.springSlideNavigation(
3228
+ verdict,
3229
+ renderedDeltaX,
3230
+ releaseVelocity.x
3231
+ );
3232
+ } else {
3233
+ springing = this.springSlidesBack(
3234
+ renderedDeltaX,
3235
+ releaseVelocity.x
3236
+ );
3237
+ }
3238
+ } else if (this.swipeDirection === "vertical") {
3239
+ if (shouldCloseOnVerticalDrag(
3240
+ endCoords.pageY - startCoords.pageY,
3241
+ releaseVelocity.y,
3242
+ window.innerHeight,
3243
+ {
3244
+ closable: this.settings.closable,
3245
+ swipeToClose: this.settings.swipeToClose
3246
+ }
3247
+ )) {
3248
+ this.closeGallery();
3249
+ return;
3250
+ }
3251
+ if (this.settings.swipeToClose) {
3252
+ springing = this.springVerticalRestore(
3253
+ endCoords.pageY - startCoords.pageY,
3254
+ releaseVelocity.y
3255
+ );
3256
+ }
3257
+ }
3258
+ if (!springing) {
3259
+ this.endDragVisuals();
3260
+ this.$backdrop.css("opacity", 1);
3261
+ }
3262
+ if (triggerClick && Math.abs(endCoords.pageX - startCoords.pageX) < 5) {
3263
+ const target = $LG(event.target);
3264
+ if (this.isPosterElement(target)) {
3265
+ this.LGel.trigger(lGEvents.posterClick);
3266
+ }
3267
+ }
3268
+ this.swipeDirection = void 0;
3269
+ });
3270
+ setTimeout(() => {
3271
+ if (!this.outer.hasClass("lg-dragging") && this.settings.mode !== "lg-slide") {
3272
+ this.outer.removeClass("lg-slide");
3273
+ }
3274
+ }, this.settings.speed + 100);
3275
+ }
3276
+ enableSwipe() {
3277
+ let startCoords = {};
3278
+ let endCoords = {};
3279
+ let isMoved = false;
3280
+ let isSwiping = false;
3281
+ if (this.settings.enableSwipe) {
3282
+ this.$inner.on("touchstart.lg", (e) => {
3283
+ this.dragOrSwipeEnabled = true;
3284
+ const $item = this.getSlideItem(this.index);
3285
+ if (($LG(e.target).hasClass("lg-item") || $item.get().contains(e.target)) && !this.outer.hasClass("lg-zoomed") && !this.lgBusy && e.touches.length === 1) {
3286
+ isSwiping = true;
3287
+ this.touchAction = "swipe";
3288
+ isMoved = false;
3289
+ endCoords = {};
3290
+ this.stopSlideSpring();
3291
+ this.manageSwipeClass();
3292
+ this.swipeSamples = [
3293
+ {
3294
+ x: e.touches[0].pageX,
3295
+ y: e.touches[0].pageY,
3296
+ t: Date.now()
3297
+ }
3298
+ ];
3299
+ startCoords = {
3300
+ pageX: e.touches[0].pageX,
3301
+ pageY: e.touches[0].pageY
3302
+ };
3303
+ }
3304
+ });
3305
+ this.$inner.on("touchmove.lg", (e) => {
3306
+ if (isSwiping && this.touchAction === "swipe" && e.touches.length === 1) {
3307
+ endCoords = {
3308
+ pageX: e.touches[0].pageX,
3309
+ pageY: e.touches[0].pageY
3310
+ };
3311
+ this.touchMove(startCoords, endCoords, e);
3312
+ isMoved = true;
3313
+ }
3314
+ });
3315
+ this.$inner.on("touchend.lg", (event) => {
3316
+ if (this.touchAction === "swipe") {
3317
+ if (isMoved) {
3318
+ isMoved = false;
3319
+ this.touchEnd(endCoords, startCoords, event);
3320
+ } else if (isSwiping) {
3321
+ const target = $LG(event.target);
3322
+ if (this.isPosterElement(target)) {
3323
+ this.LGel.trigger(lGEvents.posterClick);
3324
+ }
3325
+ }
3326
+ this.touchAction = void 0;
3327
+ isSwiping = false;
3328
+ }
3329
+ });
3330
+ }
3331
+ }
3332
+ enableDrag() {
3333
+ let startCoords = {};
3334
+ let endCoords = {};
3335
+ let isDraging = false;
3336
+ let isMoved = false;
3337
+ if (this.settings.enableDrag) {
3338
+ this.outer.on("mousedown.lg", (e) => {
3339
+ this.dragOrSwipeEnabled = true;
3340
+ const $item = this.getSlideItem(this.index);
3341
+ if ($LG(e.target).hasClass("lg-item") || $item.get().contains(e.target)) {
3342
+ if (!this.outer.hasClass("lg-zoomed") && !this.lgBusy) {
3343
+ e.preventDefault();
3344
+ this.stopSlideSpring();
3345
+ this.manageSwipeClass();
3346
+ this.swipeSamples = [
3347
+ { x: e.pageX, y: e.pageY, t: Date.now() }
3348
+ ];
3349
+ startCoords = {
3350
+ pageX: e.pageX,
3351
+ pageY: e.pageY
3352
+ };
3353
+ isDraging = true;
3354
+ this.outer.get().scrollLeft += 1;
3355
+ this.outer.get().scrollLeft -= 1;
3356
+ this.outer.removeClass("lg-grab").addClass("lg-grabbing");
3357
+ this.LGel.trigger(lGEvents.dragStart);
3358
+ }
3359
+ }
3360
+ });
3361
+ $LG(window).on(`mousemove.lg.global${this.lgId}`, (e) => {
3362
+ if (isDraging && this.lgOpened) {
3363
+ isMoved = true;
3364
+ endCoords = {
3365
+ pageX: e.pageX,
3366
+ pageY: e.pageY
3367
+ };
3368
+ this.touchMove(startCoords, endCoords);
3369
+ this.LGel.trigger(lGEvents.dragMove);
3370
+ }
3371
+ });
3372
+ $LG(window).on(`mouseup.lg.global${this.lgId}`, (event) => {
3373
+ if (!this.lgOpened) {
3374
+ return;
3375
+ }
3376
+ const target = $LG(event.target);
3377
+ if (isMoved) {
3378
+ isMoved = false;
3379
+ this.touchEnd(endCoords, startCoords, event);
3380
+ this.LGel.trigger(lGEvents.dragEnd);
3381
+ } else if (this.isPosterElement(target)) {
3382
+ this.LGel.trigger(lGEvents.posterClick);
3383
+ }
3384
+ if (isDraging) {
3385
+ isDraging = false;
3386
+ this.outer.removeClass("lg-grabbing").addClass("lg-grab");
3387
+ }
3388
+ });
3389
+ }
3390
+ }
3391
+ triggerPosterClick() {
3392
+ this.$inner.on("click.lg", (event) => {
3393
+ if (!this.dragOrSwipeEnabled && this.isPosterElement($LG(event.target))) {
3394
+ this.LGel.trigger(lGEvents.posterClick);
3395
+ }
3396
+ });
3397
+ }
3398
+ manageSwipeClass() {
3399
+ let _touchNext = this.index + 1;
3400
+ let _touchPrev = this.index - 1;
3401
+ if (this.settings.loop && this.galleryItems.length > 2) {
3402
+ if (this.index === 0) {
3403
+ _touchPrev = this.galleryItems.length - 1;
3404
+ } else if (this.index === this.galleryItems.length - 1) {
3405
+ _touchNext = 0;
3406
+ }
3407
+ }
3408
+ this.outer.find(".lg-item").removeClass("lg-next-slide lg-prev-slide");
3409
+ if (_touchPrev > -1) {
3410
+ this.getSlideItem(_touchPrev).addClass("lg-prev-slide");
3411
+ }
3412
+ this.getSlideItem(_touchNext).addClass("lg-next-slide");
3413
+ }
3414
+ /**
3415
+ * Go to next slide
3416
+ * @param {Boolean} fromTouch - true if slide function called via touch event
3417
+ * @category lGPublicMethods
3418
+ * @example
3419
+ * const plugin = lightGallery();
3420
+ * plugin.goToNextSlide();
3421
+ * @see <a href="/demos/methods/">Demo</a>
3422
+ */
3423
+ goToNextSlide(fromTouch) {
3424
+ let _loop = this.settings.loop;
3425
+ if (fromTouch && this.galleryItems.length < 3) {
3426
+ _loop = false;
3427
+ }
3428
+ if (!this.lgBusy) {
3429
+ if (this.index + 1 < this.galleryItems.length) {
3430
+ this.index++;
3431
+ this.LGel.trigger(lGEvents.beforeNextSlide, {
3432
+ index: this.index
3433
+ });
3434
+ this.slide(this.index, !!fromTouch, false, "next");
3435
+ } else {
3436
+ if (_loop) {
3437
+ this.index = 0;
3438
+ this.LGel.trigger(lGEvents.beforeNextSlide, {
3439
+ index: this.index
3440
+ });
3441
+ this.slide(this.index, !!fromTouch, false, "next");
3442
+ } else if (this.settings.slideEndAnimation && !fromTouch) {
3443
+ this.outer.addClass("lg-right-end");
3444
+ setTimeout(() => {
3445
+ this.outer.removeClass("lg-right-end");
3446
+ }, 400);
3447
+ }
3448
+ }
3449
+ }
3450
+ }
3451
+ /**
3452
+ * Go to previous slides
3453
+ * @param {Boolean} fromTouch - true if slide function called via touch event
3454
+ * @category lGPublicMethods
3455
+ * @example
3456
+ * const plugin = lightGallery({});
3457
+ * plugin.goToPrevSlide();
3458
+ * @see <a href="/demos/methods/">Demo</a>
3459
+ *
3460
+ */
3461
+ goToPrevSlide(fromTouch) {
3462
+ let _loop = this.settings.loop;
3463
+ if (fromTouch && this.galleryItems.length < 3) {
3464
+ _loop = false;
3465
+ }
3466
+ if (!this.lgBusy) {
3467
+ if (this.index > 0) {
3468
+ this.index--;
3469
+ this.LGel.trigger(lGEvents.beforePrevSlide, {
3470
+ index: this.index,
3471
+ fromTouch
3472
+ });
3473
+ this.slide(this.index, !!fromTouch, false, "prev");
3474
+ } else {
3475
+ if (_loop) {
3476
+ this.index = this.galleryItems.length - 1;
3477
+ this.LGel.trigger(lGEvents.beforePrevSlide, {
3478
+ index: this.index,
3479
+ fromTouch
3480
+ });
3481
+ this.slide(this.index, !!fromTouch, false, "prev");
3482
+ } else if (this.settings.slideEndAnimation && !fromTouch) {
3483
+ this.outer.addClass("lg-left-end");
3484
+ setTimeout(() => {
3485
+ this.outer.removeClass("lg-left-end");
3486
+ }, 400);
3487
+ }
3488
+ }
3489
+ }
3490
+ }
3491
+ keyPress() {
3492
+ $LG(window).on(`keydown.lg.global${this.lgId}`, (e) => {
3493
+ if (this.lgOpened && this.settings.escKey === true && e.keyCode === 27) {
3494
+ e.preventDefault();
3495
+ if (this.settings.allowMediaOverlap && this.outer.hasClass("lg-can-toggle") && this.outer.hasClass("lg-components-open")) {
3496
+ this.outer.removeClass("lg-components-open");
3497
+ } else {
3498
+ this.closeGallery();
3499
+ }
3500
+ }
3501
+ if (this.lgOpened && this.galleryItems.length > 1) {
3502
+ const rtl = this.getDirection() === "rtl";
3503
+ if (e.keyCode === 37) {
3504
+ e.preventDefault();
3505
+ if (rtl) {
3506
+ this.goToNextSlide();
3507
+ } else {
3508
+ this.goToPrevSlide();
3509
+ }
3510
+ }
3511
+ if (e.keyCode === 39) {
3512
+ e.preventDefault();
3513
+ if (rtl) {
3514
+ this.goToPrevSlide();
3515
+ } else {
3516
+ this.goToNextSlide();
3517
+ }
3518
+ }
3519
+ }
3520
+ });
3521
+ }
3522
+ arrow() {
3523
+ this.getElementById("lg-prev").on("click.lg", () => {
3524
+ this.goToPrevSlide();
3525
+ });
3526
+ this.getElementById("lg-next").on("click.lg", () => {
3527
+ this.goToNextSlide();
3528
+ });
3529
+ }
3530
+ arrowDisable(index) {
3531
+ if (!this.settings.loop && this.settings.hideControlOnEnd) {
3532
+ const $prev = this.getElementById("lg-prev");
3533
+ const $next = this.getElementById("lg-next");
3534
+ if (index + 1 === this.galleryItems.length) {
3535
+ $next.attr("disabled", "disabled").addClass("disabled");
3536
+ } else {
3537
+ $next.removeAttr("disabled").removeClass("disabled");
3538
+ }
3539
+ if (index === 0) {
3540
+ $prev.attr("disabled", "disabled").addClass("disabled");
3541
+ } else {
3542
+ $prev.removeAttr("disabled").removeClass("disabled");
3543
+ }
3544
+ }
3545
+ }
3546
+ setTranslate($el, xValue, yValue, scaleX = 1, scaleY = 1) {
3547
+ $el.css(
3548
+ "transform",
3549
+ "translate3d(" + xValue + "px, " + yValue + "px, 0px) scale3d(" + scaleX + ", " + scaleY + ", 1)"
3550
+ );
3551
+ }
3552
+ mousewheel() {
3553
+ let lastCall = 0;
3554
+ this.outer.on("wheel.lg", (e) => {
3555
+ if (!e.deltaY || this.galleryItems.length < 2) {
3556
+ return;
3557
+ }
3558
+ e.preventDefault();
3559
+ const now = (/* @__PURE__ */ new Date()).getTime();
3560
+ if (now - lastCall < 1e3) {
3561
+ return;
3562
+ }
3563
+ lastCall = now;
3564
+ if (e.deltaY > 0) {
3565
+ this.goToNextSlide();
3566
+ } else if (e.deltaY < 0) {
3567
+ this.goToPrevSlide();
3568
+ }
3569
+ });
3570
+ }
3571
+ isSlideElement(target) {
3572
+ return target.hasClass("lg-outer") || target.hasClass("lg-item") || target.hasClass("lg-img-wrap") || target.hasClass("lg-img-rotate");
3573
+ }
3574
+ isPosterElement(target) {
3575
+ const playButton = this.getSlideItem(this.index).find(".lg-video-play-button").get();
3576
+ return target.hasClass("lg-video-poster") || target.hasClass("lg-video-play-button") || playButton && playButton.contains(target.get());
3577
+ }
3578
+ /**
3579
+ * Maximize minimize inline gallery.
3580
+ * @category lGPublicMethods
3581
+ */
3582
+ toggleMaximize() {
3583
+ this.getElementById("lg-maximize").on("click.lg", () => {
3584
+ this.$container.toggleClass("lg-inline");
3585
+ this.refreshOnResize();
3586
+ });
3587
+ }
3588
+ invalidateItems() {
3589
+ for (let index = 0; index < this.items.length; index++) {
3590
+ const element = this.items[index];
3591
+ const $element = $LG(element);
3592
+ $element.off(`click.lgcustom-item-${$element.attr("data-lg-id")}`);
3593
+ }
3594
+ }
3595
+ trapFocus() {
3596
+ this.$container.get().focus({
3597
+ preventScroll: true
3598
+ });
3599
+ $LG(window).on(`keydown.lg.global${this.lgId}`, (e) => {
3600
+ if (!this.lgOpened) {
3601
+ return;
3602
+ }
3603
+ const isTabPressed = e.key === "Tab" || e.keyCode === 9;
3604
+ if (!isTabPressed) {
3605
+ return;
3606
+ }
3607
+ const focusableEls = utils.getFocusableElements(
3608
+ this.$container.get()
3609
+ );
3610
+ const firstFocusableEl = focusableEls[0];
3611
+ const lastFocusableEl = focusableEls[focusableEls.length - 1];
3612
+ if (e.shiftKey) {
3613
+ if (document.activeElement === firstFocusableEl) {
3614
+ lastFocusableEl.focus();
3615
+ e.preventDefault();
3616
+ }
3617
+ } else {
3618
+ if (document.activeElement === lastFocusableEl) {
3619
+ firstFocusableEl.focus();
3620
+ e.preventDefault();
3621
+ }
3622
+ }
3623
+ });
3624
+ }
3625
+ manageCloseGallery() {
3626
+ if (!this.settings.closable) return;
3627
+ let mousedown = false;
3628
+ this.getElementById("lg-close").on("click.lg", () => {
3629
+ this.closeGallery();
3630
+ });
3631
+ if (this.settings.closeOnTap) {
3632
+ this.outer.on("mousedown.lg", (e) => {
3633
+ const target = $LG(e.target);
3634
+ if (this.isSlideElement(target)) {
3635
+ mousedown = true;
3636
+ } else {
3637
+ mousedown = false;
3638
+ }
3639
+ });
3640
+ this.outer.on("mousemove.lg", () => {
3641
+ mousedown = false;
3642
+ });
3643
+ this.outer.on("mouseup.lg", (e) => {
3644
+ const target = $LG(e.target);
3645
+ if (this.isSlideElement(target) && mousedown) {
3646
+ if (!this.outer.hasClass("lg-dragging")) {
3647
+ this.closeGallery();
3648
+ }
3649
+ }
3650
+ });
3651
+ }
3652
+ }
3653
+ /**
3654
+ * Close lightGallery if it is opened.
3655
+ *
3656
+ * @description If closable is false in the settings, you need to pass true via closeGallery method to force close gallery
3657
+ * @return returns the estimated time to close gallery completely including the close animation duration
3658
+ * @category lGPublicMethods
3659
+ * @example
3660
+ * const plugin = lightGallery();
3661
+ * plugin.closeGallery();
3662
+ *
3663
+ */
3664
+ closeGallery(force) {
3665
+ if (!this.lgOpened || !this.settings.closable && !force) {
3666
+ return 0;
3667
+ }
3668
+ this.LGel.trigger(lGEvents.beforeClose);
3669
+ if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
3670
+ $LG(window).scrollTop(this.prevScrollTop);
3671
+ }
3672
+ const currentItem = this.items[this.index];
3673
+ let transform;
3674
+ if (this.zoomFromOrigin && currentItem) {
3675
+ const { top, bottom } = this.mediaContainerPosition;
3676
+ const { __slideVideoInfo, poster } = this.galleryItems[this.index];
3677
+ const imageSize = utils.getSize(
3678
+ currentItem,
3679
+ this.outer,
3680
+ top + bottom,
3681
+ __slideVideoInfo && poster && this.settings.videoMaxSize
3682
+ );
3683
+ transform = this.getOriginTransform(currentItem, imageSize);
3684
+ }
3685
+ if (!transform) {
3686
+ transform = getCenterCloseTransform();
3687
+ this.outer.addClass("lg-close-to-center");
3688
+ }
3689
+ if (transform) {
3690
+ this.outer.addClass("lg-closing lg-zoom-from-image");
3691
+ this.getSlideItem(this.index).addClass("lg-start-end-progress").css(
3692
+ "transition-duration",
3693
+ this.settings.startAnimationDuration + "ms"
3694
+ ).css("transform", transform);
3695
+ } else {
3696
+ this.outer.addClass("lg-hide-items");
3697
+ this.outer.removeClass("lg-zoom-from-image");
3698
+ }
3699
+ this.destroyModules();
3700
+ this.lGalleryOn = false;
3701
+ this.isDummyImageRemoved = false;
3702
+ this.zoomFromOrigin = this.settings.zoomFromOrigin;
3703
+ clearTimeout(this.hideBarTimeout);
3704
+ this.hideBarTimeout = false;
3705
+ $LG("html").removeClass("lg-on");
3706
+ this.outer.removeClass("lg-visible lg-components-open");
3707
+ this.$backdrop.removeClass("in").css("opacity", 0);
3708
+ const removeTimeout = transform ? Math.max(
3709
+ this.settings.startAnimationDuration,
3710
+ this.settings.backdropDuration
3711
+ ) : this.settings.backdropDuration;
3712
+ this.$container.removeClass("lg-show-in");
3713
+ setTimeout(() => {
3714
+ if (transform) {
3715
+ this.outer.removeClass("lg-zoom-from-image");
3716
+ }
3717
+ this.$container.removeClass("lg-show");
3718
+ this.resetScrollBar();
3719
+ this.$backdrop.removeAttr("style").css(
3720
+ "transition-duration",
3721
+ this.settings.backdropDuration + "ms"
3722
+ );
3723
+ this.outer.removeClass(
3724
+ `lg-closing lg-close-to-center ${this.settings.startClass}`
3725
+ );
3726
+ this.getSlideItem(this.index).removeClass("lg-start-end-progress");
3727
+ this.$inner.empty();
3728
+ const announcer = this.getElementById("lg-announcer").get();
3729
+ if (announcer) {
3730
+ announcer.textContent = "";
3731
+ }
3732
+ if (this.lgOpened) {
3733
+ this.LGel.trigger(lGEvents.afterClose, {
3734
+ instance: this
3735
+ });
3736
+ }
3737
+ if (this.$container.get()) {
3738
+ this.$container.get().blur();
3739
+ }
3740
+ if (this.prevActiveElement && this.prevActiveElement.isConnected) {
3741
+ this.prevActiveElement.focus({ preventScroll: true });
3742
+ }
3743
+ this.prevActiveElement = void 0;
3744
+ this.lgOpened = false;
3745
+ }, removeTimeout + 100);
3746
+ return removeTimeout + 100;
3747
+ }
3748
+ initModules() {
3749
+ this.plugins.forEach((module) => {
3750
+ try {
3751
+ module.init();
3752
+ } catch (err) {
3753
+ console.warn(
3754
+ `lightGallery:- make sure lightGallery module is properly initiated. See https://www.lightgalleryjs.com/docs/methods/`
3755
+ );
3756
+ }
3757
+ });
3758
+ }
3759
+ destroyModules(destroy) {
3760
+ this.plugins.forEach((module) => {
3761
+ try {
3762
+ if (destroy) {
3763
+ module.destroy();
3764
+ } else {
3765
+ module.closeGallery && module.closeGallery();
3766
+ }
3767
+ } catch (err) {
3768
+ console.warn(
3769
+ `lightGallery:- make sure lightGallery module is properly destroyed. See https://www.lightgalleryjs.com/docs/methods/`
3770
+ );
3771
+ }
3772
+ });
3773
+ }
3774
+ /**
3775
+ * Refresh lightGallery with new set of children.
3776
+ *
3777
+ * @description This is useful to update the gallery when the child elements are changed without calling destroy method.
3778
+ *
3779
+ * If you are using dynamic mode, you can pass the modified array of dynamicEl as the first parameter to refresh the dynamic gallery
3780
+ * @see <a href="/demos/dynamic-mode/">Demo</a>
3781
+ * @category lGPublicMethods
3782
+ * @example
3783
+ * const plugin = lightGallery();
3784
+ * // Delete or add children, then call
3785
+ * plugin.refresh();
3786
+ *
3787
+ */
3788
+ refresh(galleryItems) {
3789
+ if (!this.settings.dynamic) {
3790
+ this.invalidateItems();
3791
+ }
3792
+ if (galleryItems) {
3793
+ this.galleryItems = galleryItems;
3794
+ } else {
3795
+ this.galleryItems = this.getItems();
3796
+ }
3797
+ this.updateControls();
3798
+ this.openGalleryOnItemClick();
3799
+ this.LGel.trigger(lGEvents.updateSlides);
3800
+ }
3801
+ updateControls() {
3802
+ this.addSlideVideoInfo(this.galleryItems);
3803
+ this.updateCounterTotal();
3804
+ this.manageSingleSlideClassName();
3805
+ }
3806
+ destroyGallery() {
3807
+ var _a;
3808
+ this.destroyModules(true);
3809
+ if (!this.settings.dynamic) {
3810
+ this.invalidateItems();
3811
+ }
3812
+ $LG(window).off(`.lg.global${this.lgId}`);
3813
+ this.LGel.off(".lg");
3814
+ (_a = this.toolbarOverflow) == null ? void 0 : _a.destroy();
3815
+ this.toolbarOverflow = void 0;
3816
+ this.$container.remove();
3817
+ }
3818
+ /**
3819
+ * Destroy lightGallery.
3820
+ * Destroy lightGallery and its plugin instances completely
3821
+ *
3822
+ * @description This method also calls CloseGallery function internally. Returns the time takes to completely close and destroy the instance.
3823
+ * In case if you want to re-initialize lightGallery right after destroying it, initialize it only once the destroy process is completed.
3824
+ * You can use refresh method most of the times.
3825
+ * @category lGPublicMethods
3826
+ * @example
3827
+ * const plugin = lightGallery();
3828
+ * plugin.destroy();
3829
+ *
3830
+ */
3831
+ destroy() {
3832
+ const closeTimeout = this.closeGallery(true);
3833
+ if (closeTimeout) {
3834
+ setTimeout(this.destroyGallery.bind(this), closeTimeout);
3835
+ } else {
3836
+ this.destroyGallery();
3837
+ }
3838
+ return closeTimeout;
3839
+ }
3840
+ }
3841
+ function lightGallery(el, options) {
3842
+ return new LightGallery(el, options);
3843
+ }
3844
+ lightGallery.setLicenseKey = setLicenseKey;
3845
+ export {
3846
+ lightGallery as default
3847
+ };
3848
+ //# sourceMappingURL=lightgallery.es5.js.map