@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,2162 @@
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, C as MIN_CROP_SIZE, D as THUMB_STROKE_WIDTH, E as THUMB_SIDE_SIZE, F as InternalEventType, G as ALL_FILTERS, J as TabId, K as ALL_TABS, S as MAX_INTERACTION_SIZE, T as THUMB_CORNER_SIZE, U as ALL_COLOR_OPERATIONS, W as ALL_CROP_OPERATIONS, X as operationsToTransformations, Y as COMMON_OPERATIONS, Z as transformationsToOperations, _ as sidePath, a as clamp, b as GUIDE_STROKE_WIDTH, c as createSvgNode, ct as __decorate, d as moveRect, et as createCdnUrlModifiers, f as rectContainsPoint, g as setSvgNodeAttrs, h as roundRect, j as LitBlock, l as isRectInsideRect, lt as debounce, m as rotateSize, n as getClosestAspectRatio, nt as extractOperations, o as constraintRect, ot as UID, p as resizeRect, q as COLOR_OPERATIONS_CONFIG, r as parseCropPreset, rt as extractUuid, s as cornerPath, tt as createOriginalUrl, u as isRectMatchesAspectRatio, v as thumbCursor, w as MIN_INTERACTION_SIZE, x as GUIDE_THIRD, y as CROP_PADDING } from "./Icon-CqTVC82Q.js";
8
+ import { f as deserializeCsv, p as serializeCsv } from "./plugins-DxjsQUa8.js";
9
+ import { n as PACKAGE_VERSION, t as PACKAGE_NAME } from "./env-B1nfXy9i.js";
10
+ import { html, nothing } from "lit";
11
+ import { property, state } from "lit/decorators.js";
12
+ import { unsafeSVG } from "lit/directives/unsafe-svg.js";
13
+ import { createRef, ref } from "lit/directives/ref.js";
14
+ import { styleMap } from "lit/directives/style-map.js";
15
+ import { ifDefined } from "lit/directives/if-defined.js";
16
+ import { when } from "lit/directives/when.js";
17
+ import { classMap } from "lit/directives/class-map.js";
18
+ const throttle = (d, B) => {
19
+ let V = !1, H, U = 0, W = ((...W) => {
20
+ V ? (H && clearTimeout(H), H = setTimeout(() => {
21
+ Date.now() - U >= B && (d(...W), U = Date.now());
22
+ }, Math.max(B - (Date.now() - U), 0))) : (d(...W), U = Date.now(), V = !0);
23
+ });
24
+ return Object.defineProperty(W, "cancel", {
25
+ configurable: !1,
26
+ writable: !1,
27
+ enumerable: !1,
28
+ value: () => {
29
+ H && clearTimeout(H);
30
+ }
31
+ }), W;
32
+ }, TRANSPARENT_PIXEL_SRC = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
33
+ function preloadImage(d) {
34
+ let B = new Image();
35
+ return {
36
+ promise: new Promise((V, H) => {
37
+ B.src = d, B.onload = () => V(), B.onerror = (d) => H(d);
38
+ }),
39
+ image: B,
40
+ cancel: () => {
41
+ B.naturalWidth === 0 && (B.src = TRANSPARENT_PIXEL_SRC);
42
+ }
43
+ };
44
+ }
45
+ function batchPreloadImages(d) {
46
+ let B = [];
47
+ for (let V of d) {
48
+ let d = preloadImage(V);
49
+ B.push(d);
50
+ }
51
+ let V = B.map((d) => d.image);
52
+ return {
53
+ promise: Promise.allSettled(B.map((d) => d.promise)),
54
+ images: V,
55
+ cancel: () => {
56
+ B.forEach((d) => {
57
+ d.cancel();
58
+ });
59
+ }
60
+ };
61
+ }
62
+ function normalize(...d) {
63
+ return d.reduce((d, B) => {
64
+ if (typeof B == "string") return d[B] = !0, d;
65
+ for (let V of Object.keys(B)) d[V] = B[V];
66
+ return d;
67
+ }, {});
68
+ }
69
+ function classNames(...d) {
70
+ let B = normalize(...d);
71
+ return Object.keys(B).reduce((d, V) => (B[V] && d.push(V), d), []).join(" ");
72
+ }
73
+ function applyClassNames(d, ...B) {
74
+ let V = normalize(...B);
75
+ for (let B of Object.keys(V)) d.classList.toggle(B, !!V[B]);
76
+ }
77
+ var isTabIdValue = (d) => ALL_TABS.includes(d);
78
+ const parseTabs = (d) => {
79
+ if (!d) return ALL_TABS;
80
+ let B = deserializeCsv(d).filter(isTabIdValue);
81
+ return B.length === 0 ? ALL_TABS : B;
82
+ };
83
+ function initState(B) {
84
+ return {
85
+ "*originalUrl": null,
86
+ "*loadingOperations": /* @__PURE__ */ new Map(),
87
+ "*faderEl": null,
88
+ "*cropperEl": null,
89
+ "*imgEl": null,
90
+ "*imgContainerEl": null,
91
+ "*networkProblems": !1,
92
+ "*imageSize": null,
93
+ "*editorTransformations": {},
94
+ "*cropPresetList": [],
95
+ "*currentAspectRatio": null,
96
+ "*tabList": ALL_TABS,
97
+ "*tabId": TabId.CROP,
98
+ "*on.retryNetwork": () => {
99
+ let d = B.querySelectorAll("img");
100
+ for (let B of d) {
101
+ let d = B.src;
102
+ B.src = TRANSPARENT_PIXEL_SRC, B.src = d;
103
+ }
104
+ B.$["*networkProblems"] = !1;
105
+ },
106
+ "*on.apply": (V) => {
107
+ if (!V) return;
108
+ let H = B.$["*originalUrl"];
109
+ if (!H) {
110
+ console.warn("Original URL is null, cannot apply transformations");
111
+ return;
112
+ }
113
+ let U = createCdnUrlModifiers(transformationsToOperations(V), "preview"), W = {
114
+ originalUrl: H,
115
+ cdnUrlModifiers: U,
116
+ cdnUrl: createCdnUrl(H, U),
117
+ transformations: V
118
+ };
119
+ B.dispatchEvent(new CustomEvent("apply", {
120
+ detail: W,
121
+ bubbles: !0,
122
+ composed: !0
123
+ })), B.remove();
124
+ },
125
+ "*on.cancel": () => {
126
+ B.remove(), B.dispatchEvent(new CustomEvent("cancel", {
127
+ bubbles: !0,
128
+ composed: !0
129
+ }));
130
+ }
131
+ };
132
+ }
133
+ var svg_sprite_default = "<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>", DEFAULT_STYLE = {
134
+ transition: "uc-transition",
135
+ visible: "uc-visible",
136
+ hidden: "uc-hidden"
137
+ }, PresenceToggle = class extends LitBlock {
138
+ constructor(...d) {
139
+ super(...d), this._visible = !1, this._styles = DEFAULT_STYLE, this._visibleStyle = DEFAULT_STYLE.visible, this._hiddenStyle = DEFAULT_STYLE.hidden, this._externalTransitions = !1, this._initialRenderComplete = !1;
140
+ }
141
+ set visible(d) {
142
+ this._visible = d, this._handleVisible();
143
+ }
144
+ get visible() {
145
+ return this._visible;
146
+ }
147
+ set styles(d) {
148
+ this._styles = d, this._externalTransitions = !0, this._visibleStyle = d.visible ?? DEFAULT_STYLE.visible, this._hiddenStyle = d.hidden ?? DEFAULT_STYLE.hidden;
149
+ }
150
+ get styles() {
151
+ return this._styles;
152
+ }
153
+ _handleVisible() {
154
+ this.style.visibility = this._visible ? "inherit" : "hidden", applyClassNames(this, {
155
+ [DEFAULT_STYLE.transition]: !this._externalTransitions,
156
+ [this._visibleStyle]: this._visible,
157
+ [this._hiddenStyle]: !this._visible
158
+ }), this.toggleAttribute("inert", !this._visible);
159
+ }
160
+ _dispatchInitialRenderEvent() {
161
+ this._initialRenderComplete || (this._initialRenderComplete = !0, this.dispatchEvent(new CustomEvent("initial-render", {
162
+ bubbles: !0,
163
+ composed: !0
164
+ })));
165
+ }
166
+ initCallback() {
167
+ super.initCallback(), this.classList.toggle("uc-initial", !0), this._externalTransitions || this.classList.add(DEFAULT_STYLE.transition), this._handleVisible(), setTimeout(() => {
168
+ this.classList.toggle("uc-initial", !1), this._dispatchInitialRenderEvent();
169
+ }, 0);
170
+ }
171
+ };
172
+ __decorate([property({ type: Boolean })], PresenceToggle.prototype, "visible", null), __decorate([property({ attribute: !1 })], PresenceToggle.prototype, "styles", null);
173
+ var LineLoaderUi = class extends LitBlock {
174
+ constructor(...d) {
175
+ super(...d), this.active = !1, this._lineRef = createRef(), this._isAnimating = !1, this._handleTransitionEndRight = () => {
176
+ let d = this._lineRef.value;
177
+ d && (this._resetLine(d), this._isAnimating && this.active && this._start());
178
+ };
179
+ }
180
+ firstUpdated(d) {
181
+ super.firstUpdated(d), this.active && this._start();
182
+ }
183
+ updated(d) {
184
+ super.updated(d), d.has("active") && (this.active ? this._start() : this._stop());
185
+ }
186
+ _start() {
187
+ let d = this._lineRef.value;
188
+ if (!d) return;
189
+ this._isAnimating = !0;
190
+ let { width: B } = this.getBoundingClientRect();
191
+ d.removeEventListener("transitionend", this._handleTransitionEndRight), d.style.transition = "transform 1s", d.style.opacity = "1", d.style.transform = `translateX(${B}px)`, d.addEventListener("transitionend", this._handleTransitionEndRight, { once: !0 });
192
+ }
193
+ _stop() {
194
+ let d = this._lineRef.value;
195
+ d && (this._isAnimating = !1, d.removeEventListener("transitionend", this._handleTransitionEndRight), this._resetLine(d));
196
+ }
197
+ _resetLine(d) {
198
+ d.style.transition = "initial", d.style.opacity = "0", d.style.transform = "translateX(-101%)";
199
+ }
200
+ render() {
201
+ return html`
202
+ <div class="uc-inner">
203
+ <div class="uc-line" ${ref(this._lineRef)}></div>
204
+ </div>
205
+ `;
206
+ }
207
+ };
208
+ __decorate([property({
209
+ type: Boolean,
210
+ reflect: !0
211
+ })], LineLoaderUi.prototype, "active", void 0);
212
+ var BtnUi = class extends LitBlock {
213
+ constructor(...d) {
214
+ super(...d), this.text = "", this.icon = "", this.reverse = !1, this.theme = "default", this.ariaRole = void 0, this.ariaControls = "", this.titleProp = "", this.active = !1;
215
+ }
216
+ firstUpdated(d) {
217
+ super.firstUpdated(d), this._applyReverse(), this._applyThemeClass();
218
+ }
219
+ updated(d) {
220
+ super.updated(d), d.has("reverse") && this._applyReverse(), d.has("theme") && this._applyThemeClass();
221
+ }
222
+ _applyReverse() {
223
+ this.style.flexDirection = this.reverse ? "row-reverse" : "";
224
+ }
225
+ _applyThemeClass() {
226
+ this.theme && this.theme !== "custom" && (this.className = `uc-${this.theme}`);
227
+ }
228
+ get _iconClassMap() {
229
+ let d = this._computedIconHidden;
230
+ return {
231
+ "uc-icon": !0,
232
+ "uc-icon_left": !this.reverse,
233
+ "uc-icon_right": this.reverse,
234
+ "uc-icon_hidden": d,
235
+ "uc-icon_single": this._computedIconSingle
236
+ };
237
+ }
238
+ get _computedIconHidden() {
239
+ return !this.icon;
240
+ }
241
+ get _computedIconSingle() {
242
+ return !this.text && !this._computedIconHidden;
243
+ }
244
+ render() {
245
+ return html`
246
+ <button
247
+ type="button"
248
+ role=${ifDefined(this.ariaRole || void 0)}
249
+ aria-controls=${ifDefined(this.ariaControls || void 0)}
250
+ aria-label=${ifDefined(this.l10n(this.titleProp))}
251
+ title=${ifDefined(this.l10n(this.titleProp))}
252
+ >
253
+ <uc-icon
254
+ class=${classMap(this._iconClassMap)}
255
+ name=${ifDefined(this.icon || void 0)}
256
+ ?hidden=${this._computedIconHidden}
257
+ ></uc-icon>
258
+ <div class="uc-text">${this.text}</div>
259
+ </button>
260
+ `;
261
+ }
262
+ };
263
+ __decorate([property({ type: String })], BtnUi.prototype, "text", void 0), __decorate([property({ type: String })], BtnUi.prototype, "icon", void 0), __decorate([property({
264
+ type: Boolean,
265
+ reflect: !0
266
+ })], BtnUi.prototype, "reverse", void 0), __decorate([property({
267
+ type: String,
268
+ reflect: !0
269
+ })], BtnUi.prototype, "theme", void 0), __decorate([property({ attribute: "aria-role" })], BtnUi.prototype, "ariaRole", void 0), __decorate([property({ attribute: "aria-controls" })], BtnUi.prototype, "ariaControls", void 0), __decorate([property({ attribute: "title-prop" })], BtnUi.prototype, "titleProp", void 0), __decorate([property({
270
+ type: Boolean,
271
+ noAccessor: !0
272
+ })], BtnUi.prototype, "active", void 0);
273
+ function pick(d, B) {
274
+ let V = {};
275
+ for (let H of B) {
276
+ let B = d[H];
277
+ (Object.hasOwn(d, H) || B !== void 0) && (V[H] = B);
278
+ }
279
+ return V;
280
+ }
281
+ function viewerImageSrc(B, V, H) {
282
+ let U = window.devicePixelRatio, W = Math.min(Math.ceil(V * U), 3e3), G = U >= 2 ? "lightest" : "normal";
283
+ return createCdnUrl(B, createCdnUrlModifiers(COMMON_OPERATIONS, transformationsToOperations(H), `quality/${G}`, `stretch/off/-/resize/${W}x`, `@clib/${PACKAGE_NAME}/${PACKAGE_VERSION}/uc-cloud-image-editor/`));
284
+ }
285
+ var CropFrame = class extends LitBlock {
286
+ constructor(...d) {
287
+ super(...d), this._backdropMaskId = `uc-backdrop-mask-${UID.generateFastUid()}`, this._guidesHidden = !1, this._draggingValue = !1, this._svgRef = createRef(), this._svgReady = !1, this._pendingMaskHref = null, this._handlePointerUp = (d) => {
288
+ this._updateCursor(), this._dragging &&= (d.stopPropagation(), d.preventDefault(), !1);
289
+ }, this._handlePointerMove = (d) => {
290
+ if (!this._dragging || !this._dragStartPoint || !this._draggingThumb) return;
291
+ d.stopPropagation(), d.preventDefault();
292
+ let B = this._svgElement;
293
+ if (!B) return;
294
+ let { x: V, y: H } = B.getBoundingClientRect(), U = d.x - V, W = d.y - H, G = U - this._dragStartPoint[0], K = W - this._dragStartPoint[1], { direction: q } = this._draggingThumb, J = this._calcCropBox(q, [G, K]);
295
+ J && (this.$["*cropBox"] = J);
296
+ }, this._handleSvgPointerMove = (d) => {
297
+ this._frameThumbs && (this._hoverThumb = Object.values(this._frameThumbs).find((B) => {
298
+ if (!B || this._shouldThumbBeDisabled(B.direction)) return !1;
299
+ let V = B.interactionNode.getBoundingClientRect();
300
+ return rectContainsPoint({
301
+ x: V.x,
302
+ y: V.y,
303
+ width: V.width,
304
+ height: V.height
305
+ }, [d.x, d.y]);
306
+ }), this._updateCursor());
307
+ };
308
+ }
309
+ get _svgElement() {
310
+ return this._svgRef.value ?? null;
311
+ }
312
+ get _dragging() {
313
+ return this._draggingValue;
314
+ }
315
+ set _dragging(d) {
316
+ this._draggingValue !== d && (this._draggingValue = d, this._applyGuidesDragState());
317
+ }
318
+ _applyGuidesDragState() {
319
+ this._frameGuides && this._frameGuides.setAttribute("class", classNames({
320
+ "uc-guides--hidden": this._guidesHidden,
321
+ "uc-guides--visible": !this._guidesHidden && this._draggingValue,
322
+ "uc-guides--semi-hidden": !this._guidesHidden && !this._draggingValue
323
+ }));
324
+ }
325
+ _shouldThumbBeDisabled(d) {
326
+ let B = this.$["*imageBox"];
327
+ if (!B) return !1;
328
+ if (d === "" && B.height <= 1 && B.width <= 1) return !0;
329
+ let V = B.height <= 1 && (d.includes("n") || d.includes("s")), H = B.width <= 1 && (d.includes("e") || d.includes("w"));
330
+ return V || H;
331
+ }
332
+ _createBackdrop() {
333
+ let d = this.$["*cropBox"];
334
+ if (!d) return;
335
+ let { x: B, y: V, width: H, height: U } = d, W = this._svgElement;
336
+ if (!W) return;
337
+ let G = createSvgNode("mask", { id: this._backdropMaskId }), K = createSvgNode("rect", {
338
+ x: 0,
339
+ y: 0,
340
+ width: "100%",
341
+ height: "100%",
342
+ fill: "white"
343
+ }), q = createSvgNode("rect", {
344
+ x: B,
345
+ y: V,
346
+ width: H,
347
+ height: U,
348
+ fill: "black"
349
+ });
350
+ G.appendChild(K), G.appendChild(q);
351
+ let J = createSvgNode("rect", {
352
+ x: 0,
353
+ y: 0,
354
+ width: "100%",
355
+ height: "100%",
356
+ fill: "var(--color-image-background)",
357
+ "fill-opacity": .85,
358
+ mask: `url(#${this._backdropMaskId})`
359
+ });
360
+ W.appendChild(J), W.appendChild(G), this._backdropMask = G, this._backdropMaskInner = q;
361
+ }
362
+ _resizeBackdrop() {
363
+ this._backdropMask && (this._backdropMask.style.display = "none", window.requestAnimationFrame(() => {
364
+ this._backdropMask && (this._backdropMask.style.display = "block");
365
+ }));
366
+ }
367
+ _updateBackdrop() {
368
+ let d = this.$["*cropBox"];
369
+ if (!d) return;
370
+ let { x: B, y: V, width: H, height: U } = d;
371
+ this._backdropMaskInner && setSvgNodeAttrs(this._backdropMaskInner, {
372
+ x: B,
373
+ y: V,
374
+ width: H,
375
+ height: U
376
+ });
377
+ }
378
+ _updateFrame() {
379
+ let d = this.$["*cropBox"];
380
+ if (!(!d || !this._frameGuides || !this._frameThumbs)) {
381
+ for (let B of Object.values(this._frameThumbs)) {
382
+ if (!B) continue;
383
+ let { direction: V, pathNode: H, interactionNode: U, groupNode: W } = B, G = V === "", K = V.length === 2, { x: q, y: J, width: Y, height: X } = d;
384
+ if (G) setSvgNodeAttrs(U, {
385
+ x: q,
386
+ y: J,
387
+ width: Y,
388
+ height: X
389
+ });
390
+ else {
391
+ let B = clamp(Math.min(Y, X) / 82 / 2, 0, 1), W = K ? cornerPath(d, V, B) : sidePath(d, V, B), G = W.center;
392
+ if (!G) continue;
393
+ let q = Math.max(24 * clamp(Math.min(Y, X) / 24 / 3, 0, 1), 6);
394
+ setSvgNodeAttrs(U, {
395
+ x: G[0] - q,
396
+ y: G[1] - q,
397
+ width: q * 2,
398
+ height: q * 2
399
+ }), setSvgNodeAttrs(H, { d: W.d });
400
+ }
401
+ let Z = this._shouldThumbBeDisabled(V);
402
+ W.setAttribute("class", classNames("uc-thumb", {
403
+ "uc-thumb--hidden": Z,
404
+ "uc-thumb--visible": !Z
405
+ }));
406
+ }
407
+ setSvgNodeAttrs(this._frameGuides, {
408
+ x: d.x - 1 * .5,
409
+ y: d.y - 1 * .5,
410
+ width: d.width + 1,
411
+ height: d.height + 1
412
+ });
413
+ }
414
+ }
415
+ _createThumb(d, B) {
416
+ let V = createSvgNode("g");
417
+ V.classList.add("uc-thumb"), V.setAttribute("with-effects", "");
418
+ let H = createSvgNode("rect", { fill: "transparent" }), U = createSvgNode("path", {
419
+ stroke: "currentColor",
420
+ fill: "none",
421
+ "stroke-width": 3
422
+ });
423
+ V.appendChild(U), V.appendChild(H), d[B] = {
424
+ direction: B,
425
+ pathNode: U,
426
+ interactionNode: H,
427
+ groupNode: V
428
+ }, B === "" && (V.style.cursor = "move"), H.addEventListener("pointerdown", this._handlePointerDown.bind(this, B));
429
+ }
430
+ _createThumbs() {
431
+ let d = {};
432
+ for (let B = 0; B < 3; B++) for (let V = 0; V < 3; V++) {
433
+ let H = `${[
434
+ "n",
435
+ "",
436
+ "s"
437
+ ][B]}${[
438
+ "w",
439
+ "",
440
+ "e"
441
+ ][V]}`;
442
+ H !== "" && this._createThumb(d, H);
443
+ }
444
+ return this._createThumb(d, ""), d;
445
+ }
446
+ _createGuides() {
447
+ let d = createSvgNode("svg"), B = createSvgNode("rect", {
448
+ x: 0,
449
+ y: 0,
450
+ width: "100%",
451
+ height: "100%",
452
+ fill: "none",
453
+ stroke: "currentColor",
454
+ "stroke-width": 1,
455
+ "stroke-opacity": .5
456
+ });
457
+ d.appendChild(B);
458
+ for (let B = 1; B <= 2; B++) {
459
+ let V = createSvgNode("line", {
460
+ x1: `${GUIDE_THIRD * B}%`,
461
+ y1: "0%",
462
+ x2: `${GUIDE_THIRD * B}%`,
463
+ y2: "100%",
464
+ stroke: "currentColor",
465
+ "stroke-width": 1,
466
+ "stroke-opacity": .3
467
+ });
468
+ d.appendChild(V);
469
+ }
470
+ for (let B = 1; B <= 2; B++) {
471
+ let V = createSvgNode("line", {
472
+ x1: "0%",
473
+ y1: `${GUIDE_THIRD * B}%`,
474
+ x2: "100%",
475
+ y2: `${GUIDE_THIRD * B}%`,
476
+ stroke: "currentColor",
477
+ "stroke-width": 1,
478
+ "stroke-opacity": .3
479
+ });
480
+ d.appendChild(V);
481
+ }
482
+ return d.classList.add("uc-guides", "uc-guides--semi-hidden"), d;
483
+ }
484
+ _createFrame() {
485
+ let d = this._svgElement;
486
+ if (!d) return;
487
+ let B = document.createDocumentFragment(), V = this._createGuides();
488
+ B.appendChild(V);
489
+ let H = this._createThumbs();
490
+ for (let { groupNode: d } of Object.values(H)) B.appendChild(d);
491
+ d.appendChild(B), this._frameThumbs = H, this._frameGuides = V, this._applyGuidesDragState();
492
+ }
493
+ _handlePointerDown(d, B) {
494
+ if (!this._frameThumbs) return;
495
+ let V = this._frameThumbs[d];
496
+ if (!V || this._shouldThumbBeDisabled(d)) return;
497
+ let H = this.$["*cropBox"], U = this._svgElement;
498
+ if (!U) return;
499
+ let { x: W, y: G } = U.getBoundingClientRect(), K = B.x - W, q = B.y - G;
500
+ this._dragging = !0, this._draggingThumb = V, this._dragStartPoint = [K, q], this._dragStartCrop = { ...H };
501
+ }
502
+ _calcCropBox(d, B) {
503
+ let [V, H] = B, U = this.$["*imageBox"], W = this._dragStartCrop ?? this.$["*cropBox"], G = this.$["*currentAspectRatio"], K = G ? G.width / G.height : void 0;
504
+ if (W = d === "" ? moveRect({
505
+ rect: W,
506
+ delta: [V, H],
507
+ imageBox: U
508
+ }) : resizeRect({
509
+ rect: W,
510
+ delta: [V, H],
511
+ direction: d,
512
+ aspectRatio: K,
513
+ imageBox: U
514
+ }), !Object.values(W).every((d) => Number.isFinite(d) && d >= 0)) {
515
+ console.error("CropFrame is trying to create invalid rectangle", { payload: W });
516
+ return;
517
+ }
518
+ return constraintRect(roundRect(W), U);
519
+ }
520
+ _updateCursor() {
521
+ let d = this._hoverThumb, B = this._svgElement;
522
+ B && (B.style.cursor = d ? thumbCursor(d.direction) : "initial");
523
+ }
524
+ _createMask(d) {
525
+ if (this._frameImage) {
526
+ this._frameImage.setAttribute("href", d);
527
+ return;
528
+ }
529
+ let B = this._svgElement;
530
+ if (!B) {
531
+ this._pendingMaskHref = d;
532
+ return;
533
+ }
534
+ this._pendingMaskHref = null;
535
+ let V = document.createDocumentFragment(), H = createSvgNode("image", { href: d });
536
+ H.setAttribute("class", "uc-cloud-mask"), V.appendChild(H), B.appendChild(V), this._frameImage = H;
537
+ }
538
+ _updateMask() {
539
+ let d = this.$["*cropBox"];
540
+ if (!d || !this._frameImage) return;
541
+ let { x: B, y: V, width: H, height: U } = d;
542
+ setSvgNodeAttrs(this._frameImage, {
543
+ x: B,
544
+ y: V,
545
+ height: U,
546
+ width: H
547
+ });
548
+ }
549
+ _render() {
550
+ this._svgReady && (this._updateBackdrop(), this._updateFrame(), this._updateMask());
551
+ }
552
+ toggleThumbs(d) {
553
+ if (this._frameThumbs) for (let B of Object.values(this._frameThumbs)) {
554
+ if (!B) continue;
555
+ let { groupNode: V } = B;
556
+ V.setAttribute("class", classNames("uc-thumb", {
557
+ "uc-thumb--hidden": !d,
558
+ "uc-thumb--visible": d
559
+ }));
560
+ }
561
+ }
562
+ initCallback() {
563
+ super.initCallback(), this.sub("*imageBox", () => {
564
+ this._resizeBackdrop(), this._svgReady && window.requestAnimationFrame(() => {
565
+ this._render();
566
+ });
567
+ }), this.sub("*cropBox", (d) => {
568
+ d && (this._guidesHidden = d.height <= 1 || d.width <= 1, this._applyGuidesDragState(), this._svgReady && window.requestAnimationFrame(() => {
569
+ this._render();
570
+ }));
571
+ }), this.subConfigValue("cloudImageEditorMaskHref", (d) => {
572
+ d && this._createMask(d);
573
+ }), document.addEventListener("pointermove", this._handlePointerMove, !0), document.addEventListener("pointerup", this._handlePointerUp, !0);
574
+ }
575
+ firstUpdated(d) {
576
+ super.firstUpdated(d), this._initializeSvg();
577
+ }
578
+ _initializeSvg() {
579
+ let d = this._svgElement;
580
+ if (!(!d || this._svgReady)) {
581
+ if (this._createBackdrop(), this._createFrame(), this._svgReady = !0, d.addEventListener("pointermove", this._handleSvgPointerMove, !0), this._pendingMaskHref) {
582
+ let d = this._pendingMaskHref;
583
+ this._pendingMaskHref = null, this._createMask(d);
584
+ }
585
+ this._render();
586
+ }
587
+ }
588
+ disconnectedCallback() {
589
+ super.disconnectedCallback(), this._svgElement?.removeEventListener("pointermove", this._handleSvgPointerMove, !0), document.removeEventListener("pointermove", this._handlePointerMove, !0), document.removeEventListener("pointerup", this._handlePointerUp, !0);
590
+ }
591
+ render() {
592
+ return html`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${ref(this._svgRef)}></svg>`;
593
+ }
594
+ };
595
+ __decorate([state()], CropFrame.prototype, "_draggingValue", void 0);
596
+ function validateCrop(d) {
597
+ return d ? [({ dimensions: d, coords: B }) => [...d, ...B].every((d) => Number.isInteger(d) && Number.isFinite(d)), ({ dimensions: d, coords: B }) => d.every((d) => d > 0) && B.every((d) => d >= 0)].every((B) => B(d)) : !0;
598
+ }
599
+ var EditorImageCropper = class extends LitBlock {
600
+ constructor() {
601
+ super(), this.ctxOwner = !0, this._imageSize = {
602
+ width: 0,
603
+ height: 0
604
+ }, this._ctx = null, this._isActive = !1, this._image = null, this._canvasRef = createRef(), this._frameRef = createRef(), this.init$ = {
605
+ ...this.init$,
606
+ "*padding": 20,
607
+ "*operations": {
608
+ rotate: 0,
609
+ mirror: !1,
610
+ flip: !1
611
+ },
612
+ "*imageBox": {
613
+ x: 0,
614
+ y: 0,
615
+ width: 0,
616
+ height: 0
617
+ },
618
+ "*cropBox": {
619
+ x: 0,
620
+ y: 0,
621
+ width: 0,
622
+ height: 0
623
+ }
624
+ }, this._commitDebounced = debounce(this._commit.bind(this), 300), this._handleResizeThrottled = throttle(() => {
625
+ !this.isConnected || !this._isActive || (this._initCanvas(), this._syncTransformations(), this._alignImage(), this._alignCrop(), this._draw());
626
+ }, 100);
627
+ }
628
+ firstUpdated(d) {
629
+ super.firstUpdated(d), this._initCanvas();
630
+ }
631
+ _syncTransformations() {
632
+ let d = this.$["*editorTransformations"], B = pick(d, Object.keys(this.$["*operations"])), V = {
633
+ ...this.$["*operations"],
634
+ ...B
635
+ };
636
+ this.$["*operations"] = V;
637
+ }
638
+ _initCanvas() {
639
+ let d = this._canvasRef.value;
640
+ if (!d) return;
641
+ let B = d.getContext("2d"), V = this.offsetWidth, H = this.offsetHeight, U = window.devicePixelRatio;
642
+ d.style.width = `${V}px`, d.style.height = `${H}px`, d.width = V * U, d.height = H * U, B?.scale(U, U), this._canvas = d, this._ctx = B;
643
+ }
644
+ _alignImage() {
645
+ if (!this._isActive || !this._image) return;
646
+ let d = this._image, B = this.$["*padding"], { rotate: V } = this.$["*operations"], H = {
647
+ width: this.offsetWidth,
648
+ height: this.offsetHeight
649
+ }, U = rotateSize({
650
+ width: d.naturalWidth,
651
+ height: d.naturalHeight
652
+ }, V), W;
653
+ if (U.width > H.width - B * 2 || U.height > H.height - B * 2) {
654
+ let d = U.width / U.height;
655
+ if (d > H.width / H.height) {
656
+ let V = H.width - B * 2, U = V / d;
657
+ W = {
658
+ x: 0 + B,
659
+ y: B + (H.height - B * 2) / 2 - U / 2,
660
+ width: V,
661
+ height: U
662
+ };
663
+ } else {
664
+ let V = H.height - B * 2, U = V * d;
665
+ W = {
666
+ x: B + (H.width - B * 2) / 2 - U / 2,
667
+ y: 0 + B,
668
+ width: U,
669
+ height: V
670
+ };
671
+ }
672
+ } else {
673
+ let { width: d, height: V } = U;
674
+ W = {
675
+ x: B + (H.width - B * 2) / 2 - d / 2,
676
+ y: B + (H.height - B * 2) / 2 - V / 2,
677
+ width: d,
678
+ height: V
679
+ };
680
+ }
681
+ this.$["*imageBox"] = roundRect(W);
682
+ }
683
+ _alignCrop() {
684
+ let d = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], H = this.$["*editorTransformations"].crop, { width: U, x: W, y: G } = B;
685
+ if (H) {
686
+ let { dimensions: [K, q], coords: [J, Y] } = H, { width: X } = rotateSize(this._imageSize, V), Z = U / X;
687
+ d = constraintRect(roundRect({
688
+ x: W + J * Z,
689
+ y: G + Y * Z,
690
+ width: K * Z,
691
+ height: q * Z
692
+ }), B);
693
+ }
694
+ let K = this.$["*currentAspectRatio"], q = K ? K.width / K.height : void 0;
695
+ if (!isRectInsideRect(d, B) || q && !isRectMatchesAspectRatio(d, q)) {
696
+ let V = B.width / B.height, H = B.width, U = B.height;
697
+ q && (V > q ? H = Math.min(B.height * q, B.width) : U = Math.min(B.width / q, B.height)), d = {
698
+ x: B.x + B.width / 2 - H / 2,
699
+ y: B.y + B.height / 2 - U / 2,
700
+ width: H,
701
+ height: U
702
+ };
703
+ }
704
+ this.$["*cropBox"] = constraintRect(roundRect(d), B);
705
+ }
706
+ _drawImage() {
707
+ let d = this._ctx;
708
+ if (!d) return;
709
+ let B = this._image;
710
+ if (!B) return;
711
+ let V = this.$["*imageBox"], { mirror: H, flip: U, rotate: W } = this.$["*operations"], G = rotateSize({
712
+ width: V.width,
713
+ height: V.height
714
+ }, W);
715
+ d.save(), d.translate(V.x + V.width / 2, V.y + V.height / 2), d.rotate(W * Math.PI * -1 / 180), d.scale(H ? -1 : 1, U ? -1 : 1), d.drawImage(B, -G.width / 2, -G.height / 2, G.width, G.height), d.restore();
716
+ }
717
+ _draw() {
718
+ if (!this._isActive || !this._image || !this._canvas || !this._ctx) return;
719
+ let d = this._canvas;
720
+ this._ctx.clearRect(0, 0, d.width, d.height), this._drawImage();
721
+ }
722
+ _animateIn({ fromViewer: d }) {
723
+ this._image && (this._frameRef.value?.toggleThumbs(!0), this._transitionToImage(), setTimeout(() => {
724
+ this.className = classNames({
725
+ "uc-active_from_viewer": d,
726
+ "uc-active_from_editor": !d,
727
+ "uc-inactive_to_editor": !1
728
+ });
729
+ }));
730
+ }
731
+ _getCropDimensions() {
732
+ let d = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], { width: H, height: U } = B, { width: W, height: G } = rotateSize(this._imageSize, V), { width: K, height: q } = d, J = H / W, Y = U / G;
733
+ return [clamp(Math.round(K / J), 1, W), clamp(Math.round(q / Y), 1, G)];
734
+ }
735
+ _getCropTransformation() {
736
+ let d = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], { width: H, height: U, x: W, y: G } = B, { width: K, height: q } = rotateSize(this._imageSize, V), { x: J, y: Y } = d, X = H / K, Z = U / q, Q = this._getCropDimensions(), $ = {
737
+ dimensions: Q,
738
+ coords: [clamp(Math.round((J - W) / X), 0, K - Q[0]), clamp(Math.round((Y - G) / Z), 0, q - Q[1])]
739
+ };
740
+ if (!validateCrop($)) {
741
+ console.error("Cropper is trying to create invalid crop object", { payload: $ });
742
+ return;
743
+ }
744
+ if (!(Q[0] === K && Q[1] === q)) return $;
745
+ }
746
+ _commit() {
747
+ if (!this.isConnected || !this._imageSize) return;
748
+ let { rotate: d, mirror: B, flip: V } = this.$["*operations"], H = this._getCropTransformation(), U = {
749
+ ...this.$["*editorTransformations"],
750
+ crop: H,
751
+ rotate: d,
752
+ mirror: B,
753
+ flip: V
754
+ };
755
+ this.$["*editorTransformations"] = U;
756
+ }
757
+ setValue(d, B) {
758
+ this.$["*operations"] = {
759
+ ...this.$["*operations"],
760
+ [d]: B
761
+ }, this._isActive && (this._alignImage(), this._alignCrop(), this._draw());
762
+ }
763
+ getValue(d) {
764
+ return this.$["*operations"][d];
765
+ }
766
+ async activate(d, { fromViewer: B } = {}) {
767
+ if (!this._isActive) {
768
+ this._isActive = !0, await this.updateComplete, this._initCanvas(), this._imageSize = d, this.removeEventListener("transitionend", this._reset);
769
+ try {
770
+ let d = this.$["*originalUrl"], V = this.$["*editorTransformations"];
771
+ this._image = await this._waitForImage(d, V), this._syncTransformations(), this._handleResizeThrottled(), this._animateIn({ fromViewer: B });
772
+ } catch (d) {
773
+ console.error("Failed to activate cropper", { error: d }), this.telemetryManager.sendEventError(d, "cloud editor image. Failed to activate cropper");
774
+ }
775
+ this._observer = new ResizeObserver((d) => {
776
+ let [B] = d;
777
+ B && B.contentRect.width > 0 && B.contentRect.height > 0 && this._isActive && this._image && this._handleResizeThrottled();
778
+ }), this._observer.observe(this);
779
+ }
780
+ }
781
+ deactivate({ reset: d = !1 } = {}) {
782
+ this._isActive && (!d && this._commit(), this._isActive = !1, this._transitionToCrop(), this.className = classNames({
783
+ "uc-active_from_viewer": !1,
784
+ "uc-active_from_editor": !1,
785
+ "uc-inactive_to_editor": !0
786
+ }), this._frameRef.value?.toggleThumbs(!1), this.addEventListener("transitionend", this._reset, { once: !0 }), this._observer?.disconnect());
787
+ }
788
+ _transitionToCrop() {
789
+ let d = this._getCropDimensions(), B = this.$["*cropBox"], V = Math.min(this.offsetWidth, d[0]) / B.width, H = Math.min(this.offsetHeight, d[1]) / B.height, U = Math.min(V, H), W = B.x + B.width / 2, G = B.y + B.height / 2;
790
+ this.style.transform = `scale(${U}) translate(${(this.offsetWidth / 2 - W) / U}px, ${(this.offsetHeight / 2 - G) / U}px)`, this.style.transformOrigin = `${W}px ${G}px`;
791
+ }
792
+ _transitionToImage() {
793
+ let d = this.$["*cropBox"], B = d.x + d.width / 2, V = d.y + d.height / 2;
794
+ this.style.transform = "scale(1)", this.style.transformOrigin = `${B}px ${V}px`;
795
+ }
796
+ _reset() {
797
+ this._isActive || (this._image = null);
798
+ }
799
+ async _waitForImage(d, B) {
800
+ let V = this.offsetWidth;
801
+ B = {
802
+ ...B,
803
+ crop: void 0,
804
+ rotate: void 0,
805
+ flip: void 0,
806
+ mirror: void 0
807
+ };
808
+ let H = await this.proxyUrl(viewerImageSrc(d, V, B)), { promise: U, cancel: W, image: G } = preloadImage(H), K = this._handleImageLoading(H);
809
+ return G.addEventListener("load", K, { once: !0 }), G.addEventListener("error", K, { once: !0 }), this._cancelPreload?.(), this._cancelPreload = W, U.then(() => G).catch((d) => (console.error("Failed to load image", { error: d }), this.$["*networkProblems"] = !0, G));
810
+ }
811
+ _handleImageLoading(d) {
812
+ let B = "crop", V = this.$["*loadingOperations"], H = V.get(B);
813
+ return H || (H = /* @__PURE__ */ new Map(), V.set(B, H)), H.get(d) || (H.set(d, !0), this.$["*loadingOperations"] = V), () => {
814
+ let H = V.get(B);
815
+ H?.has(d) && (H.delete(d), this.$["*loadingOperations"] = V);
816
+ };
817
+ }
818
+ initCallback() {
819
+ super.initCallback(), this.sub("*imageBox", () => {
820
+ this._draw();
821
+ }), this.sub("*cropBox", () => {
822
+ this._image && this._commitDebounced();
823
+ }), this.sub("*currentAspectRatio", () => {
824
+ this._alignCrop();
825
+ }), setTimeout(() => {
826
+ this.sub("*networkProblems", (d) => {
827
+ d || this._isActive && this._imageSize && this.activate(this._imageSize, { fromViewer: !1 });
828
+ });
829
+ }, 0);
830
+ }
831
+ disconnectedCallback() {
832
+ super.disconnectedCallback(), this._observer?.disconnect(), this._image &&= null;
833
+ }
834
+ render() {
835
+ return html`
836
+ <canvas class="uc-canvas" ${ref(this._canvasRef)}></canvas>
837
+ <uc-crop-frame ${ref(this._frameRef)}></uc-crop-frame>
838
+ `;
839
+ }
840
+ };
841
+ __decorate([state()], EditorImageCropper.prototype, "_image", void 0);
842
+ function linspace(d, B, V) {
843
+ let H = V, U = V - 1, W = Array(H);
844
+ for (let V = U; V >= 0; --V) W[V] = Math.ceil((V * B + (U - V) * d) / U);
845
+ return W;
846
+ }
847
+ function isOperationKey(d) {
848
+ return typeof d == "string" && d in COLOR_OPERATIONS_CONFIG;
849
+ }
850
+ function splitBySections(d) {
851
+ let B = [];
852
+ for (let V = 0; V < d.length - 1; V += 1) {
853
+ let H = d[V], U = d[V + 1];
854
+ typeof H == "number" && typeof U == "number" && B.push([H, U]);
855
+ }
856
+ return B;
857
+ }
858
+ function calculateOpacities(d, B, V) {
859
+ let H = splitBySections(d).find(([d, V]) => d <= B && B <= V);
860
+ if (!H) return d.map(() => 0);
861
+ let [U, W] = H;
862
+ return d.map((d) => {
863
+ let H = Math.abs(U - W) || 1, G = Math.abs(B - U) / H;
864
+ return U === d ? B > V ? 1 : 1 - G : W === d ? B >= V ? G : 1 : 0;
865
+ });
866
+ }
867
+ function calculateZIndices(d, B) {
868
+ return d.map((V, H) => V < B ? d.length - H : H);
869
+ }
870
+ function keypointsRange(d, B) {
871
+ let V = COLOR_OPERATIONS_CONFIG[d].keypointsNumber, { range: H, zero: U } = COLOR_OPERATIONS_CONFIG[d];
872
+ return [...new Set([
873
+ ...linspace(H[0], U, V + 1),
874
+ ...linspace(U, H[1], V + 1),
875
+ U,
876
+ B
877
+ ])].sort((d, B) => d - B);
878
+ }
879
+ var EditorImageFader = class extends LitBlock {
880
+ constructor() {
881
+ super(), this._isActive = !1, this._hidden = !0, this._operation = "initial", this._transformations = {}, this._keypoints = [], this._raf = 0, this._previewHostRef = createRef(), this._layersHostRef = createRef(), this.classList.add("uc-inactive_to_cropper"), this._addKeypointDebounced = debounce(async (d, B, V) => {
882
+ let H = () => !this._isSame(d, B) || this._value !== V || !!this._keypoints.find((d) => d.value === V);
883
+ if (H()) return;
884
+ let U = await this._constructKeypoint(d, V), W = new Image();
885
+ W.src = U.src;
886
+ let G = this._handleImageLoading(U.src);
887
+ W.addEventListener("load", G, { once: !0 }), W.addEventListener("error", G, { once: !0 }), U.image = W, W.classList.add("uc-fader-image"), W.addEventListener("load", () => {
888
+ if (H()) return;
889
+ let B = this._keypoints, G = B.findIndex((d) => d.value > V);
890
+ G === -1 && (G = B.length);
891
+ let K = B[G]?.image, q = this._layersHostRef.value;
892
+ !q || K && !q.contains(K) || (B.splice(G, 0, U), K ? q.insertBefore(W, K) : q.appendChild(W), this._update(d, V));
893
+ }, { once: !0 }), W.addEventListener("error", () => {
894
+ this.$["*networkProblems"] = !0;
895
+ }, { once: !0 });
896
+ }, 600);
897
+ }
898
+ _handleImageLoading(d) {
899
+ let B = this._operation, V = this.$["*loadingOperations"];
900
+ V.has(B) || V.set(B, /* @__PURE__ */ new Map());
901
+ let H = V.get(B);
902
+ return H && !H.get(d) && (H.set(d, !0), this.$["*loadingOperations"] = V), () => {
903
+ let H = V.get(B);
904
+ H?.has(d) && (H.delete(d), this.$["*loadingOperations"] = V);
905
+ };
906
+ }
907
+ _flush() {
908
+ window.cancelAnimationFrame(this._raf), this._raf = window.requestAnimationFrame(() => {
909
+ for (let d of this._keypoints) {
910
+ let { image: B } = d;
911
+ B && (B.style.opacity = d.opacity.toString(), B.style.zIndex = d.zIndex.toString());
912
+ }
913
+ });
914
+ }
915
+ _imageSrc({ url: d = this._url, filter: B = this._filter ?? void 0, operation: V, value: H } = {}) {
916
+ if (!d) throw Error("URL is not defined");
917
+ let U = { ...this._transformations };
918
+ V && (V === "filter" ? B && typeof H == "number" && (U.filter = {
919
+ name: B,
920
+ amount: H
921
+ }) : typeof H == "number" && (U[V] = H));
922
+ let W = this.offsetWidth;
923
+ return this.proxyUrl(viewerImageSrc(d, W, U));
924
+ }
925
+ async _constructKeypoint(d, B) {
926
+ return {
927
+ src: await this._imageSrc({
928
+ operation: d,
929
+ value: B
930
+ }),
931
+ image: void 0,
932
+ opacity: 0,
933
+ zIndex: 0,
934
+ value: B
935
+ };
936
+ }
937
+ _isSame(d, B) {
938
+ return this._operation === d && this._filter === B;
939
+ }
940
+ set(d) {
941
+ let B = typeof d == "string" ? parseInt(d, 10) : d;
942
+ !isOperationKey(this._operation) || !Number.isFinite(B) || (this._update(this._operation, B), this._addKeypointDebounced(this._operation, this._filter, B));
943
+ }
944
+ _update(d, B) {
945
+ this._operation = d, this._value = B;
946
+ let { zero: V } = COLOR_OPERATIONS_CONFIG[d], H = this._keypoints.map((d) => d.value), U = calculateOpacities(H, B, V), W = calculateZIndices(H, V);
947
+ this._keypoints.forEach((d, B) => {
948
+ let V = U[B], H = W[B];
949
+ typeof V == "number" && (d.opacity = V), typeof H == "number" && (d.zIndex = H);
950
+ }), this._flush();
951
+ }
952
+ _createPreviewImage() {
953
+ let d = new Image();
954
+ return d.classList.add("uc-fader-image", "uc-fader-image--preview"), d.style.opacity = "0", d;
955
+ }
956
+ async _initNodes() {
957
+ this._previewImage = this._previewImage || this._createPreviewImage();
958
+ let d = this._previewImage;
959
+ d && this._ensurePreviewAttached(d);
960
+ let { images: B, promise: V, cancel: H } = batchPreloadImages(this._keypoints.map((d) => d.src));
961
+ B.forEach((d) => {
962
+ let B = this._handleImageLoading(d.src);
963
+ d.addEventListener("load", B), d.addEventListener("error", B);
964
+ }), this._cancelLastImages = () => {
965
+ H(), this._cancelLastImages = void 0;
966
+ };
967
+ let U = this._operation, W = this._filter;
968
+ if (await V, this._isActive && this._isSame(U, W)) {
969
+ let d = this._layersHostRef.value;
970
+ if (!d) return;
971
+ d.replaceChildren(), this._keypoints.forEach((V, H) => {
972
+ let U = B[H];
973
+ U && (U.classList.add("uc-fader-image"), V.image = U, d.appendChild(U));
974
+ }), this._flush();
975
+ }
976
+ }
977
+ async setTransformations(d) {
978
+ if (this._transformations = d, this._previewImage) {
979
+ let d = await this._imageSrc(), B = this._handleImageLoading(d);
980
+ this._previewImage.src = d, this._previewImage.addEventListener("load", B, { once: !0 }), this._previewImage.addEventListener("error", B, { once: !0 }), this._previewImage.style.opacity = "1", this._previewImage.addEventListener("error", () => {
981
+ this.$["*networkProblems"] = !0;
982
+ }, { once: !0 });
983
+ }
984
+ }
985
+ async preload({ url: d, filter: B, operation: V, value: H }) {
986
+ if (!V || typeof H != "number") return;
987
+ this._cancelBatchPreload?.();
988
+ let U = keypointsRange(V, H), { cancel: W } = batchPreloadImages(await Promise.all(U.map((H) => this._imageSrc({
989
+ url: d,
990
+ filter: B,
991
+ operation: V,
992
+ value: H
993
+ }))));
994
+ this._cancelBatchPreload = W;
995
+ }
996
+ _setOriginalSrc(d) {
997
+ let B = this._previewImage || this._createPreviewImage();
998
+ if (this._ensurePreviewAttached(B), this._previewImage = B, B.src === d) {
999
+ B.style.opacity = "1", B.style.transform = "scale(1)", this.className = classNames({
1000
+ "uc-active_from_viewer": this._fromViewer,
1001
+ "uc-active_from_cropper": !this._fromViewer,
1002
+ "uc-inactive_to_cropper": !1
1003
+ });
1004
+ return;
1005
+ }
1006
+ B.style.opacity = "0";
1007
+ let V = this._handleImageLoading(d);
1008
+ B.addEventListener("error", V, { once: !0 }), B.src = d, B.addEventListener("load", () => {
1009
+ V(), B && (B.style.opacity = "1", B.style.transform = "scale(1)", this.className = classNames({
1010
+ "uc-active_from_viewer": this._fromViewer,
1011
+ "uc-active_from_cropper": !this._fromViewer,
1012
+ "uc-inactive_to_cropper": !1
1013
+ }));
1014
+ }, { once: !0 }), B.addEventListener("error", () => {
1015
+ this.$["*networkProblems"] = !0;
1016
+ }, { once: !0 });
1017
+ }
1018
+ async activate({ url: d, operation: B, value: V, filter: H, fromViewer: U }) {
1019
+ if (this._isActive = !0, this._hidden = !1, await this.updateComplete, this._url = d, this._operation = B ?? "initial", this._value = V, this._filter = H, this._fromViewer = U, typeof V != "number" && !H) {
1020
+ let d = await this._imageSrc({
1021
+ operation: B,
1022
+ value: V
1023
+ });
1024
+ this._setOriginalSrc(d), this._clearLayersHost();
1025
+ return;
1026
+ }
1027
+ !B || typeof V != "number" || (this._keypoints = await Promise.all(keypointsRange(B, V).map((d) => this._constructKeypoint(B, d))), this._update(B, V), this._initNodes());
1028
+ }
1029
+ deactivate({ hide: d = !0 } = {}) {
1030
+ this._isActive = !1, this._cancelLastImages?.(), this._cancelBatchPreload?.(), d && !this._hidden ? (this._hidden = !0, this._previewImage && (this._previewImage.style.transform = "scale(1)"), this.className = classNames({
1031
+ "uc-active_from_viewer": !1,
1032
+ "uc-active_from_cropper": !1,
1033
+ "uc-inactive_to_cropper": !0
1034
+ }), this.addEventListener("transitionend", () => {
1035
+ this._clearLayersHost();
1036
+ }, { once: !0 })) : this._clearLayersHost();
1037
+ }
1038
+ _ensurePreviewAttached(d) {
1039
+ let B = this._previewHostRef.value;
1040
+ B && (B.contains(d) || B.appendChild(d));
1041
+ }
1042
+ _clearLayersHost() {
1043
+ this._layersHostRef.value?.replaceChildren();
1044
+ }
1045
+ render() {
1046
+ return html`
1047
+ <div class="uc-fader-preview-host" ${ref(this._previewHostRef)}></div>
1048
+ <div class="uc-fader-layers-host" ${ref(this._layersHostRef)}></div>
1049
+ `;
1050
+ }
1051
+ }, SliderUi = class extends LitBlock {
1052
+ constructor() {
1053
+ super(), this._thumbSize = 0, this._inputRef = createRef(), this._thumbRef = createRef(), this._stepsRef = createRef(), this.disabled = !1, this.min = 0, this.max = 100, this.defaultValue = 0, this.zero = 0, this._currentValue = 0, this._handleSliderInput = (d) => {
1054
+ d.stopPropagation();
1055
+ let B = this._extractEventValue(d);
1056
+ B !== null && (this._setCurrentValue(B), this._emitSliderEvent("slider-input", B));
1057
+ }, this._handleSliderChange = (d) => {
1058
+ d.stopPropagation();
1059
+ let B = this._extractEventValue(d);
1060
+ B !== null && this._setCurrentValue(B);
1061
+ }, this._handleInputFocus = () => {
1062
+ this.style.setProperty("--color-effect", "var(--hover-color-rgb)");
1063
+ }, this._handleInputBlur = () => {
1064
+ this.style.setProperty("--color-effect", "var(--idle-color-rgb)");
1065
+ }, this.setAttribute("with-effects", "");
1066
+ }
1067
+ _emitSliderEvent(d, B) {
1068
+ this.dispatchEvent(new CustomEvent(d, {
1069
+ detail: { value: B },
1070
+ bubbles: !0,
1071
+ composed: !0
1072
+ }));
1073
+ }
1074
+ firstUpdated(d) {
1075
+ super.firstUpdated(d), this._thumbSize = Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"), 10) || 0, this._syncInputValue(this._currentValue), this._updateSteps(), this._observer = new ResizeObserver(() => {
1076
+ this._updateSteps(), this._updateValue(this._currentValue);
1077
+ }), this._observer.observe(this);
1078
+ let B = this._inputRef.value;
1079
+ B?.addEventListener("focus", this._handleInputFocus), B?.addEventListener("blur", this._handleInputBlur), window.setTimeout(() => {
1080
+ this._updateValue(this._currentValue);
1081
+ }, 0);
1082
+ }
1083
+ willUpdate(d) {
1084
+ super.willUpdate(d), d.has("defaultValue") && this.defaultValue !== this._currentValue && this._setCurrentValue(this.defaultValue), (d.has("min") || d.has("max")) && this.hasUpdated && (this._updateSteps(), this._updateValue(this._currentValue)), d.has("zero") && this.hasUpdated && this._updateZeroDot(this._currentValue);
1085
+ }
1086
+ _updateValue(d) {
1087
+ this._updateZeroDot(d);
1088
+ let B = this.max - this.min;
1089
+ if (B === 0) return;
1090
+ let { width: V } = this.getBoundingClientRect(), H = 100 / B * (d - this.min) * (V - this._thumbSize) / 100;
1091
+ window.requestAnimationFrame(() => {
1092
+ let d = this._thumbRef.value;
1093
+ d && (d.style.transform = `translateX(${H}px)`);
1094
+ });
1095
+ }
1096
+ _updateZeroDot(d) {
1097
+ if (!this._zeroDotEl) return;
1098
+ let B = this.max - this.min;
1099
+ if (B === 0) return;
1100
+ this._zeroDotEl.style.opacity = d === this.zero ? "0" : "1";
1101
+ let { width: V } = this.getBoundingClientRect(), H = 100 / B * (this.zero - this.min) * (V - this._thumbSize) / 100;
1102
+ window.requestAnimationFrame(() => {
1103
+ this._zeroDotEl && (this._zeroDotEl.style.transform = `translateX(${H}px)`);
1104
+ });
1105
+ }
1106
+ _updateSteps() {
1107
+ let d = this._stepsRef.value;
1108
+ if (!d) return;
1109
+ let { width: B } = d.getBoundingClientRect(), V = Math.ceil(B / 2), H = Math.ceil(V / 15) - 2;
1110
+ if (this._stepsCount === H) return;
1111
+ let U = document.createDocumentFragment(), W = document.createElement("div"), G = document.createElement("div");
1112
+ W.className = "uc-minor-step", G.className = "uc-border-step", U.appendChild(G);
1113
+ for (let d = 0; d < H; d += 1) U.appendChild(W.cloneNode());
1114
+ U.appendChild(G.cloneNode());
1115
+ for (let d = 0; d < H; d += 1) U.appendChild(W.cloneNode());
1116
+ U.appendChild(G.cloneNode());
1117
+ let K = document.createElement("div");
1118
+ K.className = "uc-zero-dot", U.appendChild(K), this._zeroDotEl = K, d.innerHTML = "", d.appendChild(U), this._stepsCount = H;
1119
+ }
1120
+ disconnectedCallback() {
1121
+ super.disconnectedCallback();
1122
+ let d = this._inputRef.value;
1123
+ d?.removeEventListener("focus", this._handleInputFocus), d?.removeEventListener("blur", this._handleInputBlur), this._observer?.disconnect(), this._observer = void 0;
1124
+ }
1125
+ _setCurrentValue(d) {
1126
+ Number.isFinite(d) && (this._currentValue = d, this.hasUpdated && (this._syncInputValue(d), this._updateValue(d)));
1127
+ }
1128
+ _syncInputValue(d) {
1129
+ let B = this._inputRef.value;
1130
+ B && (B.value = String(d));
1131
+ }
1132
+ _extractEventValue(d) {
1133
+ let B = d.currentTarget;
1134
+ if (!B) return null;
1135
+ let V = Number.parseInt(B.value, 10);
1136
+ return Number.isFinite(V) ? V : null;
1137
+ }
1138
+ render() {
1139
+ return html`
1140
+ <div class="uc-steps" ${ref(this._stepsRef)}></div>
1141
+ <div class="uc-thumb" ${ref(this._thumbRef)}></div>
1142
+ <input
1143
+ class="uc-input"
1144
+ type="range"
1145
+ ${ref(this._inputRef)}
1146
+ .min=${String(this.min)}
1147
+ .max=${String(this.max)}
1148
+ .value=${String(this._currentValue)}
1149
+ ?disabled=${this.disabled}
1150
+ @input=${this._handleSliderInput}
1151
+ @change=${this._handleSliderChange}
1152
+ />
1153
+ `;
1154
+ }
1155
+ };
1156
+ __decorate([property({
1157
+ type: Boolean,
1158
+ reflect: !0
1159
+ })], SliderUi.prototype, "disabled", void 0), __decorate([property({ type: Number })], SliderUi.prototype, "min", void 0), __decorate([property({ type: Number })], SliderUi.prototype, "max", void 0), __decorate([property({
1160
+ type: Number,
1161
+ attribute: !1
1162
+ })], SliderUi.prototype, "defaultValue", void 0), __decorate([property({ type: Number })], SliderUi.prototype, "zero", void 0), __decorate([state()], SliderUi.prototype, "_currentValue", void 0);
1163
+ const FAKE_ORIGINAL_FILTER = "original";
1164
+ var EditorSlider = class extends LitBlock {
1165
+ constructor(...d) {
1166
+ super(...d), this.state = {
1167
+ operation: "filter",
1168
+ filter: void 0,
1169
+ originalUrl: "",
1170
+ disabled: !1,
1171
+ min: 0,
1172
+ max: 100,
1173
+ value: 0,
1174
+ defaultValue: 0,
1175
+ zero: 0
1176
+ }, this._handleInput = (d) => {
1177
+ let { value: B } = d.detail;
1178
+ this.$["*faderEl"]?.set(B), this.state = {
1179
+ ...this.state,
1180
+ value: B
1181
+ };
1182
+ };
1183
+ }
1184
+ setOperation(d, B) {
1185
+ this.state = {
1186
+ ...this.state,
1187
+ operation: d,
1188
+ filter: B
1189
+ }, this._initializeValues();
1190
+ let V = this.$["*faderEl"], H = this.state.originalUrl || this.$["*originalUrl"];
1191
+ V && H && V.activate({
1192
+ url: H,
1193
+ operation: this.state.operation,
1194
+ value: this.state.filter === "original" ? void 0 : this.state.value,
1195
+ filter: this.state.filter === "original" ? void 0 : this.state.filter,
1196
+ fromViewer: !1
1197
+ });
1198
+ }
1199
+ _initializeValues() {
1200
+ let d = this.state.operation, { range: B, zero: V } = COLOR_OPERATIONS_CONFIG[d], [H, U] = B;
1201
+ this.state = {
1202
+ ...this.state,
1203
+ min: H,
1204
+ max: U,
1205
+ zero: V
1206
+ };
1207
+ let W = this.$["*editorTransformations"][d];
1208
+ if (d === "filter") {
1209
+ let d = Number(U), B = W;
1210
+ if (B) {
1211
+ let { name: V, amount: H } = B;
1212
+ d = V === this.state.filter ? H : U;
1213
+ }
1214
+ this.state = {
1215
+ ...this.state,
1216
+ value: d,
1217
+ defaultValue: d
1218
+ };
1219
+ return;
1220
+ }
1221
+ let G = W === void 0 ? V : W;
1222
+ this.state = {
1223
+ ...this.state,
1224
+ value: G,
1225
+ defaultValue: G
1226
+ };
1227
+ }
1228
+ apply() {
1229
+ let d = { ...this.$["*editorTransformations"] };
1230
+ this.state.operation === "filter" ? !this.state.filter || this.state.filter === "original" ? delete d.filter : d.filter = {
1231
+ name: this.state.filter,
1232
+ amount: this.state.value
1233
+ } : d[this.state.operation] = this.state.value, this.$["*editorTransformations"] = d;
1234
+ }
1235
+ cancel() {
1236
+ this.$["*faderEl"]?.deactivate({ hide: !1 });
1237
+ }
1238
+ initCallback() {
1239
+ super.initCallback(), this.sub("*originalUrl", (d) => {
1240
+ d && (this.state = {
1241
+ ...this.state,
1242
+ originalUrl: d
1243
+ });
1244
+ });
1245
+ }
1246
+ updated(d) {
1247
+ if (super.updated(d), d.has("state")) {
1248
+ let d = `${this.state.filter ?? this.state.operation} ${this.state.value}`;
1249
+ this.$["*operationTooltip"] = d;
1250
+ }
1251
+ }
1252
+ render() {
1253
+ return html`
1254
+ <uc-slider-ui
1255
+ .disabled=${this.state.disabled}
1256
+ .min=${this.state.min}
1257
+ .max=${this.state.max}
1258
+ .defaultValue=${this.state.defaultValue}
1259
+ .zero=${this.state.zero}
1260
+ @slider-input=${this._handleInput}
1261
+ ></uc-slider-ui>
1262
+ `;
1263
+ }
1264
+ };
1265
+ __decorate([state()], EditorSlider.prototype, "state", void 0);
1266
+ function parseFilterValue(d) {
1267
+ if (!d) return null;
1268
+ let B = d.match(/^([A-Za-z]+)\s+(\d+)$/);
1269
+ if (!B) return null;
1270
+ let [, V, H] = B;
1271
+ return !V || H === void 0 ? null : {
1272
+ filter: V,
1273
+ value: Number(H)
1274
+ };
1275
+ }
1276
+ var EditorButtonControl = class extends LitBlock {
1277
+ constructor(...d) {
1278
+ super(...d), this.active = !1, this.title = "", this.icon = "", this.titleProp = "";
1279
+ }
1280
+ get buttonClasses() {
1281
+ let d = this.active;
1282
+ return {
1283
+ "uc-active": d,
1284
+ "uc-not_active": !d
1285
+ };
1286
+ }
1287
+ _updateHostStateClasses() {
1288
+ let d = this.buttonClasses;
1289
+ for (let [B, V] of Object.entries(d)) this.classList.toggle(B, V);
1290
+ }
1291
+ onClick(d) {}
1292
+ connectedCallback() {
1293
+ super.connectedCallback(), this._updateHostStateClasses();
1294
+ }
1295
+ updated(d) {
1296
+ super.updated(d), d.has("active") && this._updateHostStateClasses();
1297
+ }
1298
+ render() {
1299
+ let d = this.onClick, B = this.title;
1300
+ return html`
1301
+ <button
1302
+ role="option"
1303
+ type="button"
1304
+ aria-label=${ifDefined(this.titleProp)}
1305
+ title=${ifDefined(this.titleProp)}
1306
+ @click=${d}
1307
+ >
1308
+ <uc-icon name=${this.icon}></uc-icon>
1309
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1310
+ </button>
1311
+ `;
1312
+ }
1313
+ };
1314
+ __decorate([state()], EditorButtonControl.prototype, "active", void 0), __decorate([state()], EditorButtonControl.prototype, "title", void 0), __decorate([state()], EditorButtonControl.prototype, "icon", void 0), __decorate([state()], EditorButtonControl.prototype, "titleProp", void 0);
1315
+ var SIZE_RECT_FIXED = 12, SIZE_SVG_WRAPPER = 16, getAdjustResolutions = (d) => {
1316
+ let B = 12, V = 12;
1317
+ return d.width / d.height >= 1 ? (B = SIZE_RECT_FIXED, V = Math.round(SIZE_RECT_FIXED * d.height / d.width)) : (V = SIZE_RECT_FIXED, B = Math.round(SIZE_RECT_FIXED * d.width / d.height)), {
1318
+ width: B,
1319
+ height: V
1320
+ };
1321
+ }, EditorFreeformButtonControl = class extends EditorButtonControl {
1322
+ initCallback() {
1323
+ super.initCallback(), this.icon = "arrow-dropdown", this.sub("*currentAspectRatio", (d) => {
1324
+ let B = this._computeTitle(d);
1325
+ this.title = B, this.titleProp = B;
1326
+ });
1327
+ }
1328
+ onClick() {
1329
+ this.$["*showListAspectRatio"] = !0;
1330
+ }
1331
+ _computeTitle(d) {
1332
+ return d ? d.hasFreeform ? this.l10n("freeform-crop") : this.l10n("crop-to-shape", { value: `${d.width}:${d.height}` }) : "";
1333
+ }
1334
+ render() {
1335
+ let d = this.onClick, B = this.title;
1336
+ return html`
1337
+ <button
1338
+ role="option"
1339
+ type="button"
1340
+ class=${classMap(this.buttonClasses)}
1341
+ aria-label=${ifDefined(this.titleProp)}
1342
+ title=${ifDefined(this.titleProp)}
1343
+ @click=${d}
1344
+ >
1345
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1346
+ <uc-icon name=${this.icon}></uc-icon>
1347
+ </button>
1348
+ `;
1349
+ }
1350
+ }, EditorAspectRatioButtonControl = class extends EditorButtonControl {
1351
+ constructor(...d) {
1352
+ super(...d), this._aspectRatio = null;
1353
+ }
1354
+ get aspectRatio() {
1355
+ return this._aspectRatio;
1356
+ }
1357
+ set aspectRatio(d) {
1358
+ if (this._aspectRatio === d) return;
1359
+ let B = this._aspectRatio;
1360
+ this._aspectRatio = d, this.requestUpdate("aspectRatio", B), d ? this._updateAspectRatioPresentation(d) : (this.removeAttribute("uc-aspect-ratio-freeform"), this.title = "", this.titleProp = "");
1361
+ }
1362
+ initCallback() {
1363
+ super.initCallback(), this._aspectRatio && this._updateAspectRatioPresentation(this._aspectRatio), this.sub("*currentAspectRatio", (d) => {
1364
+ this.active = d && d.id === this._aspectRatio?.id || d?.width === this._aspectRatio?.width && d?.height === this._aspectRatio?.height;
1365
+ });
1366
+ }
1367
+ onClick() {
1368
+ this.$["*currentAspectRatio"]?.id !== this._aspectRatio?.id && (this.$["*currentAspectRatio"] = this._aspectRatio);
1369
+ }
1370
+ _updateAspectRatioPresentation(d) {
1371
+ if (!this.isConnected) return;
1372
+ let B = !!d.hasFreeform;
1373
+ this.toggleAttribute("uc-aspect-ratio-freeform", B), (() => {
1374
+ let V = B ? this.l10n("custom") : `${d.width}:${d.height}`;
1375
+ return this.title = V, V;
1376
+ })(), (() => {
1377
+ let V = this.l10n("a11y-cloud-editor-apply-aspect-ratio", {
1378
+ name: B ? this.l10n("custom").toLowerCase() : this.l10n("crop-to-shape", { value: `${d.width}:${d.height}` }).toLowerCase(),
1379
+ value: ""
1380
+ });
1381
+ return this.titleProp = V, V;
1382
+ })(), B || this.requestUpdate();
1383
+ }
1384
+ _renderIcon() {
1385
+ let d = this._aspectRatio;
1386
+ if (!d || d.hasFreeform) return html`<uc-icon name=${this.icon}></uc-icon>`;
1387
+ let { width: B, height: V } = getAdjustResolutions(d);
1388
+ return html`
1389
+ <uc-icon>
1390
+ <svg
1391
+ viewBox="0 0 ${SIZE_SVG_WRAPPER} ${SIZE_SVG_WRAPPER}"
1392
+ aria-hidden="true"
1393
+ focusable="false"
1394
+ >
1395
+ <rect
1396
+ x=${(SIZE_SVG_WRAPPER - B) / 2}
1397
+ y=${(SIZE_SVG_WRAPPER - V) / 2}
1398
+ width=${B}
1399
+ height=${V}
1400
+ rx="2"
1401
+ fill="none"
1402
+ stroke="currentColor"
1403
+ stroke-width="1.2"
1404
+ stroke-linejoin="round"
1405
+ ></rect>
1406
+ </svg>
1407
+ </uc-icon>
1408
+ `;
1409
+ }
1410
+ render() {
1411
+ let d = this.onClick, B = this.title;
1412
+ return html`
1413
+ <button
1414
+ role="option"
1415
+ type="button"
1416
+ class=${classMap(this.buttonClasses)}
1417
+ aria-label=${ifDefined(this.titleProp)}
1418
+ title=${ifDefined(this.titleProp)}
1419
+ @click=${d}
1420
+ >
1421
+ ${this._renderIcon()}
1422
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1423
+ </button>
1424
+ `;
1425
+ }
1426
+ };
1427
+ __decorate([property({ attribute: !1 })], EditorAspectRatioButtonControl.prototype, "aspectRatio", null);
1428
+ function nextAngle(d) {
1429
+ let B = d + 90;
1430
+ return B = B >= 360 ? 0 : B, B;
1431
+ }
1432
+ function nextValue(d, B) {
1433
+ if (d === "rotate") return nextAngle(typeof B == "number" ? B : 0);
1434
+ if (d === "mirror" || d === "flip") return !B;
1435
+ throw Error(`Unsupported operation: ${d}`);
1436
+ }
1437
+ var EditorCropButtonControl = class extends EditorButtonControl {
1438
+ constructor(...d) {
1439
+ super(...d), this.operation = void 0;
1440
+ }
1441
+ willUpdate(d) {
1442
+ super.willUpdate(d), this.operation ? (this.titleProp = this.l10n("a11y-cloud-editor-apply-crop", { name: this.l10n(this.operation).toLowerCase() }), this.icon = this.operation) : (this.icon = "", this.titleProp = "");
1443
+ }
1444
+ onClick(d) {
1445
+ if (!this.operation) return;
1446
+ let B = this.$["*cropperEl"], V = B.getValue(this.operation), H = nextValue(this.operation, V);
1447
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], {
1448
+ operation: this.operation,
1449
+ next: H,
1450
+ prev: V
1451
+ }), B.setValue(this.operation, H);
1452
+ }
1453
+ };
1454
+ __decorate([property({ type: String })], EditorCropButtonControl.prototype, "operation", void 0);
1455
+ var EditorFilterControl = class extends EditorButtonControl {
1456
+ constructor(...d) {
1457
+ super(...d), this._operation = "", this._filter = "", this._originalUrl = "", this._lastPreviewRequestId = 0, this._previewImage = null, this._previewLoaded = !1, this.isOriginal = !1, this._iconSize = 20;
1458
+ }
1459
+ get filter() {
1460
+ return this._filter;
1461
+ }
1462
+ set filter(d) {
1463
+ let B = d ?? "";
1464
+ if (this._filter === B) return;
1465
+ let V = this._filter;
1466
+ this._filter = B, this._operation = "filter", this.isOriginal = B === FAKE_ORIGINAL_FILTER, this.icon = this.isOriginal ? "original" : "slider", this._iconSize = this.isOriginal ? 40 : 20, this.requestUpdate("filter", V), this.isConnected && this._updateFilterLabels(B);
1467
+ }
1468
+ onClick(d) {
1469
+ if (this.active) this.isOriginal || (this.$["*sliderEl"].setOperation(this._operation, this._filter), this.$["*showSlider"] = !0);
1470
+ else {
1471
+ let d = this.$["*sliderEl"];
1472
+ d.setOperation(this._operation, this._filter), d.apply();
1473
+ }
1474
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], { operation: parseFilterValue(this.$["*operationTooltip"]) }), this.$["*currentFilter"] = this._filter;
1475
+ }
1476
+ _previewSrc() {
1477
+ let B = parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"), 10), V = Number.isFinite(B) && B > 0 ? B : this._iconSize || 32, H = window.devicePixelRatio, U = Math.ceil(H * V), W = H >= 2 ? "lightest" : "normal", G = { ...this.$["*editorTransformations"] };
1478
+ return G[this._operation] = this._filter === "original" ? void 0 : {
1479
+ name: this._filter,
1480
+ amount: 100
1481
+ }, createCdnUrl(this._originalUrl, createCdnUrlModifiers(COMMON_OPERATIONS, transformationsToOperations(G), `quality/${W}`, `scale_crop/${U}x${U}/center`, `@clib/${PACKAGE_NAME}/${PACKAGE_VERSION}/uc-cloud-image-editor/`));
1482
+ }
1483
+ async _observerCallback(d, B) {
1484
+ d[0]?.isIntersecting ? await this._loadPreview(B) : this._cancelPreload?.();
1485
+ }
1486
+ initCallback() {
1487
+ super.initCallback(), this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), { threshold: [0, 1] }), this._originalUrl = this.$["*originalUrl"] ?? "", this.sub("*originalUrl", (d) => {
1488
+ this._originalUrl = d ?? "", !this.isOriginal && this._originalUrl && this.isConnected && !this._previewImage && (this._observer?.observe(this), this._schedulePreviewVisibilityCheck());
1489
+ }), this.isOriginal || (this._observer?.observe(this), this._schedulePreviewVisibilityCheck()), this._filter && this._updateFilterLabels(this._filter), this.sub("*currentFilter", (d) => {
1490
+ this.active = !!(d && d === this._filter);
1491
+ }), this.sub("*networkProblems", async (d) => {
1492
+ d || (this._previewImage ? await this._loadPreview() : this._schedulePreviewVisibilityCheck());
1493
+ });
1494
+ }
1495
+ disconnectedCallback() {
1496
+ super.disconnectedCallback(), this._observer?.disconnect(), this._cancelPreload?.(), this._clearPreviewVisibilityChecks();
1497
+ }
1498
+ updated(d) {
1499
+ super.updated(d), d.has("isOriginal") && (this.isOriginal ? this._observer?.unobserve(this) : (this._observer?.observe(this), this._schedulePreviewVisibilityCheck()));
1500
+ }
1501
+ _updateFilterLabels(d) {
1502
+ if (!d) {
1503
+ this.titleProp = "";
1504
+ return;
1505
+ }
1506
+ this.titleProp = this.l10n("a11y-cloud-editor-apply-filter", { name: d.toLowerCase() });
1507
+ }
1508
+ async _loadPreview(d) {
1509
+ if (!this.isConnected) {
1510
+ d?.unobserve(this), this._cancelPreload?.(), this._cancelPreload = void 0;
1511
+ return;
1512
+ }
1513
+ if (!this._originalUrl) {
1514
+ !this._previewVisibilityCheckTimeout && !this._previewVisibilityCheckRaf && this._schedulePreviewVisibilityCheck();
1515
+ return;
1516
+ }
1517
+ let B = ++this._lastPreviewRequestId, V = "";
1518
+ try {
1519
+ V = await this.proxyUrl(this._previewSrc());
1520
+ } catch (d) {
1521
+ this.$["*networkProblems"] = !0, console.error("Failed to resolve preview URL", { error: d });
1522
+ return;
1523
+ }
1524
+ this._previewLoaded = !1, this._cancelPreload?.();
1525
+ let { promise: H, cancel: U } = preloadImage(V);
1526
+ this._cancelPreload = () => {
1527
+ U(), this._lastPreviewRequestId === B && (this._cancelPreload = void 0);
1528
+ };
1529
+ try {
1530
+ if (await H, this._lastPreviewRequestId !== B || !this.isConnected) return;
1531
+ this._previewImage = V, this._previewLoaded = !0, this._clearPreviewVisibilityChecks(), (d ?? this._observer)?.unobserve(this);
1532
+ } catch (d) {
1533
+ this.$["*networkProblems"] = !0, console.error("Failed to load image", { error: d }), this._schedulePreviewVisibilityCheck();
1534
+ } finally {
1535
+ this._lastPreviewRequestId === B && (this._cancelPreload = void 0);
1536
+ }
1537
+ }
1538
+ _schedulePreviewVisibilityCheck() {
1539
+ if (!this.isConnected || this._previewImage || this._previewLoaded || this.isOriginal || this.$["*networkProblems"]) {
1540
+ this._clearPreviewVisibilityChecks();
1541
+ return;
1542
+ }
1543
+ this._previewVisibilityCheckRaf && cancelAnimationFrame(this._previewVisibilityCheckRaf), this._previewVisibilityCheckRaf = requestAnimationFrame(() => {
1544
+ if (this._previewVisibilityCheckRaf = void 0, !this.isConnected || this._previewImage || this._previewLoaded || this.isOriginal) {
1545
+ this._clearPreviewVisibilityChecks();
1546
+ return;
1547
+ }
1548
+ let d = this.getBoundingClientRect(), B = d.width > 0 && d.height > 0, V = window.innerWidth || document.documentElement.clientWidth, H = window.innerHeight || document.documentElement.clientHeight;
1549
+ if (B && d.bottom > 0 && d.right > 0 && d.top < H && d.left < V) {
1550
+ this._loadPreview();
1551
+ return;
1552
+ }
1553
+ this._previewVisibilityCheckTimeout = window.setTimeout(() => {
1554
+ this._previewVisibilityCheckTimeout = void 0, this._schedulePreviewVisibilityCheck();
1555
+ }, 500);
1556
+ });
1557
+ }
1558
+ _clearPreviewVisibilityChecks() {
1559
+ this._previewVisibilityCheckRaf &&= (cancelAnimationFrame(this._previewVisibilityCheckRaf), void 0), this._previewVisibilityCheckTimeout &&= (window.clearTimeout(this._previewVisibilityCheckTimeout), void 0);
1560
+ }
1561
+ get _shouldShowPreview() {
1562
+ return !!(this._previewLoaded && !this.active && !this.isOriginal);
1563
+ }
1564
+ render() {
1565
+ let d = this.onClick, B = { opacity: this._shouldShowPreview ? "1" : "0" };
1566
+ this._previewImage && (B.backgroundImage = `url(${this._previewImage})`);
1567
+ let V = { opacity: this.active || this.isOriginal ? "1" : "0" };
1568
+ return html`
1569
+ <button
1570
+ role="option"
1571
+ type="button"
1572
+ class=${classMap(this.buttonClasses)}
1573
+ aria-label=${ifDefined(this.titleProp)}
1574
+ title=${ifDefined(this.titleProp)}
1575
+ @click=${d}
1576
+ >
1577
+ <div class="uc-preview" ?data-loaded=${this._previewLoaded} style=${styleMap(B)}></div>
1578
+ <uc-icon
1579
+ class=${classMap({ "uc-original-icon": this.isOriginal })}
1580
+ name=${this.icon}
1581
+ style=${styleMap(V)}
1582
+ ></uc-icon>
1583
+ </button>
1584
+ `;
1585
+ }
1586
+ };
1587
+ __decorate([state()], EditorFilterControl.prototype, "_previewImage", void 0), __decorate([state()], EditorFilterControl.prototype, "_previewLoaded", void 0), __decorate([state()], EditorFilterControl.prototype, "isOriginal", void 0), __decorate([state()], EditorFilterControl.prototype, "_iconSize", void 0), __decorate([property({ type: String })], EditorFilterControl.prototype, "filter", null);
1588
+ var EditorOperationControl = class extends EditorButtonControl {
1589
+ constructor(...d) {
1590
+ super(...d), this._operation = "";
1591
+ }
1592
+ get operation() {
1593
+ return this._operation;
1594
+ }
1595
+ set operation(d) {
1596
+ let B = d ?? "";
1597
+ if (this._operation === B) return;
1598
+ let V = this._operation;
1599
+ this._operation = B, this.requestUpdate("operation", V), this.isConnected && B && this._updateOperationMetadata(B);
1600
+ }
1601
+ _updateOperationMetadata(d) {
1602
+ this.icon = d, (() => {
1603
+ let B = this.l10n("a11y-cloud-editor-apply-tuning", { name: this.l10n(d).toLowerCase() });
1604
+ return this.titleProp = B, B;
1605
+ })(), (() => {
1606
+ let B = this.l10n(d);
1607
+ return this.title = B, B;
1608
+ })();
1609
+ }
1610
+ initCallback() {
1611
+ super.initCallback(), this._operation && this._updateOperationMetadata(this._operation), this.sub("*editorTransformations", (d) => {
1612
+ if (!this._operation) return;
1613
+ let { zero: B } = COLOR_OPERATIONS_CONFIG[this._operation], V = d[this._operation];
1614
+ this.active = V === void 0 ? !1 : V !== B;
1615
+ });
1616
+ }
1617
+ onClick(d) {
1618
+ this.$["*sliderEl"]?.setOperation(this._operation), this.$["*showSlider"] = !0, this.$["*currentOperation"] = this._operation, this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], { operation: parseFilterValue(this.$["*operationTooltip"]) });
1619
+ }
1620
+ };
1621
+ __decorate([property({ type: String })], EditorOperationControl.prototype, "operation", null);
1622
+ var X_THRESHOLD = 1, noopScrollListener = () => {}, EditorScroller = class extends LitBlock {
1623
+ constructor(...d) {
1624
+ super(...d), this.hiddenScrollbar = !1, this._handleWheel = (d) => {
1625
+ d.preventDefault();
1626
+ let { deltaY: B, deltaX: V } = d;
1627
+ if (Math.abs(V) > X_THRESHOLD) {
1628
+ this.scrollLeft += V;
1629
+ return;
1630
+ }
1631
+ this.scrollLeft += B;
1632
+ };
1633
+ }
1634
+ connectedCallback() {
1635
+ super.connectedCallback(), this.addEventListener("wheel", this._handleWheel, { passive: !1 }), this.addEventListener("scroll", noopScrollListener, { passive: !0 });
1636
+ }
1637
+ disconnectedCallback() {
1638
+ this.removeEventListener("wheel", this._handleWheel), this.removeEventListener("scroll", noopScrollListener), super.disconnectedCallback();
1639
+ }
1640
+ };
1641
+ __decorate([property({
1642
+ type: Boolean,
1643
+ noAccessor: !0,
1644
+ attribute: "hidden-scrollbar"
1645
+ })], EditorScroller.prototype, "hiddenScrollbar", void 0);
1646
+ var EditorToolbar = class extends LitBlock {
1647
+ constructor(...d) {
1648
+ super(...d), this._showLoader = !1, this.showMainToolbar = !0, this.showSubToolbar = !1, this._showTabToggles = !0, this.tabList = [...ALL_TABS], this.activeTab = TabId.CROP, this._useSliderPanel = !0, this._tooltipVisible = !1, this._operationTooltip = null, this._tabIndicatorOffset = 0, this._tabIndicatorWidth = 0, this._sliderRef = createRef(), this._tabIndicatorRef = createRef(), this.tabToggleRefs = {
1649
+ [TabId.CROP]: createRef(),
1650
+ [TabId.TUNING]: createRef(),
1651
+ [TabId.FILTERS]: createRef()
1652
+ }, this._handleWindowResize = () => {
1653
+ this._syncTabIndicator();
1654
+ }, this._cropPresets = [], this._debouncedShowLoader = debounce((d) => {
1655
+ this._showLoader = d;
1656
+ }, 500), this._updateInfoTooltip = debounce(() => {
1657
+ let d = this.$["*editorTransformations"], B = this.$["*currentOperation"], V = "", H = !1;
1658
+ if (this.$["*tabId"] === TabId.FILTERS) if (H = !0, this.$["*currentFilter"] && d?.filter?.name === this.$["*currentFilter"]) {
1659
+ let B = d?.filter?.amount || 100;
1660
+ V = `${this.$["*currentFilter"]} ${B}`;
1661
+ } else V = this.l10n(FAKE_ORIGINAL_FILTER);
1662
+ else if (this.showSubToolbar && this.$["*tabId"] === TabId.TUNING && B) {
1663
+ H = !0;
1664
+ let U = d?.[B] || COLOR_OPERATIONS_CONFIG[B].zero;
1665
+ V = `${this.l10n(B)} ${U}`;
1666
+ }
1667
+ H && (this.$["*operationTooltip"] = V), this._tooltipVisible = H;
1668
+ }, 0), this._subTopToolbarStyles = {
1669
+ hidden: "uc-sub-toolbar--top-hidden",
1670
+ visible: "uc-sub-toolbar--visible"
1671
+ }, this._subBottomToolbarStyles = {
1672
+ hidden: "uc-sub-toolbar--bottom-hidden",
1673
+ visible: "uc-sub-toolbar--visible"
1674
+ }, this._tabToggleStyles = {
1675
+ hidden: "uc-tab-toggle--hidden",
1676
+ visible: "uc-tab-toggle--visible"
1677
+ }, this._tabTogglesStyles = {
1678
+ hidden: "uc-tab-toggles--hidden",
1679
+ visible: "uc-tab-toggles--visible"
1680
+ }, this.init$ = {
1681
+ ...this.init$,
1682
+ "*sliderEl": null,
1683
+ "*showSlider": !1,
1684
+ "*showListAspectRatio": !1,
1685
+ "*currentFilter": FAKE_ORIGINAL_FILTER,
1686
+ "*currentOperation": null,
1687
+ "*operationTooltip": null
1688
+ }, this._handleCancel = (d) => {
1689
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], { action: "cancel" }), this._cancelPreload?.();
1690
+ let B = this.$["*on.cancel"];
1691
+ B?.();
1692
+ }, this._handleApply = (d) => {
1693
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], { action: "apply" });
1694
+ let B = this.$["*on.apply"];
1695
+ B?.(this.$["*editorTransformations"]);
1696
+ }, this._handleApplySlider = (d) => {
1697
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], {
1698
+ action: "apply-slider",
1699
+ operation: parseFilterValue(this.$["*operationTooltip"])
1700
+ }), this._sliderRef.value?.apply(), this._onSliderClose();
1701
+ }, this._handleCancelSlider = (d) => {
1702
+ this.telemetryManager.sendEventCloudImageEditor(d, this.$["*tabId"], { action: "cancel-slider" }), this._sliderRef.value?.cancel(), this._onSliderClose();
1703
+ }, this._handleTabClick = (d) => {
1704
+ let B = d.currentTarget?.getAttribute("data-id");
1705
+ B && (this.telemetryManager.sendEventCloudImageEditor(d, B), this._activateTab(B, { fromViewer: !1 }));
1706
+ };
1707
+ }
1708
+ _onSliderClose() {
1709
+ this.$["*showSlider"] = !1, this.$["*tabId"] === TabId.CROP && (this.$["*showListAspectRatio"] = !1), this.$["*tabId"] === TabId.TUNING && (this._tooltipVisible = !1);
1710
+ }
1711
+ _activateTab(d, { fromViewer: B = !1, force: V = !1 } = {}) {
1712
+ this.$["*tabId"] !== d && (this.$["*tabId"] = d), this._applyTabState(d, {
1713
+ fromViewer: B,
1714
+ force: V
1715
+ });
1716
+ }
1717
+ _applyTabState(d, { fromViewer: B, force: V = !1 }) {
1718
+ if (!V && this.activeTab === d) {
1719
+ this._syncTabIndicator();
1720
+ return;
1721
+ }
1722
+ this.activeTab = d;
1723
+ let H = this.$["*faderEl"], U = this.$["*cropperEl"];
1724
+ d === TabId.CROP ? (H?.deactivate(), this.$["*imageSize"] && U?.activate(this.$["*imageSize"], { fromViewer: B })) : (H?.activate({
1725
+ url: this.$["*originalUrl"],
1726
+ fromViewer: B
1727
+ }), U?.deactivate());
1728
+ for (let B of ALL_TABS) {
1729
+ let V = B === d, H = this.tabToggleRefs[B]?.value;
1730
+ H && (H.active = V), V && this._syncTabIndicator();
1731
+ }
1732
+ }
1733
+ _syncTabIndicator() {
1734
+ let d = this.tabToggleRefs[this.activeTab]?.value, B = this._tabIndicatorRef.value;
1735
+ if (!d || !B) return;
1736
+ let V = d.offsetLeft, H = d.offsetWidth || Number(getComputedStyle(d).width.replace("px", ""));
1737
+ (this._tabIndicatorOffset !== V || this._tabIndicatorWidth !== H) && (this._tabIndicatorOffset = V, this._tabIndicatorWidth = H, B.style.transform = `translateX(${V}px)`, B.style.width = `${H}px`);
1738
+ }
1739
+ get _hasAspectRatioPicker() {
1740
+ return this._cropPresets.length >= 3;
1741
+ }
1742
+ _renderControlsByTab(d) {
1743
+ switch (d) {
1744
+ case TabId.CROP: return this._renderCropTabControls();
1745
+ case TabId.FILTERS: return this._renderFilterTabControls();
1746
+ case TabId.TUNING: return this._renderTuningTabControls();
1747
+ default: return [];
1748
+ }
1749
+ }
1750
+ _renderCropTabControls() {
1751
+ let d = [];
1752
+ if (this._hasAspectRatioPicker) d.push(() => this._renderFreeformControl());
1753
+ else for (let B of this._cropPresets) d.push(() => this._renderAspectRatioControl(B));
1754
+ for (let B of ALL_CROP_OPERATIONS) d.push(() => this._renderCropOperationControl(B));
1755
+ return this._renderControlGroup(d);
1756
+ }
1757
+ _renderFilterTabControls() {
1758
+ let d = [FAKE_ORIGINAL_FILTER, ...ALL_FILTERS].map((d) => () => this._renderFilterControl(d));
1759
+ return this._renderControlGroup(d);
1760
+ }
1761
+ _renderTuningTabControls() {
1762
+ let d = ALL_COLOR_OPERATIONS.map((d) => () => this._renderOperationControl(d));
1763
+ return this._renderControlGroup(d);
1764
+ }
1765
+ _renderControlGroup(d) {
1766
+ return d.length ? d.map((d) => d()) : [];
1767
+ }
1768
+ _renderFreeformControl() {
1769
+ return html`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`;
1770
+ }
1771
+ _renderAspectRatioControl(d) {
1772
+ return html`<uc-editor-aspect-ratio-button-control .aspectRatio=${d}></uc-editor-aspect-ratio-button-control>`;
1773
+ }
1774
+ _renderCropOperationControl(d) {
1775
+ return html`<uc-editor-crop-button-control .operation=${d}></uc-editor-crop-button-control>`;
1776
+ }
1777
+ _renderFilterControl(d) {
1778
+ return html`<uc-editor-filter-control .filter=${d}></uc-editor-filter-control>`;
1779
+ }
1780
+ _renderOperationControl(d) {
1781
+ return html`<uc-editor-operation-control .operation=${d}></uc-editor-operation-control>`;
1782
+ }
1783
+ _renderAspectRatioList() {
1784
+ return this._hasAspectRatioPicker ? this._cropPresets.map((d) => this._renderAspectRatioControl(d)) : [];
1785
+ }
1786
+ async _preloadEditedImage() {
1787
+ if (this.$["*imgContainerEl"] && this.$["*originalUrl"]) {
1788
+ let d = this.$["*imgContainerEl"].offsetWidth, B = await this.proxyUrl(viewerImageSrc(this.$["*originalUrl"], d, this.$["*editorTransformations"]));
1789
+ this._cancelPreload?.();
1790
+ let { cancel: V } = batchPreloadImages([B]);
1791
+ this._cancelPreload = () => {
1792
+ V(), this._cancelPreload = void 0;
1793
+ };
1794
+ }
1795
+ }
1796
+ initCallback() {
1797
+ super.initCallback(), this._cropPresets = [...this.$["*cropPresetList"] ?? []], this.sub("*cropPresetList", (d) => {
1798
+ this._cropPresets = [...d ?? []];
1799
+ }), this.sub("*imageSize", (d) => {
1800
+ d && setTimeout(() => {
1801
+ this._activateTab(this.$["*tabId"], { fromViewer: !0 });
1802
+ }, 0);
1803
+ }), this.sub("*editorTransformations", (d) => {
1804
+ let B = d?.filter?.name;
1805
+ this.$["*currentFilter"] !== B && (this.$["*currentFilter"] = B ?? "");
1806
+ }), this.sub("*currentFilter", () => {
1807
+ this._updateInfoTooltip();
1808
+ }), this.sub("*currentOperation", () => {
1809
+ this._updateInfoTooltip();
1810
+ }), this.sub("*tabId", (d) => {
1811
+ this._applyTabState(d, {
1812
+ fromViewer: !1,
1813
+ force: !0
1814
+ }), this._updateInfoTooltip();
1815
+ }), this.sub("*originalUrl", () => {
1816
+ this.$["*faderEl"]?.deactivate();
1817
+ }), this.sub("*editorTransformations", (d) => {
1818
+ this._preloadEditedImage(), this.$["*faderEl"]?.setTransformations(d);
1819
+ }), this.sub("*loadingOperations", (d) => {
1820
+ let B = !1;
1821
+ for (let [, V] of d.entries()) {
1822
+ if (B) break;
1823
+ for (let [, d] of V.entries()) if (d) {
1824
+ B = !0;
1825
+ break;
1826
+ }
1827
+ }
1828
+ this._debouncedShowLoader(B);
1829
+ }), this.sub("*showSlider", (d) => {
1830
+ d ? (this.showSubToolbar = !0, this.showMainToolbar = !1, this._useSliderPanel = !0) : this.$["*showListAspectRatio"] || (this.showSubToolbar = !1, this.showMainToolbar = !0);
1831
+ }), this.sub("*showListAspectRatio", (d) => {
1832
+ d ? (this.showSubToolbar = !0, this.showMainToolbar = !1, this._useSliderPanel = !1) : this.$["*showSlider"] || (this.showSubToolbar = !1, this.showMainToolbar = !0);
1833
+ }), this.sub("*tabList", (d) => {
1834
+ if (this.tabList = d, this._showTabToggles = d.length > 1, !d.includes(this.$["*tabId"]) && d.length > 0) {
1835
+ let [B] = d;
1836
+ B && this._activateTab(B, { fromViewer: !1 });
1837
+ return;
1838
+ }
1839
+ this._syncTabIndicator();
1840
+ }), this.sub("*operationTooltip", (d) => {
1841
+ this._operationTooltip = d;
1842
+ }), this._updateInfoTooltip();
1843
+ }
1844
+ connectedCallback() {
1845
+ super.connectedCallback(), window.addEventListener("resize", this._handleWindowResize);
1846
+ }
1847
+ firstUpdated(d) {
1848
+ super.firstUpdated(d), this._assignSharedElements(), this._syncTabIndicator();
1849
+ }
1850
+ updated(d) {
1851
+ super.updated(d), (d.has("activeTab") || d.has("tabList")) && this.updateComplete.then(() => this._syncTabIndicator()), (d.has("showSubToolbar") || d.has("showMainToolbar")) && this._assignSharedElements();
1852
+ }
1853
+ disconnectedCallback() {
1854
+ window.removeEventListener("resize", this._handleWindowResize), super.disconnectedCallback(), this.$["*showSlider"] = !1, this.$["*showListAspectRatio"] = !1;
1855
+ }
1856
+ _assignSharedElements() {
1857
+ let d = this._sliderRef.value;
1858
+ d && (this.$["*sliderEl"] = d);
1859
+ }
1860
+ _renderTabToggle(d) {
1861
+ let B = this.tabList.includes(d), V = this.activeTab === d, H = this.tabList.indexOf(d), U = H >= 0 ? styleMap({ gridColumn: `${H + 1}` }) : nothing;
1862
+ return html`
1863
+ <uc-presence-toggle class="uc-tab-toggle" .visible=${B} .styles=${this._tabToggleStyles}>
1864
+ <uc-btn-ui
1865
+ theme="tab"
1866
+ data-id=${d}
1867
+ icon=${d}
1868
+ role="tab"
1869
+ aria-controls=${`tab_${d}`}
1870
+ aria-selected=${V ? "true" : "false"}
1871
+ title-prop=${`a11y-editor-tab-${d}`}
1872
+ .active=${V}
1873
+ style=${U}
1874
+ @click=${this._handleTabClick}
1875
+ ${ref(this.tabToggleRefs[d])}
1876
+ ></uc-btn-ui>
1877
+ </uc-presence-toggle>
1878
+ `;
1879
+ }
1880
+ _renderTabContent(d) {
1881
+ let B = this._renderControlsByTab(d);
1882
+ return html`
1883
+ <div
1884
+ id=${`tab_${d}`}
1885
+ class="uc-tab-content"
1886
+ >
1887
+ <uc-editor-scroller hidden-scrollbar>
1888
+ <div class="uc-controls-list_align">
1889
+ <div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">
1890
+ ${B.length ? B : nothing}
1891
+ </div>
1892
+ </div>
1893
+ </uc-editor-scroller>
1894
+ </div>
1895
+ `;
1896
+ }
1897
+ render() {
1898
+ let d = ["uc-info-tooltip", this._tooltipVisible ? "uc-info-tooltip_visible" : "uc-info-tooltip_hidden"].join(" "), B = this._hasAspectRatioPicker;
1899
+ return html`
1900
+ <uc-line-loader-ui .active=${this._showLoader}></uc-line-loader-ui>
1901
+ <div class="uc-info-tooltip_container">
1902
+ <div class="uc-info-tooltip_wrapper">
1903
+ <div class=${d}>${this._operationTooltip ?? ""}</div>
1904
+ </div>
1905
+ </div>
1906
+ <div class="uc-toolbar-container">
1907
+ <uc-presence-toggle
1908
+ role="tablist"
1909
+ class="uc-sub-toolbar"
1910
+ .visible=${this.showMainToolbar}
1911
+ .styles=${this._subTopToolbarStyles}
1912
+ >
1913
+ <div class="uc-tab-content-row">
1914
+ ${ALL_TABS.map((d) => when(this.activeTab === d, () => this._renderTabContent(d)))}
1915
+ </div>
1916
+ <div class="uc-controls-row">
1917
+ <uc-presence-toggle
1918
+ class="uc-tab-toggles"
1919
+ .visible=${this._showTabToggles}
1920
+ .styles=${this._tabTogglesStyles}
1921
+ @initial-render=${() => this._syncTabIndicator()}
1922
+ >
1923
+ <div
1924
+ class="uc-tab-toggles_indicator"
1925
+ ${ref(this._tabIndicatorRef)}
1926
+ ></div>
1927
+ ${ALL_TABS.map((d) => this._renderTabToggle(d))}
1928
+ </uc-presence-toggle>
1929
+ <uc-btn-ui
1930
+ style="order: -1"
1931
+ theme="secondary-icon"
1932
+ icon="closeMax"
1933
+ title-prop="cancel"
1934
+ @click=${this._handleCancel}
1935
+ ></uc-btn-ui>
1936
+ <uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this._handleApply}></uc-btn-ui>
1937
+ </div>
1938
+ </uc-presence-toggle>
1939
+ <uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this._subBottomToolbarStyles}>
1940
+ <div class="uc-slider" ?hidden=${!this._useSliderPanel}>
1941
+ <uc-editor-slider ${ref(this._sliderRef)}></uc-editor-slider>
1942
+ </div>
1943
+
1944
+ <div class="uc-list-aspect-ratio-container" ?hidden=${this._useSliderPanel || !B}>
1945
+ ${B ? html`<div class="uc-list-aspect-ratio">${this._renderAspectRatioList()}</div>` : nothing}
1946
+ </div>
1947
+ <div class="uc-controls-row">
1948
+ <uc-btn-ui theme="secondary" @click=${this._handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui>
1949
+ <uc-btn-ui theme="primary" @click=${this._handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui>
1950
+ </div>
1951
+ </uc-presence-toggle>
1952
+ </div>
1953
+ `;
1954
+ }
1955
+ };
1956
+ __decorate([state()], EditorToolbar.prototype, "_showLoader", void 0), __decorate([state()], EditorToolbar.prototype, "showMainToolbar", void 0), __decorate([state()], EditorToolbar.prototype, "showSubToolbar", void 0), __decorate([state()], EditorToolbar.prototype, "_showTabToggles", void 0), __decorate([state()], EditorToolbar.prototype, "tabList", void 0), __decorate([state()], EditorToolbar.prototype, "activeTab", void 0), __decorate([state()], EditorToolbar.prototype, "_useSliderPanel", void 0), __decorate([state()], EditorToolbar.prototype, "_tooltipVisible", void 0), __decorate([state()], EditorToolbar.prototype, "_operationTooltip", void 0), __decorate([state()], EditorToolbar.prototype, "_cropPresets", void 0);
1957
+ var DEFAULT_TABS = serializeCsv([...ALL_TABS]), CloudImageEditorBlock = class extends LitBlock {
1958
+ constructor(...d) {
1959
+ super(...d), this.ctxOwner = !0, this._statusMessage = "", this._imageSrc = TRANSPARENT_PIXEL_SRC, this._fileType = "", this._showLoader = !1, this.uuid = null, this.cdnUrl = null, this.cropPreset = "", this.tabs = DEFAULT_TABS, this._hasNetworkProblems = !1, this._isInitialized = !1, this._pendingInitUpdate = null, this._debouncedShowLoader = debounce((d) => {
1960
+ this._showLoader = d;
1961
+ }, 300), this._imgRef = createRef(), this._cropperRef = createRef(), this._faderRef = createRef(), this._imgContainerRef = createRef(), this._handleImageLoad = () => {
1962
+ this._debouncedShowLoader(!1), this._imageSrc !== "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" && (this.$["*networkProblems"] = !1);
1963
+ }, this._handleImageError = () => {
1964
+ this._debouncedShowLoader(!1), this.$["*networkProblems"] = !0;
1965
+ }, this._handleRetryNetwork = () => {
1966
+ let d = this.$["*on.retryNetwork"];
1967
+ d?.();
1968
+ }, this.init$ = {
1969
+ ...this.init$,
1970
+ ...initState(this)
1971
+ };
1972
+ }
1973
+ static {
1974
+ this.styleAttrs = ["uc-cloud-image-editor"];
1975
+ }
1976
+ _scheduleInitialization() {
1977
+ this._isInitialized || this._pendingInitUpdate || (this._pendingInitUpdate = this.updateComplete.then(() => {
1978
+ this._pendingInitUpdate = null, this._isInitialized = !0;
1979
+ }));
1980
+ }
1981
+ initCallback() {
1982
+ super.initCallback(), this._syncTabListFromProp(), this._syncCropPresetState();
1983
+ }
1984
+ _assignSharedElements() {
1985
+ let d = this._faderRef.value;
1986
+ d && (this.$["*faderEl"] = d);
1987
+ let B = this._cropperRef.value;
1988
+ B && (this.$["*cropperEl"] = B);
1989
+ let V = this._imgContainerRef.value;
1990
+ V && (this.$["*imgContainerEl"] = V);
1991
+ let H = this._imgRef.value;
1992
+ H && (this.$["*imgEl"] = H);
1993
+ }
1994
+ _attachImageListeners() {
1995
+ let d = this._imgRef.value;
1996
+ d && (d.addEventListener("load", this._handleImageLoad), d.addEventListener("error", this._handleImageError));
1997
+ }
1998
+ _detachImageListeners() {
1999
+ let d = this._imgRef.value;
2000
+ d && (d.removeEventListener("load", this._handleImageLoad), d.removeEventListener("error", this._handleImageError));
2001
+ }
2002
+ get _imageClassName() {
2003
+ let d = this.$["*tabId"];
2004
+ return classNames("uc-image", {
2005
+ "uc-image_hidden_to_cropper": d === TabId.CROP,
2006
+ "uc-image_hidden_effects": d !== TabId.CROP
2007
+ });
2008
+ }
2009
+ _waitForSize() {
2010
+ return new Promise((d, B) => {
2011
+ let V = window.setTimeout(() => {
2012
+ B(/* @__PURE__ */ Error("[cloud-image-editor] timeout waiting for non-zero container size"));
2013
+ }, 3e3), H = new ResizeObserver((B) => {
2014
+ let [U] = B;
2015
+ U && U.contentRect.width > 0 && U.contentRect.height > 0 && (window.clearTimeout(V), H.disconnect(), window.setTimeout(() => d(), 0));
2016
+ });
2017
+ H.observe(this);
2018
+ });
2019
+ }
2020
+ firstUpdated(d) {
2021
+ super.firstUpdated(d), this._assignSharedElements(), this._attachImageListeners(), this.initEditor();
2022
+ let B = !!(this.uuid || this.cdnUrl), V = d.has("uuid") || d.has("cdnUrl");
2023
+ B && !V && this.updateImage();
2024
+ }
2025
+ disconnectedCallback() {
2026
+ this._detachImageListeners(), super.disconnectedCallback();
2027
+ }
2028
+ render() {
2029
+ let d = this._fileType ?? "", B = this._statusMessage ?? "", V = this._imageSrc || "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=", H = this._showLoader, U = this._hasNetworkProblems;
2030
+ return html`
2031
+ ${unsafeSVG(svg_sprite_default)}
2032
+ <div class="uc-wrapper uc-wrapper_desktop">
2033
+ <uc-presence-toggle class="uc-network_problems_splash" .visible=${U}>
2034
+ <div class="uc-network_problems_content">
2035
+ <div class="uc-network_problems_icon">
2036
+ <uc-icon name="sad"></uc-icon>
2037
+ </div>
2038
+ <div class="uc-network_problems_text">Network error</div>
2039
+ </div>
2040
+ <div class="uc-network_problems_footer">
2041
+ <uc-btn-ui theme="primary" text="Retry" @click=${this._handleRetryNetwork}></uc-btn-ui>
2042
+ </div>
2043
+ </uc-presence-toggle>
2044
+ <div class="uc-viewport">
2045
+ <div class="uc-file_type_outer">
2046
+ <div class="uc-file_type">${d}</div>
2047
+ </div>
2048
+ <div class="uc-image_container" ${ref(this._imgContainerRef)}>
2049
+ <img src=${V} class=${this._imageClassName} ${ref(this._imgRef)} />
2050
+ ${when(this._isInitialized, () => html`<uc-editor-image-cropper ${ref(this._cropperRef)}></uc-editor-image-cropper>`)}
2051
+ <uc-editor-image-fader ${ref(this._faderRef)}></uc-editor-image-fader>
2052
+ </div>
2053
+ <div class="uc-info_pan">${B}</div>
2054
+ </div>
2055
+ <div class="uc-toolbar">
2056
+ <uc-line-loader-ui .active=${H}></uc-line-loader-ui>
2057
+ <div class="uc-toolbar_content uc-toolbar_content__editor">
2058
+ ${when(this._isInitialized, () => html`<uc-editor-toolbar></uc-editor-toolbar>`)}
2059
+ </div>
2060
+ </div>
2061
+ </div>
2062
+ `;
2063
+ }
2064
+ updated(d) {
2065
+ super.updated(d), d.has("uuid") && this.uuid && this.updateImage(), d.has("cdnUrl") && this.cdnUrl && this.updateImage(), d.has("tabs") && this._syncTabListFromProp(), (d.has("cropPreset") || d.has("cdnUrl")) && this._syncCropPresetState();
2066
+ }
2067
+ _syncTabListFromProp() {
2068
+ let d = this.tabs || DEFAULT_TABS;
2069
+ this.$["*tabList"] = parseTabs(d);
2070
+ }
2071
+ _syncCropPresetState() {
2072
+ let d = parseCropPreset(this.cropPreset ?? ""), B = null;
2073
+ if (this.cdnUrl) {
2074
+ let V = operationsToTransformations(extractOperations(this.cdnUrl));
2075
+ if (Array.isArray(V?.crop?.dimensions)) {
2076
+ let [H, U] = V.crop.dimensions;
2077
+ B = getClosestAspectRatio(H, U, d, .1);
2078
+ }
2079
+ }
2080
+ this.$["*cropPresetList"] = d, this.$["*currentAspectRatio"] = B ?? d?.[0] ?? null;
2081
+ }
2082
+ async updateImage() {
2083
+ if (this.isConnected) {
2084
+ if (await this._waitForSize(), this.cdnUrl) {
2085
+ let d = this.cdnUrl, B = createOriginalUrl(d, extractUuid(d));
2086
+ if (B === this.$["*originalUrl"]) return;
2087
+ this.$["*originalUrl"] = B;
2088
+ let V = operationsToTransformations(extractOperations(d));
2089
+ this.$["*editorTransformations"] = V;
2090
+ } else if (this.uuid) {
2091
+ let d = createOriginalUrl(this.cfg.cdnCname, this.uuid);
2092
+ if (d === this.$["*originalUrl"]) return;
2093
+ this.$["*originalUrl"] = d, Object.keys(this.$["*editorTransformations"]).length > 0 && (this.$["*editorTransformations"] = {});
2094
+ } else throw Error("No UUID nor CDN URL provided");
2095
+ this.$["*tabId"] === TabId.CROP ? this.$["*cropperEl"]?.deactivate({ reset: !0 }) : this.$["*faderEl"]?.deactivate();
2096
+ try {
2097
+ let B = this.$["*originalUrl"], V = await this.proxyUrl(createCdnUrl(B, createCdnUrlModifiers("json"))), { width: H, height: U } = await fetch(V).then((d) => d.json());
2098
+ this.$["*imageSize"] = {
2099
+ width: H,
2100
+ height: U
2101
+ }, this.$["*tabId"] === TabId.CROP ? this.$["*cropperEl"]?.activate(this.$["*imageSize"]) : this.$["*faderEl"]?.activate({ url: B });
2102
+ } catch (d) {
2103
+ d && (this.telemetryManager.sendEventError(d, "cloud editor image. Failed to load image info"), console.error("Failed to load image info", d));
2104
+ }
2105
+ this._scheduleInitialization();
2106
+ }
2107
+ }
2108
+ async initEditor() {
2109
+ try {
2110
+ await this._waitForSize();
2111
+ } catch (d) {
2112
+ this.isConnected && console.error(d.message);
2113
+ return;
2114
+ }
2115
+ this.classList.add("uc-editor_ON"), this.sub("*networkProblems", (d) => {
2116
+ this._hasNetworkProblems = !!d;
2117
+ }), this.sub("*editorTransformations", (B) => {
2118
+ if (Object.keys(B).length === 0) return;
2119
+ let V = this.$["*originalUrl"], H = createCdnUrlModifiers(transformationsToOperations(B), "preview"), U = {
2120
+ originalUrl: V,
2121
+ cdnUrlModifiers: H,
2122
+ cdnUrl: createCdnUrl(V, H),
2123
+ transformations: B
2124
+ };
2125
+ this.dispatchEvent(new CustomEvent("change", {
2126
+ detail: U,
2127
+ bubbles: !0,
2128
+ composed: !0
2129
+ }));
2130
+ }, !1);
2131
+ }
2132
+ };
2133
+ __decorate([state()], CloudImageEditorBlock.prototype, "_statusMessage", void 0), __decorate([state()], CloudImageEditorBlock.prototype, "_imageSrc", void 0), __decorate([state()], CloudImageEditorBlock.prototype, "_fileType", void 0), __decorate([state()], CloudImageEditorBlock.prototype, "_showLoader", void 0), __decorate([property({
2134
+ type: String,
2135
+ reflect: !0
2136
+ })], CloudImageEditorBlock.prototype, "uuid", void 0), __decorate([property({
2137
+ type: String,
2138
+ attribute: "cdn-url",
2139
+ reflect: !0
2140
+ })], CloudImageEditorBlock.prototype, "cdnUrl", void 0), __decorate([property({
2141
+ type: String,
2142
+ attribute: "crop-preset",
2143
+ reflect: !0
2144
+ })], CloudImageEditorBlock.prototype, "cropPreset", void 0), __decorate([property({
2145
+ type: String,
2146
+ reflect: !0
2147
+ })], CloudImageEditorBlock.prototype, "tabs", void 0), __decorate([state()], CloudImageEditorBlock.prototype, "_hasNetworkProblems", void 0), __decorate([state()], CloudImageEditorBlock.prototype, "_isInitialized", void 0);
2148
+ var CloudImageEditor = class extends CloudImageEditorBlock {
2149
+ static {
2150
+ this.styleAttrs = [...super.styleAttrs, "uc-wgt-common"];
2151
+ }
2152
+ constructor() {
2153
+ super(), this.init$ = {
2154
+ ...this.init$,
2155
+ "*solution": this.tagName
2156
+ };
2157
+ }
2158
+ initCallback() {
2159
+ super.initCallback(), this.telemetryManager.sendEvent({ eventType: InternalEventType.INIT_SOLUTION }), this.a11y?.registerBlock(this);
2160
+ }
2161
+ };
2162
+ export { PresenceToggle as _, EditorOperationControl as a, EditorAspectRatioButtonControl as c, SliderUi as d, EditorImageFader as f, LineLoaderUi as g, BtnUi as h, EditorScroller as i, EditorFreeformButtonControl as l, CropFrame as m, CloudImageEditorBlock as n, EditorFilterControl as o, EditorImageCropper as p, EditorToolbar as r, EditorCropButtonControl as s, CloudImageEditor as t, EditorSlider as u, throttle as v };