@uploadcare/file-uploader 1.27.0 → 1.28.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/dist/CameraSource-DbyO6GoK.js +481 -0
  2. package/dist/CameraSource-px4BzEMI.js +9 -0
  3. package/dist/CloudImageEditor-BIxf1V4M.js +2162 -0
  4. package/dist/CloudImageEditorActivity-CJxP5N0S.js +9 -0
  5. package/dist/CloudImageEditorActivity-d4DpK6fQ.js +87 -0
  6. package/dist/Config-DuWre5p3.js +433 -0
  7. package/dist/ExternalSource-BKTFp95O.js +248 -0
  8. package/dist/ExternalSource-CR5DG0Jv.js +9 -0
  9. package/dist/Icon-CqTVC82Q.js +1811 -0
  10. package/dist/LitUploaderBlock-BA34rzeU.js +998 -0
  11. package/dist/UrlSource-BxVL9Pve.js +9 -0
  12. package/dist/UrlSource-DZK5EBwT.js +73 -0
  13. package/dist/abstract/CTX.d.ts +40 -0
  14. package/dist/abstract/TypedCollection.d.ts +47 -0
  15. package/dist/abstract/TypedCollection.test.d.ts +1 -0
  16. package/dist/abstract/TypedData.d.ts +12 -0
  17. package/dist/abstract/TypedData.test.d.ts +1 -0
  18. package/dist/abstract/UploaderPublicApi.d.ts +41 -0
  19. package/dist/abstract/buildOutputCollectionState.d.ts +3 -0
  20. package/dist/abstract/customConfigOptions.d.ts +65 -0
  21. package/dist/abstract/defineComponents.d.ts +1 -0
  22. package/dist/abstract/features/ClipboardLayer.d.ts +12 -0
  23. package/dist/abstract/loadFileUploaderFrom.d.ts +3 -4
  24. package/dist/abstract/loadFileUploaderFrom.js +7 -6
  25. package/dist/abstract/localeRegistry.d.ts +5 -0
  26. package/dist/abstract/managers/LocaleManager.d.ts +10 -0
  27. package/dist/abstract/managers/ModalManager.d.ts +53 -0
  28. package/dist/abstract/managers/SecureUploadsManager.d.ts +7 -0
  29. package/dist/abstract/managers/TelemetryManager.d.ts +41 -0
  30. package/dist/abstract/managers/ValidationManager.d.ts +34 -0
  31. package/dist/abstract/managers/__tests__/ModalManager.test.d.ts +13 -0
  32. package/dist/abstract/managers/__tests__/SecureUploadsManager.test.d.ts +1 -0
  33. package/dist/abstract/managers/a11y.d.ts +9 -0
  34. package/dist/abstract/managers/plugin/PluginManager.d.ts +25 -0
  35. package/dist/abstract/managers/plugin/PluginTypes.d.ts +146 -0
  36. package/dist/abstract/managers/plugin/index.d.ts +2 -0
  37. package/dist/abstract/sharedConfigKey.d.ts +2 -0
  38. package/dist/abstract/uploadEntrySchema.d.ts +34 -0
  39. package/dist/blocks/ActivityHeader/ActivityHeader.d.ts +8 -0
  40. package/dist/blocks/CameraSource/CameraSource.d.ts +121 -0
  41. package/dist/blocks/CameraSource/__tests__/calcCameraModes.test.d.ts +1 -0
  42. package/dist/blocks/CameraSource/calcCameraModes.d.ts +5 -0
  43. package/dist/blocks/CameraSource/constants.d.ts +15 -0
  44. package/dist/blocks/CloudImageEditor/index.d.ts +1 -0
  45. package/dist/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts +60 -0
  46. package/dist/blocks/CloudImageEditor/src/CropFrame.d.ts +56 -0
  47. package/dist/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +24 -0
  48. package/dist/blocks/CloudImageEditor/src/EditorButtonControl.d.ts +14 -0
  49. package/dist/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts +13 -0
  50. package/dist/blocks/CloudImageEditor/src/EditorFilterControl.d.ts +35 -0
  51. package/dist/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +56 -0
  52. package/dist/blocks/CloudImageEditor/src/EditorImageFader.d.ts +63 -0
  53. package/dist/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +15 -0
  54. package/dist/blocks/CloudImageEditor/src/EditorScroller.d.ts +15 -0
  55. package/dist/blocks/CloudImageEditor/src/EditorSlider.d.ts +33 -0
  56. package/dist/blocks/CloudImageEditor/src/EditorToolbar.d.ts +68 -0
  57. package/dist/blocks/CloudImageEditor/src/crop-utils.d.ts +36 -0
  58. package/dist/blocks/CloudImageEditor/src/crop-utils.test.d.ts +1 -0
  59. package/dist/blocks/CloudImageEditor/src/cropper-constants.d.ts +10 -0
  60. package/dist/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts +31 -0
  61. package/dist/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts +19 -0
  62. package/dist/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts +27 -0
  63. package/dist/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts +38 -0
  64. package/dist/blocks/CloudImageEditor/src/index.d.ts +15 -0
  65. package/dist/blocks/CloudImageEditor/src/lib/classNames.d.ts +5 -0
  66. package/dist/blocks/CloudImageEditor/src/lib/classNames.test.d.ts +1 -0
  67. package/dist/blocks/CloudImageEditor/src/lib/linspace.d.ts +1 -0
  68. package/dist/blocks/CloudImageEditor/src/lib/linspace.test.d.ts +1 -0
  69. package/dist/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +4 -0
  70. package/dist/blocks/CloudImageEditor/src/lib/parseCropPreset.test.d.ts +1 -0
  71. package/dist/blocks/CloudImageEditor/src/lib/parseTabs.d.ts +2 -0
  72. package/dist/blocks/CloudImageEditor/src/lib/pick.d.ts +1 -0
  73. package/dist/blocks/CloudImageEditor/src/lib/pick.test.d.ts +1 -0
  74. package/dist/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +7 -0
  75. package/dist/blocks/CloudImageEditor/src/state.d.ts +20 -0
  76. package/dist/blocks/CloudImageEditor/src/svg-sprite.d.ts +2 -0
  77. package/dist/blocks/CloudImageEditor/src/toolbar-constants.d.ts +61 -0
  78. package/dist/blocks/CloudImageEditor/src/types.d.ts +60 -0
  79. package/dist/blocks/CloudImageEditor/src/util.d.ts +2 -0
  80. package/dist/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +7 -0
  81. package/dist/blocks/CloudImageEditor/src/utils/parseFilterValue.test.d.ts +1 -0
  82. package/dist/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +25 -0
  83. package/dist/blocks/Config/Config.d.ts +60 -0
  84. package/dist/blocks/Config/assertions.d.ts +5 -0
  85. package/dist/blocks/Config/computed-properties.d.ts +24 -0
  86. package/dist/blocks/Config/computed-properties.test.d.ts +1 -0
  87. package/dist/blocks/Config/initialConfig.d.ts +6 -0
  88. package/dist/blocks/Config/normalizeConfigValue.d.ts +2 -0
  89. package/dist/blocks/Config/validatorsType.d.ts +18 -0
  90. package/dist/blocks/Copyright/Copyright.d.ts +10 -0
  91. package/dist/blocks/DropArea/DropArea.d.ts +47 -0
  92. package/dist/blocks/DropArea/addDropzone.d.ts +17 -0
  93. package/dist/blocks/DropArea/getDropItems.d.ts +12 -0
  94. package/dist/blocks/ExternalSource/ExternalSource.d.ts +45 -0
  95. package/dist/blocks/ExternalSource/MessageBridge.d.ts +11 -0
  96. package/dist/blocks/ExternalSource/buildThemeDefinition.d.ts +4 -0
  97. package/dist/blocks/ExternalSource/query-string.d.ts +1 -0
  98. package/dist/blocks/ExternalSource/types.d.ts +105 -0
  99. package/dist/blocks/FileItem/FileItem.d.ts +50 -0
  100. package/dist/blocks/FileItem/FileItemConfig.d.ts +10 -0
  101. package/dist/blocks/FormInput/FormInput.d.ts +18 -0
  102. package/dist/blocks/Icon/Icon.d.ts +19 -0
  103. package/dist/blocks/Img/Img.d.ts +14 -0
  104. package/dist/blocks/Img/ImgBase.d.ts +29 -0
  105. package/dist/blocks/Img/ImgConfig.d.ts +28 -0
  106. package/dist/blocks/Img/configurations.d.ts +11 -0
  107. package/dist/blocks/Img/props-map.d.ts +28 -0
  108. package/dist/blocks/Img/utils/parseObjectToString.d.ts +2 -0
  109. package/dist/blocks/Modal/Modal.d.ts +34 -0
  110. package/dist/blocks/PluginActivityRenderer/PluginActivityRenderer.d.ts +32 -0
  111. package/dist/blocks/PluginActivityRenderer/index.d.ts +1 -0
  112. package/dist/blocks/ProgressBar/ProgressBar.d.ts +21 -0
  113. package/dist/blocks/ProgressBarCommon/ProgressBarCommon.d.ts +17 -0
  114. package/dist/blocks/Select/Select.d.ts +18 -0
  115. package/dist/blocks/SimpleBtn/SimpleBtn.d.ts +15 -0
  116. package/dist/blocks/SourceBtn/SourceBtn.d.ts +23 -0
  117. package/dist/blocks/SourceList/SourceList.d.ts +24 -0
  118. package/dist/blocks/Spinner/Spinner.d.ts +9 -0
  119. package/dist/blocks/StartFrom/StartFrom.d.ts +12 -0
  120. package/dist/blocks/Thumb/Thumb.d.ts +35 -0
  121. package/dist/blocks/UploadCtxProvider/EventEmitter.d.ts +70 -0
  122. package/dist/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +44 -0
  123. package/dist/blocks/UploadList/UploadList.d.ts +39 -0
  124. package/dist/blocks/UrlSource/UrlSource.d.ts +14 -0
  125. package/dist/blocks/svg-backgrounds/svg-backgrounds.d.ts +3 -0
  126. package/dist/blocks/themes/uc-basic/svg-sprite.d.ts +2 -0
  127. package/dist/cameraPlugin-dGash48Q.js +8 -0
  128. package/dist/cloud-image-editor-fNswWrI4.js +11 -0
  129. package/dist/cloudImageEditorPlugin-2EU0Pm_j.js +8 -0
  130. package/dist/core.d.ts +42 -0
  131. package/dist/en-DNCwRJsB.js +135 -0
  132. package/dist/env-B1nfXy9i.js +8 -0
  133. package/dist/env.d.ts +2 -4
  134. package/dist/env.js +7 -6
  135. package/dist/externalSourcesPlugin-DKQqk3AC.js +8 -0
  136. package/dist/imageShrinkPlugin-DAx8eRen.js +8 -0
  137. package/dist/index.css +3964 -6
  138. package/dist/index.d.ts +29 -2715
  139. package/dist/index.js +1011 -8
  140. package/dist/index.layered.css +4478 -7
  141. package/dist/instagramPlugin-k67tMAo3.js +8 -0
  142. package/dist/lit/BaseComponent.d.ts +12 -0
  143. package/dist/lit/Constructor.d.ts +1 -0
  144. package/dist/lit/CssDataMixin.d.ts +7 -0
  145. package/dist/lit/LightDomMixin.d.ts +8 -0
  146. package/dist/lit/LitActivityBlock.d.ts +53 -0
  147. package/dist/lit/LitBlock.d.ts +83 -0
  148. package/dist/lit/LitSolutionBlock.d.ts +21 -0
  149. package/dist/lit/LitUploaderBlock.d.ts +53 -0
  150. package/dist/lit/PubSubCompat.d.ts +18 -0
  151. package/dist/lit/RegisterableElementMixin.d.ts +7 -0
  152. package/dist/lit/SharedState.d.ts +119 -0
  153. package/dist/lit/SymbioteCompatMixin.d.ts +40 -0
  154. package/dist/lit/TestModeController.d.ts +16 -0
  155. package/dist/lit/Uid.d.ts +3 -0
  156. package/dist/lit/activity-constants.d.ts +11 -0
  157. package/dist/lit/createDebugPrinter.d.ts +3 -0
  158. package/dist/lit/findBlockInCtx.d.ts +3 -0
  159. package/dist/lit/getOutputData.d.ts +2 -0
  160. package/dist/lit/hasBlockInCtx.d.ts +3 -0
  161. package/dist/lit/l10n.d.ts +5 -0
  162. package/dist/lit/parseCssPropertyValue.d.ts +1 -0
  163. package/dist/lit/shared-instances.d.ts +65 -0
  164. package/dist/loadFileUploaderFrom-BWJM43Yq.js +28 -0
  165. package/dist/locales/file-uploader/ar.d.ts +1 -4
  166. package/dist/locales/file-uploader/ar.js +142 -6
  167. package/dist/locales/file-uploader/az.d.ts +1 -4
  168. package/dist/locales/file-uploader/az.js +134 -6
  169. package/dist/locales/file-uploader/ca.d.ts +1 -4
  170. package/dist/locales/file-uploader/ca.js +136 -6
  171. package/dist/locales/file-uploader/cs.d.ts +1 -4
  172. package/dist/locales/file-uploader/cs.js +138 -6
  173. package/dist/locales/file-uploader/da.d.ts +1 -4
  174. package/dist/locales/file-uploader/da.js +134 -6
  175. package/dist/locales/file-uploader/de.d.ts +1 -4
  176. package/dist/locales/file-uploader/de.js +134 -6
  177. package/dist/locales/file-uploader/el.d.ts +1 -4
  178. package/dist/locales/file-uploader/el.js +134 -6
  179. package/dist/locales/file-uploader/en.d.ts +1 -4
  180. package/dist/locales/file-uploader/en.js +7 -6
  181. package/dist/locales/file-uploader/es.d.ts +1 -4
  182. package/dist/locales/file-uploader/es.js +136 -6
  183. package/dist/locales/file-uploader/et.d.ts +1 -4
  184. package/dist/locales/file-uploader/et.js +134 -6
  185. package/dist/locales/file-uploader/fi.d.ts +1 -4
  186. package/dist/locales/file-uploader/fi.js +134 -6
  187. package/dist/locales/file-uploader/fr.d.ts +1 -4
  188. package/dist/locales/file-uploader/fr.js +136 -6
  189. package/dist/locales/file-uploader/he.d.ts +1 -4
  190. package/dist/locales/file-uploader/he.js +136 -6
  191. package/dist/locales/file-uploader/hy.d.ts +1 -4
  192. package/dist/locales/file-uploader/hy.js +134 -6
  193. package/dist/locales/file-uploader/is.d.ts +1 -4
  194. package/dist/locales/file-uploader/is.js +134 -6
  195. package/dist/locales/file-uploader/it.d.ts +1 -4
  196. package/dist/locales/file-uploader/it.js +136 -6
  197. package/dist/locales/file-uploader/ja.d.ts +1 -4
  198. package/dist/locales/file-uploader/ja.js +134 -6
  199. package/dist/locales/file-uploader/ka.d.ts +1 -4
  200. package/dist/locales/file-uploader/ka.js +134 -6
  201. package/dist/locales/file-uploader/kk.d.ts +1 -4
  202. package/dist/locales/file-uploader/kk.js +134 -6
  203. package/dist/locales/file-uploader/ko.d.ts +1 -4
  204. package/dist/locales/file-uploader/ko.js +134 -6
  205. package/dist/locales/file-uploader/lv.d.ts +1 -4
  206. package/dist/locales/file-uploader/lv.js +136 -6
  207. package/dist/locales/file-uploader/nb.d.ts +1 -4
  208. package/dist/locales/file-uploader/nb.js +134 -6
  209. package/dist/locales/file-uploader/nl.d.ts +1 -4
  210. package/dist/locales/file-uploader/nl.js +134 -6
  211. package/dist/locales/file-uploader/pl.d.ts +1 -4
  212. package/dist/locales/file-uploader/pl.js +138 -6
  213. package/dist/locales/file-uploader/pt.d.ts +1 -4
  214. package/dist/locales/file-uploader/pt.js +136 -6
  215. package/dist/locales/file-uploader/ro.d.ts +1 -4
  216. package/dist/locales/file-uploader/ro.js +136 -6
  217. package/dist/locales/file-uploader/ru.d.ts +1 -4
  218. package/dist/locales/file-uploader/ru.js +138 -6
  219. package/dist/locales/file-uploader/sk.d.ts +1 -4
  220. package/dist/locales/file-uploader/sk.js +138 -6
  221. package/dist/locales/file-uploader/sr.d.ts +1 -4
  222. package/dist/locales/file-uploader/sr.js +136 -6
  223. package/dist/locales/file-uploader/sv.d.ts +1 -4
  224. package/dist/locales/file-uploader/sv.js +134 -6
  225. package/dist/locales/file-uploader/tr.d.ts +1 -4
  226. package/dist/locales/file-uploader/tr.js +134 -6
  227. package/dist/locales/file-uploader/uk.d.ts +1 -4
  228. package/dist/locales/file-uploader/uk.js +138 -6
  229. package/dist/locales/file-uploader/vi.d.ts +1 -4
  230. package/dist/locales/file-uploader/vi.js +134 -6
  231. package/dist/locales/file-uploader/zh-TW.d.ts +1 -4
  232. package/dist/locales/file-uploader/zh-TW.js +134 -6
  233. package/dist/locales/file-uploader/zh.d.ts +1 -4
  234. package/dist/locales/file-uploader/zh.js +134 -6
  235. package/dist/plugins/cameraPlugin.d.ts +2 -0
  236. package/dist/plugins/cloudImageEditorPlugin.d.ts +2 -0
  237. package/dist/plugins/externalSourcesPlugin.d.ts +2 -0
  238. package/dist/plugins/imageShrinkPlugin.d.ts +2 -0
  239. package/dist/plugins/instagramPlugin.d.ts +2 -0
  240. package/dist/plugins/unsplashPlugin.d.ts +16 -0
  241. package/dist/plugins/urlSourcePlugin.d.ts +2 -0
  242. package/dist/plugins-DxjsQUa8.js +278 -0
  243. package/dist/solutions/adaptive-image/index.d.ts +2 -0
  244. package/dist/solutions/cloud-image-editor/CloudImageEditor.d.ts +11 -0
  245. package/dist/solutions/cloud-image-editor/index.d.ts +5 -0
  246. package/dist/solutions/file-uploader/inline/FileUploaderInline.d.ts +20 -0
  247. package/dist/solutions/file-uploader/inline/index.d.ts +1 -0
  248. package/dist/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +23 -0
  249. package/dist/solutions/file-uploader/minimal/index.d.ts +1 -0
  250. package/dist/solutions/file-uploader/regular/FileUploaderRegular.d.ts +17 -0
  251. package/dist/solutions/file-uploader/regular/index.d.ts +1 -0
  252. package/dist/types/dom.d.ts +1 -0
  253. package/dist/types/events.d.ts +4 -0
  254. package/dist/types/exported.d.ts +492 -0
  255. package/dist/types/index.d.ts +5 -0
  256. package/dist/urlSourcePlugin-9xdB7Pvw.js +8 -0
  257. package/dist/utils/UID.d.ts +5 -0
  258. package/dist/utils/UID.test.d.ts +1 -0
  259. package/dist/utils/UploadSource.d.ts +37 -0
  260. package/dist/utils/WindowHeightTracker.d.ts +9 -0
  261. package/dist/utils/abilities.d.ts +1 -0
  262. package/dist/utils/applyStyles.d.ts +1 -0
  263. package/dist/utils/browser-info.d.ts +12 -0
  264. package/dist/utils/browser-info.test.d.ts +1 -0
  265. package/dist/utils/cdn-utils.d.ts +53 -0
  266. package/dist/utils/cdn-utils.test.d.ts +1 -0
  267. package/dist/utils/comma-separated.d.ts +2 -0
  268. package/dist/utils/debounce.d.ts +3 -0
  269. package/dist/utils/delay.d.ts +1 -0
  270. package/dist/utils/fileTypes.d.ts +11 -0
  271. package/dist/utils/fileTypes.test.d.ts +1 -0
  272. package/dist/utils/get-top-level-origin.d.ts +1 -0
  273. package/dist/utils/get-top-level-origin.test.d.ts +1 -0
  274. package/dist/utils/getLocaleDirection.d.ts +1 -0
  275. package/dist/utils/getPluralForm.d.ts +1 -0
  276. package/dist/utils/getPluralForm.test.d.ts +1 -0
  277. package/dist/utils/isPromiseLike.d.ts +1 -0
  278. package/dist/utils/isPromiseLike.test.d.ts +1 -0
  279. package/dist/utils/isSecureTokenExpired.d.ts +8 -0
  280. package/dist/utils/isSecureTokenExpired.test.d.ts +1 -0
  281. package/dist/utils/memoize.d.ts +1 -0
  282. package/dist/utils/memoize.test.d.ts +1 -0
  283. package/dist/utils/mixinClass.d.ts +8 -0
  284. package/dist/utils/parseCdnUrl.d.ts +11 -0
  285. package/dist/utils/parseCdnUrl.test.d.ts +1 -0
  286. package/dist/utils/parseShrink.d.ts +7 -0
  287. package/dist/utils/parseShrink.test.d.ts +1 -0
  288. package/dist/utils/preloadImage.d.ts +10 -0
  289. package/dist/utils/prettyBytes.d.ts +11 -0
  290. package/dist/utils/prettyBytes.test.d.ts +1 -0
  291. package/dist/utils/resizeImage.d.ts +1 -0
  292. package/dist/utils/stringToArray.d.ts +1 -0
  293. package/dist/utils/stringToArray.test.d.ts +1 -0
  294. package/dist/utils/template-utils.d.ts +16 -0
  295. package/dist/utils/template-utils.test.d.ts +1 -0
  296. package/dist/utils/throttle.d.ts +3 -0
  297. package/dist/utils/toKebabCase.d.ts +2 -0
  298. package/dist/utils/toKebabCase.test.d.ts +1 -0
  299. package/dist/utils/transparentPixelSrc.d.ts +1 -0
  300. package/dist/utils/uniqueArray.d.ts +1 -0
  301. package/dist/utils/uniqueArray.test.d.ts +1 -0
  302. package/dist/utils/userAgent.d.ts +2 -0
  303. package/dist/utils/validators/collection/index.d.ts +2 -0
  304. package/dist/utils/validators/collection/validateCollectionUploadError.d.ts +2 -0
  305. package/dist/utils/validators/collection/validateMultiple.d.ts +2 -0
  306. package/dist/utils/validators/file/index.d.ts +4 -0
  307. package/dist/utils/validators/file/validateFileType.d.ts +2 -0
  308. package/dist/utils/validators/file/validateIsImage.d.ts +2 -0
  309. package/dist/utils/validators/file/validateMaxSizeLimit.d.ts +2 -0
  310. package/dist/utils/validators/file/validateUploadError.d.ts +2 -0
  311. package/dist/utils/warnOnce.d.ts +1 -0
  312. package/dist/utils/wildcardRegexp.d.ts +1 -0
  313. package/dist/utils/wildcardRegexp.test.d.ts +1 -0
  314. package/dist/utils/withResolvers.d.ts +5 -0
  315. package/dist/utils/withResolvers.test.d.ts +1 -0
  316. package/package.json +10 -4
  317. package/dist/index.ssr.js +0 -1538
  318. package/web/file-uploader.iife.min.d.ts +0 -2859
  319. package/web/file-uploader.iife.min.js +0 -8
  320. package/web/file-uploader.iife.min.js.LEGAL.txt +0 -71
  321. package/web/file-uploader.min.d.ts +0 -2859
  322. package/web/file-uploader.min.js +0 -8
  323. package/web/file-uploader.min.js.LEGAL.txt +0 -71
  324. package/web/uc-basic.layered.min.css +0 -7
  325. package/web/uc-basic.min.css +0 -6
  326. package/web/uc-cloud-image-editor.layered.min.css +0 -7
  327. package/web/uc-cloud-image-editor.min.css +0 -6
  328. package/web/uc-cloud-image-editor.min.d.ts +0 -2816
  329. package/web/uc-cloud-image-editor.min.js +0 -8
  330. package/web/uc-cloud-image-editor.min.js.LEGAL.txt +0 -70
  331. package/web/uc-file-uploader-inline.layered.min.css +0 -7
  332. package/web/uc-file-uploader-inline.min.css +0 -6
  333. package/web/uc-file-uploader-inline.min.d.ts +0 -2859
  334. package/web/uc-file-uploader-inline.min.js +0 -8
  335. package/web/uc-file-uploader-inline.min.js.LEGAL.txt +0 -71
  336. package/web/uc-file-uploader-minimal.layered.min.css +0 -7
  337. package/web/uc-file-uploader-minimal.min.css +0 -6
  338. package/web/uc-file-uploader-minimal.min.d.ts +0 -2859
  339. package/web/uc-file-uploader-minimal.min.js +0 -8
  340. package/web/uc-file-uploader-minimal.min.js.LEGAL.txt +0 -71
  341. package/web/uc-file-uploader-regular.layered.min.css +0 -7
  342. package/web/uc-file-uploader-regular.min.css +0 -6
  343. package/web/uc-file-uploader-regular.min.d.ts +0 -2859
  344. package/web/uc-file-uploader-regular.min.js +0 -8
  345. package/web/uc-file-uploader-regular.min.js.LEGAL.txt +0 -71
  346. package/web/uc-img.min.d.ts +0 -75
  347. package/web/uc-img.min.js +0 -8
  348. package/web/uc-img.min.js.LEGAL.txt +0 -24
