@opendesign-plus-test/components 0.0.1-rc.176 → 0.0.1-rc.178

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 (345) hide show
  1. package/dist/chunk-OElCookieNotice.cjs.js +1 -1
  2. package/dist/chunk-OElCookieNotice.es.js +405 -147
  3. package/dist/components/header-language-switcher/OHeaderLanguageSwitcher.vue.d.ts +1 -1
  4. package/dist/components/meeting/OMeetingMinutes.vue.d.ts +0 -1
  5. package/dist/components/meeting/OMeetingSendMinutesForm.vue.d.ts +1 -127
  6. package/dist/components/meeting/components/OMeetingSendMinutesDialog.vue.d.ts +1 -127
  7. package/dist/components/meeting/index.d.ts +1 -128
  8. package/dist/components/meeting/types.d.ts +0 -2
  9. package/dist/components/user-center/OAccountSecurity.vue.d.ts +39 -0
  10. package/dist/components/user-center/OAccountSetting.vue.d.ts +22 -0
  11. package/dist/components/user-center/OAppFooterSimple.vue.d.ts +12 -0
  12. package/dist/components/user-center/OAppHeader.vue.d.ts +43 -0
  13. package/dist/components/user-center/OAsideBar.vue.d.ts +26 -0
  14. package/dist/components/user-center/OLayout.vue.d.ts +18 -0
  15. package/dist/components/user-center/OTheAccountManage.vue.d.ts +18 -0
  16. package/dist/components/user-center/OTheCreateMeeting.vue.d.ts +18 -0
  17. package/dist/components/user-center/OTheMeeting.vue.d.ts +14 -0
  18. package/dist/components/user-center/OThirdPartyBindings.vue.d.ts +22 -0
  19. package/dist/components/user-center/OUserInfo.vue.d.ts +159 -0
  20. package/dist/components/user-center/const/common.const.d.ts +17 -0
  21. package/dist/components/user-center/index.d.ts +801 -0
  22. package/dist/components/user-center/internal/OAppDialog.vue.d.ts +197 -0
  23. package/dist/components/user-center/internal/OAppEmpty.vue.d.ts +25 -0
  24. package/dist/components/user-center/internal/OCommonHeader.vue.d.ts +94 -0
  25. package/dist/components/user-center/internal/OCountdownButton.vue.d.ts +20 -0
  26. package/dist/components/user-center/internal/ODeleteAccountModal.vue.d.ts +189 -0
  27. package/dist/components/user-center/internal/OEditNicknameDialog.vue.d.ts +164 -0
  28. package/dist/components/user-center/internal/OEditOrgDialog.vue.d.ts +182 -0
  29. package/dist/components/user-center/internal/OMaskEye.vue.d.ts +18 -0
  30. package/dist/components/user-center/internal/OModifyPwd.vue.d.ts +426 -0
  31. package/dist/components/user-center/internal/OPasswordPopInput.vue.d.ts +174 -0
  32. package/dist/components/user-center/internal/OToBindingTipModal.vue.d.ts +37 -0
  33. package/dist/components/user-center/internal/OUnbindingThirdpartyAccountModal.vue.d.ts +30 -0
  34. package/dist/components/user-center/internal/OUploadAvatar.vue.d.ts +55 -0
  35. package/dist/components/user-center/rolesMap.d.ts +10 -0
  36. package/dist/components/user-center/types/captcha.d.ts +6 -0
  37. package/dist/components/user-center/types/interface.d.ts +13 -0
  38. package/dist/components/user-center/types/search.d.ts +67 -0
  39. package/dist/components/user-center/types/usercenter.interface.d.ts +57 -0
  40. package/dist/components/user-center/utils/helper.d.ts +4 -0
  41. package/dist/components/user-center/utils/rules.d.ts +11 -0
  42. package/dist/components/user-center/utils/utils.d.ts +17 -0
  43. package/dist/components/user-center/verify/Verify.vue.d.ts +2 -0
  44. package/dist/components/user-center/verify/VerifySlide.vue.d.ts +2 -0
  45. package/dist/components/user-center/verify/utils/ase.d.ts +5 -0
  46. package/dist/components/user-center/verify/utils/util.d.ts +6 -0
  47. package/dist/components.cjs.js +68 -44
  48. package/dist/components.css +9 -1
  49. package/dist/components.es.js +28915 -17442
  50. package/dist/index.d.ts +1 -0
  51. package/dist/treeshaking/_virtual/_commonjs-dynamic-modules.mjs +6 -0
  52. package/dist/treeshaking/_virtual/cropperjs/dist/cropper.css +309 -0
  53. package/dist/treeshaking/_virtual/cropperjs/dist/cropper.esm.js.mjs +2739 -0
  54. package/dist/treeshaking/_virtual/crypto-js/aes.js.mjs +162 -0
  55. package/dist/treeshaking/_virtual/crypto-js/aes.js2.mjs +4 -0
  56. package/dist/treeshaking/_virtual/crypto-js/blowfish.js.mjs +1197 -0
  57. package/dist/treeshaking/_virtual/crypto-js/blowfish.js2.mjs +4 -0
  58. package/dist/treeshaking/_virtual/crypto-js/cipher-core.js.mjs +649 -0
  59. package/dist/treeshaking/_virtual/crypto-js/cipher-core.js2.mjs +4 -0
  60. package/dist/treeshaking/_virtual/crypto-js/core.js.mjs +614 -0
  61. package/dist/treeshaking/_virtual/crypto-js/core.js2.mjs +4 -0
  62. package/dist/treeshaking/_virtual/crypto-js/enc-base64.js.mjs +112 -0
  63. package/dist/treeshaking/_virtual/crypto-js/enc-base64.js2.mjs +4 -0
  64. package/dist/treeshaking/_virtual/crypto-js/enc-base64url.js.mjs +123 -0
  65. package/dist/treeshaking/_virtual/crypto-js/enc-base64url.js2.mjs +4 -0
  66. package/dist/treeshaking/_virtual/crypto-js/enc-utf16.js.mjs +122 -0
  67. package/dist/treeshaking/_virtual/crypto-js/enc-utf16.js2.mjs +4 -0
  68. package/dist/treeshaking/_virtual/crypto-js/evpkdf.js.mjs +97 -0
  69. package/dist/treeshaking/_virtual/crypto-js/evpkdf.js2.mjs +4 -0
  70. package/dist/treeshaking/_virtual/crypto-js/format-hex.js.mjs +65 -0
  71. package/dist/treeshaking/_virtual/crypto-js/format-hex.js2.mjs +4 -0
  72. package/dist/treeshaking/_virtual/crypto-js/hmac.js.mjs +111 -0
  73. package/dist/treeshaking/_virtual/crypto-js/hmac.js2.mjs +4 -0
  74. package/dist/treeshaking/_virtual/crypto-js/index.js.mjs +7 -0
  75. package/dist/treeshaking/_virtual/crypto-js/index.js2.mjs +55 -0
  76. package/dist/treeshaking/_virtual/crypto-js/index.js3.mjs +4 -0
  77. package/dist/treeshaking/_virtual/crypto-js/lib-typedarrays.js.mjs +49 -0
  78. package/dist/treeshaking/_virtual/crypto-js/lib-typedarrays.js2.mjs +4 -0
  79. package/dist/treeshaking/_virtual/crypto-js/md5.js.mjs +183 -0
  80. package/dist/treeshaking/_virtual/crypto-js/md5.js2.mjs +4 -0
  81. package/dist/treeshaking/_virtual/crypto-js/mode-cfb.js.mjs +57 -0
  82. package/dist/treeshaking/_virtual/crypto-js/mode-cfb.js2.mjs +4 -0
  83. package/dist/treeshaking/_virtual/crypto-js/mode-ctr-gladman.js.mjs +85 -0
  84. package/dist/treeshaking/_virtual/crypto-js/mode-ctr-gladman.js2.mjs +4 -0
  85. package/dist/treeshaking/_virtual/crypto-js/mode-ctr.js.mjs +45 -0
  86. package/dist/treeshaking/_virtual/crypto-js/mode-ctr.js2.mjs +4 -0
  87. package/dist/treeshaking/_virtual/crypto-js/mode-ecb.js.mjs +36 -0
  88. package/dist/treeshaking/_virtual/crypto-js/mode-ecb.js2.mjs +4 -0
  89. package/dist/treeshaking/_virtual/crypto-js/mode-ofb.js.mjs +43 -0
  90. package/dist/treeshaking/_virtual/crypto-js/mode-ofb.js2.mjs +4 -0
  91. package/dist/treeshaking/_virtual/crypto-js/pad-ansix923.js.mjs +37 -0
  92. package/dist/treeshaking/_virtual/crypto-js/pad-ansix923.js2.mjs +4 -0
  93. package/dist/treeshaking/_virtual/crypto-js/pad-iso10126.js.mjs +33 -0
  94. package/dist/treeshaking/_virtual/crypto-js/pad-iso10126.js2.mjs +4 -0
  95. package/dist/treeshaking/_virtual/crypto-js/pad-iso97971.js.mjs +32 -0
  96. package/dist/treeshaking/_virtual/crypto-js/pad-iso97971.js2.mjs +4 -0
  97. package/dist/treeshaking/_virtual/crypto-js/pad-nopadding.js.mjs +28 -0
  98. package/dist/treeshaking/_virtual/crypto-js/pad-nopadding.js2.mjs +4 -0
  99. package/dist/treeshaking/_virtual/crypto-js/pad-zeropadding.js.mjs +39 -0
  100. package/dist/treeshaking/_virtual/crypto-js/pad-zeropadding.js2.mjs +4 -0
  101. package/dist/treeshaking/_virtual/crypto-js/pbkdf2.js.mjs +104 -0
  102. package/dist/treeshaking/_virtual/crypto-js/pbkdf2.js2.mjs +4 -0
  103. package/dist/treeshaking/_virtual/crypto-js/rabbit-legacy.js.mjs +134 -0
  104. package/dist/treeshaking/_virtual/crypto-js/rabbit-legacy.js2.mjs +4 -0
  105. package/dist/treeshaking/_virtual/crypto-js/rabbit.js.mjs +137 -0
  106. package/dist/treeshaking/_virtual/crypto-js/rabbit.js2.mjs +4 -0
  107. package/dist/treeshaking/_virtual/crypto-js/rc4.js.mjs +91 -0
  108. package/dist/treeshaking/_virtual/crypto-js/rc4.js2.mjs +4 -0
  109. package/dist/treeshaking/_virtual/crypto-js/ripemd160.js.mjs +485 -0
  110. package/dist/treeshaking/_virtual/crypto-js/ripemd160.js2.mjs +4 -0
  111. package/dist/treeshaking/_virtual/crypto-js/sha1.js.mjs +95 -0
  112. package/dist/treeshaking/_virtual/crypto-js/sha1.js2.mjs +4 -0
  113. package/dist/treeshaking/_virtual/crypto-js/sha224.js.mjs +50 -0
  114. package/dist/treeshaking/_virtual/crypto-js/sha224.js2.mjs +4 -0
  115. package/dist/treeshaking/_virtual/crypto-js/sha256.js.mjs +125 -0
  116. package/dist/treeshaking/_virtual/crypto-js/sha256.js2.mjs +4 -0
  117. package/dist/treeshaking/_virtual/crypto-js/sha3.js.mjs +207 -0
  118. package/dist/treeshaking/_virtual/crypto-js/sha3.js2.mjs +4 -0
  119. package/dist/treeshaking/_virtual/crypto-js/sha384.js.mjs +52 -0
  120. package/dist/treeshaking/_virtual/crypto-js/sha384.js2.mjs +4 -0
  121. package/dist/treeshaking/_virtual/crypto-js/sha512.js.mjs +287 -0
  122. package/dist/treeshaking/_virtual/crypto-js/sha512.js2.mjs +4 -0
  123. package/dist/treeshaking/_virtual/crypto-js/tripledes.js.mjs +789 -0
  124. package/dist/treeshaking/_virtual/crypto-js/tripledes.js2.mjs +4 -0
  125. package/dist/treeshaking/_virtual/crypto-js/x64-core.js.mjs +261 -0
  126. package/dist/treeshaking/_virtual/crypto-js/x64-core.js2.mjs +4 -0
  127. package/dist/treeshaking/_virtual/icon-add-dark.mjs +40 -0
  128. package/dist/treeshaking/_virtual/icon-add-new.mjs +17 -0
  129. package/dist/treeshaking/_virtual/icon-check.mjs +20 -0
  130. package/dist/treeshaking/_virtual/icon-chevron-right2.mjs +20 -0
  131. package/dist/treeshaking/_virtual/icon-close2.mjs +20 -0
  132. package/dist/treeshaking/_virtual/icon-done.mjs +20 -0
  133. package/dist/treeshaking/_virtual/icon-edit-new.mjs +17 -0
  134. package/dist/treeshaking/_virtual/icon-email.mjs +22 -0
  135. package/dist/treeshaking/_virtual/icon-eye-off.mjs +20 -0
  136. package/dist/treeshaking/_virtual/icon-eye.mjs +20 -0
  137. package/dist/treeshaking/_virtual/icon-gitcode-new.mjs +30 -0
  138. package/dist/treeshaking/_virtual/icon-gitee.mjs +5 -5
  139. package/dist/treeshaking/_virtual/icon-gitee2.mjs +20 -0
  140. package/dist/treeshaking/_virtual/icon-github.mjs +20 -0
  141. package/dist/treeshaking/_virtual/icon-loading.mjs +24 -0
  142. package/dist/treeshaking/_virtual/icon-minus-dark.mjs +74 -0
  143. package/dist/treeshaking/_virtual/icon-minus-new.mjs +17 -0
  144. package/dist/treeshaking/_virtual/icon-openatom.mjs +21 -0
  145. package/dist/treeshaking/_virtual/icon-phone.mjs +22 -0
  146. package/dist/treeshaking/_virtual/icon-refresh2.mjs +45 -0
  147. package/dist/treeshaking/_virtual/icon-setting.mjs +20 -0
  148. package/dist/treeshaking/_virtual/icon-tips.mjs +13 -2
  149. package/dist/treeshaking/_virtual/icon-tips2.mjs +17 -0
  150. package/dist/treeshaking/_virtual/icon-wechat.mjs +18 -0
  151. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/Observable.js.mjs +100 -0
  152. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/Subscriber.js.mjs +147 -0
  153. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/Subscription.js.mjs +139 -0
  154. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/config.js.mjs +6 -0
  155. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.mjs +17 -0
  156. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/symbol/observable.js.mjs +6 -0
  157. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.mjs +14 -0
  158. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/arrRemove.js.mjs +9 -0
  159. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/createErrorClass.js.mjs +13 -0
  160. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/errorContext.js.mjs +8 -0
  161. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/identity.js.mjs +6 -0
  162. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/isFunction.js.mjs +6 -0
  163. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/noop.js.mjs +5 -0
  164. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/pipe.js.mjs +17 -0
  165. package/dist/treeshaking/_virtual/rxjs/dist/esm5/internal/util/reportUnhandledError.js.mjs +11 -0
  166. package/dist/treeshaking/_virtual/tslib/tslib.es6.mjs.mjs +64 -0
  167. package/dist/treeshaking/assets/user-center/images/avatar.png.mjs +4 -0
  168. package/dist/treeshaking/assets/user-center/images/default-user-photo.png.mjs +4 -0
  169. package/dist/treeshaking/assets/user-center/images/left-arrow-dark.svg.mjs +4 -0
  170. package/dist/treeshaking/assets/user-center/images/left-arrow-light.svg.mjs +4 -0
  171. package/dist/treeshaking/assets/user-center/images/noData.svg.mjs +4 -0
  172. package/dist/treeshaking/assets/user-center/images/warning-dark.svg.mjs +4 -0
  173. package/dist/treeshaking/assets/user-center/images/warning-light.svg.mjs +4 -0
  174. package/dist/treeshaking/components/footer/OFooter.vue.mjs +2 -2
  175. package/dist/treeshaking/components/footer/index.mjs +3 -3
  176. package/dist/treeshaking/components/header/OHeader.vue.mjs +2 -2
  177. package/dist/treeshaking/components/header/OHeaderMobile.vue.mjs +2 -2
  178. package/dist/treeshaking/components/header/index.mjs +6 -6
  179. package/dist/treeshaking/components/header-language-switcher/OHeaderLanguageSwitcher.css +25 -25
  180. package/dist/treeshaking/components/header-language-switcher/OHeaderLanguageSwitcher.vue.d.ts +1 -1
  181. package/dist/treeshaking/components/header-language-switcher/OHeaderLanguageSwitcher.vue.mjs +2 -2
  182. package/dist/treeshaking/components/header-language-switcher/index.mjs +3 -3
  183. package/dist/treeshaking/components/header-search/OHeaderSearch.vue.mjs +2 -2
  184. package/dist/treeshaking/components/header-search/index.mjs +3 -3
  185. package/dist/treeshaking/components/header-theme/OHeaderTheme.vue.mjs +2 -2
  186. package/dist/treeshaking/components/header-theme/index.mjs +3 -3
  187. package/dist/treeshaking/components/header-user/OHeaderUser.vue.mjs +2 -2
  188. package/dist/treeshaking/components/header-user/index.mjs +3 -3
  189. package/dist/treeshaking/components/meeting/OMeetingMinutes.css +46 -42
  190. package/dist/treeshaking/components/meeting/OMeetingMinutes.vue.d.ts +0 -1
  191. package/dist/treeshaking/components/meeting/OMeetingMinutes.vue.mjs +74 -115
  192. package/dist/treeshaking/components/meeting/OMeetingMinutesCopyDetail.css +17 -17
  193. package/dist/treeshaking/components/meeting/OMeetingMinutesCopyDetail.vue.mjs +1 -1
  194. package/dist/treeshaking/components/meeting/OMeetingMinutesCopyDetail.vue2.mjs +1 -2
  195. package/dist/treeshaking/components/meeting/OMeetingSendMinutesForm.css +66 -85
  196. package/dist/treeshaking/components/meeting/OMeetingSendMinutesForm.vue.d.ts +1 -127
  197. package/dist/treeshaking/components/meeting/OMeetingSendMinutesForm.vue.mjs +5 -219
  198. package/dist/treeshaking/components/meeting/OMeetingSendMinutesForm.vue2.mjs +181 -0
  199. package/dist/treeshaking/components/meeting/OMeetingSigCalendar.vue.mjs +1 -1
  200. package/dist/treeshaking/components/meeting/components/OMeetingSendMinutesDialog.css +3 -3
  201. package/dist/treeshaking/components/meeting/components/OMeetingSendMinutesDialog.vue.d.ts +1 -127
  202. package/dist/treeshaking/components/meeting/components/OMeetingSendMinutesDialog.vue.mjs +1 -1
  203. package/dist/treeshaking/components/meeting/components/OMeetingSendMinutesDialog.vue2.mjs +2 -3
  204. package/dist/treeshaking/components/meeting/index.d.ts +1 -128
  205. package/dist/treeshaking/components/meeting/index.mjs +6 -7
  206. package/dist/treeshaking/components/meeting/types.d.ts +0 -2
  207. package/dist/treeshaking/components/sig/components/OSigMember.vue.mjs +1 -1
  208. package/dist/treeshaking/components/summit/OSummitLive.css +20 -20
  209. package/dist/treeshaking/components/summit/OSummitLive.vue.mjs +1 -1
  210. package/dist/treeshaking/components/summit/OSummitLive.vue2.mjs +1 -1
  211. package/dist/treeshaking/components/user-center/OAccountSecurity.css +215 -0
  212. package/dist/treeshaking/components/user-center/OAccountSecurity.vue.d.ts +39 -0
  213. package/dist/treeshaking/components/user-center/OAccountSecurity.vue.mjs +7 -0
  214. package/dist/treeshaking/components/user-center/OAccountSecurity.vue2.mjs +291 -0
  215. package/dist/treeshaking/components/user-center/OAccountSetting.css +199 -0
  216. package/dist/treeshaking/components/user-center/OAccountSetting.vue.d.ts +22 -0
  217. package/dist/treeshaking/components/user-center/OAccountSetting.vue.mjs +7 -0
  218. package/dist/treeshaking/components/user-center/OAccountSetting.vue2.mjs +393 -0
  219. package/dist/treeshaking/components/user-center/OAppFooterSimple.vue.d.ts +12 -0
  220. package/dist/treeshaking/components/user-center/OAppFooterSimple.vue.mjs +51 -0
  221. package/dist/treeshaking/components/user-center/OAppFooterSimple.vue2.mjs +4 -0
  222. package/dist/treeshaking/components/user-center/OAppHeader.css +23 -0
  223. package/dist/treeshaking/components/user-center/OAppHeader.vue.d.ts +43 -0
  224. package/dist/treeshaking/components/user-center/OAppHeader.vue.mjs +7 -0
  225. package/dist/treeshaking/components/user-center/OAppHeader.vue2.mjs +208 -0
  226. package/dist/treeshaking/components/user-center/OAsideBar.css +65 -0
  227. package/dist/treeshaking/components/user-center/OAsideBar.vue.d.ts +26 -0
  228. package/dist/treeshaking/components/user-center/OAsideBar.vue.mjs +7 -0
  229. package/dist/treeshaking/components/user-center/OAsideBar.vue2.mjs +108 -0
  230. package/dist/treeshaking/components/user-center/OLayout.css +30 -0
  231. package/dist/treeshaking/components/user-center/OLayout.vue.d.ts +18 -0
  232. package/dist/treeshaking/components/user-center/OLayout.vue.mjs +7 -0
  233. package/dist/treeshaking/components/user-center/OLayout.vue2.mjs +27 -0
  234. package/dist/treeshaking/components/user-center/OTheAccountManage.css +25 -0
  235. package/dist/treeshaking/components/user-center/OTheAccountManage.vue.d.ts +18 -0
  236. package/dist/treeshaking/components/user-center/OTheAccountManage.vue.mjs +7 -0
  237. package/dist/treeshaking/components/user-center/OTheAccountManage.vue2.mjs +26 -0
  238. package/dist/treeshaking/components/user-center/OTheCreateMeeting.css +48 -0
  239. package/dist/treeshaking/components/user-center/OTheCreateMeeting.vue.d.ts +18 -0
  240. package/dist/treeshaking/components/user-center/OTheCreateMeeting.vue.mjs +7 -0
  241. package/dist/treeshaking/components/user-center/OTheCreateMeeting.vue2.mjs +103 -0
  242. package/dist/treeshaking/components/user-center/OTheMeeting.css +183 -0
  243. package/dist/treeshaking/components/user-center/OTheMeeting.vue.d.ts +14 -0
  244. package/dist/treeshaking/components/user-center/OTheMeeting.vue.mjs +7 -0
  245. package/dist/treeshaking/components/user-center/OTheMeeting.vue2.mjs +125 -0
  246. package/dist/treeshaking/components/user-center/OThirdPartyBindings.css +85 -0
  247. package/dist/treeshaking/components/user-center/OThirdPartyBindings.vue.d.ts +22 -0
  248. package/dist/treeshaking/components/user-center/OThirdPartyBindings.vue.mjs +7 -0
  249. package/dist/treeshaking/components/user-center/OThirdPartyBindings.vue2.mjs +387 -0
  250. package/dist/treeshaking/components/user-center/OUserInfo.css +239 -0
  251. package/dist/treeshaking/components/user-center/OUserInfo.vue.d.ts +159 -0
  252. package/dist/treeshaking/components/user-center/OUserInfo.vue.mjs +9 -0
  253. package/dist/treeshaking/components/user-center/OUserInfo.vue2.mjs +557 -0
  254. package/dist/treeshaking/components/user-center/OUserInfo2.css +44 -0
  255. package/dist/treeshaking/components/user-center/OUserInfo3.css +16 -0
  256. package/dist/treeshaking/components/user-center/const/common.const.d.ts +17 -0
  257. package/dist/treeshaking/components/user-center/const/common.const.mjs +31 -0
  258. package/dist/treeshaking/components/user-center/index.d.ts +801 -0
  259. package/dist/treeshaking/components/user-center/index.mjs +81 -0
  260. package/dist/treeshaking/components/user-center/internal/OAppDialog.css +68 -0
  261. package/dist/treeshaking/components/user-center/internal/OAppDialog.vue.d.ts +197 -0
  262. package/dist/treeshaking/components/user-center/internal/OAppDialog.vue.mjs +7 -0
  263. package/dist/treeshaking/components/user-center/internal/OAppDialog.vue2.mjs +440 -0
  264. package/dist/treeshaking/components/user-center/internal/OAppEmpty.css +63 -0
  265. package/dist/treeshaking/components/user-center/internal/OAppEmpty.vue.d.ts +25 -0
  266. package/dist/treeshaking/components/user-center/internal/OAppEmpty.vue.mjs +7 -0
  267. package/dist/treeshaking/components/user-center/internal/OAppEmpty.vue2.mjs +41 -0
  268. package/dist/treeshaking/components/user-center/internal/OCommonHeader.css +27 -0
  269. package/dist/treeshaking/components/user-center/internal/OCommonHeader.vue.d.ts +94 -0
  270. package/dist/treeshaking/components/user-center/internal/OCommonHeader.vue.mjs +7 -0
  271. package/dist/treeshaking/components/user-center/internal/OCommonHeader.vue2.mjs +135 -0
  272. package/dist/treeshaking/components/user-center/internal/OCountdownButton.vue.d.ts +20 -0
  273. package/dist/treeshaking/components/user-center/internal/OCountdownButton.vue.mjs +67 -0
  274. package/dist/treeshaking/components/user-center/internal/OCountdownButton.vue2.mjs +4 -0
  275. package/dist/treeshaking/components/user-center/internal/ODeleteAccountModal.css +171 -0
  276. package/dist/treeshaking/components/user-center/internal/ODeleteAccountModal.vue.d.ts +189 -0
  277. package/dist/treeshaking/components/user-center/internal/ODeleteAccountModal.vue.mjs +8 -0
  278. package/dist/treeshaking/components/user-center/internal/ODeleteAccountModal.vue2.mjs +319 -0
  279. package/dist/treeshaking/components/user-center/internal/ODeleteAccountModal2.css +57 -0
  280. package/dist/treeshaking/components/user-center/internal/OEditNicknameDialog.css +57 -0
  281. package/dist/treeshaking/components/user-center/internal/OEditNicknameDialog.vue.d.ts +164 -0
  282. package/dist/treeshaking/components/user-center/internal/OEditNicknameDialog.vue.mjs +8 -0
  283. package/dist/treeshaking/components/user-center/internal/OEditNicknameDialog.vue2.mjs +149 -0
  284. package/dist/treeshaking/components/user-center/internal/OEditNicknameDialog2.css +13 -0
  285. package/dist/treeshaking/components/user-center/internal/OEditOrgDialog.css +57 -0
  286. package/dist/treeshaking/components/user-center/internal/OEditOrgDialog.vue.d.ts +182 -0
  287. package/dist/treeshaking/components/user-center/internal/OEditOrgDialog.vue.mjs +8 -0
  288. package/dist/treeshaking/components/user-center/internal/OEditOrgDialog.vue2.mjs +162 -0
  289. package/dist/treeshaking/components/user-center/internal/OEditOrgDialog2.css +13 -0
  290. package/dist/treeshaking/components/user-center/internal/OMaskEye.css +11 -0
  291. package/dist/treeshaking/components/user-center/internal/OMaskEye.vue.d.ts +18 -0
  292. package/dist/treeshaking/components/user-center/internal/OMaskEye.vue.mjs +7 -0
  293. package/dist/treeshaking/components/user-center/internal/OMaskEye.vue2.mjs +30 -0
  294. package/dist/treeshaking/components/user-center/internal/OModifyPwd.css +78 -0
  295. package/dist/treeshaking/components/user-center/internal/OModifyPwd.vue.d.ts +426 -0
  296. package/dist/treeshaking/components/user-center/internal/OModifyPwd.vue.mjs +7 -0
  297. package/dist/treeshaking/components/user-center/internal/OModifyPwd.vue2.mjs +460 -0
  298. package/dist/treeshaking/components/user-center/internal/OPasswordPopInput.css +18 -0
  299. package/dist/treeshaking/components/user-center/internal/OPasswordPopInput.vue.d.ts +174 -0
  300. package/dist/treeshaking/components/user-center/internal/OPasswordPopInput.vue.mjs +7 -0
  301. package/dist/treeshaking/components/user-center/internal/OPasswordPopInput.vue2.mjs +147 -0
  302. package/dist/treeshaking/components/user-center/internal/OToBindingTipModal.css +50 -0
  303. package/dist/treeshaking/components/user-center/internal/OToBindingTipModal.vue.d.ts +37 -0
  304. package/dist/treeshaking/components/user-center/internal/OToBindingTipModal.vue.mjs +7 -0
  305. package/dist/treeshaking/components/user-center/internal/OToBindingTipModal.vue2.mjs +117 -0
  306. package/dist/treeshaking/components/user-center/internal/OUnbindingThirdpartyAccountModal.css +58 -0
  307. package/dist/treeshaking/components/user-center/internal/OUnbindingThirdpartyAccountModal.vue.d.ts +30 -0
  308. package/dist/treeshaking/components/user-center/internal/OUnbindingThirdpartyAccountModal.vue.mjs +7 -0
  309. package/dist/treeshaking/components/user-center/internal/OUnbindingThirdpartyAccountModal.vue2.mjs +107 -0
  310. package/dist/treeshaking/components/user-center/internal/OUploadAvatar.css +524 -0
  311. package/dist/treeshaking/components/user-center/internal/OUploadAvatar.vue.d.ts +55 -0
  312. package/dist/treeshaking/components/user-center/internal/OUploadAvatar.vue.mjs +8 -0
  313. package/dist/treeshaking/components/user-center/internal/OUploadAvatar.vue2.mjs +455 -0
  314. package/dist/treeshaking/components/user-center/internal/OUploadAvatar2.css +304 -0
  315. package/dist/treeshaking/components/user-center/rolesMap.d.ts +10 -0
  316. package/dist/treeshaking/components/user-center/rolesMap.mjs +29 -0
  317. package/dist/treeshaking/components/user-center/styles/global.css +357 -0
  318. package/dist/treeshaking/components/user-center/styles/variables.css +362 -0
  319. package/dist/treeshaking/components/user-center/types/captcha.d.ts +6 -0
  320. package/dist/treeshaking/components/user-center/types/interface.d.ts +13 -0
  321. package/dist/treeshaking/components/user-center/types/search.d.ts +67 -0
  322. package/dist/treeshaking/components/user-center/types/usercenter.interface.d.ts +57 -0
  323. package/dist/treeshaking/components/user-center/utils/helper.d.ts +4 -0
  324. package/dist/treeshaking/components/user-center/utils/helper.mjs +6 -0
  325. package/dist/treeshaking/components/user-center/utils/rules.d.ts +11 -0
  326. package/dist/treeshaking/components/user-center/utils/rules.mjs +145 -0
  327. package/dist/treeshaking/components/user-center/utils/utils.d.ts +17 -0
  328. package/dist/treeshaking/components/user-center/utils/utils.mjs +47 -0
  329. package/dist/treeshaking/components/user-center/verify/Verify.css +282 -0
  330. package/dist/treeshaking/components/user-center/verify/Verify.vue.d.ts +2 -0
  331. package/dist/treeshaking/components/user-center/verify/Verify.vue.mjs +61 -0
  332. package/dist/treeshaking/components/user-center/verify/Verify.vue2.mjs +83 -0
  333. package/dist/treeshaking/components/user-center/verify/VerifySlide.vue.d.ts +2 -0
  334. package/dist/treeshaking/components/user-center/verify/VerifySlide.vue.mjs +122 -0
  335. package/dist/treeshaking/components/user-center/verify/VerifySlide.vue2.mjs +366 -0
  336. package/dist/treeshaking/components/user-center/verify/utils/ase.d.ts +5 -0
  337. package/dist/treeshaking/components/user-center/verify/utils/ase.mjs +13 -0
  338. package/dist/treeshaking/components/user-center/verify/utils/util.d.ts +6 -0
  339. package/dist/treeshaking/components/user-center/verify/utils/util.mjs +34 -0
  340. package/dist/treeshaking/i18n/en.mjs +131 -2
  341. package/dist/treeshaking/i18n/zh.mjs +131 -2
  342. package/dist/treeshaking/index.d.ts +1 -0
  343. package/dist/treeshaking/index.mjs +12 -0
  344. package/package.json +13 -6
  345. package/dist/treeshaking/components/meeting/OMeetingSendMinutesForm.vue3.mjs +0 -5