@@ -0,0 +1,998 @@
1
+ /**
2
+ * @license
3
+ * Package: @uploadcare/file-uploader@1.28.0-alpha.0 (MIT)
4
+ * License: https://github.com/uploadcare/blob/main/LICENSE
5
+ * Built: 2026-03-02T14:46:15.080Z
6
+ */
7
+ import { $ as createCdnUrl, A as CameraSourceTypes, B as SharedInstance, I as activityBlockCtx, M as createL10n, N as getPluralForm, O as warnOnce, P as EventType, Q as stringToArray, R as uploaderBlockCtx, V as DEFAULT_CDN_CNAME, et as createCdnUrlModifiers, i as calculateMaxCenteredCropFrame, it as sharedConfigKey, j as LitBlock, lt as debounce, ot as UID, pt as PubSub, r as parseCropPreset } from "./Icon-CqTVC82Q.js";
8
+ import { c as UploadSource, d as ACTIVITY_TYPES, f as deserializeCsv, l as browserFeatures, p as serializeCsv, s as ExternalUploadSource, u as browserInfo } from "./plugins-DxjsQUa8.js";
9
+ import { n as PACKAGE_VERSION, t as PACKAGE_NAME } from "./env-B1nfXy9i.js";
10
+ import { NetworkError, Queue, UploadError, getUserAgent, uploadFileGroup } from "@uploadcare/upload-client";
11
+ var msToUnixTimestamp = (p) => typeof p == "number" ? Math.floor(p / 1e3) : 0;
12
+ const isSecureTokenExpired = (p, { threshold: H }) => {
13
+ let { secureExpire: U } = p, W = msToUnixTimestamp(Date.now()), G = Number(U);
14
+ return W + msToUnixTimestamp(H) >= G;
15
+ };
16
+ var SecureUploadsManager = class extends SharedInstance {
17
+ constructor(...p) {
18
+ super(...p), this._secureToken = null;
19
+ }
20
+ async getSecureToken() {
21
+ let { secureSignature: p, secureExpire: H, secureUploadsSignatureResolver: U, secureUploadsExpireThreshold: W } = this._cfg;
22
+ if ((p || H) && U && console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."), U) {
23
+ if (!this._secureToken || isSecureTokenExpired(this._secureToken, { threshold: W })) {
24
+ this._secureToken ? this._debugPrint("Secure signature is expired. Resolving a new one...") : this._debugPrint("Secure signature is not set yet.");
25
+ try {
26
+ let p = await U();
27
+ p ? !p.secureSignature || !p.secureExpire ? console.error("Secure signature resolver returned an invalid result:", p) : (this._debugPrint("Secure signature resolved:", p), this._debugPrint("Secure signature will expire in", (/* @__PURE__ */ new Date(Number(p.secureExpire) * 1e3)).toISOString()), this._secureToken = p) : (this._debugPrint("Secure signature resolver returned nothing."), this._secureToken = null);
28
+ } catch (p) {
29
+ console.error("Secure signature resolving failed. Falling back to the previous one.", p), this._sharedInstancesBag.telemetryManager.sendEventError(p, "secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");
30
+ }
31
+ }
32
+ return this._secureToken;
33
+ }
34
+ return p && H ? (this._debugPrint("Secure signature and expire are set. Using them...", {
35
+ secureSignature: p,
36
+ secureExpire: H
37
+ }), {
38
+ secureSignature: p,
39
+ secureExpire: H
40
+ }) : null;
41
+ }
42
+ destroy() {
43
+ super.destroy(), this._secureToken = null;
44
+ }
45
+ };
46
+ const validateCollectionUploadError = (p, H) => {
47
+ if (p.failedCount > 0) return {
48
+ type: "SOME_FILES_HAS_ERRORS",
49
+ message: H.l10n("some-files-were-not-uploaded")
50
+ };
51
+ }, validateMultiple = (p, H) => {
52
+ let U = p.totalCount, W = H.cfg.multiple ? H.cfg.multipleMin : 0, G = H.cfg.multiple ? H.cfg.multipleMax : 1;
53
+ if (W && U < W) return {
54
+ type: "TOO_FEW_FILES",
55
+ message: H.l10n("files-count-limit-error-too-few", {
56
+ min: W,
57
+ max: G,
58
+ total: U
59
+ }),
60
+ payload: {
61
+ total: U,
62
+ min: W,
63
+ max: G
64
+ }
65
+ };
66
+ if (G && U > G) return {
67
+ type: "TOO_MANY_FILES",
68
+ message: H.l10n("files-count-limit-error-too-many", {
69
+ min: W,
70
+ max: G,
71
+ total: U
72
+ }),
73
+ payload: {
74
+ total: U,
75
+ min: W,
76
+ max: G
77
+ }
78
+ };
79
+ }, BASIC_IMAGE_WILDCARD = "image/*", HEIC_IMAGE_MIME_LIST = [
80
+ "image/heif",
81
+ "image/heif-sequence",
82
+ "image/heic",
83
+ "image/heic-sequence",
84
+ "image/avif",
85
+ "image/avif-sequence",
86
+ ".heif",
87
+ ".heifs",
88
+ ".heic",
89
+ ".heics",
90
+ ".avif",
91
+ ".avifs"
92
+ ], IMAGE_ACCEPT_LIST = (() => browserInfo.safariDesktop ? [BASIC_IMAGE_WILDCARD] : [BASIC_IMAGE_WILDCARD, ...HEIC_IMAGE_MIME_LIST])(), mergeFileTypes = (p) => p ? p.filter((p) => typeof p == "string").flatMap((p) => stringToArray(p)) : [], matchMimeType = (p, H) => H.some((H) => {
93
+ if (H.endsWith("*")) {
94
+ let U = H.replace("*", "");
95
+ return p.startsWith(U);
96
+ }
97
+ return p === H;
98
+ }), matchExtension = (p, H) => H.some((H) => H.startsWith(".") ? p.toLowerCase().endsWith(H.toLowerCase()) : !1), fileIsImage = (p) => {
99
+ let H = p?.type;
100
+ return H ? matchMimeType(H, IMAGE_ACCEPT_LIST) : !1;
101
+ }, validateFileType = (p, H) => {
102
+ let U = H.cfg.imgOnly, W = H.cfg.accept, G = mergeFileTypes([...U ? IMAGE_ACCEPT_LIST : [], W]);
103
+ if (!G.length) return;
104
+ let K = p.mimeType, q = p.name;
105
+ if (!K || !q) return;
106
+ let J = matchMimeType(K, G), Y = matchExtension(q, G);
107
+ if (!J && !Y) return {
108
+ type: "FORBIDDEN_FILE_TYPE",
109
+ message: H.l10n("file-type-not-allowed"),
110
+ payload: { entry: p }
111
+ };
112
+ }, validateIsImage = (p, H) => {
113
+ let U = H.cfg.imgOnly, W = p.isImage;
114
+ if (!(!U || W) && !(!p.fileInfo && p.externalUrl) && !(!p.fileInfo && !p.mimeType)) return {
115
+ type: "NOT_AN_IMAGE",
116
+ message: H.l10n("images-only-accepted"),
117
+ payload: { entry: p }
118
+ };
119
+ };
120
+ var BASE = 1e3;
121
+ const ByteUnitEnum = Object.freeze({
122
+ AUTO: "auto",
123
+ BYTE: "byte",
124
+ KB: "kb",
125
+ MB: "mb",
126
+ GB: "gb",
127
+ TB: "tb",
128
+ PB: "pb"
129
+ });
130
+ var round = (p) => Math.ceil(p * 100) / 100;
131
+ const prettyBytes = (p, H = ByteUnitEnum.AUTO) => {
132
+ let U = H === ByteUnitEnum.AUTO;
133
+ return H === ByteUnitEnum.BYTE || U && p < BASE ** 1 ? `${p} ${getPluralForm("en-US", p) === "one" ? "byte" : "bytes"}` : H === ByteUnitEnum.KB || U && p < BASE ** 2 ? `${round(p / BASE ** 1)} KB` : H === ByteUnitEnum.MB || U && p < BASE ** 3 ? `${round(p / BASE ** 2)} MB` : H === ByteUnitEnum.GB || U && p < BASE ** 4 ? `${round(p / BASE ** 3)} GB` : H === ByteUnitEnum.TB || U && p < BASE ** 5 ? `${round(p / BASE ** 4)} TB` : `${round(p / BASE ** 5)} PB`;
134
+ }, validateMaxSizeLimit = (p, H) => {
135
+ let U = H.cfg.maxLocalFileSizeBytes, W = p.size;
136
+ if (U && W && W > U) return {
137
+ type: "FILE_SIZE_EXCEEDED",
138
+ message: H.l10n("files-max-size-limit-error", { maxFileSize: prettyBytes(U) }),
139
+ payload: { entry: p }
140
+ };
141
+ }, validateUploadError = (p, H) => {
142
+ let { internalId: U } = p;
143
+ if (!H._uploadCollection.hasItem(U)) return;
144
+ let W = H._uploadCollection.read(U)?.getValue("uploadError");
145
+ if (!W) return;
146
+ if (W instanceof UploadError) return {
147
+ type: "UPLOAD_ERROR",
148
+ message: W.message,
149
+ payload: {
150
+ entry: p,
151
+ error: W
152
+ }
153
+ };
154
+ if (W instanceof NetworkError) return {
155
+ type: "NETWORK_ERROR",
156
+ message: W.message,
157
+ payload: {
158
+ entry: p,
159
+ error: W
160
+ }
161
+ };
162
+ let G = W instanceof Error ? W : Error("Unknown error", { cause: W });
163
+ return {
164
+ type: "UNKNOWN_ERROR",
165
+ message: G.message,
166
+ payload: {
167
+ entry: p,
168
+ error: G
169
+ }
170
+ };
171
+ };
172
+ var LOG_TEXT = {
173
+ FILE_VALIDATION_FAILED: "File validator execution has failed",
174
+ FILE_VALIDATION_TIMEOUT: "File validator execution has timed out",
175
+ COLLECTION_VALIDATION_FAILED: "Collection validator execution has failed",
176
+ MISSING_ERROR_MESSAGE: "Missing message. We recommend adding message: value."
177
+ }, getValidatorDescriptor = (p) => typeof p == "function" ? {
178
+ runOn: "change",
179
+ validator: p
180
+ } : p, ValidationManager = class extends SharedInstance {
181
+ get _uploadCollection() {
182
+ return this._sharedInstancesBag.uploadCollection;
183
+ }
184
+ constructor(p) {
185
+ super(p), this._commonFileValidators = [
186
+ validateIsImage,
187
+ validateFileType,
188
+ validateMaxSizeLimit,
189
+ validateUploadError
190
+ ], this._commonCollectionValidators = [validateMultiple, validateCollectionUploadError], this._queue = new Queue(20), this._runQueueDebounced = debounce(() => {
191
+ this._queue.run();
192
+ }, 500), this._isDestroyed = !1, this._entryValidationState = /* @__PURE__ */ new Map();
193
+ let H = debounce(() => {
194
+ this.runFileValidators("change"), this.runCollectionValidators();
195
+ }, 0);
196
+ this.addSub(this._ctx.sub(sharedConfigKey("maxLocalFileSizeBytes"), H)), this.addSub(this._ctx.sub(sharedConfigKey("multipleMin"), H)), this.addSub(this._ctx.sub(sharedConfigKey("multipleMax"), H)), this.addSub(this._ctx.sub(sharedConfigKey("multiple"), H)), this.addSub(this._ctx.sub(sharedConfigKey("imgOnly"), H)), this.addSub(this._ctx.sub(sharedConfigKey("accept"), H)), this.addSub(this._ctx.sub(sharedConfigKey("validationConcurrency"), (p) => {
197
+ this._queue.concurrency = p;
198
+ }));
199
+ }
200
+ runFileValidators(p, H) {
201
+ if (this._isDestroyed) return;
202
+ let U = H ?? this._uploadCollection.items();
203
+ for (let H of U) {
204
+ let U = this._uploadCollection.read(H);
205
+ U && this._runFileValidatorsForEntry(U, p);
206
+ }
207
+ }
208
+ runCollectionValidators() {
209
+ if (this._isDestroyed) return;
210
+ let p = this._sharedInstancesBag.api, H = p.getOutputCollectionState(), U = [], W = this._cfg.collectionValidators;
211
+ for (let G of [...this._commonCollectionValidators, ...W]) try {
212
+ let W = G(H, p);
213
+ if (!W) continue;
214
+ W && (U.push(this._addCustomTypeToValidationError(W)), W.message || console.warn(LOG_TEXT.MISSING_ERROR_MESSAGE));
215
+ } catch (p) {
216
+ console.warn(LOG_TEXT.COLLECTION_VALIDATION_FAILED, p);
217
+ }
218
+ this._ctx.pub("*collectionErrors", U), U.length > 0 && this._sharedInstancesBag.eventEmitter.emit(EventType.COMMON_UPLOAD_FAILED, () => p.getOutputCollectionState(), { debounce: !0 });
219
+ }
220
+ cleanupValidationForEntry(p) {
221
+ let H = this._entryValidationState.get(p.uid);
222
+ H && (H.abortController?.abort(), this._entryValidationState.delete(p.uid));
223
+ }
224
+ async _runFileValidatorsForEntry(p, H) {
225
+ if (this._isDestroyed) return;
226
+ let U = this._sharedInstancesBag.api, W = this._getEntryValidationState(p), G = W.promise ?? Promise.resolve(), K = (async () => {
227
+ if (this._isDestroyed || (await G, this._isDestroyed)) return;
228
+ let K = this._getValidatorDescriptorsForEntry(p, H);
229
+ if (K.length === 0 || !this._uploadCollection.hasItem(p.uid)) return;
230
+ p.setMultipleValues({
231
+ isQueuedForValidation: !0,
232
+ isValidationPending: !0
233
+ });
234
+ let q = U.getOutputItem(p.uid), J = new AbortController();
235
+ W.abortController = J;
236
+ let Y = this._cfg.validationTimeout, X = this._getValidatorDescriptors(), Z = new Set(K.map((p) => p.validator)), Q = [];
237
+ for (let p of X) if (!Z.has(p.validator)) {
238
+ let H = W.lastErrorThrownByValidator.get(p.validator);
239
+ H && Q.push(H);
240
+ }
241
+ let $ = K.map((p) => async () => {
242
+ if (this._isDestroyed) return;
243
+ let H = setTimeout(() => {
244
+ W.skippedValidators.add(p.validator), J.abort(), console.warn(LOG_TEXT.FILE_VALIDATION_TIMEOUT);
245
+ }, Y);
246
+ try {
247
+ let H = await p.validator(q, U, { signal: J.signal });
248
+ if (!H || J.signal.aborted) {
249
+ W.lastErrorThrownByValidator.set(p.validator, void 0);
250
+ return;
251
+ }
252
+ let G = this._addCustomTypeToValidationError(H);
253
+ W.lastErrorThrownByValidator.set(p.validator, G), Q.push(G), H.message || console.warn(LOG_TEXT.MISSING_ERROR_MESSAGE);
254
+ } catch (H) {
255
+ J.signal.aborted || (W.skippedValidators.add(p.validator), console.warn(LOG_TEXT.FILE_VALIDATION_FAILED, H), this._sharedInstancesBag.telemetryManager.sendEventError(H, `file validator. ${LOG_TEXT.FILE_VALIDATION_FAILED}`));
256
+ } finally {
257
+ clearTimeout(H), p.runOn !== "change" && W.skippedValidators.add(p.validator);
258
+ }
259
+ });
260
+ if (this._runQueueDebounced(), await this._queue.add(async () => {
261
+ this._isDestroyed || (p.setValue("isQueuedForValidation", !1), await Promise.all($.map((p) => p())).catch(() => {}));
262
+ }, { autoRun: !1 }), J.signal.aborted) {
263
+ p.setMultipleValues({
264
+ isQueuedForValidation: !1,
265
+ isValidationPending: !1
266
+ });
267
+ return;
268
+ }
269
+ p.setMultipleValues({
270
+ isValidationPending: !1,
271
+ isQueuedForValidation: !1,
272
+ errors: Q
273
+ });
274
+ })();
275
+ W.promise = K;
276
+ try {
277
+ await K;
278
+ } finally {
279
+ W.promise === K && (W.promise = void 0);
280
+ }
281
+ }
282
+ _addCustomTypeToValidationError(p) {
283
+ return {
284
+ ...p,
285
+ type: p.type ?? "CUSTOM_ERROR"
286
+ };
287
+ }
288
+ _getEntryValidationState(p) {
289
+ let H = this._entryValidationState.get(p.uid);
290
+ if (H) return H;
291
+ let U = {
292
+ abortController: void 0,
293
+ skippedValidators: /* @__PURE__ */ new WeakSet(),
294
+ promise: void 0,
295
+ lastErrorThrownByValidator: /* @__PURE__ */ new WeakMap()
296
+ };
297
+ return this._entryValidationState.set(p.uid, U), U;
298
+ }
299
+ _getValidatorDescriptors() {
300
+ let p = this._cfg.fileValidators;
301
+ return [...this._commonFileValidators, ...p].map(getValidatorDescriptor);
302
+ }
303
+ _getValidatorDescriptorsForEntry(p, H) {
304
+ let U = this._getEntryValidationState(p);
305
+ return this._getValidatorDescriptors().filter((p) => !U.skippedValidators.has(p.validator)).filter((p) => p.runOn === H);
306
+ }
307
+ destroy() {
308
+ this._isDestroyed = !0, this._runQueueDebounced.cancel();
309
+ for (let p of this._entryValidationState.values()) p.abortController?.abort(), p.promise = void 0;
310
+ this._entryValidationState.clear();
311
+ }
312
+ }, MSG_NAME = "[Typed State] Wrong property name: ", TypedData = class {
313
+ constructor(p) {
314
+ this._ctxId = UID.generateFastUid(), this._data = PubSub.registerCtx(p, this._ctxId);
315
+ }
316
+ get uid() {
317
+ return this._ctxId;
318
+ }
319
+ setValue(p, H) {
320
+ if (!this._data.has(p)) {
321
+ console.warn(`${MSG_NAME}${String(p)}`);
322
+ return;
323
+ }
324
+ this._data.read(p) !== H && this._data.pub(p, H);
325
+ }
326
+ setMultipleValues(p) {
327
+ for (let [H, U] of Object.entries(p)) this.setValue(H, U);
328
+ }
329
+ getValue(p) {
330
+ return this._data.has(p) || console.warn(`${MSG_NAME}${String(p)}`), this._data.read(p);
331
+ }
332
+ subscribe(p, H) {
333
+ return this._data.sub(p, H);
334
+ }
335
+ destroy() {
336
+ PubSub.deleteCtx(this._ctxId);
337
+ }
338
+ }, TypedCollection = class p {
339
+ static {
340
+ this._destroyDelayMs = 1e4;
341
+ }
342
+ constructor(p) {
343
+ this._subsMap = Object.create(null), this._propertyObservers = /* @__PURE__ */ new Set(), this._collectionObservers = /* @__PURE__ */ new Set(), this._items = /* @__PURE__ */ new Set(), this._removed = /* @__PURE__ */ new Set(), this._added = /* @__PURE__ */ new Set(), this._markedToDestroy = /* @__PURE__ */ new Set(), this._initialValue = p.initialValue, this._ctxId = UID.generateFastUid(), this._data = PubSub.registerCtx({}, this._ctxId), this._watchList = p.watchList || [];
344
+ let H = Object.create(null);
345
+ this._notifyObservers = (p, U) => {
346
+ this._observeTimeout && window.clearTimeout(this._observeTimeout), H[p] || (H[p] = /* @__PURE__ */ new Set()), H[p].add(U), this._observeTimeout = window.setTimeout(() => {
347
+ Object.keys(H).length !== 0 && (this._propertyObservers.forEach((p) => {
348
+ p({ ...H });
349
+ }), H = Object.create(null));
350
+ }), this._scheduleDestroyMarkedItems();
351
+ }, p.handler && this.observeCollection(p.handler);
352
+ }
353
+ _notify() {
354
+ this._notifyTimeout && window.clearTimeout(this._notifyTimeout), this._notifyTimeout = window.setTimeout(() => {
355
+ let p = new Set(this._added), H = new Set(this._removed);
356
+ this._added.clear(), this._removed.clear();
357
+ for (let U of this._collectionObservers) U?.([...this._items], p, H);
358
+ this._scheduleDestroyMarkedItems();
359
+ });
360
+ }
361
+ _scheduleDestroyMarkedItems() {
362
+ this._markedToDestroy.size !== 0 && (this._destroyTimeout && window.clearTimeout(this._destroyTimeout), this._destroyTimeout = window.setTimeout(() => {
363
+ let p = [...this._markedToDestroy];
364
+ this._markedToDestroy.clear();
365
+ for (let H of p) H.destroy();
366
+ }, p._destroyDelayMs));
367
+ }
368
+ observeCollection(p) {
369
+ return this._collectionObservers.add(p), this._items.size > 0 && this._notify(), () => {
370
+ this.unobserveCollection(p);
371
+ };
372
+ }
373
+ unobserveCollection(p) {
374
+ this._collectionObservers.delete(p);
375
+ }
376
+ add(p) {
377
+ let H = new TypedData(this._initialValue);
378
+ for (let [U, W] of Object.entries(p)) H.setValue(U, W);
379
+ return this._items.add(H.uid), this._notify(), this._data.add(H.uid, H), this._added.add(H), this._watchList.forEach((p) => {
380
+ this._subsMap[H.uid] || (this._subsMap[H.uid] = []), this._subsMap[H.uid]?.push(H.subscribe(p, () => {
381
+ this._notifyObservers(p, H.uid);
382
+ }));
383
+ }), H.uid;
384
+ }
385
+ hasItem(p) {
386
+ return this._items.has(p);
387
+ }
388
+ read(p) {
389
+ return this._data.read(p) ?? null;
390
+ }
391
+ readProp(p, H) {
392
+ let U = this.read(p);
393
+ if (!U) throw Error(`TypedCollection#readProp: Item with id ${p} not found`);
394
+ return U.getValue(H);
395
+ }
396
+ publishProp(p, H, U) {
397
+ let W = this.read(p);
398
+ if (!W) throw Error(`TypedCollection#publishProp: Item with id ${p} not found`);
399
+ W.setValue(H, U);
400
+ }
401
+ remove(p) {
402
+ let H = this.read(p);
403
+ H && (this._removed.add(H), this._markedToDestroy.add(H)), this._items.delete(p), this._notify(), this._data.pub(p, void 0), this._subsMap[p]?.forEach((p) => {
404
+ p();
405
+ }), delete this._subsMap[p];
406
+ }
407
+ clearAll() {
408
+ this._items.forEach((p) => {
409
+ this.remove(p);
410
+ });
411
+ }
412
+ observeProperties(p) {
413
+ return this._propertyObservers.add(p), () => {
414
+ this.unobserveProperties(p);
415
+ };
416
+ }
417
+ unobserveProperties(p) {
418
+ this._propertyObservers.delete(p);
419
+ }
420
+ findItems(p) {
421
+ let H = [];
422
+ return this._items.forEach((U) => {
423
+ let W = this.read(U);
424
+ W && p(W) && H.push(U);
425
+ }), H;
426
+ }
427
+ items() {
428
+ return [...this._items];
429
+ }
430
+ get size() {
431
+ return this._items.size;
432
+ }
433
+ destroy() {
434
+ this._observeTimeout && window.clearTimeout(this._observeTimeout), this._notifyTimeout && window.clearTimeout(this._notifyTimeout), this._destroyTimeout && window.clearTimeout(this._destroyTimeout);
435
+ for (let p of this._markedToDestroy) p.destroy();
436
+ this._markedToDestroy.clear(), PubSub.deleteCtx(this._ctxId), this._propertyObservers = /* @__PURE__ */ new Set(), this._collectionObservers = /* @__PURE__ */ new Set();
437
+ for (let p of Object.keys(this._subsMap)) this._subsMap[p]?.forEach((p) => {
438
+ p();
439
+ }), delete this._subsMap[p];
440
+ }
441
+ };
442
+ const calcCameraModes = (p) => ({
443
+ isVideoRecordingEnabled: deserializeCsv(p.cameraModes).includes(CameraSourceTypes.VIDEO),
444
+ isPhotoEnabled: deserializeCsv(p.cameraModes).includes(CameraSourceTypes.PHOTO)
445
+ }), findBlockInCtx = (p, H) => {
446
+ for (let U of p) if (H(U)) return U;
447
+ }, hasBlockInCtx = (p, H) => {
448
+ for (let U of p) if (H(U)) return !0;
449
+ return !1;
450
+ };
451
+ function applyStyles(p, H) {
452
+ for (let U in H) U.includes("-") ? p.style.setProperty(U, String(H[U])) : p.style[U] = String(H[U]);
453
+ }
454
+ var cdnUrlRegex = RegExp("^/?([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})(?:/(-/(?:[^/]+/)+)?([^/]*))?$", "i");
455
+ const parseCdnUrl = ({ url: p, cdnBase: H }) => {
456
+ let U = new URL(H), W = new URL(DEFAULT_CDN_CNAME), G = new URL(p);
457
+ if (U.host !== G.host && W.host !== G.host) return null;
458
+ let K = cdnUrlRegex.exec(G.pathname);
459
+ if (!K) return null;
460
+ let [, q, J, Y] = K;
461
+ return q ? {
462
+ uuid: q,
463
+ cdnUrlModifiers: J || "",
464
+ filename: Y || null
465
+ } : null;
466
+ }, getOutputData = (p) => p.uploadCollection.items().map((H) => p.api.getOutputItem(H));
467
+ function memoize(p) {
468
+ let H = /* @__PURE__ */ new Map();
469
+ return (...U) => {
470
+ let W = JSON.stringify(U);
471
+ if (H.has(W)) return H.get(W);
472
+ let G = p(...U);
473
+ return H.set(W, G), G;
474
+ };
475
+ }
476
+ function createAsyncAssertWrapper(p) {
477
+ let H = !1;
478
+ return setTimeout(() => {
479
+ H = !0;
480
+ }, 0), (U) => ((...W) => (H && warnOnce(p), U(...W)));
481
+ }
482
+ function buildOutputCollectionState(p) {
483
+ let H = {}, U = p.ctx, W = {
484
+ progress: () => U.read("*commonProgress"),
485
+ errors: () => U.read("*collectionErrors"),
486
+ group: () => U.read("*groupInfo"),
487
+ totalCount: () => p.uploadCollection.size,
488
+ failedCount: () => H.failedEntries.length,
489
+ successCount: () => H.successEntries.length,
490
+ uploadingCount: () => H.uploadingEntries.length,
491
+ status: () => H.isFailed ? "failed" : H.isUploading ? "uploading" : H.isSuccess ? "success" : "idle",
492
+ isSuccess: () => H.allEntries.length > 0 && H.errors.length === 0 && H.successEntries.length === H.allEntries.length,
493
+ isUploading: () => H.allEntries.some((p) => p.status === "uploading"),
494
+ isFailed: () => H.errors.length > 0 || H.failedEntries.length > 0,
495
+ allEntries: () => getOutputData(p),
496
+ successEntries: () => H.allEntries.filter((p) => p.status === "success"),
497
+ failedEntries: () => H.allEntries.filter((p) => p.status === "failed"),
498
+ uploadingEntries: () => H.allEntries.filter((p) => p.status === "uploading"),
499
+ idleEntries: () => H.allEntries.filter((p) => p.status === "idle")
500
+ }, G = createAsyncAssertWrapper("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");
501
+ for (let [p, U] of Object.entries(W)) {
502
+ let W = p, K = memoize(G(U));
503
+ Object.defineProperty(H, W, {
504
+ get: K,
505
+ enumerable: !0
506
+ });
507
+ }
508
+ return H;
509
+ }
510
+ var UploaderPublicApi = class extends SharedInstance {
511
+ constructor(...p) {
512
+ super(...p), this._l10n = createL10n(() => this._ctx), this.addFileFromUrl = (p, { silent: H, fileName: U, source: W } = {}) => {
513
+ let G = this._uploadCollection.add({
514
+ externalUrl: p,
515
+ fileName: U ?? null,
516
+ silent: H ?? !1,
517
+ source: W ?? UploadSource.API
518
+ });
519
+ return this.getOutputItem(G);
520
+ }, this.addFileFromUuid = (p, { silent: H, fileName: U, source: W } = {}) => {
521
+ let G = this._uploadCollection.add({
522
+ uuid: p,
523
+ fileName: U ?? null,
524
+ silent: H ?? !1,
525
+ source: W ?? UploadSource.API
526
+ });
527
+ return this.getOutputItem(G);
528
+ }, this.addFileFromCdnUrl = (p, { silent: H, fileName: U, source: W } = {}) => {
529
+ let G = parseCdnUrl({
530
+ url: p,
531
+ cdnBase: this.cfg.cdnCname
532
+ });
533
+ if (!G) throw Error("Invalid CDN URL");
534
+ let K = this._uploadCollection.add({
535
+ uuid: G.uuid,
536
+ cdnUrl: p,
537
+ cdnUrlModifiers: G.cdnUrlModifiers,
538
+ fileName: U ?? G.filename ?? null,
539
+ silent: H ?? !1,
540
+ source: W ?? UploadSource.API
541
+ });
542
+ return this.getOutputItem(K);
543
+ }, this.addFileFromObject = (p, { silent: H, fileName: U, source: W, fullPath: G } = {}) => {
544
+ let K = this._uploadCollection.add({
545
+ file: p,
546
+ isImage: fileIsImage(p),
547
+ mimeType: p.type,
548
+ fileName: U ?? p.name,
549
+ fileSize: p.size,
550
+ silent: H ?? !1,
551
+ source: W ?? UploadSource.API,
552
+ fullPath: G ?? null
553
+ });
554
+ return this.getOutputItem(K);
555
+ }, this.removeFileByInternalId = (p) => {
556
+ if (!this._uploadCollection.read(p)) throw Error(`File with internalId ${p} not found`);
557
+ this._uploadCollection.remove(p);
558
+ }, this.uploadAll = () => {
559
+ let p = this._uploadCollection.items().filter((p) => {
560
+ let H = this._uploadCollection.read(p);
561
+ return H ? !H.getValue("isRemoved") && !H.getValue("isUploading") && !H.getValue("fileInfo") && H.getValue("errors").length === 0 && !H.getValue("isValidationPending") && !H.getValue("isQueuedForValidation") : !1;
562
+ });
563
+ p.length !== 0 && (this._ctx.pub("*uploadTrigger", new Set(p)), this._sharedInstancesBag.eventEmitter.emit(EventType.COMMON_UPLOAD_START, this.getOutputCollectionState()));
564
+ }, this.openSystemDialog = (p = {}) => {
565
+ let U = serializeCsv(mergeFileTypes([this.cfg.accept ?? "", ...this.cfg.imgOnly ? IMAGE_ACCEPT_LIST : []])), W = "uploadcare-file-input", G = document.createElement("input");
566
+ if (G.setAttribute(W, ""), applyStyles(G, {
567
+ opacity: 0,
568
+ height: 0,
569
+ width: 0,
570
+ visibility: "hidden",
571
+ position: "absolute",
572
+ top: 0,
573
+ left: 0
574
+ }), G.type = "file", G.multiple = this.cfg.multiple, p.captureCamera) {
575
+ G.capture = this.cfg.cameraCapture;
576
+ let { isPhotoEnabled: U, isVideoRecordingEnabled: W } = calcCameraModes(this.cfg);
577
+ p.modeCamera === CameraSourceTypes.PHOTO && U ? G.accept = BASIC_IMAGE_WILDCARD : p.modeCamera === CameraSourceTypes.VIDEO && W ? G.accept = "video/*" : G.accept = [BASIC_IMAGE_WILDCARD, W && "video/*"].filter(Boolean).join(",");
578
+ } else G.accept = U;
579
+ G.addEventListener("change", () => {
580
+ G.files && ([...G.files].forEach((H) => {
581
+ this.addFileFromObject(H, { source: p.captureCamera ? UploadSource.CAMERA : UploadSource.LOCAL });
582
+ }), this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.UPLOAD_LIST), G.remove());
583
+ }, { once: !0 }), document.querySelectorAll(`[${W}]`).forEach((p) => {
584
+ p.remove();
585
+ }), document.body.appendChild(G), G.dispatchEvent(new MouseEvent("click"));
586
+ }, this.initFlow = (p = !1) => {
587
+ if (this._uploadCollection.size > 0 && !p) this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.UPLOAD_LIST);
588
+ else if (this._sourceList?.length === 1) {
589
+ let p = this._sourceList[0];
590
+ if (p === "local") {
591
+ this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this.openSystemDialog();
592
+ return;
593
+ }
594
+ if (p === "camera" && browserFeatures.htmlMediaCapture) {
595
+ let { isPhotoEnabled: p, isVideoRecordingEnabled: U } = calcCameraModes(this.cfg);
596
+ if (p && U) {
597
+ this._ctx.pub("*currentActivity", ACTIVITY_TYPES.START_FROM);
598
+ return;
599
+ } else if (p || U) {
600
+ this.openSystemDialog({
601
+ captureCamera: !0,
602
+ modeCamera: p ? CameraSourceTypes.PHOTO : CameraSourceTypes.VIDEO
603
+ });
604
+ return;
605
+ } else this.openSystemDialog({
606
+ captureCamera: !0,
607
+ modeCamera: CameraSourceTypes.PHOTO
608
+ });
609
+ }
610
+ setTimeout(() => {
611
+ if (p !== this._sourceList[0]) return;
612
+ let H = this._sharedInstancesBag.blocksRegistry;
613
+ findBlockInCtx(H, (H) => "type" in H && H.type === p)?.activate();
614
+ }, 0), this._ctx.read("*currentActivity") && this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity"));
615
+ } else this._ctx.pub("*currentActivity", ACTIVITY_TYPES.START_FROM), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.START_FROM);
616
+ }, this.doneFlow = () => {
617
+ let p = findBlockInCtx(this._sharedInstancesBag.blocksRegistry, (p) => "doneActivity" in p);
618
+ p && (this._ctx.pub("*currentActivity", p.doneActivity), this._ctx.pub("*history", p.doneActivity ? [p.doneActivity] : []), this._ctx.read("*currentActivity") || this._sharedInstancesBag.modalManager?.closeAll());
619
+ }, this.setCurrentActivity = (p, ...H) => {
620
+ setTimeout(() => {
621
+ if (hasBlockInCtx(this._sharedInstancesBag.blocksRegistry, (H) => H.activityType === p)) {
622
+ this._ctx.pub("*currentActivityParams", H[0] ?? {}), this._ctx.pub("*currentActivity", p);
623
+ return;
624
+ }
625
+ console.warn(`Activity type "${p}" not found in the context`);
626
+ });
627
+ }, this.getCurrentActivity = () => this._ctx.read("*currentActivity"), this.setModalState = (p) => {
628
+ setTimeout(() => {
629
+ if (p && !this._ctx.read("*currentActivity")) {
630
+ console.warn("Can't open modal without current activity. Please use \"setCurrentActivity\" method first.");
631
+ return;
632
+ }
633
+ p ? this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity")) : (this._sharedInstancesBag.modalManager?.close(this._ctx.read("*currentActivity")), this._ctx.pub("*currentActivity", null));
634
+ });
635
+ };
636
+ }
637
+ get _uploadCollection() {
638
+ return this._sharedInstancesBag.uploadCollection;
639
+ }
640
+ get cfg() {
641
+ return this._cfg;
642
+ }
643
+ get l10n() {
644
+ return this._l10n;
645
+ }
646
+ removeAllFiles() {
647
+ this._uploadCollection.clearAll();
648
+ }
649
+ getOutputItem(p) {
650
+ let H = PubSub.getCtx(p);
651
+ if (!H) throw Error(`UploaderPublicApi#getOutputItem: Entry with ID "${p}" not found in the upload collection`);
652
+ let U = H.store, W = U.fileInfo, G = U.isRemoved ? "removed" : U.errors.length > 0 ? "failed" : U.fileInfo ? "success" : U.isUploading ? "uploading" : "idle";
653
+ return {
654
+ uuid: W?.uuid ?? U.uuid ?? null,
655
+ internalId: p,
656
+ name: W?.originalFilename ?? U.fileName,
657
+ size: W?.size ?? U.fileSize,
658
+ isImage: W?.isImage ?? U.isImage,
659
+ mimeType: W?.mimeType ?? U.mimeType,
660
+ file: U.file,
661
+ externalUrl: U.externalUrl,
662
+ cdnUrlModifiers: U.cdnUrlModifiers,
663
+ cdnUrl: U.cdnUrl ?? W?.cdnUrl ?? null,
664
+ fullPath: U.fullPath,
665
+ uploadProgress: U.uploadProgress,
666
+ fileInfo: W ?? null,
667
+ metadata: U.metadata ?? W?.metadata ?? null,
668
+ isSuccess: G === "success",
669
+ isUploading: G === "uploading",
670
+ isFailed: G === "failed",
671
+ isRemoved: G === "removed",
672
+ isValidationPending: U.isValidationPending,
673
+ errors: U.errors,
674
+ status: G,
675
+ source: U?.source
676
+ };
677
+ }
678
+ getOutputCollectionState() {
679
+ return buildOutputCollectionState(this._sharedInstancesBag);
680
+ }
681
+ get _sourceList() {
682
+ let p = [];
683
+ return this.cfg.sourceList && (p = stringToArray(this.cfg.sourceList)), p;
684
+ }
685
+ };
686
+ const initialUploadEntryData = {
687
+ file: null,
688
+ externalUrl: null,
689
+ fileName: null,
690
+ fileSize: null,
691
+ lastModified: Date.now(),
692
+ uploadProgress: 0,
693
+ uuid: null,
694
+ isImage: !1,
695
+ mimeType: null,
696
+ ctxName: null,
697
+ cdnUrl: null,
698
+ cdnUrlModifiers: null,
699
+ fileInfo: null,
700
+ isUploading: !1,
701
+ abortController: null,
702
+ thumbUrl: null,
703
+ silent: !1,
704
+ source: null,
705
+ fullPath: null,
706
+ metadata: null,
707
+ errors: [],
708
+ uploadError: null,
709
+ isRemoved: !1,
710
+ isQueuedForUploading: !1,
711
+ isValidationPending: !1,
712
+ isQueuedForValidation: !1
713
+ };
714
+ function customUserAgent(p) {
715
+ return getUserAgent({
716
+ ...p,
717
+ libraryName: PACKAGE_NAME,
718
+ libraryVersion: PACKAGE_VERSION
719
+ });
720
+ }
721
+ var ACTIVE_ATTR = "active", ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___", LitActivityBlock = class p extends LitBlock {
722
+ constructor(...p) {
723
+ super(...p), this.historyTracked = !1, this.init$ = activityBlockCtx(this), this._debouncedHistoryFlush = debounce(this._historyFlush.bind(this), 10);
724
+ }
725
+ _deactivate() {
726
+ let H = p._activityCallbacks.get(this);
727
+ this[ACTIVE_PROP] = !1, this.removeAttribute(ACTIVE_ATTR), H?.deactivateCallback?.();
728
+ }
729
+ _activate() {
730
+ let H = p._activityCallbacks.get(this);
731
+ this.$["*historyBack"] = this.historyBack.bind(this), this[ACTIVE_PROP] = !0, this.setAttribute(ACTIVE_ATTR, ""), H?.activateCallback?.(), this._debouncedHistoryFlush(), this.emit(EventType.ACTIVITY_CHANGE, { activity: this.activityType });
732
+ }
733
+ initCallback() {
734
+ super.initCallback(), this.activityType && (this.hasAttribute("activity") || this.setAttribute("activity", this.activityType), this.sub("*currentActivity", (p) => {
735
+ try {
736
+ this.activityType !== p && this[ACTIVE_PROP] ? this._deactivate() : this.activityType === p && !this[ACTIVE_PROP] && this._activate();
737
+ } catch (p) {
738
+ this.telemetryManager.sendEventError(p, `activity "${this.activityType}"`), console.error(`Error in activity "${this.activityType}". `, p);
739
+ let H = this.$["*history"][this.$["*history"].length - 1];
740
+ this.$["*currentActivity"] = H ?? null;
741
+ }
742
+ p || (this.$["*history"] = []);
743
+ }));
744
+ }
745
+ _historyFlush() {
746
+ let p = this.$["*history"];
747
+ p && (p.length > 10 && (p = p.slice(p.length - 11, p.length - 1)), this.historyTracked && p[p.length - 1] !== this.activityType && p.push(this.activityType), this.$["*history"] = p);
748
+ }
749
+ _isActivityRegistered() {
750
+ return !!this.activityType && p._activityCallbacks.has(this);
751
+ }
752
+ static {
753
+ this._activityCallbacks = /* @__PURE__ */ new Map();
754
+ }
755
+ get isActivityActive() {
756
+ return !!this[ACTIVE_PROP];
757
+ }
758
+ get couldOpenActivity() {
759
+ return !0;
760
+ }
761
+ registerActivity(H, U = {}) {
762
+ let { onActivate: W, onDeactivate: G } = U;
763
+ p._activityCallbacks.set(this, {
764
+ activateCallback: W,
765
+ deactivateCallback: G
766
+ });
767
+ }
768
+ _unregisterActivity() {
769
+ this.isActivityActive && this._deactivate(), p._activityCallbacks.delete(this);
770
+ }
771
+ disconnectedCallback() {
772
+ super.disconnectedCallback(), this._isActivityRegistered() && this._unregisterActivity();
773
+ let H = this.$["*currentActivity"];
774
+ this.blocksRegistry && ([...this.blocksRegistry].find((U) => U instanceof p && U.activityType === H) || (this.$["*currentActivity"] = null, this.modalManager?.closeAll()));
775
+ }
776
+ get activityParams() {
777
+ return this.$["*currentActivityParams"];
778
+ }
779
+ get initActivity() {
780
+ return this.getCssData("--cfg-init-activity") ?? null;
781
+ }
782
+ get doneActivity() {
783
+ return this.getCssData("--cfg-done-activity") ?? null;
784
+ }
785
+ historyBack() {
786
+ let p = this.$["*history"];
787
+ if (p) {
788
+ let H = p.pop();
789
+ for (; H === this.activityType;) H = p.pop();
790
+ let U = !!H;
791
+ H && (U = [...this.blocksRegistry].find((p) => p.activityType === H)?.couldOpenActivity ?? !1), H = U ? H : null, this.$["*currentActivity"] = H ?? null, H && this.modalManager?.open(H), this.$["*history"] = p, H || this.modalManager?.closeAll();
792
+ }
793
+ }
794
+ };
795
+ LitActivityBlock.activities = ACTIVITY_TYPES;
796
+ var LitUploaderBlock = class H extends LitActivityBlock {
797
+ constructor(...p) {
798
+ super(...p), this.couldBeCtxOwner = !1, this._isCtxOwner = !1, this.init$ = uploaderBlockCtx(this), this._flushOutputItems = debounce(async () => {
799
+ if (this.getOutputData().length !== this.uploadCollection.size) return;
800
+ let p = this.api.getOutputCollectionState();
801
+ this.$["*collectionState"] = p, this.emit(EventType.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.cfg.groupOutput && p.totalCount > 0 && p.status === "success" && this._createGroup(p);
802
+ }, 300), this._handleCollectionUpdate = (p, H, U) => {
803
+ if (this.isConnected) {
804
+ (H.size || U.size) && (this.$["*groupInfo"] = null), this.validationManager.runFileValidators("add", [...H].map((p) => p.uid));
805
+ for (let p of H) p.getValue("silent") || this.emit(EventType.FILE_ADDED, this.api.getOutputItem(p.uid));
806
+ this.validationManager.runCollectionValidators();
807
+ for (let p of U) {
808
+ this.$["*uploadTrigger"].delete(p.uid), this.validationManager.cleanupValidationForEntry(p), p.getValue("abortController")?.abort(), p.setMultipleValues({
809
+ isRemoved: !0,
810
+ abortController: null,
811
+ isUploading: !1,
812
+ uploadProgress: 0
813
+ });
814
+ let H = p?.getValue("thumbUrl");
815
+ H && URL.revokeObjectURL(H), this.emit(EventType.FILE_REMOVED, this.api.getOutputItem(p.uid));
816
+ }
817
+ this.$["*uploadList"] = p.map((p) => ({ uid: p })), this._flushCommonUploadProgress(), this._flushOutputItems();
818
+ }
819
+ }, this._handleCollectionPropertiesUpdate = (p) => {
820
+ if (!this.isConnected) return;
821
+ this._flushOutputItems();
822
+ let H = this.uploadCollection, U = [...new Set(Object.entries(p).filter(([p]) => [
823
+ "uploadError",
824
+ "fileInfo",
825
+ "cdnUrl",
826
+ "cdnUrlModifiers"
827
+ ].includes(p)).flatMap(([, p]) => [...p]))];
828
+ if (U.length > 0 && setTimeout(() => {
829
+ if (!this.isConnected) return;
830
+ let H = U.filter((H) => p.fileInfo?.has(H) && !!PubSub.getCtx(H)?.store.fileInfo);
831
+ H.length > 0 && this.validationManager.runFileValidators("upload", H), this.validationManager.runFileValidators("change", U);
832
+ }), p.uploadProgress) {
833
+ for (let H of p.uploadProgress) {
834
+ let p = PubSub.getCtx(H);
835
+ if (!p) continue;
836
+ let { isUploading: U, silent: W } = p.store;
837
+ U && !W && this.emit(EventType.FILE_UPLOAD_PROGRESS, this.api.getOutputItem(H));
838
+ }
839
+ this._flushCommonUploadProgress();
840
+ }
841
+ if (p.isUploading) for (let H of p.isUploading) {
842
+ let p = PubSub.getCtx(H);
843
+ if (!p) continue;
844
+ let { isUploading: U, silent: W } = p.store;
845
+ U && !W && this.emit(EventType.FILE_UPLOAD_START, this.api.getOutputItem(H));
846
+ }
847
+ if (p.fileInfo) {
848
+ for (let H of p.fileInfo) {
849
+ let p = PubSub.getCtx(H);
850
+ if (!p) continue;
851
+ let { fileInfo: U, silent: W } = p.store;
852
+ U && !W && this.emit(EventType.FILE_UPLOAD_SUCCESS, this.api.getOutputItem(H));
853
+ }
854
+ this.cfg.cropPreset && this._setInitialCrop(), this.cfg.cloudImageEditorAutoOpen && this._openCloudImageEditor();
855
+ }
856
+ if (p.errors) {
857
+ this.validationManager.runCollectionValidators();
858
+ for (let H of p.errors) {
859
+ let p = PubSub.getCtx(H);
860
+ if (!p) continue;
861
+ let { errors: U } = p.store;
862
+ U.length > 0 && (this.emit(EventType.FILE_UPLOAD_FAILED, this.api.getOutputItem(H)), this.emit(EventType.COMMON_UPLOAD_FAILED, () => this.api.getOutputCollectionState(), { debounce: !0 }));
863
+ }
864
+ let U = H.findItems((p) => !!p.getValue("fileInfo")), W = H.findItems((p) => p.getValue("errors").length > 0);
865
+ H.size > 0 && W.length === 0 && H.size === U.length && this.$["*collectionErrors"].length === 0 && this.emit(EventType.COMMON_UPLOAD_SUCCESS, this.api.getOutputCollectionState());
866
+ }
867
+ p.cdnUrl && ([...p.cdnUrl].filter((p) => !!this.uploadCollection.read(p)?.getValue("cdnUrl")).forEach((p) => {
868
+ this.emit(EventType.FILE_URL_CHANGED, this.api.getOutputItem(p));
869
+ }), this.$["*groupInfo"] = null);
870
+ }, this._flushCommonUploadProgress = () => {
871
+ let p = 0, H = [...this.$["*uploadTrigger"]].filter((p) => !!this.uploadCollection.read(p));
872
+ H.forEach((H) => {
873
+ let U = this.uploadCollection.readProp(H, "uploadProgress");
874
+ typeof U == "number" && (p += U);
875
+ });
876
+ let U = H.length ? Math.round(p / H.length) : 0;
877
+ this.$["*commonProgress"] !== U && (this.$["*commonProgress"] = U, this.emit(EventType.COMMON_UPLOAD_PROGRESS, this.api.getOutputCollectionState()));
878
+ };
879
+ }
880
+ get _hasCtxOwner() {
881
+ return this.hasBlockInCtx((p) => p instanceof H ? p._isCtxOwner && p.isConnected && p !== this : !1);
882
+ }
883
+ initCallback() {
884
+ super.initCallback(), this._addSharedContextInstance("*uploadCollection", () => new TypedCollection({
885
+ initialValue: initialUploadEntryData,
886
+ watchList: [
887
+ "uploadProgress",
888
+ "uploadError",
889
+ "fileInfo",
890
+ "errors",
891
+ "cdnUrl",
892
+ "isUploading",
893
+ "isValidationPending"
894
+ ]
895
+ })), this._addSharedContextInstance("*secureUploadsManager", (p) => new SecureUploadsManager(p)), this._addSharedContextInstance("*validationManager", (p) => new ValidationManager(p)), this._addSharedContextInstance("*publicApi", (p) => new UploaderPublicApi(p)), !this._hasCtxOwner && this.couldBeCtxOwner && this._initCtxOwner();
896
+ }
897
+ getAPI() {
898
+ return this.api;
899
+ }
900
+ get validationManager() {
901
+ return this._getSharedContextInstance("*validationManager");
902
+ }
903
+ get api() {
904
+ return this._getSharedContextInstance("*publicApi");
905
+ }
906
+ get uploadCollection() {
907
+ return this._getSharedContextInstance("*uploadCollection");
908
+ }
909
+ get secureUploadsManager() {
910
+ return this._getSharedContextInstance("*secureUploadsManager");
911
+ }
912
+ disconnectedCallback() {
913
+ super.disconnectedCallback(), this._isCtxOwner && this._unobserveUploadCollection(), this._flushOutputItems.cancel();
914
+ }
915
+ connectedCallback() {
916
+ super.connectedCallback(), this._isCtxOwner && this._observeUploadCollection();
917
+ }
918
+ _initCtxOwner() {
919
+ this._isCtxOwner = !0, this._observeUploadCollection(), this.subConfigValue("maxConcurrentRequests", (p) => {
920
+ this.$["*uploadQueue"].concurrency = Number(p) || 1;
921
+ });
922
+ }
923
+ _observeUploadCollection() {
924
+ this._unobserveUploadCollection(), this._unobserveCollection = this.uploadCollection.observeCollection(this._handleCollectionUpdate), this._unobserveCollectionProperties = this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);
925
+ }
926
+ _unobserveUploadCollection() {
927
+ this._unobserveCollectionProperties?.(), this._unobserveCollection?.(), this._unobserveCollectionProperties = void 0, this._unobserveCollection = void 0;
928
+ }
929
+ async _createGroup(p) {
930
+ let H = await this.getUploadClientOptions(), U = p.allEntries.map((p) => p.uuid + (p.cdnUrlModifiers ? `/${p.cdnUrlModifiers}` : "")), W = new AbortController(), G = await uploadFileGroup(U, {
931
+ ...H,
932
+ signal: W.signal
933
+ });
934
+ if (this.$["*collectionState"] !== p) {
935
+ W.abort();
936
+ return;
937
+ }
938
+ this.$["*groupInfo"] = G;
939
+ let K = this.api.getOutputCollectionState();
940
+ this.emit(EventType.GROUP_CREATED, K), this.emit(EventType.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.$["*collectionState"] = K;
941
+ }
942
+ _openCloudImageEditor() {
943
+ let [p] = this.uploadCollection.findItems((p) => !!p.getValue("fileInfo") && p.getValue("isImage")).map((p) => this.uploadCollection.read(p));
944
+ p && this.uploadCollection.size === 1 && this.cfg.useCloudImageEditor && this.hasBlockInCtx((p) => p.activityType === LitActivityBlock.activities.CLOUD_IMG_EDIT) && (this.$["*currentActivityParams"] = { internalId: p.uid }, this.$["*currentActivity"] = LitActivityBlock.activities.CLOUD_IMG_EDIT, this.modalManager?.open(LitActivityBlock.activities.CLOUD_IMG_EDIT));
945
+ }
946
+ _setInitialCrop() {
947
+ let H = parseCropPreset(this.cfg.cropPreset);
948
+ if (H) {
949
+ let [U] = H, W = this.uploadCollection.findItems((p) => !!p.getValue("fileInfo") && p.getValue("isImage") && !p.getValue("cdnUrlModifiers")?.includes("/crop/")).map((p) => this.uploadCollection.read(p)).filter(Boolean);
950
+ for (let H of W) {
951
+ let W = H.getValue("fileInfo");
952
+ if (!W || !W.imageInfo) {
953
+ console.warn("Failed to get image info for entry", H.uid);
954
+ continue;
955
+ }
956
+ let { width: G, height: K } = W.imageInfo, q = calculateMaxCenteredCropFrame(G, K, typeof U?.width == "number" && typeof U?.height == "number" && U.width > 0 && U.height > 0 ? U.width / U.height : 1), J = createCdnUrlModifiers(`crop/${q.width}x${q.height}/${q.x},${q.y}`, "preview"), Y = H.getValue("cdnUrl");
957
+ if (!Y) {
958
+ console.warn("Failed to get cdnUrl for entry", H.uid);
959
+ continue;
960
+ }
961
+ H.setMultipleValues({
962
+ cdnUrlModifiers: J,
963
+ cdnUrl: createCdnUrl(Y, J)
964
+ }), this.uploadCollection.size === 1 && this.cfg.useCloudImageEditor && this.hasBlockInCtx((p) => p.activityType === LitActivityBlock.activities.CLOUD_IMG_EDIT) && (this.$["*currentActivityParams"] = { internalId: H.uid }, this.$["*currentActivity"] = LitActivityBlock.activities.CLOUD_IMG_EDIT, this.modalManager?.open(LitActivityBlock.activities.CLOUD_IMG_EDIT));
965
+ }
966
+ }
967
+ }
968
+ async getMetadataFor(p) {
969
+ let H = this.cfg.metadata || void 0;
970
+ return typeof H == "function" ? await H(this.api.getOutputItem(p)) : H;
971
+ }
972
+ async getUploadClientOptions() {
973
+ let p = await this.secureUploadsManager.getSecureToken().catch(() => null);
974
+ return {
975
+ store: this.cfg.store,
976
+ publicKey: this.cfg.pubkey,
977
+ baseCDN: this.cfg.cdnCname,
978
+ baseURL: this.cfg.baseUrl,
979
+ userAgent: customUserAgent,
980
+ integration: this.cfg.userAgentIntegration,
981
+ secureSignature: p?.secureSignature,
982
+ secureExpire: p?.secureExpire,
983
+ retryThrottledRequestMaxTimes: this.cfg.retryThrottledRequestMaxTimes,
984
+ retryNetworkErrorMaxTimes: this.cfg.retryNetworkErrorMaxTimes,
985
+ multipartMinFileSize: this.cfg.multipartMinFileSize,
986
+ multipartChunkSize: this.cfg.multipartChunkSize,
987
+ maxConcurrentRequests: this.cfg.multipartMaxConcurrentRequests,
988
+ multipartMaxAttempts: this.cfg.multipartMaxAttempts,
989
+ checkForUrlDuplicates: !!this.cfg.checkForUrlDuplicates,
990
+ saveUrlForRecurrentUploads: !!this.cfg.saveUrlForRecurrentUploads
991
+ };
992
+ }
993
+ getOutputData() {
994
+ return getOutputData(this._sharedInstancesBag);
995
+ }
996
+ };
997
+ LitUploaderBlock.extSrcList = Object.freeze({ ...ExternalUploadSource }), LitUploaderBlock.sourceTypes = Object.freeze({ ...UploadSource });
998
+ export { LitActivityBlock as n, LitUploaderBlock as t };