@@ -0,0 +1,2739 @@
1
+ /*!
2
+ * Cropper.js v1.6.2
3
+ * https://fengyuanchen.github.io/cropperjs
4
+ *
5
+ * Copyright 2015-present Chen Fengyuan
6
+ * Released under the MIT license
7
+ *
8
+ * Date: 2024-04-21T07:43:05.335Z
9
+ */
10
+ function ownKeys(e, r) {
11
+ var t = Object.keys(e);
12
+ if (Object.getOwnPropertySymbols) {
13
+ var o = Object.getOwnPropertySymbols(e);
14
+ r && (o = o.filter(function(r2) {
15
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
16
+ })), t.push.apply(t, o);
17
+ }
18
+ return t;
19
+ }
20
+ function _objectSpread2(e) {
21
+ for (var r = 1; r < arguments.length; r++) {
22
+ var t = null != arguments[r] ? arguments[r] : {};
23
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
24
+ _defineProperty(e, r2, t[r2]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
26
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
27
+ });
28
+ }
29
+ return e;
30
+ }
31
+ function _toPrimitive(t, r) {
32
+ if ("object" != typeof t || !t) return t;
33
+ var e = t[Symbol.toPrimitive];
34
+ if (void 0 !== e) {
35
+ var i = e.call(t, r);
36
+ if ("object" != typeof i) return i;
37
+ throw new TypeError("@@toPrimitive must return a primitive value.");
38
+ }
39
+ return String(t);
40
+ }
41
+ function _toPropertyKey(t) {
42
+ var i = _toPrimitive(t, "string");
43
+ return "symbol" == typeof i ? i : i + "";
44
+ }
45
+ function _typeof(o) {
46
+ "@babel/helpers - typeof";
47
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
48
+ return typeof o2;
49
+ } : function(o2) {
50
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
51
+ }, _typeof(o);
52
+ }
53
+ function _classCallCheck(instance, Constructor) {
54
+ if (!(instance instanceof Constructor)) {
55
+ throw new TypeError("Cannot call a class as a function");
56
+ }
57
+ }
58
+ function _defineProperties(target, props) {
59
+ for (var i = 0; i < props.length; i++) {
60
+ var descriptor = props[i];
61
+ descriptor.enumerable = descriptor.enumerable || false;
62
+ descriptor.configurable = true;
63
+ if ("value" in descriptor) descriptor.writable = true;
64
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
65
+ }
66
+ }
67
+ function _createClass(Constructor, protoProps, staticProps) {
68
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
69
+ if (staticProps) _defineProperties(Constructor, staticProps);
70
+ Object.defineProperty(Constructor, "prototype", {
71
+ writable: false
72
+ });
73
+ return Constructor;
74
+ }
75
+ function _defineProperty(obj, key, value) {
76
+ key = _toPropertyKey(key);
77
+ if (key in obj) {
78
+ Object.defineProperty(obj, key, {
79
+ value,
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true
83
+ });
84
+ } else {
85
+ obj[key] = value;
86
+ }
87
+ return obj;
88
+ }
89
+ function _toConsumableArray(arr) {
90
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
91
+ }
92
+ function _arrayWithoutHoles(arr) {
93
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
94
+ }
95
+ function _iterableToArray(iter) {
96
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
97
+ }
98
+ function _unsupportedIterableToArray(o, minLen) {
99
+ if (!o) return;
100
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
101
+ var n = Object.prototype.toString.call(o).slice(8, -1);
102
+ if (n === "Object" && o.constructor) n = o.constructor.name;
103
+ if (n === "Map" || n === "Set") return Array.from(o);
104
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
105
+ }
106
+ function _arrayLikeToArray(arr, len) {
107
+ if (len == null || len > arr.length) len = arr.length;
108
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
109
+ return arr2;
110
+ }
111
+ function _nonIterableSpread() {
112
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
+ }
114
+ var IS_BROWSER = typeof window !== "undefined" && typeof window.document !== "undefined";
115
+ var WINDOW = IS_BROWSER ? window : {};
116
+ var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? "ontouchstart" in WINDOW.document.documentElement : false;
117
+ var HAS_POINTER_EVENT = IS_BROWSER ? "PointerEvent" in WINDOW : false;
118
+ var NAMESPACE = "cropper";
119
+ var ACTION_ALL = "all";
120
+ var ACTION_CROP = "crop";
121
+ var ACTION_MOVE = "move";
122
+ var ACTION_ZOOM = "zoom";
123
+ var ACTION_EAST = "e";
124
+ var ACTION_WEST = "w";
125
+ var ACTION_SOUTH = "s";
126
+ var ACTION_NORTH = "n";
127
+ var ACTION_NORTH_EAST = "ne";
128
+ var ACTION_NORTH_WEST = "nw";
129
+ var ACTION_SOUTH_EAST = "se";
130
+ var ACTION_SOUTH_WEST = "sw";
131
+ var CLASS_CROP = "".concat(NAMESPACE, "-crop");
132
+ var CLASS_DISABLED = "".concat(NAMESPACE, "-disabled");
133
+ var CLASS_HIDDEN = "".concat(NAMESPACE, "-hidden");
134
+ var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
135
+ var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible");
136
+ var CLASS_MODAL = "".concat(NAMESPACE, "-modal");
137
+ var CLASS_MOVE = "".concat(NAMESPACE, "-move");
138
+ var DATA_ACTION = "".concat(NAMESPACE, "Action");
139
+ var DATA_PREVIEW = "".concat(NAMESPACE, "Preview");
140
+ var DRAG_MODE_CROP = "crop";
141
+ var DRAG_MODE_MOVE = "move";
142
+ var DRAG_MODE_NONE = "none";
143
+ var EVENT_CROP = "crop";
144
+ var EVENT_CROP_END = "cropend";
145
+ var EVENT_CROP_MOVE = "cropmove";
146
+ var EVENT_CROP_START = "cropstart";
147
+ var EVENT_DBLCLICK = "dblclick";
148
+ var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? "touchstart" : "mousedown";
149
+ var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? "touchmove" : "mousemove";
150
+ var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? "touchend touchcancel" : "mouseup";
151
+ var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? "pointerdown" : EVENT_TOUCH_START;
152
+ var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? "pointermove" : EVENT_TOUCH_MOVE;
153
+ var EVENT_POINTER_UP = HAS_POINTER_EVENT ? "pointerup pointercancel" : EVENT_TOUCH_END;
154
+ var EVENT_READY = "ready";
155
+ var EVENT_RESIZE = "resize";
156
+ var EVENT_WHEEL = "wheel";
157
+ var EVENT_ZOOM = "zoom";
158
+ var MIME_TYPE_JPEG = "image/jpeg";
159
+ var REGEXP_ACTIONS = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/;
160
+ var REGEXP_DATA_URL = /^data:/;
161
+ var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg;base64,/;
162
+ var REGEXP_TAG_NAME = /^img|canvas$/i;
163
+ var MIN_CONTAINER_WIDTH = 200;
164
+ var MIN_CONTAINER_HEIGHT = 100;
165
+ var DEFAULTS = {
166
+ // Define the view mode of the cropper
167
+ viewMode: 0,
168
+ // 0, 1, 2, 3
169
+ // Define the dragging mode of the cropper
170
+ dragMode: DRAG_MODE_CROP,
171
+ // 'crop', 'move' or 'none'
172
+ // Define the initial aspect ratio of the crop box
173
+ initialAspectRatio: NaN,
174
+ // Define the aspect ratio of the crop box
175
+ aspectRatio: NaN,
176
+ // An object with the previous cropping result data
177
+ data: null,
178
+ // A selector for adding extra containers to preview
179
+ preview: "",
180
+ // Re-render the cropper when resize the window
181
+ responsive: true,
182
+ // Restore the cropped area after resize the window
183
+ restore: true,
184
+ // Check if the current image is a cross-origin image
185
+ checkCrossOrigin: true,
186
+ // Check the current image's Exif Orientation information
187
+ checkOrientation: true,
188
+ // Show the black modal
189
+ modal: true,
190
+ // Show the dashed lines for guiding
191
+ guides: true,
192
+ // Show the center indicator for guiding
193
+ center: true,
194
+ // Show the white modal to highlight the crop box
195
+ highlight: true,
196
+ // Show the grid background
197
+ background: true,
198
+ // Enable to crop the image automatically when initialize
199
+ autoCrop: true,
200
+ // Define the percentage of automatic cropping area when initializes
201
+ autoCropArea: 0.8,
202
+ // Enable to move the image
203
+ movable: true,
204
+ // Enable to rotate the image
205
+ rotatable: true,
206
+ // Enable to scale the image
207
+ scalable: true,
208
+ // Enable to zoom the image
209
+ zoomable: true,
210
+ // Enable to zoom the image by dragging touch
211
+ zoomOnTouch: true,
212
+ // Enable to zoom the image by wheeling mouse
213
+ zoomOnWheel: true,
214
+ // Define zoom ratio when zoom the image by wheeling mouse
215
+ wheelZoomRatio: 0.1,
216
+ // Enable to move the crop box
217
+ cropBoxMovable: true,
218
+ // Enable to resize the crop box
219
+ cropBoxResizable: true,
220
+ // Toggle drag mode between "crop" and "move" when click twice on the cropper
221
+ toggleDragModeOnDblclick: true,
222
+ // Size limitation
223
+ minCanvasWidth: 0,
224
+ minCanvasHeight: 0,
225
+ minCropBoxWidth: 0,
226
+ minCropBoxHeight: 0,
227
+ minContainerWidth: MIN_CONTAINER_WIDTH,
228
+ minContainerHeight: MIN_CONTAINER_HEIGHT,
229
+ // Shortcuts of events
230
+ ready: null,
231
+ cropstart: null,
232
+ cropmove: null,
233
+ cropend: null,
234
+ crop: null,
235
+ zoom: null
236
+ };
237
+ var TEMPLATE = '<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';
238
+ var isNaN = Number.isNaN || WINDOW.isNaN;
239
+ function isNumber(value) {
240
+ return typeof value === "number" && !isNaN(value);
241
+ }
242
+ var isPositiveNumber = function isPositiveNumber2(value) {
243
+ return value > 0 && value < Infinity;
244
+ };
245
+ function isUndefined(value) {
246
+ return typeof value === "undefined";
247
+ }
248
+ function isObject(value) {
249
+ return _typeof(value) === "object" && value !== null;
250
+ }
251
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
252
+ function isPlainObject(value) {
253
+ if (!isObject(value)) {
254
+ return false;
255
+ }
256
+ try {
257
+ var _constructor = value.constructor;
258
+ var prototype = _constructor.prototype;
259
+ return _constructor && prototype && hasOwnProperty.call(prototype, "isPrototypeOf");
260
+ } catch (error) {
261
+ return false;
262
+ }
263
+ }
264
+ function isFunction(value) {
265
+ return typeof value === "function";
266
+ }
267
+ var slice = Array.prototype.slice;
268
+ function toArray(value) {
269
+ return Array.from ? Array.from(value) : slice.call(value);
270
+ }
271
+ function forEach(data, callback) {
272
+ if (data && isFunction(callback)) {
273
+ if (Array.isArray(data) || isNumber(data.length)) {
274
+ toArray(data).forEach(function(value, key) {
275
+ callback.call(data, value, key, data);
276
+ });
277
+ } else if (isObject(data)) {
278
+ Object.keys(data).forEach(function(key) {
279
+ callback.call(data, data[key], key, data);
280
+ });
281
+ }
282
+ }
283
+ return data;
284
+ }
285
+ var assign = Object.assign || function assign2(target) {
286
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
287
+ args[_key - 1] = arguments[_key];
288
+ }
289
+ if (isObject(target) && args.length > 0) {
290
+ args.forEach(function(arg) {
291
+ if (isObject(arg)) {
292
+ Object.keys(arg).forEach(function(key) {
293
+ target[key] = arg[key];
294
+ });
295
+ }
296
+ });
297
+ }
298
+ return target;
299
+ };
300
+ var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
301
+ function normalizeDecimalNumber(value) {
302
+ var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
303
+ return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value;
304
+ }
305
+ var REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop$/;
306
+ function setStyle(element, styles) {
307
+ var style = element.style;
308
+ forEach(styles, function(value, property) {
309
+ if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
310
+ value = "".concat(value, "px");
311
+ }
312
+ style[property] = value;
313
+ });
314
+ }
315
+ function hasClass(element, value) {
316
+ return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
317
+ }
318
+ function addClass(element, value) {
319
+ if (!value) {
320
+ return;
321
+ }
322
+ if (isNumber(element.length)) {
323
+ forEach(element, function(elem) {
324
+ addClass(elem, value);
325
+ });
326
+ return;
327
+ }
328
+ if (element.classList) {
329
+ element.classList.add(value);
330
+ return;
331
+ }
332
+ var className = element.className.trim();
333
+ if (!className) {
334
+ element.className = value;
335
+ } else if (className.indexOf(value) < 0) {
336
+ element.className = "".concat(className, " ").concat(value);
337
+ }
338
+ }
339
+ function removeClass(element, value) {
340
+ if (!value) {
341
+ return;
342
+ }
343
+ if (isNumber(element.length)) {
344
+ forEach(element, function(elem) {
345
+ removeClass(elem, value);
346
+ });
347
+ return;
348
+ }
349
+ if (element.classList) {
350
+ element.classList.remove(value);
351
+ return;
352
+ }
353
+ if (element.className.indexOf(value) >= 0) {
354
+ element.className = element.className.replace(value, "");
355
+ }
356
+ }
357
+ function toggleClass(element, value, added) {
358
+ if (!value) {
359
+ return;
360
+ }
361
+ if (isNumber(element.length)) {
362
+ forEach(element, function(elem) {
363
+ toggleClass(elem, value, added);
364
+ });
365
+ return;
366
+ }
367
+ if (added) {
368
+ addClass(element, value);
369
+ } else {
370
+ removeClass(element, value);
371
+ }
372
+ }
373
+ var REGEXP_CAMEL_CASE = /([a-z\d])([A-Z])/g;
374
+ function toParamCase(value) {
375
+ return value.replace(REGEXP_CAMEL_CASE, "$1-$2").toLowerCase();
376
+ }
377
+ function getData(element, name) {
378
+ if (isObject(element[name])) {
379
+ return element[name];
380
+ }
381
+ if (element.dataset) {
382
+ return element.dataset[name];
383
+ }
384
+ return element.getAttribute("data-".concat(toParamCase(name)));
385
+ }
386
+ function setData(element, name, data) {
387
+ if (isObject(data)) {
388
+ element[name] = data;
389
+ } else if (element.dataset) {
390
+ element.dataset[name] = data;
391
+ } else {
392
+ element.setAttribute("data-".concat(toParamCase(name)), data);
393
+ }
394
+ }
395
+ function removeData(element, name) {
396
+ if (isObject(element[name])) {
397
+ try {
398
+ delete element[name];
399
+ } catch (error) {
400
+ element[name] = void 0;
401
+ }
402
+ } else if (element.dataset) {
403
+ try {
404
+ delete element.dataset[name];
405
+ } catch (error) {
406
+ element.dataset[name] = void 0;
407
+ }
408
+ } else {
409
+ element.removeAttribute("data-".concat(toParamCase(name)));
410
+ }
411
+ }
412
+ var REGEXP_SPACES = /\s\s*/;
413
+ var onceSupported = (function() {
414
+ var supported = false;
415
+ if (IS_BROWSER) {
416
+ var once = false;
417
+ var listener = function listener2() {
418
+ };
419
+ var options = Object.defineProperty({}, "once", {
420
+ get: function get() {
421
+ supported = true;
422
+ return once;
423
+ },
424
+ /**
425
+ * This setter can fix a `TypeError` in strict mode
426
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
427
+ * @param {boolean} value - The value to set
428
+ */
429
+ set: function set(value) {
430
+ once = value;
431
+ }
432
+ });
433
+ WINDOW.addEventListener("test", listener, options);
434
+ WINDOW.removeEventListener("test", listener, options);
435
+ }
436
+ return supported;
437
+ })();
438
+ function removeListener(element, type, listener) {
439
+ var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
440
+ var handler = listener;
441
+ type.trim().split(REGEXP_SPACES).forEach(function(event) {
442
+ if (!onceSupported) {
443
+ var listeners = element.listeners;
444
+ if (listeners && listeners[event] && listeners[event][listener]) {
445
+ handler = listeners[event][listener];
446
+ delete listeners[event][listener];
447
+ if (Object.keys(listeners[event]).length === 0) {
448
+ delete listeners[event];
449
+ }
450
+ if (Object.keys(listeners).length === 0) {
451
+ delete element.listeners;
452
+ }
453
+ }
454
+ }
455
+ element.removeEventListener(event, handler, options);
456
+ });
457
+ }
458
+ function addListener(element, type, listener) {
459
+ var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
460
+ var _handler = listener;
461
+ type.trim().split(REGEXP_SPACES).forEach(function(event) {
462
+ if (options.once && !onceSupported) {
463
+ var _element$listeners = element.listeners, listeners = _element$listeners === void 0 ? {} : _element$listeners;
464
+ _handler = function handler() {
465
+ delete listeners[event][listener];
466
+ element.removeEventListener(event, _handler, options);
467
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
468
+ args[_key2] = arguments[_key2];
469
+ }
470
+ listener.apply(element, args);
471
+ };
472
+ if (!listeners[event]) {
473
+ listeners[event] = {};
474
+ }
475
+ if (listeners[event][listener]) {
476
+ element.removeEventListener(event, listeners[event][listener], options);
477
+ }
478
+ listeners[event][listener] = _handler;
479
+ element.listeners = listeners;
480
+ }
481
+ element.addEventListener(event, _handler, options);
482
+ });
483
+ }
484
+ function dispatchEvent(element, type, data) {
485
+ var event;
486
+ if (isFunction(Event) && isFunction(CustomEvent)) {
487
+ event = new CustomEvent(type, {
488
+ detail: data,
489
+ bubbles: true,
490
+ cancelable: true
491
+ });
492
+ } else {
493
+ event = document.createEvent("CustomEvent");
494
+ event.initCustomEvent(type, true, true, data);
495
+ }
496
+ return element.dispatchEvent(event);
497
+ }
498
+ function getOffset(element) {
499
+ var box = element.getBoundingClientRect();
500
+ return {
501
+ left: box.left + (window.pageXOffset - document.documentElement.clientLeft),
502
+ top: box.top + (window.pageYOffset - document.documentElement.clientTop)
503
+ };
504
+ }
505
+ var location = WINDOW.location;
506
+ var REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
507
+ function isCrossOriginURL(url) {
508
+ var parts = url.match(REGEXP_ORIGINS);
509
+ return parts !== null && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port);
510
+ }
511
+ function addTimestamp(url) {
512
+ var timestamp = "timestamp=".concat((/* @__PURE__ */ new Date()).getTime());
513
+ return url + (url.indexOf("?") === -1 ? "?" : "&") + timestamp;
514
+ }
515
+ function getTransforms(_ref) {
516
+ var rotate2 = _ref.rotate, scaleX2 = _ref.scaleX, scaleY2 = _ref.scaleY, translateX = _ref.translateX, translateY = _ref.translateY;
517
+ var values = [];
518
+ if (isNumber(translateX) && translateX !== 0) {
519
+ values.push("translateX(".concat(translateX, "px)"));
520
+ }
521
+ if (isNumber(translateY) && translateY !== 0) {
522
+ values.push("translateY(".concat(translateY, "px)"));
523
+ }
524
+ if (isNumber(rotate2) && rotate2 !== 0) {
525
+ values.push("rotate(".concat(rotate2, "deg)"));
526
+ }
527
+ if (isNumber(scaleX2) && scaleX2 !== 1) {
528
+ values.push("scaleX(".concat(scaleX2, ")"));
529
+ }
530
+ if (isNumber(scaleY2) && scaleY2 !== 1) {
531
+ values.push("scaleY(".concat(scaleY2, ")"));
532
+ }
533
+ var transform = values.length ? values.join(" ") : "none";
534
+ return {
535
+ WebkitTransform: transform,
536
+ msTransform: transform,
537
+ transform
538
+ };
539
+ }
540
+ function getMaxZoomRatio(pointers) {
541
+ var pointers2 = _objectSpread2({}, pointers);
542
+ var maxRatio = 0;
543
+ forEach(pointers, function(pointer, pointerId) {
544
+ delete pointers2[pointerId];
545
+ forEach(pointers2, function(pointer2) {
546
+ var x1 = Math.abs(pointer.startX - pointer2.startX);
547
+ var y1 = Math.abs(pointer.startY - pointer2.startY);
548
+ var x2 = Math.abs(pointer.endX - pointer2.endX);
549
+ var y2 = Math.abs(pointer.endY - pointer2.endY);
550
+ var z1 = Math.sqrt(x1 * x1 + y1 * y1);
551
+ var z2 = Math.sqrt(x2 * x2 + y2 * y2);
552
+ var ratio = (z2 - z1) / z1;
553
+ if (Math.abs(ratio) > Math.abs(maxRatio)) {
554
+ maxRatio = ratio;
555
+ }
556
+ });
557
+ });
558
+ return maxRatio;
559
+ }
560
+ function getPointer(_ref2, endOnly) {
561
+ var pageX = _ref2.pageX, pageY = _ref2.pageY;
562
+ var end = {
563
+ endX: pageX,
564
+ endY: pageY
565
+ };
566
+ return endOnly ? end : _objectSpread2({
567
+ startX: pageX,
568
+ startY: pageY
569
+ }, end);
570
+ }
571
+ function getPointersCenter(pointers) {
572
+ var pageX = 0;
573
+ var pageY = 0;
574
+ var count = 0;
575
+ forEach(pointers, function(_ref3) {
576
+ var startX = _ref3.startX, startY = _ref3.startY;
577
+ pageX += startX;
578
+ pageY += startY;
579
+ count += 1;
580
+ });
581
+ pageX /= count;
582
+ pageY /= count;
583
+ return {
584
+ pageX,
585
+ pageY
586
+ };
587
+ }
588
+ function getAdjustedSizes(_ref4) {
589
+ var aspectRatio = _ref4.aspectRatio, height = _ref4.height, width = _ref4.width;
590
+ var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "contain";
591
+ var isValidWidth = isPositiveNumber(width);
592
+ var isValidHeight = isPositiveNumber(height);
593
+ if (isValidWidth && isValidHeight) {
594
+ var adjustedWidth = height * aspectRatio;
595
+ if (type === "contain" && adjustedWidth > width || type === "cover" && adjustedWidth < width) {
596
+ height = width / aspectRatio;
597
+ } else {
598
+ width = height * aspectRatio;
599
+ }
600
+ } else if (isValidWidth) {
601
+ height = width / aspectRatio;
602
+ } else if (isValidHeight) {
603
+ width = height * aspectRatio;
604
+ }
605
+ return {
606
+ width,
607
+ height
608
+ };
609
+ }
610
+ function getRotatedSizes(_ref5) {
611
+ var width = _ref5.width, height = _ref5.height, degree = _ref5.degree;
612
+ degree = Math.abs(degree) % 180;
613
+ if (degree === 90) {
614
+ return {
615
+ width: height,
616
+ height: width
617
+ };
618
+ }
619
+ var arc = degree % 90 * Math.PI / 180;
620
+ var sinArc = Math.sin(arc);
621
+ var cosArc = Math.cos(arc);
622
+ var newWidth = width * cosArc + height * sinArc;
623
+ var newHeight = width * sinArc + height * cosArc;
624
+ return degree > 90 ? {
625
+ width: newHeight,
626
+ height: newWidth
627
+ } : {
628
+ width: newWidth,
629
+ height: newHeight
630
+ };
631
+ }
632
+ function getSourceCanvas(image, _ref6, _ref7, _ref8) {
633
+ var imageAspectRatio = _ref6.aspectRatio, imageNaturalWidth = _ref6.naturalWidth, imageNaturalHeight = _ref6.naturalHeight, _ref6$rotate = _ref6.rotate, rotate2 = _ref6$rotate === void 0 ? 0 : _ref6$rotate, _ref6$scaleX = _ref6.scaleX, scaleX2 = _ref6$scaleX === void 0 ? 1 : _ref6$scaleX, _ref6$scaleY = _ref6.scaleY, scaleY2 = _ref6$scaleY === void 0 ? 1 : _ref6$scaleY;
634
+ var aspectRatio = _ref7.aspectRatio, naturalWidth = _ref7.naturalWidth, naturalHeight = _ref7.naturalHeight;
635
+ var _ref8$fillColor = _ref8.fillColor, fillColor = _ref8$fillColor === void 0 ? "transparent" : _ref8$fillColor, _ref8$imageSmoothingE = _ref8.imageSmoothingEnabled, imageSmoothingEnabled = _ref8$imageSmoothingE === void 0 ? true : _ref8$imageSmoothingE, _ref8$imageSmoothingQ = _ref8.imageSmoothingQuality, imageSmoothingQuality = _ref8$imageSmoothingQ === void 0 ? "low" : _ref8$imageSmoothingQ, _ref8$maxWidth = _ref8.maxWidth, maxWidth = _ref8$maxWidth === void 0 ? Infinity : _ref8$maxWidth, _ref8$maxHeight = _ref8.maxHeight, maxHeight = _ref8$maxHeight === void 0 ? Infinity : _ref8$maxHeight, _ref8$minWidth = _ref8.minWidth, minWidth = _ref8$minWidth === void 0 ? 0 : _ref8$minWidth, _ref8$minHeight = _ref8.minHeight, minHeight = _ref8$minHeight === void 0 ? 0 : _ref8$minHeight;
636
+ var canvas = document.createElement("canvas");
637
+ var context = canvas.getContext("2d");
638
+ var maxSizes = getAdjustedSizes({
639
+ aspectRatio,
640
+ width: maxWidth,
641
+ height: maxHeight
642
+ });
643
+ var minSizes = getAdjustedSizes({
644
+ aspectRatio,
645
+ width: minWidth,
646
+ height: minHeight
647
+ }, "cover");
648
+ var width = Math.min(maxSizes.width, Math.max(minSizes.width, naturalWidth));
649
+ var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight));
650
+ var destMaxSizes = getAdjustedSizes({
651
+ aspectRatio: imageAspectRatio,
652
+ width: maxWidth,
653
+ height: maxHeight
654
+ });
655
+ var destMinSizes = getAdjustedSizes({
656
+ aspectRatio: imageAspectRatio,
657
+ width: minWidth,
658
+ height: minHeight
659
+ }, "cover");
660
+ var destWidth = Math.min(destMaxSizes.width, Math.max(destMinSizes.width, imageNaturalWidth));
661
+ var destHeight = Math.min(destMaxSizes.height, Math.max(destMinSizes.height, imageNaturalHeight));
662
+ var params = [-destWidth / 2, -destHeight / 2, destWidth, destHeight];
663
+ canvas.width = normalizeDecimalNumber(width);
664
+ canvas.height = normalizeDecimalNumber(height);
665
+ context.fillStyle = fillColor;
666
+ context.fillRect(0, 0, width, height);
667
+ context.save();
668
+ context.translate(width / 2, height / 2);
669
+ context.rotate(rotate2 * Math.PI / 180);
670
+ context.scale(scaleX2, scaleY2);
671
+ context.imageSmoothingEnabled = imageSmoothingEnabled;
672
+ context.imageSmoothingQuality = imageSmoothingQuality;
673
+ context.drawImage.apply(context, [image].concat(_toConsumableArray(params.map(function(param) {
674
+ return Math.floor(normalizeDecimalNumber(param));
675
+ }))));
676
+ context.restore();
677
+ return canvas;
678
+ }
679
+ var fromCharCode = String.fromCharCode;
680
+ function getStringFromCharCode(dataView, start, length) {
681
+ var str = "";
682
+ length += start;
683
+ for (var i = start; i < length; i += 1) {
684
+ str += fromCharCode(dataView.getUint8(i));
685
+ }
686
+ return str;
687
+ }
688
+ var REGEXP_DATA_URL_HEAD = /^data:.*,/;
689
+ function dataURLToArrayBuffer(dataURL) {
690
+ var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, "");
691
+ var binary = atob(base64);
692
+ var arrayBuffer = new ArrayBuffer(binary.length);
693
+ var uint8 = new Uint8Array(arrayBuffer);
694
+ forEach(uint8, function(value, i) {
695
+ uint8[i] = binary.charCodeAt(i);
696
+ });
697
+ return arrayBuffer;
698
+ }
699
+ function arrayBufferToDataURL(arrayBuffer, mimeType) {
700
+ var chunks = [];
701
+ var chunkSize = 8192;
702
+ var uint8 = new Uint8Array(arrayBuffer);
703
+ while (uint8.length > 0) {
704
+ chunks.push(fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
705
+ uint8 = uint8.subarray(chunkSize);
706
+ }
707
+ return "data:".concat(mimeType, ";base64,").concat(btoa(chunks.join("")));
708
+ }
709
+ function resetAndGetOrientation(arrayBuffer) {
710
+ var dataView = new DataView(arrayBuffer);
711
+ var orientation;
712
+ try {
713
+ var littleEndian;
714
+ var app1Start;
715
+ var ifdStart;
716
+ if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) {
717
+ var length = dataView.byteLength;
718
+ var offset = 2;
719
+ while (offset + 1 < length) {
720
+ if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) {
721
+ app1Start = offset;
722
+ break;
723
+ }
724
+ offset += 1;
725
+ }
726
+ }
727
+ if (app1Start) {
728
+ var exifIDCode = app1Start + 4;
729
+ var tiffOffset = app1Start + 10;
730
+ if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") {
731
+ var endianness = dataView.getUint16(tiffOffset);
732
+ littleEndian = endianness === 18761;
733
+ if (littleEndian || endianness === 19789) {
734
+ if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) {
735
+ var firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
736
+ if (firstIFDOffset >= 8) {
737
+ ifdStart = tiffOffset + firstIFDOffset;
738
+ }
739
+ }
740
+ }
741
+ }
742
+ }
743
+ if (ifdStart) {
744
+ var _length = dataView.getUint16(ifdStart, littleEndian);
745
+ var _offset;
746
+ var i;
747
+ for (i = 0; i < _length; i += 1) {
748
+ _offset = ifdStart + i * 12 + 2;
749
+ if (dataView.getUint16(_offset, littleEndian) === 274) {
750
+ _offset += 8;
751
+ orientation = dataView.getUint16(_offset, littleEndian);
752
+ dataView.setUint16(_offset, 1, littleEndian);
753
+ break;
754
+ }
755
+ }
756
+ }
757
+ } catch (error) {
758
+ orientation = 1;
759
+ }
760
+ return orientation;
761
+ }
762
+ function parseOrientation(orientation) {
763
+ var rotate2 = 0;
764
+ var scaleX2 = 1;
765
+ var scaleY2 = 1;
766
+ switch (orientation) {
767
+ // Flip horizontal
768
+ case 2:
769
+ scaleX2 = -1;
770
+ break;
771
+ // Rotate left 180°
772
+ case 3:
773
+ rotate2 = -180;
774
+ break;
775
+ // Flip vertical
776
+ case 4:
777
+ scaleY2 = -1;
778
+ break;
779
+ // Flip vertical and rotate right 90°
780
+ case 5:
781
+ rotate2 = 90;
782
+ scaleY2 = -1;
783
+ break;
784
+ // Rotate right 90°
785
+ case 6:
786
+ rotate2 = 90;
787
+ break;
788
+ // Flip horizontal and rotate right 90°
789
+ case 7:
790
+ rotate2 = 90;
791
+ scaleX2 = -1;
792
+ break;
793
+ // Rotate left 90°
794
+ case 8:
795
+ rotate2 = -90;
796
+ break;
797
+ }
798
+ return {
799
+ rotate: rotate2,
800
+ scaleX: scaleX2,
801
+ scaleY: scaleY2
802
+ };
803
+ }
804
+ var render = {
805
+ render: function render2() {
806
+ this.initContainer();
807
+ this.initCanvas();
808
+ this.initCropBox();
809
+ this.renderCanvas();
810
+ if (this.cropped) {
811
+ this.renderCropBox();
812
+ }
813
+ },
814
+ initContainer: function initContainer() {
815
+ var element = this.element, options = this.options, container = this.container, cropper = this.cropper;
816
+ var minWidth = Number(options.minContainerWidth);
817
+ var minHeight = Number(options.minContainerHeight);
818
+ addClass(cropper, CLASS_HIDDEN);
819
+ removeClass(element, CLASS_HIDDEN);
820
+ var containerData = {
821
+ width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH),
822
+ height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT)
823
+ };
824
+ this.containerData = containerData;
825
+ setStyle(cropper, {
826
+ width: containerData.width,
827
+ height: containerData.height
828
+ });
829
+ addClass(element, CLASS_HIDDEN);
830
+ removeClass(cropper, CLASS_HIDDEN);
831
+ },
832
+ // Canvas (image wrapper)
833
+ initCanvas: function initCanvas() {
834
+ var containerData = this.containerData, imageData = this.imageData;
835
+ var viewMode = this.options.viewMode;
836
+ var rotated = Math.abs(imageData.rotate) % 180 === 90;
837
+ var naturalWidth = rotated ? imageData.naturalHeight : imageData.naturalWidth;
838
+ var naturalHeight = rotated ? imageData.naturalWidth : imageData.naturalHeight;
839
+ var aspectRatio = naturalWidth / naturalHeight;
840
+ var canvasWidth = containerData.width;
841
+ var canvasHeight = containerData.height;
842
+ if (containerData.height * aspectRatio > containerData.width) {
843
+ if (viewMode === 3) {
844
+ canvasWidth = containerData.height * aspectRatio;
845
+ } else {
846
+ canvasHeight = containerData.width / aspectRatio;
847
+ }
848
+ } else if (viewMode === 3) {
849
+ canvasHeight = containerData.width / aspectRatio;
850
+ } else {
851
+ canvasWidth = containerData.height * aspectRatio;
852
+ }
853
+ var canvasData = {
854
+ aspectRatio,
855
+ naturalWidth,
856
+ naturalHeight,
857
+ width: canvasWidth,
858
+ height: canvasHeight
859
+ };
860
+ this.canvasData = canvasData;
861
+ this.limited = viewMode === 1 || viewMode === 2;
862
+ this.limitCanvas(true, true);
863
+ canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
864
+ canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
865
+ canvasData.left = (containerData.width - canvasData.width) / 2;
866
+ canvasData.top = (containerData.height - canvasData.height) / 2;
867
+ canvasData.oldLeft = canvasData.left;
868
+ canvasData.oldTop = canvasData.top;
869
+ this.initialCanvasData = assign({}, canvasData);
870
+ },
871
+ limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
872
+ var options = this.options, containerData = this.containerData, canvasData = this.canvasData, cropBoxData = this.cropBoxData;
873
+ var viewMode = options.viewMode;
874
+ var aspectRatio = canvasData.aspectRatio;
875
+ var cropped = this.cropped && cropBoxData;
876
+ if (sizeLimited) {
877
+ var minCanvasWidth = Number(options.minCanvasWidth) || 0;
878
+ var minCanvasHeight = Number(options.minCanvasHeight) || 0;
879
+ if (viewMode > 1) {
880
+ minCanvasWidth = Math.max(minCanvasWidth, containerData.width);
881
+ minCanvasHeight = Math.max(minCanvasHeight, containerData.height);
882
+ if (viewMode === 3) {
883
+ if (minCanvasHeight * aspectRatio > minCanvasWidth) {
884
+ minCanvasWidth = minCanvasHeight * aspectRatio;
885
+ } else {
886
+ minCanvasHeight = minCanvasWidth / aspectRatio;
887
+ }
888
+ }
889
+ } else if (viewMode > 0) {
890
+ if (minCanvasWidth) {
891
+ minCanvasWidth = Math.max(minCanvasWidth, cropped ? cropBoxData.width : 0);
892
+ } else if (minCanvasHeight) {
893
+ minCanvasHeight = Math.max(minCanvasHeight, cropped ? cropBoxData.height : 0);
894
+ } else if (cropped) {
895
+ minCanvasWidth = cropBoxData.width;
896
+ minCanvasHeight = cropBoxData.height;
897
+ if (minCanvasHeight * aspectRatio > minCanvasWidth) {
898
+ minCanvasWidth = minCanvasHeight * aspectRatio;
899
+ } else {
900
+ minCanvasHeight = minCanvasWidth / aspectRatio;
901
+ }
902
+ }
903
+ }
904
+ var _getAdjustedSizes = getAdjustedSizes({
905
+ aspectRatio,
906
+ width: minCanvasWidth,
907
+ height: minCanvasHeight
908
+ });
909
+ minCanvasWidth = _getAdjustedSizes.width;
910
+ minCanvasHeight = _getAdjustedSizes.height;
911
+ canvasData.minWidth = minCanvasWidth;
912
+ canvasData.minHeight = minCanvasHeight;
913
+ canvasData.maxWidth = Infinity;
914
+ canvasData.maxHeight = Infinity;
915
+ }
916
+ if (positionLimited) {
917
+ if (viewMode > (cropped ? 0 : 1)) {
918
+ var newCanvasLeft = containerData.width - canvasData.width;
919
+ var newCanvasTop = containerData.height - canvasData.height;
920
+ canvasData.minLeft = Math.min(0, newCanvasLeft);
921
+ canvasData.minTop = Math.min(0, newCanvasTop);
922
+ canvasData.maxLeft = Math.max(0, newCanvasLeft);
923
+ canvasData.maxTop = Math.max(0, newCanvasTop);
924
+ if (cropped && this.limited) {
925
+ canvasData.minLeft = Math.min(cropBoxData.left, cropBoxData.left + (cropBoxData.width - canvasData.width));
926
+ canvasData.minTop = Math.min(cropBoxData.top, cropBoxData.top + (cropBoxData.height - canvasData.height));
927
+ canvasData.maxLeft = cropBoxData.left;
928
+ canvasData.maxTop = cropBoxData.top;
929
+ if (viewMode === 2) {
930
+ if (canvasData.width >= containerData.width) {
931
+ canvasData.minLeft = Math.min(0, newCanvasLeft);
932
+ canvasData.maxLeft = Math.max(0, newCanvasLeft);
933
+ }
934
+ if (canvasData.height >= containerData.height) {
935
+ canvasData.minTop = Math.min(0, newCanvasTop);
936
+ canvasData.maxTop = Math.max(0, newCanvasTop);
937
+ }
938
+ }
939
+ }
940
+ } else {
941
+ canvasData.minLeft = -canvasData.width;
942
+ canvasData.minTop = -canvasData.height;
943
+ canvasData.maxLeft = containerData.width;
944
+ canvasData.maxTop = containerData.height;
945
+ }
946
+ }
947
+ },
948
+ renderCanvas: function renderCanvas(changed, transformed) {
949
+ var canvasData = this.canvasData, imageData = this.imageData;
950
+ if (transformed) {
951
+ var _getRotatedSizes = getRotatedSizes({
952
+ width: imageData.naturalWidth * Math.abs(imageData.scaleX || 1),
953
+ height: imageData.naturalHeight * Math.abs(imageData.scaleY || 1),
954
+ degree: imageData.rotate || 0
955
+ }), naturalWidth = _getRotatedSizes.width, naturalHeight = _getRotatedSizes.height;
956
+ var width = canvasData.width * (naturalWidth / canvasData.naturalWidth);
957
+ var height = canvasData.height * (naturalHeight / canvasData.naturalHeight);
958
+ canvasData.left -= (width - canvasData.width) / 2;
959
+ canvasData.top -= (height - canvasData.height) / 2;
960
+ canvasData.width = width;
961
+ canvasData.height = height;
962
+ canvasData.aspectRatio = naturalWidth / naturalHeight;
963
+ canvasData.naturalWidth = naturalWidth;
964
+ canvasData.naturalHeight = naturalHeight;
965
+ this.limitCanvas(true, false);
966
+ }
967
+ if (canvasData.width > canvasData.maxWidth || canvasData.width < canvasData.minWidth) {
968
+ canvasData.left = canvasData.oldLeft;
969
+ }
970
+ if (canvasData.height > canvasData.maxHeight || canvasData.height < canvasData.minHeight) {
971
+ canvasData.top = canvasData.oldTop;
972
+ }
973
+ canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
974
+ canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
975
+ this.limitCanvas(false, true);
976
+ canvasData.left = Math.min(Math.max(canvasData.left, canvasData.minLeft), canvasData.maxLeft);
977
+ canvasData.top = Math.min(Math.max(canvasData.top, canvasData.minTop), canvasData.maxTop);
978
+ canvasData.oldLeft = canvasData.left;
979
+ canvasData.oldTop = canvasData.top;
980
+ setStyle(this.canvas, assign({
981
+ width: canvasData.width,
982
+ height: canvasData.height
983
+ }, getTransforms({
984
+ translateX: canvasData.left,
985
+ translateY: canvasData.top
986
+ })));
987
+ this.renderImage(changed);
988
+ if (this.cropped && this.limited) {
989
+ this.limitCropBox(true, true);
990
+ }
991
+ },
992
+ renderImage: function renderImage(changed) {
993
+ var canvasData = this.canvasData, imageData = this.imageData;
994
+ var width = imageData.naturalWidth * (canvasData.width / canvasData.naturalWidth);
995
+ var height = imageData.naturalHeight * (canvasData.height / canvasData.naturalHeight);
996
+ assign(imageData, {
997
+ width,
998
+ height,
999
+ left: (canvasData.width - width) / 2,
1000
+ top: (canvasData.height - height) / 2
1001
+ });
1002
+ setStyle(this.image, assign({
1003
+ width: imageData.width,
1004
+ height: imageData.height
1005
+ }, getTransforms(assign({
1006
+ translateX: imageData.left,
1007
+ translateY: imageData.top
1008
+ }, imageData))));
1009
+ if (changed) {
1010
+ this.output();
1011
+ }
1012
+ },
1013
+ initCropBox: function initCropBox() {
1014
+ var options = this.options, canvasData = this.canvasData;
1015
+ var aspectRatio = options.aspectRatio || options.initialAspectRatio;
1016
+ var autoCropArea = Number(options.autoCropArea) || 0.8;
1017
+ var cropBoxData = {
1018
+ width: canvasData.width,
1019
+ height: canvasData.height
1020
+ };
1021
+ if (aspectRatio) {
1022
+ if (canvasData.height * aspectRatio > canvasData.width) {
1023
+ cropBoxData.height = cropBoxData.width / aspectRatio;
1024
+ } else {
1025
+ cropBoxData.width = cropBoxData.height * aspectRatio;
1026
+ }
1027
+ }
1028
+ this.cropBoxData = cropBoxData;
1029
+ this.limitCropBox(true, true);
1030
+ cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
1031
+ cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight);
1032
+ cropBoxData.width = Math.max(cropBoxData.minWidth, cropBoxData.width * autoCropArea);
1033
+ cropBoxData.height = Math.max(cropBoxData.minHeight, cropBoxData.height * autoCropArea);
1034
+ cropBoxData.left = canvasData.left + (canvasData.width - cropBoxData.width) / 2;
1035
+ cropBoxData.top = canvasData.top + (canvasData.height - cropBoxData.height) / 2;
1036
+ cropBoxData.oldLeft = cropBoxData.left;
1037
+ cropBoxData.oldTop = cropBoxData.top;
1038
+ this.initialCropBoxData = assign({}, cropBoxData);
1039
+ },
1040
+ limitCropBox: function limitCropBox(sizeLimited, positionLimited) {
1041
+ var options = this.options, containerData = this.containerData, canvasData = this.canvasData, cropBoxData = this.cropBoxData, limited = this.limited;
1042
+ var aspectRatio = options.aspectRatio;
1043
+ if (sizeLimited) {
1044
+ var minCropBoxWidth = Number(options.minCropBoxWidth) || 0;
1045
+ var minCropBoxHeight = Number(options.minCropBoxHeight) || 0;
1046
+ var maxCropBoxWidth = limited ? Math.min(containerData.width, canvasData.width, canvasData.width + canvasData.left, containerData.width - canvasData.left) : containerData.width;
1047
+ var maxCropBoxHeight = limited ? Math.min(containerData.height, canvasData.height, canvasData.height + canvasData.top, containerData.height - canvasData.top) : containerData.height;
1048
+ minCropBoxWidth = Math.min(minCropBoxWidth, containerData.width);
1049
+ minCropBoxHeight = Math.min(minCropBoxHeight, containerData.height);
1050
+ if (aspectRatio) {
1051
+ if (minCropBoxWidth && minCropBoxHeight) {
1052
+ if (minCropBoxHeight * aspectRatio > minCropBoxWidth) {
1053
+ minCropBoxHeight = minCropBoxWidth / aspectRatio;
1054
+ } else {
1055
+ minCropBoxWidth = minCropBoxHeight * aspectRatio;
1056
+ }
1057
+ } else if (minCropBoxWidth) {
1058
+ minCropBoxHeight = minCropBoxWidth / aspectRatio;
1059
+ } else if (minCropBoxHeight) {
1060
+ minCropBoxWidth = minCropBoxHeight * aspectRatio;
1061
+ }
1062
+ if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) {
1063
+ maxCropBoxHeight = maxCropBoxWidth / aspectRatio;
1064
+ } else {
1065
+ maxCropBoxWidth = maxCropBoxHeight * aspectRatio;
1066
+ }
1067
+ }
1068
+ cropBoxData.minWidth = Math.min(minCropBoxWidth, maxCropBoxWidth);
1069
+ cropBoxData.minHeight = Math.min(minCropBoxHeight, maxCropBoxHeight);
1070
+ cropBoxData.maxWidth = maxCropBoxWidth;
1071
+ cropBoxData.maxHeight = maxCropBoxHeight;
1072
+ }
1073
+ if (positionLimited) {
1074
+ if (limited) {
1075
+ cropBoxData.minLeft = Math.max(0, canvasData.left);
1076
+ cropBoxData.minTop = Math.max(0, canvasData.top);
1077
+ cropBoxData.maxLeft = Math.min(containerData.width, canvasData.left + canvasData.width) - cropBoxData.width;
1078
+ cropBoxData.maxTop = Math.min(containerData.height, canvasData.top + canvasData.height) - cropBoxData.height;
1079
+ } else {
1080
+ cropBoxData.minLeft = 0;
1081
+ cropBoxData.minTop = 0;
1082
+ cropBoxData.maxLeft = containerData.width - cropBoxData.width;
1083
+ cropBoxData.maxTop = containerData.height - cropBoxData.height;
1084
+ }
1085
+ }
1086
+ },
1087
+ renderCropBox: function renderCropBox() {
1088
+ var options = this.options, containerData = this.containerData, cropBoxData = this.cropBoxData;
1089
+ if (cropBoxData.width > cropBoxData.maxWidth || cropBoxData.width < cropBoxData.minWidth) {
1090
+ cropBoxData.left = cropBoxData.oldLeft;
1091
+ }
1092
+ if (cropBoxData.height > cropBoxData.maxHeight || cropBoxData.height < cropBoxData.minHeight) {
1093
+ cropBoxData.top = cropBoxData.oldTop;
1094
+ }
1095
+ cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
1096
+ cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight);
1097
+ this.limitCropBox(false, true);
1098
+ cropBoxData.left = Math.min(Math.max(cropBoxData.left, cropBoxData.minLeft), cropBoxData.maxLeft);
1099
+ cropBoxData.top = Math.min(Math.max(cropBoxData.top, cropBoxData.minTop), cropBoxData.maxTop);
1100
+ cropBoxData.oldLeft = cropBoxData.left;
1101
+ cropBoxData.oldTop = cropBoxData.top;
1102
+ if (options.movable && options.cropBoxMovable) {
1103
+ setData(this.face, DATA_ACTION, cropBoxData.width >= containerData.width && cropBoxData.height >= containerData.height ? ACTION_MOVE : ACTION_ALL);
1104
+ }
1105
+ setStyle(this.cropBox, assign({
1106
+ width: cropBoxData.width,
1107
+ height: cropBoxData.height
1108
+ }, getTransforms({
1109
+ translateX: cropBoxData.left,
1110
+ translateY: cropBoxData.top
1111
+ })));
1112
+ if (this.cropped && this.limited) {
1113
+ this.limitCanvas(true, true);
1114
+ }
1115
+ if (!this.disabled) {
1116
+ this.output();
1117
+ }
1118
+ },
1119
+ output: function output() {
1120
+ this.preview();
1121
+ dispatchEvent(this.element, EVENT_CROP, this.getData());
1122
+ }
1123
+ };
1124
+ var preview = {
1125
+ initPreview: function initPreview() {
1126
+ var element = this.element, crossOrigin = this.crossOrigin;
1127
+ var preview3 = this.options.preview;
1128
+ var url = crossOrigin ? this.crossOriginUrl : this.url;
1129
+ var alt = element.alt || "The image to preview";
1130
+ var image = document.createElement("img");
1131
+ if (crossOrigin) {
1132
+ image.crossOrigin = crossOrigin;
1133
+ }
1134
+ image.src = url;
1135
+ image.alt = alt;
1136
+ this.viewBox.appendChild(image);
1137
+ this.viewBoxImage = image;
1138
+ if (!preview3) {
1139
+ return;
1140
+ }
1141
+ var previews = preview3;
1142
+ if (typeof preview3 === "string") {
1143
+ previews = element.ownerDocument.querySelectorAll(preview3);
1144
+ } else if (preview3.querySelector) {
1145
+ previews = [preview3];
1146
+ }
1147
+ this.previews = previews;
1148
+ forEach(previews, function(el) {
1149
+ var img = document.createElement("img");
1150
+ setData(el, DATA_PREVIEW, {
1151
+ width: el.offsetWidth,
1152
+ height: el.offsetHeight,
1153
+ html: el.innerHTML
1154
+ });
1155
+ if (crossOrigin) {
1156
+ img.crossOrigin = crossOrigin;
1157
+ }
1158
+ img.src = url;
1159
+ img.alt = alt;
1160
+ img.style.cssText = 'display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"';
1161
+ el.innerHTML = "";
1162
+ el.appendChild(img);
1163
+ });
1164
+ },
1165
+ resetPreview: function resetPreview() {
1166
+ forEach(this.previews, function(element) {
1167
+ var data = getData(element, DATA_PREVIEW);
1168
+ setStyle(element, {
1169
+ width: data.width,
1170
+ height: data.height
1171
+ });
1172
+ element.innerHTML = data.html;
1173
+ removeData(element, DATA_PREVIEW);
1174
+ });
1175
+ },
1176
+ preview: function preview2() {
1177
+ var imageData = this.imageData, canvasData = this.canvasData, cropBoxData = this.cropBoxData;
1178
+ var cropBoxWidth = cropBoxData.width, cropBoxHeight = cropBoxData.height;
1179
+ var width = imageData.width, height = imageData.height;
1180
+ var left = cropBoxData.left - canvasData.left - imageData.left;
1181
+ var top = cropBoxData.top - canvasData.top - imageData.top;
1182
+ if (!this.cropped || this.disabled) {
1183
+ return;
1184
+ }
1185
+ setStyle(this.viewBoxImage, assign({
1186
+ width,
1187
+ height
1188
+ }, getTransforms(assign({
1189
+ translateX: -left,
1190
+ translateY: -top
1191
+ }, imageData))));
1192
+ forEach(this.previews, function(element) {
1193
+ var data = getData(element, DATA_PREVIEW);
1194
+ var originalWidth = data.width;
1195
+ var originalHeight = data.height;
1196
+ var newWidth = originalWidth;
1197
+ var newHeight = originalHeight;
1198
+ var ratio = 1;
1199
+ if (cropBoxWidth) {
1200
+ ratio = originalWidth / cropBoxWidth;
1201
+ newHeight = cropBoxHeight * ratio;
1202
+ }
1203
+ if (cropBoxHeight && newHeight > originalHeight) {
1204
+ ratio = originalHeight / cropBoxHeight;
1205
+ newWidth = cropBoxWidth * ratio;
1206
+ newHeight = originalHeight;
1207
+ }
1208
+ setStyle(element, {
1209
+ width: newWidth,
1210
+ height: newHeight
1211
+ });
1212
+ setStyle(element.getElementsByTagName("img")[0], assign({
1213
+ width: width * ratio,
1214
+ height: height * ratio
1215
+ }, getTransforms(assign({
1216
+ translateX: -left * ratio,
1217
+ translateY: -top * ratio
1218
+ }, imageData))));
1219
+ });
1220
+ }
1221
+ };
1222
+ var events = {
1223
+ bind: function bind() {
1224
+ var element = this.element, options = this.options, cropper = this.cropper;
1225
+ if (isFunction(options.cropstart)) {
1226
+ addListener(element, EVENT_CROP_START, options.cropstart);
1227
+ }
1228
+ if (isFunction(options.cropmove)) {
1229
+ addListener(element, EVENT_CROP_MOVE, options.cropmove);
1230
+ }
1231
+ if (isFunction(options.cropend)) {
1232
+ addListener(element, EVENT_CROP_END, options.cropend);
1233
+ }
1234
+ if (isFunction(options.crop)) {
1235
+ addListener(element, EVENT_CROP, options.crop);
1236
+ }
1237
+ if (isFunction(options.zoom)) {
1238
+ addListener(element, EVENT_ZOOM, options.zoom);
1239
+ }
1240
+ addListener(cropper, EVENT_POINTER_DOWN, this.onCropStart = this.cropStart.bind(this));
1241
+ if (options.zoomable && options.zoomOnWheel) {
1242
+ addListener(cropper, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), {
1243
+ passive: false,
1244
+ capture: true
1245
+ });
1246
+ }
1247
+ if (options.toggleDragModeOnDblclick) {
1248
+ addListener(cropper, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this));
1249
+ }
1250
+ addListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove = this.cropMove.bind(this));
1251
+ addListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd = this.cropEnd.bind(this));
1252
+ if (options.responsive) {
1253
+ addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this));
1254
+ }
1255
+ },
1256
+ unbind: function unbind() {
1257
+ var element = this.element, options = this.options, cropper = this.cropper;
1258
+ if (isFunction(options.cropstart)) {
1259
+ removeListener(element, EVENT_CROP_START, options.cropstart);
1260
+ }
1261
+ if (isFunction(options.cropmove)) {
1262
+ removeListener(element, EVENT_CROP_MOVE, options.cropmove);
1263
+ }
1264
+ if (isFunction(options.cropend)) {
1265
+ removeListener(element, EVENT_CROP_END, options.cropend);
1266
+ }
1267
+ if (isFunction(options.crop)) {
1268
+ removeListener(element, EVENT_CROP, options.crop);
1269
+ }
1270
+ if (isFunction(options.zoom)) {
1271
+ removeListener(element, EVENT_ZOOM, options.zoom);
1272
+ }
1273
+ removeListener(cropper, EVENT_POINTER_DOWN, this.onCropStart);
1274
+ if (options.zoomable && options.zoomOnWheel) {
1275
+ removeListener(cropper, EVENT_WHEEL, this.onWheel, {
1276
+ passive: false,
1277
+ capture: true
1278
+ });
1279
+ }
1280
+ if (options.toggleDragModeOnDblclick) {
1281
+ removeListener(cropper, EVENT_DBLCLICK, this.onDblclick);
1282
+ }
1283
+ removeListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove);
1284
+ removeListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd);
1285
+ if (options.responsive) {
1286
+ removeListener(window, EVENT_RESIZE, this.onResize);
1287
+ }
1288
+ }
1289
+ };
1290
+ var handlers = {
1291
+ resize: function resize() {
1292
+ if (this.disabled) {
1293
+ return;
1294
+ }
1295
+ var options = this.options, container = this.container, containerData = this.containerData;
1296
+ var ratioX = container.offsetWidth / containerData.width;
1297
+ var ratioY = container.offsetHeight / containerData.height;
1298
+ var ratio = Math.abs(ratioX - 1) > Math.abs(ratioY - 1) ? ratioX : ratioY;
1299
+ if (ratio !== 1) {
1300
+ var canvasData;
1301
+ var cropBoxData;
1302
+ if (options.restore) {
1303
+ canvasData = this.getCanvasData();
1304
+ cropBoxData = this.getCropBoxData();
1305
+ }
1306
+ this.render();
1307
+ if (options.restore) {
1308
+ this.setCanvasData(forEach(canvasData, function(n, i) {
1309
+ canvasData[i] = n * ratio;
1310
+ }));
1311
+ this.setCropBoxData(forEach(cropBoxData, function(n, i) {
1312
+ cropBoxData[i] = n * ratio;
1313
+ }));
1314
+ }
1315
+ }
1316
+ },
1317
+ dblclick: function dblclick() {
1318
+ if (this.disabled || this.options.dragMode === DRAG_MODE_NONE) {
1319
+ return;
1320
+ }
1321
+ this.setDragMode(hasClass(this.dragBox, CLASS_CROP) ? DRAG_MODE_MOVE : DRAG_MODE_CROP);
1322
+ },
1323
+ wheel: function wheel(event) {
1324
+ var _this = this;
1325
+ var ratio = Number(this.options.wheelZoomRatio) || 0.1;
1326
+ var delta = 1;
1327
+ if (this.disabled) {
1328
+ return;
1329
+ }
1330
+ event.preventDefault();
1331
+ if (this.wheeling) {
1332
+ return;
1333
+ }
1334
+ this.wheeling = true;
1335
+ setTimeout(function() {
1336
+ _this.wheeling = false;
1337
+ }, 50);
1338
+ if (event.deltaY) {
1339
+ delta = event.deltaY > 0 ? 1 : -1;
1340
+ } else if (event.wheelDelta) {
1341
+ delta = -event.wheelDelta / 120;
1342
+ } else if (event.detail) {
1343
+ delta = event.detail > 0 ? 1 : -1;
1344
+ }
1345
+ this.zoom(-delta * ratio, event);
1346
+ },
1347
+ cropStart: function cropStart(event) {
1348
+ var buttons = event.buttons, button = event.button;
1349
+ if (this.disabled || (event.type === "mousedown" || event.type === "pointerdown" && event.pointerType === "mouse") && // No primary button (Usually the left button)
1350
+ (isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0 || event.ctrlKey)) {
1351
+ return;
1352
+ }
1353
+ var options = this.options, pointers = this.pointers;
1354
+ var action;
1355
+ if (event.changedTouches) {
1356
+ forEach(event.changedTouches, function(touch) {
1357
+ pointers[touch.identifier] = getPointer(touch);
1358
+ });
1359
+ } else {
1360
+ pointers[event.pointerId || 0] = getPointer(event);
1361
+ }
1362
+ if (Object.keys(pointers).length > 1 && options.zoomable && options.zoomOnTouch) {
1363
+ action = ACTION_ZOOM;
1364
+ } else {
1365
+ action = getData(event.target, DATA_ACTION);
1366
+ }
1367
+ if (!REGEXP_ACTIONS.test(action)) {
1368
+ return;
1369
+ }
1370
+ if (dispatchEvent(this.element, EVENT_CROP_START, {
1371
+ originalEvent: event,
1372
+ action
1373
+ }) === false) {
1374
+ return;
1375
+ }
1376
+ event.preventDefault();
1377
+ this.action = action;
1378
+ this.cropping = false;
1379
+ if (action === ACTION_CROP) {
1380
+ this.cropping = true;
1381
+ addClass(this.dragBox, CLASS_MODAL);
1382
+ }
1383
+ },
1384
+ cropMove: function cropMove(event) {
1385
+ var action = this.action;
1386
+ if (this.disabled || !action) {
1387
+ return;
1388
+ }
1389
+ var pointers = this.pointers;
1390
+ event.preventDefault();
1391
+ if (dispatchEvent(this.element, EVENT_CROP_MOVE, {
1392
+ originalEvent: event,
1393
+ action
1394
+ }) === false) {
1395
+ return;
1396
+ }
1397
+ if (event.changedTouches) {
1398
+ forEach(event.changedTouches, function(touch) {
1399
+ assign(pointers[touch.identifier] || {}, getPointer(touch, true));
1400
+ });
1401
+ } else {
1402
+ assign(pointers[event.pointerId || 0] || {}, getPointer(event, true));
1403
+ }
1404
+ this.change(event);
1405
+ },
1406
+ cropEnd: function cropEnd(event) {
1407
+ if (this.disabled) {
1408
+ return;
1409
+ }
1410
+ var action = this.action, pointers = this.pointers;
1411
+ if (event.changedTouches) {
1412
+ forEach(event.changedTouches, function(touch) {
1413
+ delete pointers[touch.identifier];
1414
+ });
1415
+ } else {
1416
+ delete pointers[event.pointerId || 0];
1417
+ }
1418
+ if (!action) {
1419
+ return;
1420
+ }
1421
+ event.preventDefault();
1422
+ if (!Object.keys(pointers).length) {
1423
+ this.action = "";
1424
+ }
1425
+ if (this.cropping) {
1426
+ this.cropping = false;
1427
+ toggleClass(this.dragBox, CLASS_MODAL, this.cropped && this.options.modal);
1428
+ }
1429
+ dispatchEvent(this.element, EVENT_CROP_END, {
1430
+ originalEvent: event,
1431
+ action
1432
+ });
1433
+ }
1434
+ };
1435
+ var change = {
1436
+ change: function change2(event) {
1437
+ var options = this.options, canvasData = this.canvasData, containerData = this.containerData, cropBoxData = this.cropBoxData, pointers = this.pointers;
1438
+ var action = this.action;
1439
+ var aspectRatio = options.aspectRatio;
1440
+ var left = cropBoxData.left, top = cropBoxData.top, width = cropBoxData.width, height = cropBoxData.height;
1441
+ var right = left + width;
1442
+ var bottom = top + height;
1443
+ var minLeft = 0;
1444
+ var minTop = 0;
1445
+ var maxWidth = containerData.width;
1446
+ var maxHeight = containerData.height;
1447
+ var renderable = true;
1448
+ var offset;
1449
+ if (!aspectRatio && event.shiftKey) {
1450
+ aspectRatio = width && height ? width / height : 1;
1451
+ }
1452
+ if (this.limited) {
1453
+ minLeft = cropBoxData.minLeft;
1454
+ minTop = cropBoxData.minTop;
1455
+ maxWidth = minLeft + Math.min(containerData.width, canvasData.width, canvasData.left + canvasData.width);
1456
+ maxHeight = minTop + Math.min(containerData.height, canvasData.height, canvasData.top + canvasData.height);
1457
+ }
1458
+ var pointer = pointers[Object.keys(pointers)[0]];
1459
+ var range = {
1460
+ x: pointer.endX - pointer.startX,
1461
+ y: pointer.endY - pointer.startY
1462
+ };
1463
+ var check = function check2(side) {
1464
+ switch (side) {
1465
+ case ACTION_EAST:
1466
+ if (right + range.x > maxWidth) {
1467
+ range.x = maxWidth - right;
1468
+ }
1469
+ break;
1470
+ case ACTION_WEST:
1471
+ if (left + range.x < minLeft) {
1472
+ range.x = minLeft - left;
1473
+ }
1474
+ break;
1475
+ case ACTION_NORTH:
1476
+ if (top + range.y < minTop) {
1477
+ range.y = minTop - top;
1478
+ }
1479
+ break;
1480
+ case ACTION_SOUTH:
1481
+ if (bottom + range.y > maxHeight) {
1482
+ range.y = maxHeight - bottom;
1483
+ }
1484
+ break;
1485
+ }
1486
+ };
1487
+ switch (action) {
1488
+ // Move crop box
1489
+ case ACTION_ALL:
1490
+ left += range.x;
1491
+ top += range.y;
1492
+ break;
1493
+ // Resize crop box
1494
+ case ACTION_EAST:
1495
+ if (range.x >= 0 && (right >= maxWidth || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
1496
+ renderable = false;
1497
+ break;
1498
+ }
1499
+ check(ACTION_EAST);
1500
+ width += range.x;
1501
+ if (width < 0) {
1502
+ action = ACTION_WEST;
1503
+ width = -width;
1504
+ left -= width;
1505
+ }
1506
+ if (aspectRatio) {
1507
+ height = width / aspectRatio;
1508
+ top += (cropBoxData.height - height) / 2;
1509
+ }
1510
+ break;
1511
+ case ACTION_NORTH:
1512
+ if (range.y <= 0 && (top <= minTop || aspectRatio && (left <= minLeft || right >= maxWidth))) {
1513
+ renderable = false;
1514
+ break;
1515
+ }
1516
+ check(ACTION_NORTH);
1517
+ height -= range.y;
1518
+ top += range.y;
1519
+ if (height < 0) {
1520
+ action = ACTION_SOUTH;
1521
+ height = -height;
1522
+ top -= height;
1523
+ }
1524
+ if (aspectRatio) {
1525
+ width = height * aspectRatio;
1526
+ left += (cropBoxData.width - width) / 2;
1527
+ }
1528
+ break;
1529
+ case ACTION_WEST:
1530
+ if (range.x <= 0 && (left <= minLeft || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
1531
+ renderable = false;
1532
+ break;
1533
+ }
1534
+ check(ACTION_WEST);
1535
+ width -= range.x;
1536
+ left += range.x;
1537
+ if (width < 0) {
1538
+ action = ACTION_EAST;
1539
+ width = -width;
1540
+ left -= width;
1541
+ }
1542
+ if (aspectRatio) {
1543
+ height = width / aspectRatio;
1544
+ top += (cropBoxData.height - height) / 2;
1545
+ }
1546
+ break;
1547
+ case ACTION_SOUTH:
1548
+ if (range.y >= 0 && (bottom >= maxHeight || aspectRatio && (left <= minLeft || right >= maxWidth))) {
1549
+ renderable = false;
1550
+ break;
1551
+ }
1552
+ check(ACTION_SOUTH);
1553
+ height += range.y;
1554
+ if (height < 0) {
1555
+ action = ACTION_NORTH;
1556
+ height = -height;
1557
+ top -= height;
1558
+ }
1559
+ if (aspectRatio) {
1560
+ width = height * aspectRatio;
1561
+ left += (cropBoxData.width - width) / 2;
1562
+ }
1563
+ break;
1564
+ case ACTION_NORTH_EAST:
1565
+ if (aspectRatio) {
1566
+ if (range.y <= 0 && (top <= minTop || right >= maxWidth)) {
1567
+ renderable = false;
1568
+ break;
1569
+ }
1570
+ check(ACTION_NORTH);
1571
+ height -= range.y;
1572
+ top += range.y;
1573
+ width = height * aspectRatio;
1574
+ } else {
1575
+ check(ACTION_NORTH);
1576
+ check(ACTION_EAST);
1577
+ if (range.x >= 0) {
1578
+ if (right < maxWidth) {
1579
+ width += range.x;
1580
+ } else if (range.y <= 0 && top <= minTop) {
1581
+ renderable = false;
1582
+ }
1583
+ } else {
1584
+ width += range.x;
1585
+ }
1586
+ if (range.y <= 0) {
1587
+ if (top > minTop) {
1588
+ height -= range.y;
1589
+ top += range.y;
1590
+ }
1591
+ } else {
1592
+ height -= range.y;
1593
+ top += range.y;
1594
+ }
1595
+ }
1596
+ if (width < 0 && height < 0) {
1597
+ action = ACTION_SOUTH_WEST;
1598
+ height = -height;
1599
+ width = -width;
1600
+ top -= height;
1601
+ left -= width;
1602
+ } else if (width < 0) {
1603
+ action = ACTION_NORTH_WEST;
1604
+ width = -width;
1605
+ left -= width;
1606
+ } else if (height < 0) {
1607
+ action = ACTION_SOUTH_EAST;
1608
+ height = -height;
1609
+ top -= height;
1610
+ }
1611
+ break;
1612
+ case ACTION_NORTH_WEST:
1613
+ if (aspectRatio) {
1614
+ if (range.y <= 0 && (top <= minTop || left <= minLeft)) {
1615
+ renderable = false;
1616
+ break;
1617
+ }
1618
+ check(ACTION_NORTH);
1619
+ height -= range.y;
1620
+ top += range.y;
1621
+ width = height * aspectRatio;
1622
+ left += cropBoxData.width - width;
1623
+ } else {
1624
+ check(ACTION_NORTH);
1625
+ check(ACTION_WEST);
1626
+ if (range.x <= 0) {
1627
+ if (left > minLeft) {
1628
+ width -= range.x;
1629
+ left += range.x;
1630
+ } else if (range.y <= 0 && top <= minTop) {
1631
+ renderable = false;
1632
+ }
1633
+ } else {
1634
+ width -= range.x;
1635
+ left += range.x;
1636
+ }
1637
+ if (range.y <= 0) {
1638
+ if (top > minTop) {
1639
+ height -= range.y;
1640
+ top += range.y;
1641
+ }
1642
+ } else {
1643
+ height -= range.y;
1644
+ top += range.y;
1645
+ }
1646
+ }
1647
+ if (width < 0 && height < 0) {
1648
+ action = ACTION_SOUTH_EAST;
1649
+ height = -height;
1650
+ width = -width;
1651
+ top -= height;
1652
+ left -= width;
1653
+ } else if (width < 0) {
1654
+ action = ACTION_NORTH_EAST;
1655
+ width = -width;
1656
+ left -= width;
1657
+ } else if (height < 0) {
1658
+ action = ACTION_SOUTH_WEST;
1659
+ height = -height;
1660
+ top -= height;
1661
+ }
1662
+ break;
1663
+ case ACTION_SOUTH_WEST:
1664
+ if (aspectRatio) {
1665
+ if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) {
1666
+ renderable = false;
1667
+ break;
1668
+ }
1669
+ check(ACTION_WEST);
1670
+ width -= range.x;
1671
+ left += range.x;
1672
+ height = width / aspectRatio;
1673
+ } else {
1674
+ check(ACTION_SOUTH);
1675
+ check(ACTION_WEST);
1676
+ if (range.x <= 0) {
1677
+ if (left > minLeft) {
1678
+ width -= range.x;
1679
+ left += range.x;
1680
+ } else if (range.y >= 0 && bottom >= maxHeight) {
1681
+ renderable = false;
1682
+ }
1683
+ } else {
1684
+ width -= range.x;
1685
+ left += range.x;
1686
+ }
1687
+ if (range.y >= 0) {
1688
+ if (bottom < maxHeight) {
1689
+ height += range.y;
1690
+ }
1691
+ } else {
1692
+ height += range.y;
1693
+ }
1694
+ }
1695
+ if (width < 0 && height < 0) {
1696
+ action = ACTION_NORTH_EAST;
1697
+ height = -height;
1698
+ width = -width;
1699
+ top -= height;
1700
+ left -= width;
1701
+ } else if (width < 0) {
1702
+ action = ACTION_SOUTH_EAST;
1703
+ width = -width;
1704
+ left -= width;
1705
+ } else if (height < 0) {
1706
+ action = ACTION_NORTH_WEST;
1707
+ height = -height;
1708
+ top -= height;
1709
+ }
1710
+ break;
1711
+ case ACTION_SOUTH_EAST:
1712
+ if (aspectRatio) {
1713
+ if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) {
1714
+ renderable = false;
1715
+ break;
1716
+ }
1717
+ check(ACTION_EAST);
1718
+ width += range.x;
1719
+ height = width / aspectRatio;
1720
+ } else {
1721
+ check(ACTION_SOUTH);
1722
+ check(ACTION_EAST);
1723
+ if (range.x >= 0) {
1724
+ if (right < maxWidth) {
1725
+ width += range.x;
1726
+ } else if (range.y >= 0 && bottom >= maxHeight) {
1727
+ renderable = false;
1728
+ }
1729
+ } else {
1730
+ width += range.x;
1731
+ }
1732
+ if (range.y >= 0) {
1733
+ if (bottom < maxHeight) {
1734
+ height += range.y;
1735
+ }
1736
+ } else {
1737
+ height += range.y;
1738
+ }
1739
+ }
1740
+ if (width < 0 && height < 0) {
1741
+ action = ACTION_NORTH_WEST;
1742
+ height = -height;
1743
+ width = -width;
1744
+ top -= height;
1745
+ left -= width;
1746
+ } else if (width < 0) {
1747
+ action = ACTION_SOUTH_WEST;
1748
+ width = -width;
1749
+ left -= width;
1750
+ } else if (height < 0) {
1751
+ action = ACTION_NORTH_EAST;
1752
+ height = -height;
1753
+ top -= height;
1754
+ }
1755
+ break;
1756
+ // Move canvas
1757
+ case ACTION_MOVE:
1758
+ this.move(range.x, range.y);
1759
+ renderable = false;
1760
+ break;
1761
+ // Zoom canvas
1762
+ case ACTION_ZOOM:
1763
+ this.zoom(getMaxZoomRatio(pointers), event);
1764
+ renderable = false;
1765
+ break;
1766
+ // Create crop box
1767
+ case ACTION_CROP:
1768
+ if (!range.x || !range.y) {
1769
+ renderable = false;
1770
+ break;
1771
+ }
1772
+ offset = getOffset(this.cropper);
1773
+ left = pointer.startX - offset.left;
1774
+ top = pointer.startY - offset.top;
1775
+ width = cropBoxData.minWidth;
1776
+ height = cropBoxData.minHeight;
1777
+ if (range.x > 0) {
1778
+ action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST;
1779
+ } else if (range.x < 0) {
1780
+ left -= width;
1781
+ action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST;
1782
+ }
1783
+ if (range.y < 0) {
1784
+ top -= height;
1785
+ }
1786
+ if (!this.cropped) {
1787
+ removeClass(this.cropBox, CLASS_HIDDEN);
1788
+ this.cropped = true;
1789
+ if (this.limited) {
1790
+ this.limitCropBox(true, true);
1791
+ }
1792
+ }
1793
+ break;
1794
+ }
1795
+ if (renderable) {
1796
+ cropBoxData.width = width;
1797
+ cropBoxData.height = height;
1798
+ cropBoxData.left = left;
1799
+ cropBoxData.top = top;
1800
+ this.action = action;
1801
+ this.renderCropBox();
1802
+ }
1803
+ forEach(pointers, function(p) {
1804
+ p.startX = p.endX;
1805
+ p.startY = p.endY;
1806
+ });
1807
+ }
1808
+ };
1809
+ var methods = {
1810
+ // Show the crop box manually
1811
+ crop: function crop() {
1812
+ if (this.ready && !this.cropped && !this.disabled) {
1813
+ this.cropped = true;
1814
+ this.limitCropBox(true, true);
1815
+ if (this.options.modal) {
1816
+ addClass(this.dragBox, CLASS_MODAL);
1817
+ }
1818
+ removeClass(this.cropBox, CLASS_HIDDEN);
1819
+ this.setCropBoxData(this.initialCropBoxData);
1820
+ }
1821
+ return this;
1822
+ },
1823
+ // Reset the image and crop box to their initial states
1824
+ reset: function reset() {
1825
+ if (this.ready && !this.disabled) {
1826
+ this.imageData = assign({}, this.initialImageData);
1827
+ this.canvasData = assign({}, this.initialCanvasData);
1828
+ this.cropBoxData = assign({}, this.initialCropBoxData);
1829
+ this.renderCanvas();
1830
+ if (this.cropped) {
1831
+ this.renderCropBox();
1832
+ }
1833
+ }
1834
+ return this;
1835
+ },
1836
+ // Clear the crop box
1837
+ clear: function clear() {
1838
+ if (this.cropped && !this.disabled) {
1839
+ assign(this.cropBoxData, {
1840
+ left: 0,
1841
+ top: 0,
1842
+ width: 0,
1843
+ height: 0
1844
+ });
1845
+ this.cropped = false;
1846
+ this.renderCropBox();
1847
+ this.limitCanvas(true, true);
1848
+ this.renderCanvas();
1849
+ removeClass(this.dragBox, CLASS_MODAL);
1850
+ addClass(this.cropBox, CLASS_HIDDEN);
1851
+ }
1852
+ return this;
1853
+ },
1854
+ /**
1855
+ * Replace the image's src and rebuild the cropper
1856
+ * @param {string} url - The new URL.
1857
+ * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one.
1858
+ * @returns {Cropper} this
1859
+ */
1860
+ replace: function replace(url) {
1861
+ var hasSameSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1862
+ if (!this.disabled && url) {
1863
+ if (this.isImg) {
1864
+ this.element.src = url;
1865
+ }
1866
+ if (hasSameSize) {
1867
+ this.url = url;
1868
+ this.image.src = url;
1869
+ if (this.ready) {
1870
+ this.viewBoxImage.src = url;
1871
+ forEach(this.previews, function(element) {
1872
+ element.getElementsByTagName("img")[0].src = url;
1873
+ });
1874
+ }
1875
+ } else {
1876
+ if (this.isImg) {
1877
+ this.replaced = true;
1878
+ }
1879
+ this.options.data = null;
1880
+ this.uncreate();
1881
+ this.load(url);
1882
+ }
1883
+ }
1884
+ return this;
1885
+ },
1886
+ // Enable (unfreeze) the cropper
1887
+ enable: function enable() {
1888
+ if (this.ready && this.disabled) {
1889
+ this.disabled = false;
1890
+ removeClass(this.cropper, CLASS_DISABLED);
1891
+ }
1892
+ return this;
1893
+ },
1894
+ // Disable (freeze) the cropper
1895
+ disable: function disable() {
1896
+ if (this.ready && !this.disabled) {
1897
+ this.disabled = true;
1898
+ addClass(this.cropper, CLASS_DISABLED);
1899
+ }
1900
+ return this;
1901
+ },
1902
+ /**
1903
+ * Destroy the cropper and remove the instance from the image
1904
+ * @returns {Cropper} this
1905
+ */
1906
+ destroy: function destroy() {
1907
+ var element = this.element;
1908
+ if (!element[NAMESPACE]) {
1909
+ return this;
1910
+ }
1911
+ element[NAMESPACE] = void 0;
1912
+ if (this.isImg && this.replaced) {
1913
+ element.src = this.originalUrl;
1914
+ }
1915
+ this.uncreate();
1916
+ return this;
1917
+ },
1918
+ /**
1919
+ * Move the canvas with relative offsets
1920
+ * @param {number} offsetX - The relative offset distance on the x-axis.
1921
+ * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis.
1922
+ * @returns {Cropper} this
1923
+ */
1924
+ move: function move(offsetX) {
1925
+ var offsetY = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : offsetX;
1926
+ var _this$canvasData = this.canvasData, left = _this$canvasData.left, top = _this$canvasData.top;
1927
+ return this.moveTo(isUndefined(offsetX) ? offsetX : left + Number(offsetX), isUndefined(offsetY) ? offsetY : top + Number(offsetY));
1928
+ },
1929
+ /**
1930
+ * Move the canvas to an absolute point
1931
+ * @param {number} x - The x-axis coordinate.
1932
+ * @param {number} [y=x] - The y-axis coordinate.
1933
+ * @returns {Cropper} this
1934
+ */
1935
+ moveTo: function moveTo(x) {
1936
+ var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x;
1937
+ var canvasData = this.canvasData;
1938
+ var changed = false;
1939
+ x = Number(x);
1940
+ y = Number(y);
1941
+ if (this.ready && !this.disabled && this.options.movable) {
1942
+ if (isNumber(x)) {
1943
+ canvasData.left = x;
1944
+ changed = true;
1945
+ }
1946
+ if (isNumber(y)) {
1947
+ canvasData.top = y;
1948
+ changed = true;
1949
+ }
1950
+ if (changed) {
1951
+ this.renderCanvas(true);
1952
+ }
1953
+ }
1954
+ return this;
1955
+ },
1956
+ /**
1957
+ * Zoom the canvas with a relative ratio
1958
+ * @param {number} ratio - The target ratio.
1959
+ * @param {Event} _originalEvent - The original event if any.
1960
+ * @returns {Cropper} this
1961
+ */
1962
+ zoom: function zoom(ratio, _originalEvent) {
1963
+ var canvasData = this.canvasData;
1964
+ ratio = Number(ratio);
1965
+ if (ratio < 0) {
1966
+ ratio = 1 / (1 - ratio);
1967
+ } else {
1968
+ ratio = 1 + ratio;
1969
+ }
1970
+ return this.zoomTo(canvasData.width * ratio / canvasData.naturalWidth, null, _originalEvent);
1971
+ },
1972
+ /**
1973
+ * Zoom the canvas to an absolute ratio
1974
+ * @param {number} ratio - The target ratio.
1975
+ * @param {Object} pivot - The zoom pivot point coordinate.
1976
+ * @param {Event} _originalEvent - The original event if any.
1977
+ * @returns {Cropper} this
1978
+ */
1979
+ zoomTo: function zoomTo(ratio, pivot, _originalEvent) {
1980
+ var options = this.options, canvasData = this.canvasData;
1981
+ var width = canvasData.width, height = canvasData.height, naturalWidth = canvasData.naturalWidth, naturalHeight = canvasData.naturalHeight;
1982
+ ratio = Number(ratio);
1983
+ if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
1984
+ var newWidth = naturalWidth * ratio;
1985
+ var newHeight = naturalHeight * ratio;
1986
+ if (dispatchEvent(this.element, EVENT_ZOOM, {
1987
+ ratio,
1988
+ oldRatio: width / naturalWidth,
1989
+ originalEvent: _originalEvent
1990
+ }) === false) {
1991
+ return this;
1992
+ }
1993
+ if (_originalEvent) {
1994
+ var pointers = this.pointers;
1995
+ var offset = getOffset(this.cropper);
1996
+ var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
1997
+ pageX: _originalEvent.pageX,
1998
+ pageY: _originalEvent.pageY
1999
+ };
2000
+ canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
2001
+ canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
2002
+ } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
2003
+ canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
2004
+ canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
2005
+ } else {
2006
+ canvasData.left -= (newWidth - width) / 2;
2007
+ canvasData.top -= (newHeight - height) / 2;
2008
+ }
2009
+ canvasData.width = newWidth;
2010
+ canvasData.height = newHeight;
2011
+ this.renderCanvas(true);
2012
+ }
2013
+ return this;
2014
+ },
2015
+ /**
2016
+ * Rotate the canvas with a relative degree
2017
+ * @param {number} degree - The rotate degree.
2018
+ * @returns {Cropper} this
2019
+ */
2020
+ rotate: function rotate(degree) {
2021
+ return this.rotateTo((this.imageData.rotate || 0) + Number(degree));
2022
+ },
2023
+ /**
2024
+ * Rotate the canvas to an absolute degree
2025
+ * @param {number} degree - The rotate degree.
2026
+ * @returns {Cropper} this
2027
+ */
2028
+ rotateTo: function rotateTo(degree) {
2029
+ degree = Number(degree);
2030
+ if (isNumber(degree) && this.ready && !this.disabled && this.options.rotatable) {
2031
+ this.imageData.rotate = degree % 360;
2032
+ this.renderCanvas(true, true);
2033
+ }
2034
+ return this;
2035
+ },
2036
+ /**
2037
+ * Scale the image on the x-axis.
2038
+ * @param {number} scaleX - The scale ratio on the x-axis.
2039
+ * @returns {Cropper} this
2040
+ */
2041
+ scaleX: function scaleX(_scaleX) {
2042
+ var scaleY2 = this.imageData.scaleY;
2043
+ return this.scale(_scaleX, isNumber(scaleY2) ? scaleY2 : 1);
2044
+ },
2045
+ /**
2046
+ * Scale the image on the y-axis.
2047
+ * @param {number} scaleY - The scale ratio on the y-axis.
2048
+ * @returns {Cropper} this
2049
+ */
2050
+ scaleY: function scaleY(_scaleY) {
2051
+ var scaleX2 = this.imageData.scaleX;
2052
+ return this.scale(isNumber(scaleX2) ? scaleX2 : 1, _scaleY);
2053
+ },
2054
+ /**
2055
+ * Scale the image
2056
+ * @param {number} scaleX - The scale ratio on the x-axis.
2057
+ * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
2058
+ * @returns {Cropper} this
2059
+ */
2060
+ scale: function scale(scaleX2) {
2061
+ var scaleY2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scaleX2;
2062
+ var imageData = this.imageData;
2063
+ var transformed = false;
2064
+ scaleX2 = Number(scaleX2);
2065
+ scaleY2 = Number(scaleY2);
2066
+ if (this.ready && !this.disabled && this.options.scalable) {
2067
+ if (isNumber(scaleX2)) {
2068
+ imageData.scaleX = scaleX2;
2069
+ transformed = true;
2070
+ }
2071
+ if (isNumber(scaleY2)) {
2072
+ imageData.scaleY = scaleY2;
2073
+ transformed = true;
2074
+ }
2075
+ if (transformed) {
2076
+ this.renderCanvas(true, true);
2077
+ }
2078
+ }
2079
+ return this;
2080
+ },
2081
+ /**
2082
+ * Get the cropped area position and size data (base on the original image)
2083
+ * @param {boolean} [rounded=false] - Indicate if round the data values or not.
2084
+ * @returns {Object} The result cropped data.
2085
+ */
2086
+ getData: function getData2() {
2087
+ var rounded = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
2088
+ var options = this.options, imageData = this.imageData, canvasData = this.canvasData, cropBoxData = this.cropBoxData;
2089
+ var data;
2090
+ if (this.ready && this.cropped) {
2091
+ data = {
2092
+ x: cropBoxData.left - canvasData.left,
2093
+ y: cropBoxData.top - canvasData.top,
2094
+ width: cropBoxData.width,
2095
+ height: cropBoxData.height
2096
+ };
2097
+ var ratio = imageData.width / imageData.naturalWidth;
2098
+ forEach(data, function(n, i) {
2099
+ data[i] = n / ratio;
2100
+ });
2101
+ if (rounded) {
2102
+ var bottom = Math.round(data.y + data.height);
2103
+ var right = Math.round(data.x + data.width);
2104
+ data.x = Math.round(data.x);
2105
+ data.y = Math.round(data.y);
2106
+ data.width = right - data.x;
2107
+ data.height = bottom - data.y;
2108
+ }
2109
+ } else {
2110
+ data = {
2111
+ x: 0,
2112
+ y: 0,
2113
+ width: 0,
2114
+ height: 0
2115
+ };
2116
+ }
2117
+ if (options.rotatable) {
2118
+ data.rotate = imageData.rotate || 0;
2119
+ }
2120
+ if (options.scalable) {
2121
+ data.scaleX = imageData.scaleX || 1;
2122
+ data.scaleY = imageData.scaleY || 1;
2123
+ }
2124
+ return data;
2125
+ },
2126
+ /**
2127
+ * Set the cropped area position and size with new data
2128
+ * @param {Object} data - The new data.
2129
+ * @returns {Cropper} this
2130
+ */
2131
+ setData: function setData2(data) {
2132
+ var options = this.options, imageData = this.imageData, canvasData = this.canvasData;
2133
+ var cropBoxData = {};
2134
+ if (this.ready && !this.disabled && isPlainObject(data)) {
2135
+ var transformed = false;
2136
+ if (options.rotatable) {
2137
+ if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
2138
+ imageData.rotate = data.rotate;
2139
+ transformed = true;
2140
+ }
2141
+ }
2142
+ if (options.scalable) {
2143
+ if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
2144
+ imageData.scaleX = data.scaleX;
2145
+ transformed = true;
2146
+ }
2147
+ if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
2148
+ imageData.scaleY = data.scaleY;
2149
+ transformed = true;
2150
+ }
2151
+ }
2152
+ if (transformed) {
2153
+ this.renderCanvas(true, true);
2154
+ }
2155
+ var ratio = imageData.width / imageData.naturalWidth;
2156
+ if (isNumber(data.x)) {
2157
+ cropBoxData.left = data.x * ratio + canvasData.left;
2158
+ }
2159
+ if (isNumber(data.y)) {
2160
+ cropBoxData.top = data.y * ratio + canvasData.top;
2161
+ }
2162
+ if (isNumber(data.width)) {
2163
+ cropBoxData.width = data.width * ratio;
2164
+ }
2165
+ if (isNumber(data.height)) {
2166
+ cropBoxData.height = data.height * ratio;
2167
+ }
2168
+ this.setCropBoxData(cropBoxData);
2169
+ }
2170
+ return this;
2171
+ },
2172
+ /**
2173
+ * Get the container size data.
2174
+ * @returns {Object} The result container data.
2175
+ */
2176
+ getContainerData: function getContainerData() {
2177
+ return this.ready ? assign({}, this.containerData) : {};
2178
+ },
2179
+ /**
2180
+ * Get the image position and size data.
2181
+ * @returns {Object} The result image data.
2182
+ */
2183
+ getImageData: function getImageData() {
2184
+ return this.sized ? assign({}, this.imageData) : {};
2185
+ },
2186
+ /**
2187
+ * Get the canvas position and size data.
2188
+ * @returns {Object} The result canvas data.
2189
+ */
2190
+ getCanvasData: function getCanvasData() {
2191
+ var canvasData = this.canvasData;
2192
+ var data = {};
2193
+ if (this.ready) {
2194
+ forEach(["left", "top", "width", "height", "naturalWidth", "naturalHeight"], function(n) {
2195
+ data[n] = canvasData[n];
2196
+ });
2197
+ }
2198
+ return data;
2199
+ },
2200
+ /**
2201
+ * Set the canvas position and size with new data.
2202
+ * @param {Object} data - The new canvas data.
2203
+ * @returns {Cropper} this
2204
+ */
2205
+ setCanvasData: function setCanvasData(data) {
2206
+ var canvasData = this.canvasData;
2207
+ var aspectRatio = canvasData.aspectRatio;
2208
+ if (this.ready && !this.disabled && isPlainObject(data)) {
2209
+ if (isNumber(data.left)) {
2210
+ canvasData.left = data.left;
2211
+ }
2212
+ if (isNumber(data.top)) {
2213
+ canvasData.top = data.top;
2214
+ }
2215
+ if (isNumber(data.width)) {
2216
+ canvasData.width = data.width;
2217
+ canvasData.height = data.width / aspectRatio;
2218
+ } else if (isNumber(data.height)) {
2219
+ canvasData.height = data.height;
2220
+ canvasData.width = data.height * aspectRatio;
2221
+ }
2222
+ this.renderCanvas(true);
2223
+ }
2224
+ return this;
2225
+ },
2226
+ /**
2227
+ * Get the crop box position and size data.
2228
+ * @returns {Object} The result crop box data.
2229
+ */
2230
+ getCropBoxData: function getCropBoxData() {
2231
+ var cropBoxData = this.cropBoxData;
2232
+ var data;
2233
+ if (this.ready && this.cropped) {
2234
+ data = {
2235
+ left: cropBoxData.left,
2236
+ top: cropBoxData.top,
2237
+ width: cropBoxData.width,
2238
+ height: cropBoxData.height
2239
+ };
2240
+ }
2241
+ return data || {};
2242
+ },
2243
+ /**
2244
+ * Set the crop box position and size with new data.
2245
+ * @param {Object} data - The new crop box data.
2246
+ * @returns {Cropper} this
2247
+ */
2248
+ setCropBoxData: function setCropBoxData(data) {
2249
+ var cropBoxData = this.cropBoxData;
2250
+ var aspectRatio = this.options.aspectRatio;
2251
+ var widthChanged;
2252
+ var heightChanged;
2253
+ if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
2254
+ if (isNumber(data.left)) {
2255
+ cropBoxData.left = data.left;
2256
+ }
2257
+ if (isNumber(data.top)) {
2258
+ cropBoxData.top = data.top;
2259
+ }
2260
+ if (isNumber(data.width) && data.width !== cropBoxData.width) {
2261
+ widthChanged = true;
2262
+ cropBoxData.width = data.width;
2263
+ }
2264
+ if (isNumber(data.height) && data.height !== cropBoxData.height) {
2265
+ heightChanged = true;
2266
+ cropBoxData.height = data.height;
2267
+ }
2268
+ if (aspectRatio) {
2269
+ if (widthChanged) {
2270
+ cropBoxData.height = cropBoxData.width / aspectRatio;
2271
+ } else if (heightChanged) {
2272
+ cropBoxData.width = cropBoxData.height * aspectRatio;
2273
+ }
2274
+ }
2275
+ this.renderCropBox();
2276
+ }
2277
+ return this;
2278
+ },
2279
+ /**
2280
+ * Get a canvas drawn the cropped image.
2281
+ * @param {Object} [options={}] - The config options.
2282
+ * @returns {HTMLCanvasElement} - The result canvas.
2283
+ */
2284
+ getCroppedCanvas: function getCroppedCanvas() {
2285
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2286
+ if (!this.ready || !window.HTMLCanvasElement) {
2287
+ return null;
2288
+ }
2289
+ var canvasData = this.canvasData;
2290
+ var source = getSourceCanvas(this.image, this.imageData, canvasData, options);
2291
+ if (!this.cropped) {
2292
+ return source;
2293
+ }
2294
+ var _this$getData = this.getData(options.rounded), initialX = _this$getData.x, initialY = _this$getData.y, initialWidth = _this$getData.width, initialHeight = _this$getData.height;
2295
+ var ratio = source.width / Math.floor(canvasData.naturalWidth);
2296
+ if (ratio !== 1) {
2297
+ initialX *= ratio;
2298
+ initialY *= ratio;
2299
+ initialWidth *= ratio;
2300
+ initialHeight *= ratio;
2301
+ }
2302
+ var aspectRatio = initialWidth / initialHeight;
2303
+ var maxSizes = getAdjustedSizes({
2304
+ aspectRatio,
2305
+ width: options.maxWidth || Infinity,
2306
+ height: options.maxHeight || Infinity
2307
+ });
2308
+ var minSizes = getAdjustedSizes({
2309
+ aspectRatio,
2310
+ width: options.minWidth || 0,
2311
+ height: options.minHeight || 0
2312
+ }, "cover");
2313
+ var _getAdjustedSizes = getAdjustedSizes({
2314
+ aspectRatio,
2315
+ width: options.width || (ratio !== 1 ? source.width : initialWidth),
2316
+ height: options.height || (ratio !== 1 ? source.height : initialHeight)
2317
+ }), width = _getAdjustedSizes.width, height = _getAdjustedSizes.height;
2318
+ width = Math.min(maxSizes.width, Math.max(minSizes.width, width));
2319
+ height = Math.min(maxSizes.height, Math.max(minSizes.height, height));
2320
+ var canvas = document.createElement("canvas");
2321
+ var context = canvas.getContext("2d");
2322
+ canvas.width = normalizeDecimalNumber(width);
2323
+ canvas.height = normalizeDecimalNumber(height);
2324
+ context.fillStyle = options.fillColor || "transparent";
2325
+ context.fillRect(0, 0, width, height);
2326
+ var _options$imageSmoothi = options.imageSmoothingEnabled, imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi, imageSmoothingQuality = options.imageSmoothingQuality;
2327
+ context.imageSmoothingEnabled = imageSmoothingEnabled;
2328
+ if (imageSmoothingQuality) {
2329
+ context.imageSmoothingQuality = imageSmoothingQuality;
2330
+ }
2331
+ var sourceWidth = source.width;
2332
+ var sourceHeight = source.height;
2333
+ var srcX = initialX;
2334
+ var srcY = initialY;
2335
+ var srcWidth;
2336
+ var srcHeight;
2337
+ var dstX;
2338
+ var dstY;
2339
+ var dstWidth;
2340
+ var dstHeight;
2341
+ if (srcX <= -initialWidth || srcX > sourceWidth) {
2342
+ srcX = 0;
2343
+ srcWidth = 0;
2344
+ dstX = 0;
2345
+ dstWidth = 0;
2346
+ } else if (srcX <= 0) {
2347
+ dstX = -srcX;
2348
+ srcX = 0;
2349
+ srcWidth = Math.min(sourceWidth, initialWidth + srcX);
2350
+ dstWidth = srcWidth;
2351
+ } else if (srcX <= sourceWidth) {
2352
+ dstX = 0;
2353
+ srcWidth = Math.min(initialWidth, sourceWidth - srcX);
2354
+ dstWidth = srcWidth;
2355
+ }
2356
+ if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) {
2357
+ srcY = 0;
2358
+ srcHeight = 0;
2359
+ dstY = 0;
2360
+ dstHeight = 0;
2361
+ } else if (srcY <= 0) {
2362
+ dstY = -srcY;
2363
+ srcY = 0;
2364
+ srcHeight = Math.min(sourceHeight, initialHeight + srcY);
2365
+ dstHeight = srcHeight;
2366
+ } else if (srcY <= sourceHeight) {
2367
+ dstY = 0;
2368
+ srcHeight = Math.min(initialHeight, sourceHeight - srcY);
2369
+ dstHeight = srcHeight;
2370
+ }
2371
+ var params = [srcX, srcY, srcWidth, srcHeight];
2372
+ if (dstWidth > 0 && dstHeight > 0) {
2373
+ var scale2 = width / initialWidth;
2374
+ params.push(dstX * scale2, dstY * scale2, dstWidth * scale2, dstHeight * scale2);
2375
+ }
2376
+ context.drawImage.apply(context, [source].concat(_toConsumableArray(params.map(function(param) {
2377
+ return Math.floor(normalizeDecimalNumber(param));
2378
+ }))));
2379
+ return canvas;
2380
+ },
2381
+ /**
2382
+ * Change the aspect ratio of the crop box.
2383
+ * @param {number} aspectRatio - The new aspect ratio.
2384
+ * @returns {Cropper} this
2385
+ */
2386
+ setAspectRatio: function setAspectRatio(aspectRatio) {
2387
+ var options = this.options;
2388
+ if (!this.disabled && !isUndefined(aspectRatio)) {
2389
+ options.aspectRatio = Math.max(0, aspectRatio) || NaN;
2390
+ if (this.ready) {
2391
+ this.initCropBox();
2392
+ if (this.cropped) {
2393
+ this.renderCropBox();
2394
+ }
2395
+ }
2396
+ }
2397
+ return this;
2398
+ },
2399
+ /**
2400
+ * Change the drag mode.
2401
+ * @param {string} mode - The new drag mode.
2402
+ * @returns {Cropper} this
2403
+ */
2404
+ setDragMode: function setDragMode(mode) {
2405
+ var options = this.options, dragBox = this.dragBox, face = this.face;
2406
+ if (this.ready && !this.disabled) {
2407
+ var croppable = mode === DRAG_MODE_CROP;
2408
+ var movable = options.movable && mode === DRAG_MODE_MOVE;
2409
+ mode = croppable || movable ? mode : DRAG_MODE_NONE;
2410
+ options.dragMode = mode;
2411
+ setData(dragBox, DATA_ACTION, mode);
2412
+ toggleClass(dragBox, CLASS_CROP, croppable);
2413
+ toggleClass(dragBox, CLASS_MOVE, movable);
2414
+ if (!options.cropBoxMovable) {
2415
+ setData(face, DATA_ACTION, mode);
2416
+ toggleClass(face, CLASS_CROP, croppable);
2417
+ toggleClass(face, CLASS_MOVE, movable);
2418
+ }
2419
+ }
2420
+ return this;
2421
+ }
2422
+ };
2423
+ var AnotherCropper = WINDOW.Cropper;
2424
+ var Cropper = /* @__PURE__ */ (function() {
2425
+ function Cropper2(element) {
2426
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2427
+ _classCallCheck(this, Cropper2);
2428
+ if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
2429
+ throw new Error("The first argument is required and must be an <img> or <canvas> element.");
2430
+ }
2431
+ this.element = element;
2432
+ this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
2433
+ this.cropped = false;
2434
+ this.disabled = false;
2435
+ this.pointers = {};
2436
+ this.ready = false;
2437
+ this.reloading = false;
2438
+ this.replaced = false;
2439
+ this.sized = false;
2440
+ this.sizing = false;
2441
+ this.init();
2442
+ }
2443
+ return _createClass(Cropper2, [{
2444
+ key: "init",
2445
+ value: function init() {
2446
+ var element = this.element;
2447
+ var tagName = element.tagName.toLowerCase();
2448
+ var url;
2449
+ if (element[NAMESPACE]) {
2450
+ return;
2451
+ }
2452
+ element[NAMESPACE] = this;
2453
+ if (tagName === "img") {
2454
+ this.isImg = true;
2455
+ url = element.getAttribute("src") || "";
2456
+ this.originalUrl = url;
2457
+ if (!url) {
2458
+ return;
2459
+ }
2460
+ url = element.src;
2461
+ } else if (tagName === "canvas" && window.HTMLCanvasElement) {
2462
+ url = element.toDataURL();
2463
+ }
2464
+ this.load(url);
2465
+ }
2466
+ }, {
2467
+ key: "load",
2468
+ value: function load(url) {
2469
+ var _this = this;
2470
+ if (!url) {
2471
+ return;
2472
+ }
2473
+ this.url = url;
2474
+ this.imageData = {};
2475
+ var element = this.element, options = this.options;
2476
+ if (!options.rotatable && !options.scalable) {
2477
+ options.checkOrientation = false;
2478
+ }
2479
+ if (!options.checkOrientation || !window.ArrayBuffer) {
2480
+ this.clone();
2481
+ return;
2482
+ }
2483
+ if (REGEXP_DATA_URL.test(url)) {
2484
+ if (REGEXP_DATA_URL_JPEG.test(url)) {
2485
+ this.read(dataURLToArrayBuffer(url));
2486
+ } else {
2487
+ this.clone();
2488
+ }
2489
+ return;
2490
+ }
2491
+ var xhr = new XMLHttpRequest();
2492
+ var clone = this.clone.bind(this);
2493
+ this.reloading = true;
2494
+ this.xhr = xhr;
2495
+ xhr.onabort = clone;
2496
+ xhr.onerror = clone;
2497
+ xhr.ontimeout = clone;
2498
+ xhr.onprogress = function() {
2499
+ if (xhr.getResponseHeader("content-type") !== MIME_TYPE_JPEG) {
2500
+ xhr.abort();
2501
+ }
2502
+ };
2503
+ xhr.onload = function() {
2504
+ _this.read(xhr.response);
2505
+ };
2506
+ xhr.onloadend = function() {
2507
+ _this.reloading = false;
2508
+ _this.xhr = null;
2509
+ };
2510
+ if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
2511
+ url = addTimestamp(url);
2512
+ }
2513
+ xhr.open("GET", url, true);
2514
+ xhr.responseType = "arraybuffer";
2515
+ xhr.withCredentials = element.crossOrigin === "use-credentials";
2516
+ xhr.send();
2517
+ }
2518
+ }, {
2519
+ key: "read",
2520
+ value: function read(arrayBuffer) {
2521
+ var options = this.options, imageData = this.imageData;
2522
+ var orientation = resetAndGetOrientation(arrayBuffer);
2523
+ var rotate2 = 0;
2524
+ var scaleX2 = 1;
2525
+ var scaleY2 = 1;
2526
+ if (orientation > 1) {
2527
+ this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG);
2528
+ var _parseOrientation = parseOrientation(orientation);
2529
+ rotate2 = _parseOrientation.rotate;
2530
+ scaleX2 = _parseOrientation.scaleX;
2531
+ scaleY2 = _parseOrientation.scaleY;
2532
+ }
2533
+ if (options.rotatable) {
2534
+ imageData.rotate = rotate2;
2535
+ }
2536
+ if (options.scalable) {
2537
+ imageData.scaleX = scaleX2;
2538
+ imageData.scaleY = scaleY2;
2539
+ }
2540
+ this.clone();
2541
+ }
2542
+ }, {
2543
+ key: "clone",
2544
+ value: function clone() {
2545
+ var element = this.element, url = this.url;
2546
+ var crossOrigin = element.crossOrigin;
2547
+ var crossOriginUrl = url;
2548
+ if (this.options.checkCrossOrigin && isCrossOriginURL(url)) {
2549
+ if (!crossOrigin) {
2550
+ crossOrigin = "anonymous";
2551
+ }
2552
+ crossOriginUrl = addTimestamp(url);
2553
+ }
2554
+ this.crossOrigin = crossOrigin;
2555
+ this.crossOriginUrl = crossOriginUrl;
2556
+ var image = document.createElement("img");
2557
+ if (crossOrigin) {
2558
+ image.crossOrigin = crossOrigin;
2559
+ }
2560
+ image.src = crossOriginUrl || url;
2561
+ image.alt = element.alt || "The image to crop";
2562
+ this.image = image;
2563
+ image.onload = this.start.bind(this);
2564
+ image.onerror = this.stop.bind(this);
2565
+ addClass(image, CLASS_HIDE);
2566
+ element.parentNode.insertBefore(image, element.nextSibling);
2567
+ }
2568
+ }, {
2569
+ key: "start",
2570
+ value: function start() {
2571
+ var _this2 = this;
2572
+ var image = this.image;
2573
+ image.onload = null;
2574
+ image.onerror = null;
2575
+ this.sizing = true;
2576
+ var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);
2577
+ var done = function done2(naturalWidth, naturalHeight) {
2578
+ assign(_this2.imageData, {
2579
+ naturalWidth,
2580
+ naturalHeight,
2581
+ aspectRatio: naturalWidth / naturalHeight
2582
+ });
2583
+ _this2.initialImageData = assign({}, _this2.imageData);
2584
+ _this2.sizing = false;
2585
+ _this2.sized = true;
2586
+ _this2.build();
2587
+ };
2588
+ if (image.naturalWidth && !isIOSWebKit) {
2589
+ done(image.naturalWidth, image.naturalHeight);
2590
+ return;
2591
+ }
2592
+ var sizingImage = document.createElement("img");
2593
+ var body = document.body || document.documentElement;
2594
+ this.sizingImage = sizingImage;
2595
+ sizingImage.onload = function() {
2596
+ done(sizingImage.width, sizingImage.height);
2597
+ if (!isIOSWebKit) {
2598
+ body.removeChild(sizingImage);
2599
+ }
2600
+ };
2601
+ sizingImage.src = image.src;
2602
+ if (!isIOSWebKit) {
2603
+ sizingImage.style.cssText = "left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;";
2604
+ body.appendChild(sizingImage);
2605
+ }
2606
+ }
2607
+ }, {
2608
+ key: "stop",
2609
+ value: function stop() {
2610
+ var image = this.image;
2611
+ image.onload = null;
2612
+ image.onerror = null;
2613
+ image.parentNode.removeChild(image);
2614
+ this.image = null;
2615
+ }
2616
+ }, {
2617
+ key: "build",
2618
+ value: function build() {
2619
+ if (!this.sized || this.ready) {
2620
+ return;
2621
+ }
2622
+ var element = this.element, options = this.options, image = this.image;
2623
+ var container = element.parentNode;
2624
+ var template = document.createElement("div");
2625
+ template.innerHTML = TEMPLATE;
2626
+ var cropper = template.querySelector(".".concat(NAMESPACE, "-container"));
2627
+ var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas"));
2628
+ var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box"));
2629
+ var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box"));
2630
+ var face = cropBox.querySelector(".".concat(NAMESPACE, "-face"));
2631
+ this.container = container;
2632
+ this.cropper = cropper;
2633
+ this.canvas = canvas;
2634
+ this.dragBox = dragBox;
2635
+ this.cropBox = cropBox;
2636
+ this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box"));
2637
+ this.face = face;
2638
+ canvas.appendChild(image);
2639
+ addClass(element, CLASS_HIDDEN);
2640
+ container.insertBefore(cropper, element.nextSibling);
2641
+ removeClass(image, CLASS_HIDE);
2642
+ this.initPreview();
2643
+ this.bind();
2644
+ options.initialAspectRatio = Math.max(0, options.initialAspectRatio) || NaN;
2645
+ options.aspectRatio = Math.max(0, options.aspectRatio) || NaN;
2646
+ options.viewMode = Math.max(0, Math.min(3, Math.round(options.viewMode))) || 0;
2647
+ addClass(cropBox, CLASS_HIDDEN);
2648
+ if (!options.guides) {
2649
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN);
2650
+ }
2651
+ if (!options.center) {
2652
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN);
2653
+ }
2654
+ if (options.background) {
2655
+ addClass(cropper, "".concat(NAMESPACE, "-bg"));
2656
+ }
2657
+ if (!options.highlight) {
2658
+ addClass(face, CLASS_INVISIBLE);
2659
+ }
2660
+ if (options.cropBoxMovable) {
2661
+ addClass(face, CLASS_MOVE);
2662
+ setData(face, DATA_ACTION, ACTION_ALL);
2663
+ }
2664
+ if (!options.cropBoxResizable) {
2665
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN);
2666
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN);
2667
+ }
2668
+ this.render();
2669
+ this.ready = true;
2670
+ this.setDragMode(options.dragMode);
2671
+ if (options.autoCrop) {
2672
+ this.crop();
2673
+ }
2674
+ this.setData(options.data);
2675
+ if (isFunction(options.ready)) {
2676
+ addListener(element, EVENT_READY, options.ready, {
2677
+ once: true
2678
+ });
2679
+ }
2680
+ dispatchEvent(element, EVENT_READY);
2681
+ }
2682
+ }, {
2683
+ key: "unbuild",
2684
+ value: function unbuild() {
2685
+ if (!this.ready) {
2686
+ return;
2687
+ }
2688
+ this.ready = false;
2689
+ this.unbind();
2690
+ this.resetPreview();
2691
+ var parentNode = this.cropper.parentNode;
2692
+ if (parentNode) {
2693
+ parentNode.removeChild(this.cropper);
2694
+ }
2695
+ removeClass(this.element, CLASS_HIDDEN);
2696
+ }
2697
+ }, {
2698
+ key: "uncreate",
2699
+ value: function uncreate() {
2700
+ if (this.ready) {
2701
+ this.unbuild();
2702
+ this.ready = false;
2703
+ this.cropped = false;
2704
+ } else if (this.sizing) {
2705
+ this.sizingImage.onload = null;
2706
+ this.sizing = false;
2707
+ this.sized = false;
2708
+ } else if (this.reloading) {
2709
+ this.xhr.onabort = null;
2710
+ this.xhr.abort();
2711
+ } else if (this.image) {
2712
+ this.stop();
2713
+ }
2714
+ }
2715
+ /**
2716
+ * Get the no conflict cropper class.
2717
+ * @returns {Cropper} The cropper class.
2718
+ */
2719
+ }], [{
2720
+ key: "noConflict",
2721
+ value: function noConflict() {
2722
+ window.Cropper = AnotherCropper;
2723
+ return Cropper2;
2724
+ }
2725
+ /**
2726
+ * Change the default options.
2727
+ * @param {Object} options - The new default options.
2728
+ */
2729
+ }, {
2730
+ key: "setDefaults",
2731
+ value: function setDefaults(options) {
2732
+ assign(DEFAULTS, isPlainObject(options) && options);
2733
+ }
2734
+ }]);
2735
+ })();
2736
+ assign(Cropper.prototype, render, preview, events, handlers, change, methods);
2737
+ export {
2738
+ Cropper as default
2739
+ };