raffaello 1.0.0 β 1.1.1
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.
- package/README.md +53 -2
- package/dist/raffaello.min.js +3 -3
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
|
-
# RAFFAELLO
|
|
1
|
+
# RAFFAELLO JavaScript Library π¦¦
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**RAFFAELLO.js** is a browser-first comprehensive JavaScript library developped at [RTS - Radio Television Suisse](https://www.rts.ch/). It is a seamless solution for remote template-based image creation. It is design to empower users to generate images from predefined templates on the fly, right from their web browser.
|
|
4
4
|
|
|
5
|
+
> π¦ Distributed via CDN
|
|
6
|
+
> π Source code is proprietary
|
|
7
|
+
> π Public documentation and examples available
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## π Quick Start (CDN)
|
|
12
|
+
|
|
13
|
+
Include RAFFELLO in your HTML with your license key:
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script src="https://cdn.jsdelivr.net/npm/raffaello/dist/raffaello.min.js" license="abc123"></script>
|
|
17
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/raffaello/dist/raffaello.min.css">
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> β
No other dependencies are needed β everything is bundled inside
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## π Documentation & Examples
|
|
25
|
+
|
|
26
|
+
Full usage guides, examples, and API documentation are available here:
|
|
27
|
+
|
|
28
|
+
π [theokva.github.io/raffaello-docs/](https://theokva.github.io/raffaello-docs/)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## π Bug Reports & Feature Requests
|
|
33
|
+
|
|
34
|
+
Please submit issues and ideas through the public docs repository:
|
|
35
|
+
|
|
36
|
+
β‘οΈ [github.com/TheoKVA/raffaello-docs/](https://github.com/TheoKVA/raffaello-docs/)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## π‘ License
|
|
41
|
+
|
|
42
|
+
RAFFELLO is distributed under a **commercial proprietary license**.
|
|
43
|
+
|
|
44
|
+
- You may **use** the distributed code as per your commercial agreement
|
|
45
|
+
- You may **not** reverse engineer, redistribute, or modify the source
|
|
46
|
+
- The source code is **not publicly available**
|
|
47
|
+
|
|
48
|
+
For licensing inquiries, please contact: **theo.francart@rts.ch**
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## π€ Author
|
|
53
|
+
|
|
54
|
+
Coded with β€οΈ by **Theo Francart**
|
|
55
|
+
https://github.com/TheoKVA
|
package/dist/raffaello.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* RAFFAELLO - v1.
|
|
2
|
+
* RAFFAELLO - v1.1.0
|
|
3
3
|
*
|
|
4
4
|
* ,%DDJ*.
|
|
5
5
|
* .P +D+ .,. ,,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* Unauthorized use, modification, or distribution is strictly prohibited.
|
|
23
23
|
* Β© 2025 Theo Francart | RTS - Radio Television Suisse. All rights reserved.
|
|
24
24
|
*
|
|
25
|
-
* Build: 2025-04-
|
|
25
|
+
* Build: 2025-04-22
|
|
26
26
|
*/
|
|
27
27
|
!function(){"use strict";
|
|
28
28
|
/*!
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
* Released under the MIT license
|
|
34
34
|
*
|
|
35
35
|
* Date: 2022-11-20T05:30:46.114Z
|
|
36
|
-
*/var t,e;t=window,e=function(){function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach((function(e){_defineProperty(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i<e;i++)a[i]=t[i];return a}var t="undefined"!=typeof window&&void 0!==window.document,e=t?window:{},i=!(!t||!e.document.documentElement)&&"ontouchstart"in e.document.documentElement,a=!!t&&"PointerEvent"in e,n="cropper",o="all",r="crop",s="move",h="zoom",l="e",c="w",d="s",p="n",u="ne",m="nw",g="se",f="sw",v="".concat(n,"-crop"),y="".concat(n,"-disabled"),w="".concat(n,"-hidden"),x="".concat(n,"-hide"),b="".concat(n,"-invisible"),C="".concat(n,"-modal"),L="".concat(n,"-move"),S="".concat(n,"Action"),k="".concat(n,"Preview"),D="crop",E="move",M="none",R="crop",I="cropend",T="cropmove",N="cropstart",B="dblclick",A=a?"pointerdown":i?"touchstart":"mousedown",O=a?"pointermove":i?"touchmove":"mousemove",_=a?"pointerup pointercancel":i?"touchend touchcancel":"mouseup",z="ready",W="resize",P="wheel",F="zoom",H="image/jpeg",j=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,U=/^data:/,X=/^data:image\/jpeg;base64,/,Y=/^img|canvas$/i,q={viewMode:0,dragMode:D,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},$=Number.isNaN||e.isNaN;function isNumber(t){return"number"==typeof t&&!$(t)}var G=function isPositiveNumber(t){return t>0&&t<1/0};function isUndefined(t){return void 0===t}function isObject(t){return"object"===_typeof(t)&&null!==t}var K=Object.prototype.hasOwnProperty;function isPlainObject(t){if(!isObject(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&K.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}var Z=Array.prototype.slice;function toArray(t){return Array.from?Array.from(t):Z.call(t)}function forEach(t,e){return t&&isFunction(e)&&(Array.isArray(t)||isNumber(t.length)?toArray(t).forEach((function(i,a){e.call(t,i,a,t)})):isObject(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var V=Object.assign||function assign(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a<e;a++)i[a-1]=arguments[a];return isObject(t)&&i.length>0&&i.forEach((function(e){isObject(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},Q=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return Q.test(t)?Math.round(t*e)/e:t}var J=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(t,e){var i=t.style;forEach(e,(function(t,e){J.test(e)&&isNumber(t)&&(t="".concat(t,"px")),i[e]=t}))}function addClass(t,e){if(e)if(isNumber(t.length))forEach(t,(function(t){addClass(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function removeClass(t,e){e&&(isNumber(t.length)?forEach(t,(function(t){removeClass(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function toggleClass(t,e,i){e&&(isNumber(t.length)?forEach(t,(function(t){toggleClass(t,e,i)})):i?addClass(t,e):removeClass(t,e))}var tt=/([a-z\d])([A-Z])/g;function toParamCase(t){return t.replace(tt,"$1-$2").toLowerCase()}function getData(t,e){return isObject(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(toParamCase(e)))}function setData(t,e,i){isObject(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(toParamCase(e)),i)}var et=/\s\s*/,it=function(){var i=!1;if(t){var a=!1,n=function listener(){},o=Object.defineProperty({},"once",{get:function get(){return i=!0,a},set:function set(t){a=t}});e.addEventListener("test",n,o),e.removeEventListener("test",n,o)}return i}();function removeListener(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(et).forEach((function(e){if(!it){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)}))}function addListener(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(et).forEach((function(e){if(a.once&&!it){var o=t.listeners,r=void 0===o?{}:o;n=function handler(){delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,s=new Array(o),h=0;h<o;h++)s[h]=arguments[h];i.apply(t,s)},r[e]||(r[e]={}),r[e][i]&&t.removeEventListener(e,r[e][i],a),r[e][i]=n,t.listeners=r}t.addEventListener(e,n,a)}))}function dispatchEvent(t,e,i){var a;return isFunction(Event)&&isFunction(CustomEvent)?a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(a=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(a)}function getOffset(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var at=e.location,nt=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(t){var e=t.match(nt);return null!==e&&(e[1]!==at.protocol||e[2]!==at.hostname||e[3]!==at.port)}function addTimestamp(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function getTransforms(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,r=[];isNumber(n)&&0!==n&&r.push("translateX(".concat(n,"px)")),isNumber(o)&&0!==o&&r.push("translateY(".concat(o,"px)")),isNumber(e)&&0!==e&&r.push("rotate(".concat(e,"deg)")),isNumber(i)&&1!==i&&r.push("scaleX(".concat(i,")")),isNumber(a)&&1!==a&&r.push("scaleY(".concat(a,")"));var s=r.length?r.join(" "):"none";return{WebkitTransform:s,msTransform:s,transform:s}}function getPointer(t,e){var i=t.pageX,a=t.pageY,n={endX:i,endY:a};return e?n:_objectSpread2({startX:i,startY:a},n)}function getAdjustedSizes(t){var e=t.aspectRatio,i=t.height,a=t.width,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",o=G(a),r=G(i);if(o&&r){var s=i*e;"contain"===n&&s>a||"cover"===n&&s<a?i=a/e:a=i*e}else o?i=a/e:r&&(a=i*e);return{width:a,height:i}}var ot=String.fromCharCode,rt=/^data:.*,/;function resetAndGetOrientation(t){var e,i=new DataView(t);try{var a,n,o;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var r=i.byteLength,s=2;s+1<r;){if(255===i.getUint8(s)&&225===i.getUint8(s+1)){n=s;break}s+=1}if(n){var h=n+10;if("Exif"===function getStringFromCharCode(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=ot(t.getUint8(n));return a}(i,n+4,4)){var l=i.getUint16(h);if(((a=18761===l)||19789===l)&&42===i.getUint16(h+2,a)){var c=i.getUint32(h+4,a);c>=8&&(o=h+c)}}}if(o){var d,p,u=i.getUint16(o,a);for(p=0;p<u;p+=1)if(d=o+12*p+2,274===i.getUint16(d,a)){d+=8,e=i.getUint16(d,a),i.setUint16(d,1,a);break}}}catch(t){e=1}return e}var st={render:function render(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function initContainer(){var t=this.element,e=this.options,i=this.container,a=this.cropper,n=Number(e.minContainerWidth),o=Number(e.minContainerHeight);addClass(a,w),removeClass(t,w);var r={width:Math.max(i.offsetWidth,n>=0?n:200),height:Math.max(i.offsetHeight,o>=0?o:100)};this.containerData=r,setStyle(a,{width:r.width,height:r.height}),addClass(t,w),removeClass(a,w)},initCanvas:function initCanvas(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180==90,n=a?e.naturalHeight:e.naturalWidth,o=a?e.naturalWidth:e.naturalHeight,r=n/o,s=t.width,h=t.height;t.height*r>t.width?3===i?s=t.height*r:h=t.width/r:3===i?h=t.width/r:s=t.height*r;var l={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:s,height:h};this.canvasData=l,this.limited=1===i||2===i,this.limitCanvas(!0,!0),l.width=Math.min(Math.max(l.width,l.minWidth),l.maxWidth),l.height=Math.min(Math.max(l.height,l.minHeight),l.maxHeight),l.left=(t.width-l.width)/2,l.top=(t.height-l.height)/2,l.oldLeft=l.left,l.oldTop=l.top,this.initialCanvasData=V({},l)},limitCanvas:function limitCanvas(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=i.viewMode,s=n.aspectRatio,h=this.cropped&&o;if(t){var l=Number(i.minCanvasWidth)||0,c=Number(i.minCanvasHeight)||0;r>1?(l=Math.max(l,a.width),c=Math.max(c,a.height),3===r&&(c*s>l?l=c*s:c=l/s)):r>0&&(l?l=Math.max(l,h?o.width:0):c?c=Math.max(c,h?o.height:0):h&&(l=o.width,(c=o.height)*s>l?l=c*s:c=l/s));var d=getAdjustedSizes({aspectRatio:s,width:l,height:c});l=d.width,c=d.height,n.minWidth=l,n.minHeight=c,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(r>(h?0:1)){var p=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,u),h&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===r&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function renderCanvas(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=function getRotatedSizes(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),r=Math.cos(n),s=e*r+i*o,h=e*o+i*r;return a>90?{width:h,height:s}:{width:s,height:h}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,r=n.height,s=i.width*(o/i.naturalWidth),h=i.height*(r/i.naturalHeight);i.left-=(s-i.width)/2,i.top-=(h-i.height)/2,i.width=s,i.height=h,i.aspectRatio=o/r,i.naturalWidth=o,i.naturalHeight=r,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,setStyle(this.canvas,V({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function renderImage(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);V(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),setStyle(this.image,V({width:i.width,height:i.height},getTransforms(V({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function initCropBox(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,n={width:e.width,height:e.height};i&&(e.height*i>e.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=V({},n)},limitCropBox:function limitCropBox(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,s=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,l=Number(i.minCropBoxHeight)||0,c=r?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,d=r?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;h=Math.min(h,a.width),l=Math.min(l,a.height),s&&(h&&l?l*s>h?l=h/s:h=l*s:h?l=h/s:l&&(h=l*s),d*s>c?d=c/s:c=d*s),o.minWidth=Math.min(h,c),o.minHeight=Math.min(l,d),o.maxWidth=c,o.maxHeight=d}e&&(r?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function renderCropBox(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&setData(this.face,S,i.width>=e.width&&i.height>=e.height?s:o),setStyle(this.cropBox,V({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function output(){this.preview(),dispatchEvent(this.element,R,this.getData())}},ht={initPreview:function initPreview(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(e&&(o.crossOrigin=e),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,i){var r=i;"string"==typeof i?r=t.ownerDocument.querySelectorAll(i):i.querySelector&&(r=[i]),this.previews=r,forEach(r,(function(t){var i=document.createElement("img");setData(t,k,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.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;"',t.innerHTML="",t.appendChild(i)}))}},resetPreview:function resetPreview(){forEach(this.previews,(function(t){var e=getData(t,k);setStyle(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function removeData(t,e){if(isObject(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(toParamCase(e)))}(t,k)}))},preview:function preview(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,r=t.height,s=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(setStyle(this.viewBoxImage,V({width:o,height:r},getTransforms(V({translateX:-s,translateY:-h},t)))),forEach(this.previews,(function(e){var i=getData(e,k),l=i.width,c=i.height,d=l,p=c,u=1;a&&(p=n*(u=l/a)),n&&p>c&&(d=a*(u=c/n),p=c),setStyle(e,{width:d,height:p}),setStyle(e.getElementsByTagName("img")[0],V({width:o*u,height:r*u},getTransforms(V({translateX:-s*u,translateY:-h*u},t))))})))}},lt={bind:function bind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&addListener(t,N,e.cropstart),isFunction(e.cropmove)&&addListener(t,T,e.cropmove),isFunction(e.cropend)&&addListener(t,I,e.cropend),isFunction(e.crop)&&addListener(t,R,e.crop),isFunction(e.zoom)&&addListener(t,F,e.zoom),addListener(i,A,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&addListener(i,P,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&addListener(i,B,this.onDblclick=this.dblclick.bind(this)),addListener(t.ownerDocument,O,this.onCropMove=this.cropMove.bind(this)),addListener(t.ownerDocument,_,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&addListener(window,W,this.onResize=this.resize.bind(this))},unbind:function unbind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&removeListener(t,N,e.cropstart),isFunction(e.cropmove)&&removeListener(t,T,e.cropmove),isFunction(e.cropend)&&removeListener(t,I,e.cropend),isFunction(e.crop)&&removeListener(t,R,e.crop),isFunction(e.zoom)&&removeListener(t,F,e.zoom),removeListener(i,A,this.onCropStart),e.zoomable&&e.zoomOnWheel&&removeListener(i,P,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&removeListener(i,B,this.onDblclick),removeListener(t.ownerDocument,O,this.onCropMove),removeListener(t.ownerDocument,_,this.onCropEnd),e.responsive&&removeListener(window,W,this.onResize)}},ct={resize:function resize(){if(!this.disabled){var t,e,i=this.options,a=this.container,n=this.containerData,o=a.offsetWidth/n.width,r=a.offsetHeight/n.height,s=Math.abs(o-1)>Math.abs(r-1)?o:r;1!==s&&(i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(forEach(t,(function(e,i){t[i]=e*s}))),this.setCropBoxData(forEach(e,(function(t,i){e[i]=t*s})))))}},dblclick:function dblclick(){this.disabled||this.options.dragMode===M||this.setDragMode(function hasClass(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}(this.dragBox,v)?E:D)},wheel:function wheel(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function cropStart(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(isNumber(e)&&1!==e||isNumber(i)&&0!==i||t.ctrlKey))){var a,n=this.options,o=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){o[t.identifier]=getPointer(t)})):o[t.pointerId||0]=getPointer(t),a=Object.keys(o).length>1&&n.zoomable&&n.zoomOnTouch?h:getData(t.target,S),j.test(a)&&!1!==dispatchEvent(this.element,N,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===r&&(this.cropping=!0,addClass(this.dragBox,C)))}},cropMove:function cropMove(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==dispatchEvent(this.element,T,{originalEvent:t,action:e})&&(t.changedTouches?forEach(t.changedTouches,(function(t){V(i[t.identifier]||{},getPointer(t,!0))})):V(i[t.pointerId||0]||{},getPointer(t,!0)),this.change(t))}},cropEnd:function cropEnd(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,toggleClass(this.dragBox,C,this.cropped&&this.options.modal)),dispatchEvent(this.element,I,{originalEvent:t,action:e}))}}},dt={change:function change(t){var e,i=this.options,a=this.canvasData,n=this.containerData,v=this.cropBoxData,y=this.pointers,x=this.action,b=i.aspectRatio,C=v.left,L=v.top,S=v.width,k=v.height,D=C+S,E=L+k,M=0,R=0,I=n.width,T=n.height,N=!0;!b&&t.shiftKey&&(b=S&&k?S/k:1),this.limited&&(M=v.minLeft,R=v.minTop,I=M+Math.min(n.width,a.width,a.left+a.width),T=R+Math.min(n.height,a.height,a.top+a.height));var B=y[Object.keys(y)[0]],A={x:B.endX-B.startX,y:B.endY-B.startY},O=function check(t){switch(t){case l:D+A.x>I&&(A.x=I-D);break;case c:C+A.x<M&&(A.x=M-C);break;case p:L+A.y<R&&(A.y=R-L);break;case d:E+A.y>T&&(A.y=T-E)}};switch(x){case o:C+=A.x,L+=A.y;break;case l:if(A.x>=0&&(D>=I||b&&(L<=R||E>=T))){N=!1;break}O(l),(S+=A.x)<0&&(x=c,C-=S=-S),b&&(k=S/b,L+=(v.height-k)/2);break;case p:if(A.y<=0&&(L<=R||b&&(C<=M||D>=I))){N=!1;break}O(p),k-=A.y,L+=A.y,k<0&&(x=d,L-=k=-k),b&&(S=k*b,C+=(v.width-S)/2);break;case c:if(A.x<=0&&(C<=M||b&&(L<=R||E>=T))){N=!1;break}O(c),S-=A.x,C+=A.x,S<0&&(x=l,C-=S=-S),b&&(k=S/b,L+=(v.height-k)/2);break;case d:if(A.y>=0&&(E>=T||b&&(C<=M||D>=I))){N=!1;break}O(d),(k+=A.y)<0&&(x=p,L-=k=-k),b&&(S=k*b,C+=(v.width-S)/2);break;case u:if(b){if(A.y<=0&&(L<=R||D>=I)){N=!1;break}O(p),k-=A.y,L+=A.y,S=k*b}else O(p),O(l),A.x>=0?D<I?S+=A.x:A.y<=0&&L<=R&&(N=!1):S+=A.x,A.y<=0?L>R&&(k-=A.y,L+=A.y):(k-=A.y,L+=A.y);S<0&&k<0?(x=f,L-=k=-k,C-=S=-S):S<0?(x=m,C-=S=-S):k<0&&(x=g,L-=k=-k);break;case m:if(b){if(A.y<=0&&(L<=R||C<=M)){N=!1;break}O(p),k-=A.y,L+=A.y,S=k*b,C+=v.width-S}else O(p),O(c),A.x<=0?C>M?(S-=A.x,C+=A.x):A.y<=0&&L<=R&&(N=!1):(S-=A.x,C+=A.x),A.y<=0?L>R&&(k-=A.y,L+=A.y):(k-=A.y,L+=A.y);S<0&&k<0?(x=g,L-=k=-k,C-=S=-S):S<0?(x=u,C-=S=-S):k<0&&(x=f,L-=k=-k);break;case f:if(b){if(A.x<=0&&(C<=M||E>=T)){N=!1;break}O(c),S-=A.x,C+=A.x,k=S/b}else O(d),O(c),A.x<=0?C>M?(S-=A.x,C+=A.x):A.y>=0&&E>=T&&(N=!1):(S-=A.x,C+=A.x),A.y>=0?E<T&&(k+=A.y):k+=A.y;S<0&&k<0?(x=u,L-=k=-k,C-=S=-S):S<0?(x=g,C-=S=-S):k<0&&(x=m,L-=k=-k);break;case g:if(b){if(A.x>=0&&(D>=I||E>=T)){N=!1;break}O(l),k=(S+=A.x)/b}else O(d),O(l),A.x>=0?D<I?S+=A.x:A.y>=0&&E>=T&&(N=!1):S+=A.x,A.y>=0?E<T&&(k+=A.y):k+=A.y;S<0&&k<0?(x=m,L-=k=-k,C-=S=-S):S<0?(x=f,C-=S=-S):k<0&&(x=u,L-=k=-k);break;case s:this.move(A.x,A.y),N=!1;break;case h:this.zoom(function getMaxZoomRatio(t){var e=_objectSpread2({},t),i=0;return forEach(t,(function(t,a){delete e[a],forEach(e,(function(e){var a=Math.abs(t.startX-e.startX),n=Math.abs(t.startY-e.startY),o=Math.abs(t.endX-e.endX),r=Math.abs(t.endY-e.endY),s=Math.sqrt(a*a+n*n),h=(Math.sqrt(o*o+r*r)-s)/s;Math.abs(h)>Math.abs(i)&&(i=h)}))})),i}(y),t),N=!1;break;case r:if(!A.x||!A.y){N=!1;break}e=getOffset(this.cropper),C=B.startX-e.left,L=B.startY-e.top,S=v.minWidth,k=v.minHeight,A.x>0?x=A.y>0?g:u:A.x<0&&(C-=S,x=A.y>0?f:m),A.y<0&&(L-=k),this.cropped||(removeClass(this.cropBox,w),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}N&&(v.width=S,v.height=k,v.left=C,v.top=L,this.action=x,this.renderCropBox()),forEach(y,(function(t){t.startX=t.endX,t.startY=t.endY}))}},pt={crop:function crop(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&addClass(this.dragBox,C),removeClass(this.cropBox,w),this.setCropBoxData(this.initialCropBoxData)),this},reset:function reset(){return this.ready&&!this.disabled&&(this.imageData=V({},this.initialImageData),this.canvasData=V({},this.initialCanvasData),this.cropBoxData=V({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function clear(){return this.cropped&&!this.disabled&&(V(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),removeClass(this.dragBox,C),addClass(this.cropBox,w)),this},replace:function replace(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,forEach(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function enable(){return this.ready&&this.disabled&&(this.disabled=!1,removeClass(this.cropper,y)),this},disable:function disable(){return this.ready&&!this.disabled&&(this.disabled=!0,addClass(this.cropper,y)),this},destroy:function destroy(){var t=this.element;return t[n]?(t[n]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function move(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(isUndefined(t)?t:a+Number(t),isUndefined(e)?e:n+Number(e))},moveTo:function moveTo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(isNumber(t)&&(i.left=t,a=!0),isNumber(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function zoom(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function zoomTo(t,e,i){var a=this.options,n=this.canvasData,o=n.width,r=n.height,s=n.naturalWidth,h=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var l=s*t,c=h*t;if(i){var d=this.pointers,p=getOffset(this.cropper),u=d&&Object.keys(d).length?function getPointersCenter(t){var e=0,i=0,a=0;return forEach(t,(function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1})),{pageX:e/=a,pageY:i/=a}}(d):{pageX:i.pageX,pageY:i.pageY};n.left-=(l-o)*((u.pageX-p.left-n.left)/o),n.top-=(c-r)*((u.pageY-p.top-n.top)/r)}else isPlainObject(e)&&isNumber(e.x)&&isNumber(e.y)?(n.left-=(l-o)*((e.x-n.left)/o),n.top-=(c-r)*((e.y-n.top)/r)):(n.left-=(l-o)/2,n.top-=(c-r)/2);if(n.width=l,n.height=c,this.renderCanvas(!0),!1===dispatchEvent(this.element,F,{ratio:t,oldRatio:o/s,originalEvent:i}))return this}return this},rotate:function rotate(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function rotateTo(t){return isNumber(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function scaleX(t){var e=this.imageData.scaleY;return this.scale(t,isNumber(e)?e:1)},scaleY:function scaleY(t){var e=this.imageData.scaleX;return this.scale(isNumber(e)?e:1,t)},scale:function scale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(isNumber(t)&&(i.scaleX=t,a=!0),isNumber(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function getData(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,o=this.cropBoxData;if(this.ready&&this.cropped){t={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;if(forEach(t,(function(e,i){t[i]=e/r})),e){var s=Math.round(t.y+t.height),h=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=h-t.x,t.height=s-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function setData(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&isPlainObject(t)){var o=!1;e.rotatable&&isNumber(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(isNumber(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),isNumber(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var r=i.width/i.naturalWidth;isNumber(t.x)&&(n.left=t.x*r+a.left),isNumber(t.y)&&(n.top=t.y*r+a.top),isNumber(t.width)&&(n.width=t.width*r),isNumber(t.height)&&(n.height=t.height*r),this.setCropBoxData(n)}return this},getContainerData:function getContainerData(){return this.ready?V({},this.containerData):{}},getImageData:function getImageData(){return this.sized?V({},this.imageData):{}},getCanvasData:function getCanvasData(){var t=this.canvasData,e={};return this.ready&&forEach(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function setCanvasData(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(e.left=t.left),isNumber(t.top)&&(e.top=t.top),isNumber(t.width)?(e.width=t.width,e.height=t.width/i):isNumber(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function getCropBoxData(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function setCropBoxData(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(a.left=t.left),isNumber(t.top)&&(a.top=t.top),isNumber(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),isNumber(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function getCroppedCanvas(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function getSourceCanvas(t,e,i,a){var n=e.aspectRatio,o=e.naturalWidth,r=e.naturalHeight,s=e.rotate,h=void 0===s?0:s,l=e.scaleX,c=void 0===l?1:l,d=e.scaleY,p=void 0===d?1:d,u=i.aspectRatio,m=i.naturalWidth,g=i.naturalHeight,f=a.fillColor,v=void 0===f?"transparent":f,y=a.imageSmoothingEnabled,w=void 0===y||y,x=a.imageSmoothingQuality,b=void 0===x?"low":x,C=a.maxWidth,L=void 0===C?1/0:C,S=a.maxHeight,k=void 0===S?1/0:S,D=a.minWidth,E=void 0===D?0:D,M=a.minHeight,R=void 0===M?0:M,I=document.createElement("canvas"),T=I.getContext("2d"),N=getAdjustedSizes({aspectRatio:u,width:L,height:k}),B=getAdjustedSizes({aspectRatio:u,width:E,height:R},"cover"),A=Math.min(N.width,Math.max(B.width,m)),O=Math.min(N.height,Math.max(B.height,g)),_=getAdjustedSizes({aspectRatio:n,width:L,height:k}),z=getAdjustedSizes({aspectRatio:n,width:E,height:R},"cover"),W=Math.min(_.width,Math.max(z.width,o)),P=Math.min(_.height,Math.max(z.height,r)),F=[-W/2,-P/2,W,P];return I.width=normalizeDecimalNumber(A),I.height=normalizeDecimalNumber(O),T.fillStyle=v,T.fillRect(0,0,A,O),T.save(),T.translate(A/2,O/2),T.rotate(h*Math.PI/180),T.scale(c,p),T.imageSmoothingEnabled=w,T.imageSmoothingQuality=b,T.drawImage.apply(T,[t].concat(_toConsumableArray(F.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),T.restore(),I}(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),n=a.x,o=a.y,r=a.width,s=a.height,h=i.width/Math.floor(e.naturalWidth);1!==h&&(n*=h,o*=h,r*=h,s*=h);var l=r/s,c=getAdjustedSizes({aspectRatio:l,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=getAdjustedSizes({aspectRatio:l,width:t.minWidth||0,height:t.minHeight||0},"cover"),p=getAdjustedSizes({aspectRatio:l,width:t.width||(1!==h?i.width:r),height:t.height||(1!==h?i.height:s)}),u=p.width,m=p.height;u=Math.min(c.width,Math.max(d.width,u)),m=Math.min(c.height,Math.max(d.height,m));var g=document.createElement("canvas"),f=g.getContext("2d");g.width=normalizeDecimalNumber(u),g.height=normalizeDecimalNumber(m),f.fillStyle=t.fillColor||"transparent",f.fillRect(0,0,u,m);var v=t.imageSmoothingEnabled,y=void 0===v||v,w=t.imageSmoothingQuality;f.imageSmoothingEnabled=y,w&&(f.imageSmoothingQuality=w);var x,b,C,L,S,k,D=i.width,E=i.height,M=n,R=o;M<=-r||M>D?(M=0,x=0,C=0,S=0):M<=0?(C=-M,M=0,S=x=Math.min(D,r+M)):M<=D&&(C=0,S=x=Math.min(r,D-M)),x<=0||R<=-s||R>E?(R=0,b=0,L=0,k=0):R<=0?(L=-R,R=0,k=b=Math.min(E,s+R)):R<=E&&(L=0,k=b=Math.min(s,E-R));var I=[M,R,x,b];if(S>0&&k>0){var T=u/r;I.push(C*T,L*T,S*T,k*T)}return f.drawImage.apply(f,[i].concat(_toConsumableArray(I.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),g},setAspectRatio:function setAspectRatio(t){var e=this.options;return this.disabled||isUndefined(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function setDragMode(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=t===D,o=e.movable&&t===E;t=n||o?t:M,e.dragMode=t,setData(i,S,t),toggleClass(i,v,n),toggleClass(i,L,o),e.cropBoxMovable||(setData(a,S,t),toggleClass(a,v,n),toggleClass(a,L,o))}return this}},ut=e.Cropper,mt=function(){function Cropper(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Cropper),!t||!Y.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=V({},q,isPlainObject(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(Cropper,[{key:"init",value:function init(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[n]){if(e[n]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function load(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),a.checkOrientation&&window.ArrayBuffer)if(U.test(t))X.test(t)?this.read(function dataURLToArrayBuffer(t){var e=t.replace(rt,""),i=atob(e),a=new ArrayBuffer(i.length),n=new Uint8Array(a);return forEach(n,(function(t,e){n[e]=i.charCodeAt(e)})),a}(t)):this.clone();else{var n=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=n,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){n.getResponseHeader("content-type")!==H&&n.abort()},n.onload=function(){e.read(n.response)},n.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&isCrossOriginURL(t)&&i.crossOrigin&&(t=addTimestamp(t)),n.open("GET",t,!0),n.responseType="arraybuffer",n.withCredentials="use-credentials"===i.crossOrigin,n.send()}else this.clone()}}},{key:"read",value:function read(t){var e=this.options,i=this.imageData,a=resetAndGetOrientation(t),n=0,o=1,r=1;if(a>1){this.url=function arrayBufferToDataURL(t,e){for(var i=[],a=new Uint8Array(t);a.length>0;)i.push(ot.apply(null,toArray(a.subarray(0,8192)))),a=a.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,H);var s=function parseOrientation(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}(a);n=s.rotate,o=s.scaleX,r=s.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=r),this.clone()}},{key:"clone",value:function clone(){var t=this.element,e=this.url,i=t.crossOrigin,a=e;this.options.checkCrossOrigin&&isCrossOriginURL(e)&&(i||(i="anonymous"),a=addTimestamp(e)),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e,n.alt=t.alt||"The image to crop",this.image=n,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),addClass(n,x),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function start(){var t=this,i=this.image;i.onload=null,i.onerror=null,this.sizing=!0;var a=e.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(e.navigator.userAgent),n=function done(e,i){V(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=V({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!i.naturalWidth||a){var o=document.createElement("img"),r=document.body||document.documentElement;this.sizingImage=o,o.onload=function(){n(o.width,o.height),a||r.removeChild(o)},o.src=i.src,a||(o.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;",r.appendChild(o))}else n(i.naturalWidth,i.naturalHeight)}},{key:"stop",value:function stop(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function build(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,r=document.createElement("div");r.innerHTML='<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>';var s=r.querySelector(".".concat(n,"-container")),h=s.querySelector(".".concat(n,"-canvas")),l=s.querySelector(".".concat(n,"-drag-box")),c=s.querySelector(".".concat(n,"-crop-box")),d=c.querySelector(".".concat(n,"-face"));this.container=a,this.cropper=s,this.canvas=h,this.dragBox=l,this.cropBox=c,this.viewBox=s.querySelector(".".concat(n,"-view-box")),this.face=d,h.appendChild(i),addClass(t,w),a.insertBefore(s,t.nextSibling),removeClass(i,x),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,addClass(c,w),e.guides||addClass(c.getElementsByClassName("".concat(n,"-dashed")),w),e.center||addClass(c.getElementsByClassName("".concat(n,"-center")),w),e.background&&addClass(s,"".concat(n,"-bg")),e.highlight||addClass(d,b),e.cropBoxMovable&&(addClass(d,L),setData(d,S,o)),e.cropBoxResizable||(addClass(c.getElementsByClassName("".concat(n,"-line")),w),addClass(c.getElementsByClassName("".concat(n,"-point")),w)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),isFunction(e.ready)&&addListener(t,z,e.ready,{once:!0}),dispatchEvent(t,z)}}},{key:"unbuild",value:function unbuild(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),removeClass(this.element,w)}}},{key:"uncreate",value:function uncreate(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function noConflict(){return window.Cropper=ut,Cropper}},{key:"setDefaults",value:function setDefaults(t){V(q,isPlainObject(t)&&t)}}]),Cropper}();return V(mt.prototype,st,ht,lt,ct,dt,pt),mt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e();class Raffaello_CanvasLayer{constructor(t,e,i="normal",a=null){this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.type=i,this.effect=a,this.drawInstructions=null,this.bounds={minX:null,minY:null,maxX:null,maxY:null},this.isDrawn=!1}draw(t){return this.drawInstructions=t,this.drawInstructions(),this.isDrawn=!0,this}drawText(t){if(!t.text)return void(this.bounds={minX:null,maxX:null,minY:null,maxY:null});let e;if(t.text instanceof HTMLInputElement||t.text instanceof HTMLTextAreaElement)e=t.text.value;else{if("string"!=typeof t.text)return console.log("Error on the drawText(), the text input is not a valid string."),void console.log(t.text);e=t.text}const i={fontKerningOptical:!1,fontLetterSpacing:0,textAlign:{horizontal:"left",vertical:"bottom"},textBaseline:"alphabetic",anchorPoint:"none",position:{max_width:0,max_width_rescale:!1,max_lines:0,ignore_empty_lines:!0,ignore_double_spaces:!0},bounds:[!0,!0]},a={...i,...t,textAlign:{...i.textAlign,...t.textAlign},bounds:{...i.bounds,...t.bounds},position:{...i.position,...t.position}};a.fontLineHeight=t.fontLineHeight||t.fontSize;let n=e.split("\n");!1!==a.position.ignore_empty_lines&&(n=n.filter((t=>t.trim().length>0))),n=n.map((t=>t.trim())),!1!==a.position.ignore_double_spaces&&(n=n.map((t=>t.replace(/\s+/g," ")))),this.context.font=`${a.fontSize}px ${a.fontFamily}`,this.context.letterSpacing=a.fontSize/100*a.fontLetterSpacing+"px",this.context.textAlign=a.textAlign.horizontal,this.context.textBaseline=a.textBaseline,this.context.fontKerning=a.fontKerningOptical?"auto":"normal";let o=n.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxLeft)),0),r=1;if(a.position.max_width&&a.position.max_width_rescale)r=o>a.position.max_width?1/o*a.position.max_width:1;else if(a.position.max_width&&!a.position.max_width_rescale){let t=[];n.forEach((e=>{let i=e.split(" "),n="";i.forEach(((e,o)=>{let r=n+(n?" ":"")+e;this.context.measureText(r.replaceAll("Β§","")).width>a.position.max_width&&""!==n?(t.push(n),n=e):n=r,o===i.length-1&&t.push(n)}))})),n=t,o=n.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxLeft)),0)}a.position.max_lines&&(n=n.slice(0,a.position.max_lines)),this.context.font=`${a.fontSize*r}px ${a.fontFamily}`,this.context.letterSpacing=a.fontSize*r/100*a.fontLetterSpacing+"px";let s=this.context.measureText("Lp");a.bounds&&(!a.bounds[0]&&a.bounds[1]?s=this.context.measureText("p"):a.bounds[0]&&!a.bounds[1]?s=this.context.measureText("L"):a.bounds[0]||a.bounds[1]||(s=this.context.measureText("x")));let h=0;switch(a.position.true_anchorPoint_x&&(this.context.textAlign="left",h=this.context.measureText("L").actualBoundingBoxLeft,this.context.textAlign=a.textAlign.horizontal),this.context.textAlign="left",a.anchorPoint){default:case"none":break;case"true":h=this.context.measureText(n[0].slice(0,1)).actualBoundingBoxLeft;break;case"L":h=this.context.measureText("L").actualBoundingBoxLeft}this.context.textAlign=a.textAlign.horizontal;let l=a.position.pos_x,c=a.position.pos_y+s.actualBoundingBoxDescent,d=l+o*r,p=a.position.pos_y-s.actualBoundingBoxAscent,u=a.fontLineHeight*r*(n.length-1);switch(a.textAlign.vertical){default:case"top":c+=u;break;case"center":c+=u/2,p-=u/2;break;case"bottom":p-=u}switch(a.textAlign.horizontal){default:case"left":break;case"center":l-=o*r/2,d-=o*r/2;break;case"right":l-=o*r,d-=o*r}if(this.bounds={minX:l,maxX:d,minY:p,maxY:c},a.background){"string"==typeof a.background&&(a.background={fill_color:a.background,round_radius:0});let t={top:0,right:0,left:0,bottom:0};a.background.margins&&(a.background.margins.top&&(t.top=a.background.margins.top),a.background.margins.bottom&&(t.bottom=a.background.margins.bottom),a.background.margins.left&&(t.left=a.background.margins.left),a.background.margins.right&&(t.right=a.background.margins.right));let e=this.bounds.minX-t.left,i=this.bounds.maxX-this.bounds.minX+t.right+t.left,n=this.bounds.minY-t.top,o=this.bounds.maxY-this.bounds.minY+t.top+t.bottom,r=0;a.background.round_radius&&(r=a.background.round_radius),this.context.fillStyle=a.background.fill_color,a.background.stroke&&(this.context.lineWidth=a.background.stroke.width||10,this.context.strokeStyle=a.background.stroke.color||"black"),this.context.beginPath(),this.context.roundRect(e,n,i,o,r),this.context.fill(),a.background.stroke&&this.context.stroke()}n.forEach(((t,e)=>{let i,o=a.position.pos_x+h;if("center"===a.textAlign.horizontal){this.context.textAlign="left",o-=(this.context.measureText(t.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(t.replaceAll("Β§","")).actualBoundingBoxLeft)/2}switch(a.textAlign.vertical){default:case"top":i=e*a.fontLineHeight*r;break;case"bottom":i=-(n.length-1-e)*a.fontLineHeight*r;break;case"center":i=-(n.length-1)*a.fontLineHeight*r/2+e*a.fontLineHeight*r}const s=t.replace(/Β§+$/,"").split("Β§");for(let t=0;t<s.length;t++){let e="right"===a.textAlign.horizontal?s.length-1-t:t,n=s[e];if(this.context.fillStyle=a.fontFillColor,a.highlight&&e%2==1){this.context.fillStyle=a.highlight.fontFillColor?a.highlight.fontFillColor:a.fontFillColor;let t=a.highlight.fontSize?a.highlight.fontSize:a.fontSize,e=a.highlight.fontFamily?a.highlight.fontFamily:a.fontFamily;this.context.font=`${t*r}px ${e}`,this.context.letterSpacing=a.highlight.fontLetterSpacing?t*r/100*a.highlight.fontLetterSpacing+"px":t*r/100*a.fontLetterSpacing+"px"}this.context.fillText(n,o,a.position.pos_y+i),o+=("right"===a.textAlign.horizontal?-1:1)*this.context.measureText(n).width}})),this.isDrawn=!0}drawImage(...t){let e,i,a,n;if(this.context.drawImage(...t),3===t.length){const[o,r,s]=t;e=r,i=s,a=r+o.width,n=s+o.height}else if(5===t.length){const[,,,o,r,s,h]=t;e=s,i=h,a=s+o,n=h+r}else if(9===t.length){const[,,,,,o,r,s,h]=t;e=o,i=r,a=o+s,n=r+h}this.bounds={minX:e,minY:i,maxX:a,maxY:n},this.context.filter="none",this.isDrawn=!0}drawImageInput(t,e,i){this.context.drawImage(t.config.rawImage,Math.round(t.config.cropInfo.x),Math.round(t.config.cropInfo.y),Math.round(t.config.cropInfo.width),Math.round(t.config.cropInfo.height),e,i,Math.round(t.config.width),Math.round(t.config.height))}drawRect(t){const e={...{x:0,y:0,width:this.canvas.width,height:this.canvas.height,color:"rgba(1,0,0,1)",radius:0},...t};this.context.fillStyle=e.color,this.context.fillRect(e.x,e.y,e.width,e.height)}drawStar(t){const e={x_center:0,y_center:0,spikes:5,color:"rgba(0,0,0,1)",outerRadius:100,innerRadius:150,...t};var i=Math.PI/2*3,a=e.x_center,n=e.y_center,o=Math.PI/e.spikes;this.context.beginPath(),this.context.moveTo(e.x_center,e.y_center-e.outerRadius);for(let t=0;t<e.spikes;t++)a=e.x_center+Math.cos(i)*e.outerRadius,n=e.y_center+Math.sin(i)*e.outerRadius,this.context.lineTo(a,n),i+=o,a=e.x_center+Math.cos(i)*e.innerRadius,n=e.y_center+Math.sin(i)*e.innerRadius,this.context.lineTo(a,n),i+=o;this.context.lineTo(e.x_center,e.y_center-e.outerRadius),this.context.closePath(),this.context.fillStyle=e.color,this.context.fill()}drawGradient(t){const e={x:0,y:0,width:100,height:100,direction:"DOWN",gradient:[[0,"rgba(0,0,0, 0)"],[1,"rgba(0,0,0, 1)"]],...t};if(!["UP","RIGHT","DOWN","LEFT"].includes(e.direction))throw new Error('Invalid direction value. It must be "UP", "RIGHT", "DOWN", or "LEFT".');let i,a,n,o;"UP"===e.direction?(i=e.x,a=e.y+e.height,n=e.x,o=e.y):"RIGHT"===e.direction?(i=e.x,a=e.y,n=e.x+e.width,o=e.y):"DOWN"===e.direction?(i=e.x,a=e.y,n=e.x,o=e.y+e.height):"LEFT"===e.direction&&(i=e.x+e.width,a=e.y,n=e.x,o=e.y);const r=this.context.createLinearGradient(i,a,n,o);for(let t=0;t<e.gradient.length;t++){let i=e.gradient[t][0],a=e.gradient[t][1];r.addColorStop(i,a)}this.context.fillStyle=r,this.context.fillRect(e.x,e.y,e.width,e.height)}prepareFilter(t){this.context.filter=t}applyFilter(t){this.context.filter=t,this.context.drawImage(this.canvas,0,0),this.context.filter="none"}applyLUT(t){t.isLoaded||console.log("LUT not loaded",t.name);const e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=e.data;for(let e=0;e<i.length;e+=4){const a=i[e]/255,n=i[e+1]/255,o=i[e+2]/255,[r,s,h]=apply3DLUT(a,n,o,t.lutData);i[e]=255*r,i[e+1]=255*s,i[e+2]=255*h}function apply3DLUT(t,e,i,{size:a,lut:n}){const o=a-1;return n[Math.min(Math.floor(t*o),o)+Math.min(Math.floor(e*o),o)*a+Math.min(Math.floor(i*o),o)*a*a]}this.context.putImageData(e,0,0)}update(){this.drawInstructions&&(this.clear(),this.drawInstructions())}clear(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.isDrawn=!1}}class Raffaello_ImageCropper{constructor(t,e){this.container=t,this.config=e,this.config.imageReady=!1,this.initDynamicElements(),this.initElements(),this.initCropper(),this.bindEvents(),this.initRatioSelect(),this.initWatermark(),this.filterValues={},this.initFilterControls()}initDynamicElements(){const t=this.container.querySelector(".raffaello-imageContainer");t.style.backgroundColor="rgb(51, 51, 51)";const e=document.createElement("input");e.type="file",e.className="raffaello-imageInput",e.accept="image/*",e.style.display="none",t.innerHTML+="\x3c!-- FILE INPUT --\x3e",t.appendChild(e);const i=document.createElement("div");i.className="raffaello-upload";const a=document.createElement("img");checkImageSrc("src/svg/upload.svg",(t=>{a.src=t?"src/svg/upload.svg":"raffaello/src/svg/upload.svg"})),a.className="icon",i.appendChild(a),t.innerHTML+="\x3c!-- UPLOAD INPUT --\x3e",t.appendChild(i);const n=document.createElement("div");n.className="raffaello-loading";const o=document.createElement("div");o.className="raffaello-loading-circle",n.appendChild(o),t.appendChild(n);const r=this.container.querySelector(".raffaello-imageFiltres");if(r){r.classList.add("flex-row"),r.style.gap="2px";const t=document.createElement("p");t.className="small-p-2 brightness-label",r.appendChild(t);const e=document.createElement("input");e.type="range",e.name="brightness",e.displayName="LuminositΓ©",e.min="-100",e.max="100",e.value="20",r.appendChild(e);const i=document.createElement("p");i.className="small-p-2 contrast-label",r.appendChild(i);const a=document.createElement("input");a.type="range",a.name="contrast",a.displayName="Contraste",a.min="-100",a.max="100",a.value="20",r.appendChild(a);const n=document.createElement("p");n.className="small-p-2 saturate-label",r.appendChild(n);const o=document.createElement("input");o.type="range",o.name="saturate",o.displayName="Saturation",o.min="-100",o.max="100",o.value="20",r.appendChild(o)}const s=this.container.querySelector(".raffaello-cropperRestart");if(s){this.cropperRestart=s,s.classList.add("raffaello-restart"),s.style.display="none";const t=document.createElement("img");checkImageSrc("src/svg/restart.svg",(e=>{t.src=e?"src/svg/restart.svg":"raffaello/src/svg/restart.svg"})),t.className="icon",s.innerHTML+="\x3c!-- REFRESH SVG --\x3e",s.appendChild(t)}}initElements(){this.dropzone=this.container.querySelector(".raffaello-imageContainer"),this.imageInput=this.container.querySelector(".raffaello-imageInput"),this.upload=this.container.querySelector(".raffaello-upload"),this.loading=this.container.querySelector(".raffaello-loading"),this.cropperContainer=this.container.querySelector(".raffaello-cropperContainer")}initCropper(){this.cropper=new Cropper(this.cropperContainer,{aspectRatio:this.config.aspectRatio??this.config.width/this.config.height,viewMode:this.config.viewMode??2,autoCropArea:1,zoomOnWheel:this.config.zoomOnWheel??0,ready:()=>{this.applyFilters(),this.config.rawImage=this.cropperContainer,this.config.cropInfo=this.cropper.getData(),this.config.imageReady=!0,this.config.onImageReady?this.config.onImageReady():console.log(this.config)}})}bindEvents(){this.upload.addEventListener("click",(()=>{"INPUT"===this.imageInput.tagName&&"file"===this.imageInput.type||console.warn('Warning: this.imageInput is not an <input> element of type "file". Nothing should have a class "raffaello-imageInput"'),this.imageInput.click()})),this.imageInput.addEventListener("change",(t=>{this.loadSelectedImage(t)})),this.dropzone.addEventListener("dragover",(t=>t.preventDefault())),this.dropzone.addEventListener("drop",(t=>{t.preventDefault(),console.log("We have a drop");const e=t.dataTransfer.files[0];e.type.match(/^image\//)?this.loadSelectedImage({target:{files:[e]}}):console.log("Invalid file type. Only image files are allowed.")})),this.cropperContainer.addEventListener("crop",(t=>{this.config.cropInfo=this.cropper.getData()})),this.cropperRestart&&this.cropperRestart.addEventListener("click",(()=>{this.imageInput.click()})),this.config.onCrop&&this.cropperContainer.addEventListener("crop",this.config.onCrop),this.config.onCropStart&&this.cropperContainer.addEventListener("cropstart",this.config.onCropStart),this.config.onCropEnd&&this.cropperContainer.addEventListener("cropend",this.config.onCropEnd),this.config.onZoom&&this.cropperContainer.addEventListener("zoom",this.config.onZoom),void 0!==this.config.layerIndex&&void 0!==this.config.layerRef&&(this.config.onImageReady=()=>{this.config.layerRef.initiateDrawing()},this.config.onFilterChange=()=>{this.config.layerRef.canvas.updateLayers([this.config.layerIndex])},this.cropperContainer.addEventListener("onCrop",(()=>{})),this.cropperContainer.addEventListener("cropstart",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=.5})),this.cropperContainer.addEventListener("cropend",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=1,this.config.layerRef.canvas.updateLayers([this.config.layerIndex])})))}showBackInitialUI(){"none"==this.upload.style.display&&(this.upload.style.display="flex");const t=this.cropperRestart;t&&(t.style.display="none")}loadSelectedImage(t){return new Promise(((e,i)=>{const a=t.target.files[0];if(!a)return;"none"!==this.upload.style.display&&(this.upload.style.display="none"),"none"===this.loading.style.display&&(this.loading.style.display="flex");const n=this.cropperRestart;n&&(n.style.display="block");const o=new FileReader;o.addEventListener("load",(()=>{this.loading.style.display="none",this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")));let t=a.name.split(".")[0];this.config.fileName=t,this.cropperContainer.src=o.result,this.cropper.replace(this.cropperContainer.src),e(t)})),o.readAsDataURL(a)}))}initRatioSelect(){this.imageRatioSelect=this.container.querySelector(".raffaello-imageRatioSelect"),this.imageRatioSelect&&this.imageRatioSelect.addEventListener("change",(()=>{const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.width,e=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.height;this.config.width=t,this.config.height=e;const i=t/e;this.cropper.setAspectRatio(i),this.watermarkSelect&&this.resetWatermarkList()}))}setNewSize(t,e){const i=t/e;this.cropper.setAspectRatio(i)}initWatermark(){this.watermarkDiv=this.container.querySelector(".raffaello-watermark"),this.watermarkDiv&&(this.watermarkDiv.classList.add("raffaello-canvas-to-overlay","icon"),""!==this.watermarkDiv.src&&this.watermarkDiv.src!==window.location.href||(this.watermarkDiv.style.display="none"),this.cropperContainer.addEventListener("crop",(()=>{this.updateWatermarkPositionAndSize()})),this.watermarkSelect=this.container.querySelector(".raffaello-watermarkSelect"),this.watermarkSelect&&this.watermarkSelect.addEventListener("change",(()=>{this.updateWatermark()})))}updateWatermark(){const t=this.watermarkSelect.options[this.watermarkSelect.selectedIndex].dataset.watermark;t?(this.watermarkDiv.src=t,this.watermarkDiv.style.display="block"):(this.watermarkDiv.src="",this.watermarkDiv.style.display="none"),this.updateWatermarkPositionAndSize()}updateWatermarkPositionAndSize(){const t=this.cropper.getCropBoxData();this.watermarkDiv.style.width=Math.ceil(t.width)+1+"px",this.watermarkDiv.style.height=Math.ceil(t.height)+1+"px",this.watermarkDiv.style.left=t.left-.5+"px",this.watermarkDiv.style.top=t.top-.5+"px"}resetWatermarkList(){this.watermarkSelect.selectedIndex=0,this.watermarkDiv.src="",this.watermarkDiv.style.display="none";const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.ratio;for(let e=1;e<this.watermarkSelect.options.length;e++){const i=this.watermarkSelect.options[e];i.dataset.ratio===t?i.style.display="block":i.style.display="none"}}initFilterControls(){const t=this.container.querySelector(".raffaello-imageFiltres");if(t){t.querySelectorAll('input[type="range"]').forEach((t=>{const e=t.name||t.dataset.filter,i=t.displayName;this.filterValues[e]=t.value,this.updateFilterValue(e,i,t.value),t.addEventListener("input",(t=>{this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),t.addEventListener("dblclick",(t=>{t.target.value=20,this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),this.config.onFilterChange&&(t.addEventListener("input",this.config.onFilterChange),t.addEventListener("dblclick",this.config.onFilterChange))}))}}linear(t,e,i,a,n){return(t-e)/(i-e)*(n-a)+a}updateFilterValue(t,e,i){let a;a="brightness"===t?i<0?this.linear(i,-100,0,.8,1):this.linear(i,0,100,1,1.4):"contrast"===t?i<0?this.linear(i,-100,0,.9,1):this.linear(i,0,100,1,1.3):"saturate"===t?i<0?this.linear(i,-100,0,0,1):this.linear(i,0,100,1,1.3):i;let n=i,o=this.container.querySelector(`.${t}-label`);o&&(o.innerHTML=`${e.charAt(0).toUpperCase()+e.slice(1)} <i>(${n})</i>`),this.filterValues[t]=a}applyFilters(){let t=Object.entries(this.filterValues).map((([t,e])=>`${t}(${e})`)).join(" ");this.config.filter=t;const e=this.container.querySelector(".cropper-crop-box .cropper-view-box"),i=this.container.querySelector(".cropper-wrap-box div");e&&(e.style.filter=t),i&&(i.style.filter=t)}}function checkImageSrc(t,e){const i=new Image;i.onload=()=>e(!0),i.onerror=()=>e(!1),i.src=t}window.Raffaello_Canvas=class Raffaello_Canvas{constructor(t){if(this.width=t.width??1e3,this.height=t.height??1e3,this.cornerRadius=t.cornerRadius??0,this.previewContainer=t.previewContainer??null,this.nameInputContainer=t.nameInputContainer??null,this.previewQuality=t.previewQuality??"0.8",this.renderQuality=t.renderQuality??"0.96",this.layers=[],this.previewContainer){const e=window.getComputedStyle(this.previewContainer).backgroundColor;t.previewBackgroundColor?this.previewBackgroundColor=t.previewBackgroundColor:e&&"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(this.previewBackgroundColor=e)}}addLayer(t="normal",e=null){let i=new Raffaello_CanvasLayer(this.width,this.height,t,e);return this.layers.push(i),i}updateLayers(t){for(const e of t)this.layers[e]?this.layers[e].update():console.warn(`> updateLayers([${e}]): The canvas does not have a layer ${e}`);this.renderPreview()}resetLayers(){this.layers=[]}render(t=!1){let e=document.createElement("canvas");e.width=this.width,e.height=this.height;let i=e.getContext("2d");this.cornerRadius>0&&(i.save(),i.beginPath(),i.roundRect(0,0,e.width,e.height,this.cornerRadius),i.clip()),t&&null!=this.previewBackgroundColor&&(i.fillStyle=this.previewBackgroundColor,i.fillRect(0,0,e.width,e.height));for(let t=0;t<this.layers.length;t++){const e=this.layers[t],a=this.layers[t+1];let n=e.canvas;if("alpha"===a?.type){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;let i=t.getContext("2d");i.drawImage(a.canvas,0,0),i.globalCompositeOperation="source-in",i.drawImage(e.canvas,0,0),i.globalCompositeOperation="source-over",n=t}["image","normal"].includes(e.type)&&i.drawImage(n,0,0),"effect"===e.type&&(i.globalCompositeOperation=e.effect,i.drawImage(n,0,0),i.globalCompositeOperation="source-over")}return this.cornerRadius>0&&i.restore(),e}renderPreview(){if(!this.previewContainer)return;const t=this.previewContainer;/iPad|iPhone|iPod/.test(navigator.userAgent)?t.src=this.render().toDataURL("image/jpeg",.9):t.src=this.render(!0).toDataURL("image/jpeg",this.previewQuality)}downloadImage(){const t=this.render();let e,i,a=this.nameInputContainer.value.trim(),n=a?a.split(".")[0].replace(/[^a-zA-Z0-9\_-]/g,""):"Image_Raffaello";switch(a.split(".").pop().toLowerCase()){case"jpg":case"jpeg":e="image/jpeg",i=".jpg";break;default:e="image/png",i=".png"}if(/iPad|iPhone|iPod/.test(navigator.userAgent))window.alert("Appuyez et maintenez l'image pour l'enregistrer.");else{const a=document.createElement("a");a.download=n+i,a.href=t.toDataURL(e,"image/jpeg"===e?this.renderQuality:void 0),document.body.appendChild(a),a.click(),document.body.removeChild(a)}}},window.Raffaello_CanvasLayer=Raffaello_CanvasLayer,window.Raffaello_ImageCropper=Raffaello_ImageCropper,window.Raffaello_BatchImageCropper=class Raffaello_BatchImageCropper{constructor(t,e){this.input=t,this.container=this.input.container,this.canvas=this.input.canvas,this.imageConfigs=e,this.imagesAreReady=e.map((t=>!0===t.isOptionnal)),this.inputImages=[],this.initializeCroppers()}initializeCroppers(){this.inputImages=this.imageConfigs.map(((t,e)=>new Raffaello_ImageCropper(this.container.querySelector(t.selector),{width:t.width,height:t.height,viewMode:t.viewMode??2,zoomOnWheel:t.zoomOnWheel??0,onImageReady:()=>{this.markImageAsReady(e)},onCropStart:()=>{this.canvas.previewContainer.style.opacity=.5},onCropEnd:()=>{this.canvas.previewContainer.style.opacity=1,this.canvas.updateLayers([t.layerIndex])},onZoom:()=>{this.canvas.updateLayers([t.layerIndex])},onFilterChange:()=>{this.canvas.updateLayers([t.layerIndex])}})))}markImageAsReady(t){this.imagesAreReady[t]=!0,this.checkImagesAreReady()}checkImagesAreReady(){this.imagesAreReady.every((t=>t))&&(this.removePendingState(),console.log("All images are ready, starting to draw..."),this.input.initiateDrawing())}removePendingState(){this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")))}},window.Raffaello_Image=class Raffaello_Image{constructor(t){const e=t.url;this.img=new Image,this.img.src=e,this.isLoaded=!1,this.img.onload=()=>{this.isLoaded=!0,console.log(`β
Image ${e.split("/").slice(-1)} loaded successfully.`)},this.img.onerror=()=>{console.error("β Failed to load image:",e)}}getImage(){return this.isLoaded?this.img:(console.warn("β Image not loaded yet."),null)}isLoaded(){return this.isLoaded}},window.Raffaello_Font=class Raffaello_Font{constructor(t){const e=t.name;this.font=new FontFace(e,`url(${t.url})`),this.isLoaded=!1;let i=this.font;document.fonts.add(i),i.load().then((()=>{this.isLoaded=!0,console.log(`β
Font ${e} loaded successfully.`)})).catch((()=>{console.error("β Failed to load font:",e)}))}isLoaded(){return this.isLoaded}},window.Raffaello_LUT=class Raffaello_LUT{constructor(t){const e=t.url;this.lutData=null,this.isLoaded=!1,this.name=e.split("/").slice(-1),this.loadLUT(e).then((t=>{this.lutData=t,this.isLoaded=!0,console.log(`β
LUT ${this.name} loaded successfully.`)})).catch((t=>{console.log(`β Failed to load LUT: ${e}`),console.error(t)}))}async loadLUT(t){try{const e=await fetch(t),i=(await e.text()).split("\n"),a=[];let n=0;for(const t of i)if(t.startsWith("LUT_3D_SIZE"))n=parseInt(t.split(" ")[1],10);else if(!t.startsWith("#")&&""!==t.trim()){const e=t.split(" ").map(Number);3===e.length&&a.push(e)}if(!n)throw new Error("Invalid LUT file.");return{size:n,lut:a}}catch(t){throw new Error(`Error parsing LUT file: ${t.message}`)}}getLUT(){return this.isLoaded?this.lutData:(console.warn("β LUT not loaded yet."),null)}isLUTLoaded(){return this.isLoaded}},window.Raffaello_FullScreen=class Raffaello_FullScreen{constructor(t){this.previewContainers=document.querySelectorAll(`.${t.previewContainer}`),this.fullScreenElement=null,this.isFullScreen=!1,this.previewContainers.length?(this.initializeFullScreen(),this.setupEventListeners()):console.error("RAFFAELLO - No preview containers found.")}initializeFullScreen(){this.fullScreenElement=document.createElement("div"),this.fullScreenElement.classList.add("raffaello-fullscreen-overlay"),this.fullScreenElement.style.position="fixed",this.fullScreenElement.style.top="0",this.fullScreenElement.style.left="0",this.fullScreenElement.style.width="100%",this.fullScreenElement.style.height="100%",this.fullScreenElement.style.padding="25px",this.fullScreenElement.style.backgroundColor="rgba(0, 0, 0, 0.9)",this.fullScreenElement.style.display="none",this.fullScreenElement.style.zIndex="9999",this.fullScreenElement.style.cursor="pointer",this.fullScreenElement.style.alignItems="center",this.fullScreenElement.style.justifyContent="center";const t=document.createElement("img");t.style.maxWidth="100%",t.style.maxHeight="100%",t.setAttribute("draggable","false"),t.addEventListener("dragstart",(function(t){t.preventDefault()})),t.addEventListener("contextmenu",(function(t){t.preventDefault()})),this.fullScreenElement.appendChild(t),document.body.appendChild(this.fullScreenElement)}toggleFullScreen(){this.isFullScreen=!this.isFullScreen,this.isFullScreen?(this.fullScreenElement.style.display="flex",document.body.style.overflow="hidden"):(this.fullScreenElement.style.display="none",document.body.style.overflow="auto")}setupEventListeners(){this.previewContainers.forEach((t=>{t.style.cursor="pointer",t.addEventListener("click",(()=>{const e=t.src;this.fullScreenElement.querySelector("img").src=e,this.toggleFullScreen()}))})),this.fullScreenElement.addEventListener("click",(()=>{this.toggleFullScreen()}))}},window.Raffaello_PersistentInputs=class Raffaello_PersistentInputs{constructor({inputs:t,timeout:e}){this.textareas=document.querySelectorAll(`.${t}`),this.timeout=e,this.textareas.length?this.init():console.error(`INFO: No element with class ${t}`)}init(){this.cleanupOldKeys(),this.textareas.forEach(((t,e)=>{const i=this.generateKey(e);this.loadAndValidateContent(t,i);const a=this.debounce((()=>this.saveContent(t,i)),500);t.addEventListener("input",a)}))}cleanupOldKeys(){for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&e.startsWith("textareaContent_")&&localStorage.removeItem(e)}}generateKey(t){return`${window.location.pathname}_textareaContent_${this.timeout}_${t}`}loadAndValidateContent(t,e){const i=`${e}_timestamp`,a=localStorage.getItem(e),n=localStorage.getItem(i);if(a&&n){const o=Date.now()-parseInt(n,10);console.log("elapsed",o),console.log("this.timeout",this.timeout),o<=this.timeout?t.value=a:(console.log(`Key expired: ${e}`),localStorage.removeItem(e),localStorage.removeItem(i))}else localStorage.removeItem(e),localStorage.removeItem(i)}saveContent(t,e){const i=`${e}_timestamp`;localStorage.setItem(e,t.value),localStorage.setItem(i,Date.now().toString())}debounce(t,e){let i;return(...a)=>{clearTimeout(i),i=setTimeout((()=>t(...a)),e)}}},async function v_k(){const t=document.currentScript||document.querySelector('script[src*="raffaello"]'),e=t?.dataset?.key,i=atob("UkFGRkFFTExPOiBObyBsaWNlbnNlIGtleSBwcm92aWRlZA==");atob("UkFGRkFFTExPOiBJbnZhbGlkIG9yIHVuYXV0aG9yaXplZCBsaWNlbnNlIGtleQ=="),atob("UkFGRkFFTExPOiBDb3VsZCBub3QgdmFsaWRhdGUgbGljZW5zZSBrZXkgKG5ldHdvcmsgaXNzdWU/KQ=="),e||console.warn(i)}()}();
|
|
36
|
+
*/var t,e;t=window,e=function(){function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach((function(e){_defineProperty(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var t="undefined"!=typeof window&&void 0!==window.document,e=t?window:{},i=!(!t||!e.document.documentElement)&&"ontouchstart"in e.document.documentElement,n=!!t&&"PointerEvent"in e,o="cropper",r="all",s="crop",h="move",l="zoom",c="e",d="w",p="s",u="n",m="ne",g="nw",f="se",v="sw",y="".concat(o,"-crop"),w="".concat(o,"-disabled"),x="".concat(o,"-hidden"),b="".concat(o,"-hide"),C="".concat(o,"-invisible"),S="".concat(o,"-modal"),L="".concat(o,"-move"),k="".concat(o,"Action"),D="".concat(o,"Preview"),E="crop",M="move",R="none",I="crop",T="cropend",N="cropmove",B="cropstart",A="dblclick",O=n?"pointerdown":i?"touchstart":"mousedown",_=n?"pointermove":i?"touchmove":"mousemove",z=n?"pointerup pointercancel":i?"touchend touchcancel":"mouseup",W="ready",F="resize",P="wheel",j="zoom",H="image/jpeg",Y=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,U=/^data:/,X=/^data:image\/jpeg;base64,/,$=/^img|canvas$/i,Z={viewMode:0,dragMode:E,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},q=Number.isNaN||e.isNaN;function isNumber(t){return"number"==typeof t&&!q(t)}var G=function isPositiveNumber(t){return t>0&&t<1/0};function isUndefined(t){return void 0===t}function isObject(t){return"object"===_typeof(t)&&null!==t}var V=Object.prototype.hasOwnProperty;function isPlainObject(t){if(!isObject(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&V.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}var Q=Array.prototype.slice;function toArray(t){return Array.from?Array.from(t):Q.call(t)}function forEach(t,e){return t&&isFunction(e)&&(Array.isArray(t)||isNumber(t.length)?toArray(t).forEach((function(i,n){e.call(t,i,n,t)})):isObject(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var K=Object.assign||function assign(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return isObject(t)&&i.length>0&&i.forEach((function(e){isObject(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},J=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return J.test(t)?Math.round(t*e)/e:t}var tt=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(t,e){var i=t.style;forEach(e,(function(t,e){tt.test(e)&&isNumber(t)&&(t="".concat(t,"px")),i[e]=t}))}function addClass(t,e){if(e)if(isNumber(t.length))forEach(t,(function(t){addClass(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function removeClass(t,e){e&&(isNumber(t.length)?forEach(t,(function(t){removeClass(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function toggleClass(t,e,i){e&&(isNumber(t.length)?forEach(t,(function(t){toggleClass(t,e,i)})):i?addClass(t,e):removeClass(t,e))}var et=/([a-z\d])([A-Z])/g;function toParamCase(t){return t.replace(et,"$1-$2").toLowerCase()}function getData(t,e){return isObject(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(toParamCase(e)))}function setData(t,e,i){isObject(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(toParamCase(e)),i)}var it=/\s\s*/,at=function(){var i=!1;if(t){var n=!1,o=function listener(){},r=Object.defineProperty({},"once",{get:function get(){return i=!0,n},set:function set(t){n=t}});e.addEventListener("test",o,r),e.removeEventListener("test",o,r)}return i}();function removeListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(!at){var r=t.listeners;r&&r[e]&&r[e][i]&&(o=r[e][i],delete r[e][i],0===Object.keys(r[e]).length&&delete r[e],0===Object.keys(r).length&&delete t.listeners)}t.removeEventListener(e,o,n)}))}function addListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(n.once&&!at){var r=t.listeners,s=void 0===r?{}:r;o=function handler(){delete s[e][i],t.removeEventListener(e,o,n);for(var r=arguments.length,h=new Array(r),l=0;l<r;l++)h[l]=arguments[l];i.apply(t,h)},s[e]||(s[e]={}),s[e][i]&&t.removeEventListener(e,s[e][i],n),s[e][i]=o,t.listeners=s}t.addEventListener(e,o,n)}))}function dispatchEvent(t,e,i){var n;return isFunction(Event)&&isFunction(CustomEvent)?n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(n)}function getOffset(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var nt=e.location,ot=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(t){var e=t.match(ot);return null!==e&&(e[1]!==nt.protocol||e[2]!==nt.hostname||e[3]!==nt.port)}function addTimestamp(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function getTransforms(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,o=t.translateX,r=t.translateY,s=[];isNumber(o)&&0!==o&&s.push("translateX(".concat(o,"px)")),isNumber(r)&&0!==r&&s.push("translateY(".concat(r,"px)")),isNumber(e)&&0!==e&&s.push("rotate(".concat(e,"deg)")),isNumber(i)&&1!==i&&s.push("scaleX(".concat(i,")")),isNumber(n)&&1!==n&&s.push("scaleY(".concat(n,")"));var h=s.length?s.join(" "):"none";return{WebkitTransform:h,msTransform:h,transform:h}}function getPointer(t,e){var i=t.pageX,n=t.pageY,o={endX:i,endY:n};return e?o:_objectSpread2({startX:i,startY:n},o)}function getAdjustedSizes(t){var e=t.aspectRatio,i=t.height,n=t.width,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",r=G(n),s=G(i);if(r&&s){var h=i*e;"contain"===o&&h>n||"cover"===o&&h<n?i=n/e:n=i*e}else r?i=n/e:s&&(n=i*e);return{width:n,height:i}}var rt=String.fromCharCode,st=/^data:.*,/;function resetAndGetOrientation(t){var e,i=new DataView(t);try{var n,o,r;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var s=i.byteLength,h=2;h+1<s;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){o=h;break}h+=1}if(o){var l=o+10;if("Exif"===function getStringFromCharCode(t,e,i){var n="";i+=e;for(var o=e;o<i;o+=1)n+=rt(t.getUint8(o));return n}(i,o+4,4)){var c=i.getUint16(l);if(((n=18761===c)||19789===c)&&42===i.getUint16(l+2,n)){var d=i.getUint32(l+4,n);d>=8&&(r=l+d)}}}if(r){var p,u,m=i.getUint16(r,n);for(u=0;u<m;u+=1)if(p=r+12*u+2,274===i.getUint16(p,n)){p+=8,e=i.getUint16(p,n),i.setUint16(p,1,n);break}}}catch(t){e=1}return e}var ht={render:function render(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function initContainer(){var t=this.element,e=this.options,i=this.container,n=this.cropper,o=Number(e.minContainerWidth),r=Number(e.minContainerHeight);addClass(n,x),removeClass(t,x);var s={width:Math.max(i.offsetWidth,o>=0?o:200),height:Math.max(i.offsetHeight,r>=0?r:100)};this.containerData=s,setStyle(n,{width:s.width,height:s.height}),addClass(t,x),removeClass(n,x)},initCanvas:function initCanvas(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,n=Math.abs(e.rotate)%180==90,o=n?e.naturalHeight:e.naturalWidth,r=n?e.naturalWidth:e.naturalHeight,s=o/r,h=t.width,l=t.height;t.height*s>t.width?3===i?h=t.height*s:l=t.width/s:3===i?l=t.width/s:h=t.height*s;var c={aspectRatio:s,naturalWidth:o,naturalHeight:r,width:h,height:l};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=K({},c)},limitCanvas:function limitCanvas(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=i.viewMode,h=o.aspectRatio,l=this.cropped&&r;if(t){var c=Number(i.minCanvasWidth)||0,d=Number(i.minCanvasHeight)||0;s>1?(c=Math.max(c,n.width),d=Math.max(d,n.height),3===s&&(d*h>c?c=d*h:d=c/h)):s>0&&(c?c=Math.max(c,l?r.width:0):d?d=Math.max(d,l?r.height:0):l&&(c=r.width,(d=r.height)*h>c?c=d*h:d=c/h));var p=getAdjustedSizes({aspectRatio:h,width:c,height:d});c=p.width,d=p.height,o.minWidth=c,o.minHeight=d,o.maxWidth=1/0,o.maxHeight=1/0}if(e)if(s>(l?0:1)){var u=n.width-o.width,m=n.height-o.height;o.minLeft=Math.min(0,u),o.minTop=Math.min(0,m),o.maxLeft=Math.max(0,u),o.maxTop=Math.max(0,m),l&&this.limited&&(o.minLeft=Math.min(r.left,r.left+(r.width-o.width)),o.minTop=Math.min(r.top,r.top+(r.height-o.height)),o.maxLeft=r.left,o.maxTop=r.top,2===s&&(o.width>=n.width&&(o.minLeft=Math.min(0,u),o.maxLeft=Math.max(0,u)),o.height>=n.height&&(o.minTop=Math.min(0,m),o.maxTop=Math.max(0,m))))}else o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=n.width,o.maxTop=n.height},renderCanvas:function renderCanvas(t,e){var i=this.canvasData,n=this.imageData;if(e){var o=function getRotatedSizes(t){var e=t.width,i=t.height,n=t.degree;if(90==(n=Math.abs(n)%180))return{width:i,height:e};var o=n%90*Math.PI/180,r=Math.sin(o),s=Math.cos(o),h=e*s+i*r,l=e*r+i*s;return n>90?{width:l,height:h}:{width:h,height:l}}({width:n.naturalWidth*Math.abs(n.scaleX||1),height:n.naturalHeight*Math.abs(n.scaleY||1),degree:n.rotate||0}),r=o.width,s=o.height,h=i.width*(r/i.naturalWidth),l=i.height*(s/i.naturalHeight);i.left-=(h-i.width)/2,i.top-=(l-i.height)/2,i.width=h,i.height=l,i.aspectRatio=r/s,i.naturalWidth=r,i.naturalHeight=s,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,setStyle(this.canvas,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function renderImage(t){var e=this.canvasData,i=this.imageData,n=i.naturalWidth*(e.width/e.naturalWidth),o=i.naturalHeight*(e.height/e.naturalHeight);K(i,{width:n,height:o,left:(e.width-n)/2,top:(e.height-o)/2}),setStyle(this.image,K({width:i.width,height:i.height},getTransforms(K({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function initCropBox(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,n=Number(t.autoCropArea)||.8,o={width:e.width,height:e.height};i&&(e.height*i>e.width?o.height=o.width/i:o.width=o.height*i),this.cropBoxData=o,this.limitCropBox(!0,!0),o.width=Math.min(Math.max(o.width,o.minWidth),o.maxWidth),o.height=Math.min(Math.max(o.height,o.minHeight),o.maxHeight),o.width=Math.max(o.minWidth,o.width*n),o.height=Math.max(o.minHeight,o.height*n),o.left=e.left+(e.width-o.width)/2,o.top=e.top+(e.height-o.height)/2,o.oldLeft=o.left,o.oldTop=o.top,this.initialCropBoxData=K({},o)},limitCropBox:function limitCropBox(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=this.limited,h=i.aspectRatio;if(t){var l=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,d=s?Math.min(n.width,o.width,o.width+o.left,n.width-o.left):n.width,p=s?Math.min(n.height,o.height,o.height+o.top,n.height-o.top):n.height;l=Math.min(l,n.width),c=Math.min(c,n.height),h&&(l&&c?c*h>l?c=l/h:l=c*h:l?c=l/h:c&&(l=c*h),p*h>d?p=d/h:d=p*h),r.minWidth=Math.min(l,d),r.minHeight=Math.min(c,p),r.maxWidth=d,r.maxHeight=p}e&&(s?(r.minLeft=Math.max(0,o.left),r.minTop=Math.max(0,o.top),r.maxLeft=Math.min(n.width,o.left+o.width)-r.width,r.maxTop=Math.min(n.height,o.top+o.height)-r.height):(r.minLeft=0,r.minTop=0,r.maxLeft=n.width-r.width,r.maxTop=n.height-r.height))},renderCropBox:function renderCropBox(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&setData(this.face,k,i.width>=e.width&&i.height>=e.height?h:r),setStyle(this.cropBox,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function output(){this.preview(),dispatchEvent(this.element,I,this.getData())}},lt={initPreview:function initPreview(){var t=this.element,e=this.crossOrigin,i=this.options.preview,n=e?this.crossOriginUrl:this.url,o=t.alt||"The image to preview",r=document.createElement("img");if(e&&(r.crossOrigin=e),r.src=n,r.alt=o,this.viewBox.appendChild(r),this.viewBoxImage=r,i){var s=i;"string"==typeof i?s=t.ownerDocument.querySelectorAll(i):i.querySelector&&(s=[i]),this.previews=s,forEach(s,(function(t){var i=document.createElement("img");setData(t,D,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=n,i.alt=o,i.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;"',t.innerHTML="",t.appendChild(i)}))}},resetPreview:function resetPreview(){forEach(this.previews,(function(t){var e=getData(t,D);setStyle(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function removeData(t,e){if(isObject(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(toParamCase(e)))}(t,D)}))},preview:function preview(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,n=i.width,o=i.height,r=t.width,s=t.height,h=i.left-e.left-t.left,l=i.top-e.top-t.top;this.cropped&&!this.disabled&&(setStyle(this.viewBoxImage,K({width:r,height:s},getTransforms(K({translateX:-h,translateY:-l},t)))),forEach(this.previews,(function(e){var i=getData(e,D),c=i.width,d=i.height,p=c,u=d,m=1;n&&(u=o*(m=c/n)),o&&u>d&&(p=n*(m=d/o),u=d),setStyle(e,{width:p,height:u}),setStyle(e.getElementsByTagName("img")[0],K({width:r*m,height:s*m},getTransforms(K({translateX:-h*m,translateY:-l*m},t))))})))}},ct={bind:function bind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&addListener(t,B,e.cropstart),isFunction(e.cropmove)&&addListener(t,N,e.cropmove),isFunction(e.cropend)&&addListener(t,T,e.cropend),isFunction(e.crop)&&addListener(t,I,e.crop),isFunction(e.zoom)&&addListener(t,j,e.zoom),addListener(i,O,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&addListener(i,P,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&addListener(i,A,this.onDblclick=this.dblclick.bind(this)),addListener(t.ownerDocument,_,this.onCropMove=this.cropMove.bind(this)),addListener(t.ownerDocument,z,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&addListener(window,F,this.onResize=this.resize.bind(this))},unbind:function unbind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&removeListener(t,B,e.cropstart),isFunction(e.cropmove)&&removeListener(t,N,e.cropmove),isFunction(e.cropend)&&removeListener(t,T,e.cropend),isFunction(e.crop)&&removeListener(t,I,e.crop),isFunction(e.zoom)&&removeListener(t,j,e.zoom),removeListener(i,O,this.onCropStart),e.zoomable&&e.zoomOnWheel&&removeListener(i,P,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&removeListener(i,A,this.onDblclick),removeListener(t.ownerDocument,_,this.onCropMove),removeListener(t.ownerDocument,z,this.onCropEnd),e.responsive&&removeListener(window,F,this.onResize)}},dt={resize:function resize(){if(!this.disabled){var t,e,i=this.options,n=this.container,o=this.containerData,r=n.offsetWidth/o.width,s=n.offsetHeight/o.height,h=Math.abs(r-1)>Math.abs(s-1)?r:s;1!==h&&(i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(forEach(t,(function(e,i){t[i]=e*h}))),this.setCropBoxData(forEach(e,(function(t,i){e[i]=t*h})))))}},dblclick:function dblclick(){this.disabled||this.options.dragMode===R||this.setDragMode(function hasClass(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}(this.dragBox,y)?M:E)},wheel:function wheel(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,n=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50),t.deltaY?n=t.deltaY>0?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=t.detail>0?1:-1),this.zoom(-n*i,t)))},cropStart:function cropStart(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(isNumber(e)&&1!==e||isNumber(i)&&0!==i||t.ctrlKey))){var n,o=this.options,r=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){r[t.identifier]=getPointer(t)})):r[t.pointerId||0]=getPointer(t),n=Object.keys(r).length>1&&o.zoomable&&o.zoomOnTouch?l:getData(t.target,k),Y.test(n)&&!1!==dispatchEvent(this.element,B,{originalEvent:t,action:n})&&(t.preventDefault(),this.action=n,this.cropping=!1,n===s&&(this.cropping=!0,addClass(this.dragBox,S)))}},cropMove:function cropMove(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==dispatchEvent(this.element,N,{originalEvent:t,action:e})&&(t.changedTouches?forEach(t.changedTouches,(function(t){K(i[t.identifier]||{},getPointer(t,!0))})):K(i[t.pointerId||0]||{},getPointer(t,!0)),this.change(t))}},cropEnd:function cropEnd(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,toggleClass(this.dragBox,S,this.cropped&&this.options.modal)),dispatchEvent(this.element,T,{originalEvent:t,action:e}))}}},pt={change:function change(t){var e,i=this.options,n=this.canvasData,o=this.containerData,y=this.cropBoxData,w=this.pointers,b=this.action,C=i.aspectRatio,S=y.left,L=y.top,k=y.width,D=y.height,E=S+k,M=L+D,R=0,I=0,T=o.width,N=o.height,B=!0;!C&&t.shiftKey&&(C=k&&D?k/D:1),this.limited&&(R=y.minLeft,I=y.minTop,T=R+Math.min(o.width,n.width,n.left+n.width),N=I+Math.min(o.height,n.height,n.top+n.height));var A=w[Object.keys(w)[0]],O={x:A.endX-A.startX,y:A.endY-A.startY},_=function check(t){switch(t){case c:E+O.x>T&&(O.x=T-E);break;case d:S+O.x<R&&(O.x=R-S);break;case u:L+O.y<I&&(O.y=I-L);break;case p:M+O.y>N&&(O.y=N-M)}};switch(b){case r:S+=O.x,L+=O.y;break;case c:if(O.x>=0&&(E>=T||C&&(L<=I||M>=N))){B=!1;break}_(c),(k+=O.x)<0&&(b=d,S-=k=-k),C&&(D=k/C,L+=(y.height-D)/2);break;case u:if(O.y<=0&&(L<=I||C&&(S<=R||E>=T))){B=!1;break}_(u),D-=O.y,L+=O.y,D<0&&(b=p,L-=D=-D),C&&(k=D*C,S+=(y.width-k)/2);break;case d:if(O.x<=0&&(S<=R||C&&(L<=I||M>=N))){B=!1;break}_(d),k-=O.x,S+=O.x,k<0&&(b=c,S-=k=-k),C&&(D=k/C,L+=(y.height-D)/2);break;case p:if(O.y>=0&&(M>=N||C&&(S<=R||E>=T))){B=!1;break}_(p),(D+=O.y)<0&&(b=u,L-=D=-D),C&&(k=D*C,S+=(y.width-k)/2);break;case m:if(C){if(O.y<=0&&(L<=I||E>=T)){B=!1;break}_(u),D-=O.y,L+=O.y,k=D*C}else _(u),_(c),O.x>=0?E<T?k+=O.x:O.y<=0&&L<=I&&(B=!1):k+=O.x,O.y<=0?L>I&&(D-=O.y,L+=O.y):(D-=O.y,L+=O.y);k<0&&D<0?(b=v,L-=D=-D,S-=k=-k):k<0?(b=g,S-=k=-k):D<0&&(b=f,L-=D=-D);break;case g:if(C){if(O.y<=0&&(L<=I||S<=R)){B=!1;break}_(u),D-=O.y,L+=O.y,k=D*C,S+=y.width-k}else _(u),_(d),O.x<=0?S>R?(k-=O.x,S+=O.x):O.y<=0&&L<=I&&(B=!1):(k-=O.x,S+=O.x),O.y<=0?L>I&&(D-=O.y,L+=O.y):(D-=O.y,L+=O.y);k<0&&D<0?(b=f,L-=D=-D,S-=k=-k):k<0?(b=m,S-=k=-k):D<0&&(b=v,L-=D=-D);break;case v:if(C){if(O.x<=0&&(S<=R||M>=N)){B=!1;break}_(d),k-=O.x,S+=O.x,D=k/C}else _(p),_(d),O.x<=0?S>R?(k-=O.x,S+=O.x):O.y>=0&&M>=N&&(B=!1):(k-=O.x,S+=O.x),O.y>=0?M<N&&(D+=O.y):D+=O.y;k<0&&D<0?(b=m,L-=D=-D,S-=k=-k):k<0?(b=f,S-=k=-k):D<0&&(b=g,L-=D=-D);break;case f:if(C){if(O.x>=0&&(E>=T||M>=N)){B=!1;break}_(c),D=(k+=O.x)/C}else _(p),_(c),O.x>=0?E<T?k+=O.x:O.y>=0&&M>=N&&(B=!1):k+=O.x,O.y>=0?M<N&&(D+=O.y):D+=O.y;k<0&&D<0?(b=g,L-=D=-D,S-=k=-k):k<0?(b=v,S-=k=-k):D<0&&(b=m,L-=D=-D);break;case h:this.move(O.x,O.y),B=!1;break;case l:this.zoom(function getMaxZoomRatio(t){var e=_objectSpread2({},t),i=0;return forEach(t,(function(t,n){delete e[n],forEach(e,(function(e){var n=Math.abs(t.startX-e.startX),o=Math.abs(t.startY-e.startY),r=Math.abs(t.endX-e.endX),s=Math.abs(t.endY-e.endY),h=Math.sqrt(n*n+o*o),l=(Math.sqrt(r*r+s*s)-h)/h;Math.abs(l)>Math.abs(i)&&(i=l)}))})),i}(w),t),B=!1;break;case s:if(!O.x||!O.y){B=!1;break}e=getOffset(this.cropper),S=A.startX-e.left,L=A.startY-e.top,k=y.minWidth,D=y.minHeight,O.x>0?b=O.y>0?f:m:O.x<0&&(S-=k,b=O.y>0?v:g),O.y<0&&(L-=D),this.cropped||(removeClass(this.cropBox,x),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}B&&(y.width=k,y.height=D,y.left=S,y.top=L,this.action=b,this.renderCropBox()),forEach(w,(function(t){t.startX=t.endX,t.startY=t.endY}))}},ut={crop:function crop(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&addClass(this.dragBox,S),removeClass(this.cropBox,x),this.setCropBoxData(this.initialCropBoxData)),this},reset:function reset(){return this.ready&&!this.disabled&&(this.imageData=K({},this.initialImageData),this.canvasData=K({},this.initialCanvasData),this.cropBoxData=K({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function clear(){return this.cropped&&!this.disabled&&(K(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),removeClass(this.dragBox,S),addClass(this.cropBox,x)),this},replace:function replace(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,forEach(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function enable(){return this.ready&&this.disabled&&(this.disabled=!1,removeClass(this.cropper,w)),this},disable:function disable(){return this.ready&&!this.disabled&&(this.disabled=!0,addClass(this.cropper,w)),this},destroy:function destroy(){var t=this.element;return t[o]?(t[o]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function move(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=i.left,o=i.top;return this.moveTo(isUndefined(t)?t:n+Number(t),isUndefined(e)?e:o+Number(e))},moveTo:function moveTo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(isNumber(t)&&(i.left=t,n=!0),isNumber(e)&&(i.top=e,n=!0),n&&this.renderCanvas(!0)),this},zoom:function zoom(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function zoomTo(t,e,i){var n=this.options,o=this.canvasData,r=o.width,s=o.height,h=o.naturalWidth,l=o.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&n.zoomable){var c=h*t,d=l*t;if(i){var p=this.pointers,u=getOffset(this.cropper),m=p&&Object.keys(p).length?function getPointersCenter(t){var e=0,i=0,n=0;return forEach(t,(function(t){var o=t.startX,r=t.startY;e+=o,i+=r,n+=1})),{pageX:e/=n,pageY:i/=n}}(p):{pageX:i.pageX,pageY:i.pageY};o.left-=(c-r)*((m.pageX-u.left-o.left)/r),o.top-=(d-s)*((m.pageY-u.top-o.top)/s)}else isPlainObject(e)&&isNumber(e.x)&&isNumber(e.y)?(o.left-=(c-r)*((e.x-o.left)/r),o.top-=(d-s)*((e.y-o.top)/s)):(o.left-=(c-r)/2,o.top-=(d-s)/2);if(o.width=c,o.height=d,this.renderCanvas(!0),!1===dispatchEvent(this.element,j,{ratio:t,oldRatio:r/h,originalEvent:i}))return this}return this},rotate:function rotate(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function rotateTo(t){return isNumber(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function scaleX(t){var e=this.imageData.scaleY;return this.scale(t,isNumber(e)?e:1)},scaleY:function scaleY(t){var e=this.imageData.scaleX;return this.scale(isNumber(e)?e:1,t)},scale:function scale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(isNumber(t)&&(i.scaleX=t,n=!0),isNumber(e)&&(i.scaleY=e,n=!0),n&&this.renderCanvas(!0,!0)),this},getData:function getData(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,n=this.imageData,o=this.canvasData,r=this.cropBoxData;if(this.ready&&this.cropped){t={x:r.left-o.left,y:r.top-o.top,width:r.width,height:r.height};var s=n.width/n.naturalWidth;if(forEach(t,(function(e,i){t[i]=e/s})),e){var h=Math.round(t.y+t.height),l=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=l-t.x,t.height=h-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=n.rotate||0),i.scalable&&(t.scaleX=n.scaleX||1,t.scaleY=n.scaleY||1),t},setData:function setData(t){var e=this.options,i=this.imageData,n=this.canvasData,o={};if(this.ready&&!this.disabled&&isPlainObject(t)){var r=!1;e.rotatable&&isNumber(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,r=!0),e.scalable&&(isNumber(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,r=!0),isNumber(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var s=i.width/i.naturalWidth;isNumber(t.x)&&(o.left=t.x*s+n.left),isNumber(t.y)&&(o.top=t.y*s+n.top),isNumber(t.width)&&(o.width=t.width*s),isNumber(t.height)&&(o.height=t.height*s),this.setCropBoxData(o)}return this},getContainerData:function getContainerData(){return this.ready?K({},this.containerData):{}},getImageData:function getImageData(){return this.sized?K({},this.imageData):{}},getCanvasData:function getCanvasData(){var t=this.canvasData,e={};return this.ready&&forEach(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function setCanvasData(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(e.left=t.left),isNumber(t.top)&&(e.top=t.top),isNumber(t.width)?(e.width=t.width,e.height=t.width/i):isNumber(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function getCropBoxData(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function setCropBoxData(t){var e,i,n=this.cropBoxData,o=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(n.left=t.left),isNumber(t.top)&&(n.top=t.top),isNumber(t.width)&&t.width!==n.width&&(e=!0,n.width=t.width),isNumber(t.height)&&t.height!==n.height&&(i=!0,n.height=t.height),o&&(e?n.height=n.width/o:i&&(n.width=n.height*o)),this.renderCropBox()),this},getCroppedCanvas:function getCroppedCanvas(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function getSourceCanvas(t,e,i,n){var o=e.aspectRatio,r=e.naturalWidth,s=e.naturalHeight,h=e.rotate,l=void 0===h?0:h,c=e.scaleX,d=void 0===c?1:c,p=e.scaleY,u=void 0===p?1:p,m=i.aspectRatio,g=i.naturalWidth,f=i.naturalHeight,v=n.fillColor,y=void 0===v?"transparent":v,w=n.imageSmoothingEnabled,x=void 0===w||w,b=n.imageSmoothingQuality,C=void 0===b?"low":b,S=n.maxWidth,L=void 0===S?1/0:S,k=n.maxHeight,D=void 0===k?1/0:k,E=n.minWidth,M=void 0===E?0:E,R=n.minHeight,I=void 0===R?0:R,T=document.createElement("canvas"),N=T.getContext("2d"),B=getAdjustedSizes({aspectRatio:m,width:L,height:D}),A=getAdjustedSizes({aspectRatio:m,width:M,height:I},"cover"),O=Math.min(B.width,Math.max(A.width,g)),_=Math.min(B.height,Math.max(A.height,f)),z=getAdjustedSizes({aspectRatio:o,width:L,height:D}),W=getAdjustedSizes({aspectRatio:o,width:M,height:I},"cover"),F=Math.min(z.width,Math.max(W.width,r)),P=Math.min(z.height,Math.max(W.height,s)),j=[-F/2,-P/2,F,P];return T.width=normalizeDecimalNumber(O),T.height=normalizeDecimalNumber(_),N.fillStyle=y,N.fillRect(0,0,O,_),N.save(),N.translate(O/2,_/2),N.rotate(l*Math.PI/180),N.scale(d,u),N.imageSmoothingEnabled=x,N.imageSmoothingQuality=C,N.drawImage.apply(N,[t].concat(_toConsumableArray(j.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),N.restore(),T}(this.image,this.imageData,e,t);if(!this.cropped)return i;var n=this.getData(),o=n.x,r=n.y,s=n.width,h=n.height,l=i.width/Math.floor(e.naturalWidth);1!==l&&(o*=l,r*=l,s*=l,h*=l);var c=s/h,d=getAdjustedSizes({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=getAdjustedSizes({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=getAdjustedSizes({aspectRatio:c,width:t.width||(1!==l?i.width:s),height:t.height||(1!==l?i.height:h)}),m=u.width,g=u.height;m=Math.min(d.width,Math.max(p.width,m)),g=Math.min(d.height,Math.max(p.height,g));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=normalizeDecimalNumber(m),f.height=normalizeDecimalNumber(g),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,g);var y=t.imageSmoothingEnabled,w=void 0===y||y,x=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,x&&(v.imageSmoothingQuality=x);var b,C,S,L,k,D,E=i.width,M=i.height,R=o,I=r;R<=-s||R>E?(R=0,b=0,S=0,k=0):R<=0?(S=-R,R=0,k=b=Math.min(E,s+R)):R<=E&&(S=0,k=b=Math.min(s,E-R)),b<=0||I<=-h||I>M?(I=0,C=0,L=0,D=0):I<=0?(L=-I,I=0,D=C=Math.min(M,h+I)):I<=M&&(L=0,D=C=Math.min(h,M-I));var T=[R,I,b,C];if(k>0&&D>0){var N=m/s;T.push(S*N,L*N,k*N,D*N)}return v.drawImage.apply(v,[i].concat(_toConsumableArray(T.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),f},setAspectRatio:function setAspectRatio(t){var e=this.options;return this.disabled||isUndefined(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function setDragMode(t){var e=this.options,i=this.dragBox,n=this.face;if(this.ready&&!this.disabled){var o=t===E,r=e.movable&&t===M;t=o||r?t:R,e.dragMode=t,setData(i,k,t),toggleClass(i,y,o),toggleClass(i,L,r),e.cropBoxMovable||(setData(n,k,t),toggleClass(n,y,o),toggleClass(n,L,r))}return this}},mt=e.Cropper,gt=function(){function Cropper(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Cropper),!t||!$.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=K({},Z,isPlainObject(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(Cropper,[{key:"init",value:function init(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[o]){if(e[o]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function load(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,n=this.options;if(n.rotatable||n.scalable||(n.checkOrientation=!1),n.checkOrientation&&window.ArrayBuffer)if(U.test(t))X.test(t)?this.read(function dataURLToArrayBuffer(t){var e=t.replace(st,""),i=atob(e),n=new ArrayBuffer(i.length),o=new Uint8Array(n);return forEach(o,(function(t,e){o[e]=i.charCodeAt(e)})),n}(t)):this.clone();else{var o=new XMLHttpRequest,r=this.clone.bind(this);this.reloading=!0,this.xhr=o,o.onabort=r,o.onerror=r,o.ontimeout=r,o.onprogress=function(){o.getResponseHeader("content-type")!==H&&o.abort()},o.onload=function(){e.read(o.response)},o.onloadend=function(){e.reloading=!1,e.xhr=null},n.checkCrossOrigin&&isCrossOriginURL(t)&&i.crossOrigin&&(t=addTimestamp(t)),o.open("GET",t,!0),o.responseType="arraybuffer",o.withCredentials="use-credentials"===i.crossOrigin,o.send()}else this.clone()}}},{key:"read",value:function read(t){var e=this.options,i=this.imageData,n=resetAndGetOrientation(t),o=0,r=1,s=1;if(n>1){this.url=function arrayBufferToDataURL(t,e){for(var i=[],n=new Uint8Array(t);n.length>0;)i.push(rt.apply(null,toArray(n.subarray(0,8192)))),n=n.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,H);var h=function parseOrientation(t){var e=0,i=1,n=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:n=-1;break;case 5:e=90,n=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:n}}(n);o=h.rotate,r=h.scaleX,s=h.scaleY}e.rotatable&&(i.rotate=o),e.scalable&&(i.scaleX=r,i.scaleY=s),this.clone()}},{key:"clone",value:function clone(){var t=this.element,e=this.url,i=t.crossOrigin,n=e;this.options.checkCrossOrigin&&isCrossOriginURL(e)&&(i||(i="anonymous"),n=addTimestamp(e)),this.crossOrigin=i,this.crossOriginUrl=n;var o=document.createElement("img");i&&(o.crossOrigin=i),o.src=n||e,o.alt=t.alt||"The image to crop",this.image=o,o.onload=this.start.bind(this),o.onerror=this.stop.bind(this),addClass(o,b),t.parentNode.insertBefore(o,t.nextSibling)}},{key:"start",value:function start(){var t=this,i=this.image;i.onload=null,i.onerror=null,this.sizing=!0;var n=e.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(e.navigator.userAgent),o=function done(e,i){K(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=K({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!i.naturalWidth||n){var r=document.createElement("img"),s=document.body||document.documentElement;this.sizingImage=r,r.onload=function(){o(r.width,r.height),n||s.removeChild(r)},r.src=i.src,n||(r.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;",s.appendChild(r))}else o(i.naturalWidth,i.naturalHeight)}},{key:"stop",value:function stop(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function build(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,n=t.parentNode,s=document.createElement("div");s.innerHTML='<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>';var h=s.querySelector(".".concat(o,"-container")),l=h.querySelector(".".concat(o,"-canvas")),c=h.querySelector(".".concat(o,"-drag-box")),d=h.querySelector(".".concat(o,"-crop-box")),p=d.querySelector(".".concat(o,"-face"));this.container=n,this.cropper=h,this.canvas=l,this.dragBox=c,this.cropBox=d,this.viewBox=h.querySelector(".".concat(o,"-view-box")),this.face=p,l.appendChild(i),addClass(t,x),n.insertBefore(h,t.nextSibling),removeClass(i,b),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,addClass(d,x),e.guides||addClass(d.getElementsByClassName("".concat(o,"-dashed")),x),e.center||addClass(d.getElementsByClassName("".concat(o,"-center")),x),e.background&&addClass(h,"".concat(o,"-bg")),e.highlight||addClass(p,C),e.cropBoxMovable&&(addClass(p,L),setData(p,k,r)),e.cropBoxResizable||(addClass(d.getElementsByClassName("".concat(o,"-line")),x),addClass(d.getElementsByClassName("".concat(o,"-point")),x)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),isFunction(e.ready)&&addListener(t,W,e.ready,{once:!0}),dispatchEvent(t,W)}}},{key:"unbuild",value:function unbuild(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),removeClass(this.element,x)}}},{key:"uncreate",value:function uncreate(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function noConflict(){return window.Cropper=mt,Cropper}},{key:"setDefaults",value:function setDefaults(t){K(Z,isPlainObject(t)&&t)}}]),Cropper}();return K(gt.prototype,ht,lt,ct,dt,pt,ut),gt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e(),window.validLicenseCheckPassed=!0,window.systemVerified=!0,window.initComplete=!0;const i=["","Uk-FGRkF-FTExPOiBO-byBsaWNlb-nNlIGtleSB-wcm92aWRlZA==","UkFGRk-FFTExPOiBJbnZhbGlk-IG9yIHVuYXV0-aG9yaXp-lZCBsa-WNlbnNlIGtleQ==","UkFGR-kFFTE-xPOiBDb3VsZCBub3QgdmFsaWRhdGU-gbGljZW5zZSBrZX-kgKG5ldHdvcmsg-aXNzdWU/KQ==","aHR0cHM6Ly9-yYWZmYW-VsbG8ub25yZW5kZXIuY29tL2xpY2Vu-Y2U/a2V5PQ==","JmRv-bWFp-bj0=","UkFGRkF-FTExPX2xpY-2VuY2-VfY2hlY2-tlZF8=","Um-FmZmF-lbGxvX0N-hbnZh-cw==","c-mVuZ-GV-y","cmVu-ZGVy-UH-Jldmlldw==","dm-FsaW-Q=","TGljZW5-zZSB2YWxpZGF0aW9uIGNvdWxkIG5-vdCBiZSBjb25maXJtZWQuIENvbnRpbn-Vpbmcgd2l0aG91dCBkaXNhY-mxpbmcu","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd",""];function a(t){return atob(i[t].split("").filter((t=>"-"!==t)).join(""))}window.r_o=!0;class Raffaello_CanvasLayer{constructor(t,e,i="normal",n=null){this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.type=i,this.effect=n,this.drawInstructions=null,this.bounds={minX:null,minY:null,maxX:null,maxY:null},this.isDrawn=!1}draw(t){return this.drawInstructions=t,this.drawInstructions(),this.isDrawn=!0,this}drawText(t){if(!t.text)return void(this.bounds={minX:null,maxX:null,minY:null,maxY:null});let e;if(t.text instanceof HTMLInputElement||t.text instanceof HTMLTextAreaElement)e=t.text.value;else{if("string"!=typeof t.text)return console.log("Error on the drawText(), the text input is not a valid string."),void console.log(t.text);e=t.text}const i={fontKerningOptical:!1,fontLetterSpacing:0,textAlign:{horizontal:"left",vertical:"bottom"},textBaseline:"alphabetic",anchorPoint:"none",position:{max_width:0,max_width_rescale:!1,max_lines:0,ignore_empty_lines:!0,ignore_double_spaces:!0},bounds:[!0,!0]},n={...i,...t,textAlign:{...i.textAlign,...t.textAlign},bounds:{...i.bounds,...t.bounds},position:{...i.position,...t.position}};n.fontLineHeight=t.fontLineHeight||t.fontSize;let o=e.split("\n");!1!==n.position.ignore_empty_lines&&(o=o.filter((t=>t.trim().length>0))),o=o.map((t=>t.trim())),!1!==n.position.ignore_double_spaces&&(o=o.map((t=>t.replace(/\s+/g," ")))),this.context.font=`${n.fontSize}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize/100*n.fontLetterSpacing+"px",this.context.textAlign=n.textAlign.horizontal,this.context.textBaseline=n.textBaseline,this.context.fontKerning=n.fontKerningOptical?"auto":"normal";let r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxLeft)),0),s=1;if(n.position.max_width&&n.position.max_width_rescale)s=r>n.position.max_width?1/r*n.position.max_width:1;else if(n.position.max_width&&!n.position.max_width_rescale){let t=[];o.forEach((e=>{let i=e.split(" "),o="";i.forEach(((e,r)=>{let s=o+(o?" ":"")+e;this.context.measureText(s.replaceAll("Β§","")).width>n.position.max_width&&""!==o?(t.push(o),o=e):o=s,r===i.length-1&&t.push(o)}))})),o=t,r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("Β§","")).actualBoundingBoxLeft)),0)}n.position.max_lines&&(o=o.slice(0,n.position.max_lines)),this.context.font=`${n.fontSize*s}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize*s/100*n.fontLetterSpacing+"px";let h=this.context.measureText("Lp");n.bounds&&(!n.bounds[0]&&n.bounds[1]?h=this.context.measureText("p"):n.bounds[0]&&!n.bounds[1]?h=this.context.measureText("L"):n.bounds[0]||n.bounds[1]||(h=this.context.measureText("x")));let l=0;switch(n.position.true_anchorPoint_x&&(this.context.textAlign="left",l=this.context.measureText("L").actualBoundingBoxLeft,this.context.textAlign=n.textAlign.horizontal),this.context.textAlign="left",n.anchorPoint){default:case"none":break;case"true":l=this.context.measureText(o[0].slice(0,1)).actualBoundingBoxLeft;break;case"L":l=this.context.measureText("L").actualBoundingBoxLeft}this.context.textAlign=n.textAlign.horizontal;let c=n.position.pos_x,d=n.position.pos_y+h.actualBoundingBoxDescent,p=c+r*s,u=n.position.pos_y-h.actualBoundingBoxAscent,m=n.fontLineHeight*s*(o.length-1);switch(n.textAlign.vertical){default:case"top":d+=m;break;case"center":d+=m/2,u-=m/2;break;case"bottom":u-=m}switch(n.textAlign.horizontal){default:case"left":break;case"center":c-=r*s/2,p-=r*s/2;break;case"right":c-=r*s,p-=r*s}if(this.bounds={minX:c,maxX:p,minY:u,maxY:d},n.background){"string"==typeof n.background&&(n.background={fill_color:n.background,round_radius:0});let t={top:0,right:0,left:0,bottom:0};n.background.margins&&(n.background.margins.top&&(t.top=n.background.margins.top),n.background.margins.bottom&&(t.bottom=n.background.margins.bottom),n.background.margins.left&&(t.left=n.background.margins.left),n.background.margins.right&&(t.right=n.background.margins.right));let e=this.bounds.minX-t.left,i=this.bounds.maxX-this.bounds.minX+t.right+t.left,o=this.bounds.minY-t.top,r=this.bounds.maxY-this.bounds.minY+t.top+t.bottom,s=0;n.background.round_radius&&(s=n.background.round_radius),this.context.fillStyle=n.background.fill_color,n.background.stroke&&(this.context.lineWidth=n.background.stroke.width||10,this.context.strokeStyle=n.background.stroke.color||"black"),this.context.beginPath(),this.context.roundRect(e,o,i,r,s),this.context.fill(),n.background.stroke&&this.context.stroke()}o.forEach(((t,e)=>{let i,r=n.position.pos_x+l;if("center"===n.textAlign.horizontal){this.context.textAlign="left",r-=(this.context.measureText(t.replaceAll("Β§","")).actualBoundingBoxRight+this.context.measureText(t.replaceAll("Β§","")).actualBoundingBoxLeft)/2}switch(n.textAlign.vertical){default:case"top":i=e*n.fontLineHeight*s;break;case"bottom":i=-(o.length-1-e)*n.fontLineHeight*s;break;case"center":i=-(o.length-1)*n.fontLineHeight*s/2+e*n.fontLineHeight*s}const h=t.replace(/Β§+$/,"").split("Β§");for(let t=0;t<h.length;t++){let e="right"===n.textAlign.horizontal?h.length-1-t:t,o=h[e];if(this.context.fillStyle=n.fontFillColor,n.highlight&&e%2==1){this.context.fillStyle=n.highlight.fontFillColor?n.highlight.fontFillColor:n.fontFillColor;let t=n.highlight.fontSize?n.highlight.fontSize:n.fontSize,e=n.highlight.fontFamily?n.highlight.fontFamily:n.fontFamily;this.context.font=`${t*s}px ${e}`,this.context.letterSpacing=n.highlight.fontLetterSpacing?t*s/100*n.highlight.fontLetterSpacing+"px":t*s/100*n.fontLetterSpacing+"px"}this.context.fillText(o,r,n.position.pos_y+i),r+=("right"===n.textAlign.horizontal?-1:1)*this.context.measureText(o).width}})),this.isDrawn=!0}drawImage(...t){let e,i,n,o;if(this.context.drawImage(...t),3===t.length){const[r,s,h]=t;e=s,i=h,n=s+r.width,o=h+r.height}else if(5===t.length){const[,,,r,s,h,l]=t;e=h,i=l,n=h+r,o=l+s}else if(9===t.length){const[,,,,,r,s,h,l]=t;e=r,i=s,n=r+h,o=s+l}this.bounds={minX:e,minY:i,maxX:n,maxY:o},this.context.filter="none",this.isDrawn=!0}drawImageInput(t,e,i){this.context.drawImage(t.config.rawImage,Math.round(t.config.cropInfo.x),Math.round(t.config.cropInfo.y),Math.round(t.config.cropInfo.width),Math.round(t.config.cropInfo.height),e,i,Math.round(t.config.width),Math.round(t.config.height))}drawRect(t){const e={...{x:0,y:0,width:this.canvas.width,height:this.canvas.height,color:"rgba(1,0,0,1)",radius:0},...t};this.context.fillStyle=e.color,this.context.fillRect(e.x,e.y,e.width,e.height)}drawStar(t){const e={x_center:0,y_center:0,spikes:5,color:"rgba(0,0,0,1)",outerRadius:100,innerRadius:150,...t};var i=Math.PI/2*3,n=e.x_center,o=e.y_center,r=Math.PI/e.spikes;this.context.beginPath(),this.context.moveTo(e.x_center,e.y_center-e.outerRadius);for(let t=0;t<e.spikes;t++)n=e.x_center+Math.cos(i)*e.outerRadius,o=e.y_center+Math.sin(i)*e.outerRadius,this.context.lineTo(n,o),i+=r,n=e.x_center+Math.cos(i)*e.innerRadius,o=e.y_center+Math.sin(i)*e.innerRadius,this.context.lineTo(n,o),i+=r;this.context.lineTo(e.x_center,e.y_center-e.outerRadius),this.context.closePath(),this.context.fillStyle=e.color,this.context.fill()}drawGradient(t){const e={x:0,y:0,width:100,height:100,direction:"DOWN",gradient:[[0,"rgba(0,0,0, 0)"],[1,"rgba(0,0,0, 1)"]],...t};if(!["UP","RIGHT","DOWN","LEFT"].includes(e.direction))throw new Error('Invalid direction value. It must be "UP", "RIGHT", "DOWN", or "LEFT".');let i,n,o,r;"UP"===e.direction?(i=e.x,n=e.y+e.height,o=e.x,r=e.y):"RIGHT"===e.direction?(i=e.x,n=e.y,o=e.x+e.width,r=e.y):"DOWN"===e.direction?(i=e.x,n=e.y,o=e.x,r=e.y+e.height):"LEFT"===e.direction&&(i=e.x+e.width,n=e.y,o=e.x,r=e.y);const s=this.context.createLinearGradient(i,n,o,r);for(let t=0;t<e.gradient.length;t++){let i=e.gradient[t][0],n=e.gradient[t][1];s.addColorStop(i,n)}this.context.fillStyle=s,this.context.fillRect(e.x,e.y,e.width,e.height)}prepareFilter(t){this.context.filter=t}applyFilter(t){this.context.filter=t,this.context.drawImage(this.canvas,0,0),this.context.filter="none"}applyLUT(t){t.isLoaded||console.log("LUT not loaded",t.name);const e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=e.data;for(let e=0;e<i.length;e+=4){const n=i[e]/255,o=i[e+1]/255,r=i[e+2]/255,[s,h,l]=apply3DLUT(n,o,r,t.lutData);i[e]=255*s,i[e+1]=255*h,i[e+2]=255*l}function apply3DLUT(t,e,i,{size:n,lut:o}){const r=n-1;return o[Math.min(Math.floor(t*r),r)+Math.min(Math.floor(e*r),r)*n+Math.min(Math.floor(i*r),r)*n*n]}this.context.putImageData(e,0,0)}update(){this.drawInstructions&&(this.clear(),this.drawInstructions())}clear(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.isDrawn=!1}}class Raffaello_ImageCropper{constructor(t,e){this.container=t,this.config=e,this.config.imageReady=!1,this.initDynamicElements(),this.initElements(),this.initCropper(),this.bindEvents(),this.initRatioSelect(),this.initWatermark(),this.filterValues={},this.initFilterControls()}initDynamicElements(){const t=this.container.querySelector(".raffaello-imageContainer");t.style.backgroundColor="rgb(51, 51, 51)";const e=document.createElement("input");e.type="file",e.className="raffaello-imageInput",e.accept="image/*",e.style.display="none",t.innerHTML+="\x3c!-- FILE INPUT --\x3e",t.appendChild(e);const i=document.createElement("div");i.className="raffaello-upload";const n=document.createElement("img");checkImageSrc("src/svg/upload.svg",(t=>{n.src=t?"src/svg/upload.svg":"raffaello/src/svg/upload.svg"})),n.className="icon",i.appendChild(n),t.innerHTML+="\x3c!-- UPLOAD INPUT --\x3e",t.appendChild(i);const o=document.createElement("div");o.className="raffaello-loading";const r=document.createElement("div");r.className="raffaello-loading-circle",o.appendChild(r),t.appendChild(o);const s=this.container.querySelector(".raffaello-imageFiltres");if(s){s.classList.add("flex-row"),s.style.gap="2px";const t=document.createElement("p");t.className="small-p-2 brightness-label",s.appendChild(t);const e=document.createElement("input");e.type="range",e.name="brightness",e.displayName="LuminositΓ©",e.min="-100",e.max="100",e.value="20",s.appendChild(e);const i=document.createElement("p");i.className="small-p-2 contrast-label",s.appendChild(i);const n=document.createElement("input");n.type="range",n.name="contrast",n.displayName="Contraste",n.min="-100",n.max="100",n.value="20",s.appendChild(n);const o=document.createElement("p");o.className="small-p-2 saturate-label",s.appendChild(o);const r=document.createElement("input");r.type="range",r.name="saturate",r.displayName="Saturation",r.min="-100",r.max="100",r.value="20",s.appendChild(r)}const h=this.container.querySelector(".raffaello-cropperRestart");if(h){this.cropperRestart=h,h.classList.add("raffaello-restart"),h.style.display="none";const t=document.createElement("img");checkImageSrc("src/svg/restart.svg",(e=>{t.src=e?"src/svg/restart.svg":"raffaello/src/svg/restart.svg"})),t.className="icon",h.innerHTML+="\x3c!-- REFRESH SVG --\x3e",h.appendChild(t)}}initElements(){this.dropzone=this.container.querySelector(".raffaello-imageContainer"),this.imageInput=this.container.querySelector(".raffaello-imageInput"),this.upload=this.container.querySelector(".raffaello-upload"),this.loading=this.container.querySelector(".raffaello-loading"),this.cropperContainer=this.container.querySelector(".raffaello-cropperContainer")}initCropper(){this.cropper=new Cropper(this.cropperContainer,{aspectRatio:this.config.aspectRatio??this.config.width/this.config.height,viewMode:this.config.viewMode??2,autoCropArea:1,zoomOnWheel:this.config.zoomOnWheel??0,ready:()=>{this.applyFilters(),this.config.rawImage=this.cropperContainer,this.config.cropInfo=this.cropper.getData(),this.config.imageReady=!0,this.config.onImageReady?this.config.onImageReady():console.log(this.config)}})}bindEvents(){this.upload.addEventListener("click",(()=>{"INPUT"===this.imageInput.tagName&&"file"===this.imageInput.type||console.warn('Warning: this.imageInput is not an <input> element of type "file". Nothing should have a class "raffaello-imageInput"'),this.imageInput.click()})),this.imageInput.addEventListener("change",(t=>{this.loadSelectedImage(t)})),this.dropzone.addEventListener("dragover",(t=>t.preventDefault())),this.dropzone.addEventListener("drop",(t=>{t.preventDefault(),console.log("We have a drop");const e=t.dataTransfer.files[0];e.type.match(/^image\//)?this.loadSelectedImage({target:{files:[e]}}):console.log("Invalid file type. Only image files are allowed.")})),this.cropperContainer.addEventListener("crop",(t=>{this.config.cropInfo=this.cropper.getData()})),this.cropperRestart&&this.cropperRestart.addEventListener("click",(()=>{this.imageInput.click()})),this.config.onCrop&&this.cropperContainer.addEventListener("crop",this.config.onCrop),this.config.onCropStart&&this.cropperContainer.addEventListener("cropstart",this.config.onCropStart),this.config.onCropEnd&&this.cropperContainer.addEventListener("cropend",this.config.onCropEnd),this.config.onZoom&&this.cropperContainer.addEventListener("zoom",this.config.onZoom),void 0!==this.config.layerIndex&&void 0!==this.config.layerRef&&(this.config.onImageReady=()=>{this.config.layerRef.initiateDrawing()},this.config.onFilterChange=()=>{this.config.layerRef.canvas.updateLayers([this.config.layerIndex])},this.cropperContainer.addEventListener("onCrop",(()=>{})),this.cropperContainer.addEventListener("cropstart",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=.5})),this.cropperContainer.addEventListener("cropend",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=1,this.config.layerRef.canvas.updateLayers([this.config.layerIndex])})))}showBackInitialUI(){"none"==this.upload.style.display&&(this.upload.style.display="flex");const t=this.cropperRestart;t&&(t.style.display="none")}loadSelectedImage(t){return new Promise(((e,i)=>{const n=t.target.files[0];if(!n)return;"none"!==this.upload.style.display&&(this.upload.style.display="none"),"none"===this.loading.style.display&&(this.loading.style.display="flex");const o=this.cropperRestart;o&&(o.style.display="block");const r=new FileReader;r.addEventListener("load",(()=>{this.loading.style.display="none",this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")));let t=n.name.split(".")[0];this.config.fileName=t,this.cropperContainer.src=r.result,this.cropper.replace(this.cropperContainer.src),e(t)})),r.readAsDataURL(n)}))}initRatioSelect(){this.imageRatioSelect=this.container.querySelector(".raffaello-imageRatioSelect"),this.imageRatioSelect&&this.imageRatioSelect.addEventListener("change",(()=>{const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.width,e=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.height;this.config.width=t,this.config.height=e;const i=t/e;this.cropper.setAspectRatio(i),this.watermarkSelect&&this.resetWatermarkList()}))}setNewSize(t,e){const i=t/e;this.cropper.setAspectRatio(i)}initWatermark(){this.watermarkDiv=this.container.querySelector(".raffaello-watermark"),this.watermarkDiv&&(this.watermarkDiv.classList.add("raffaello-canvas-to-overlay","icon"),""!==this.watermarkDiv.src&&this.watermarkDiv.src!==window.location.href||(this.watermarkDiv.style.display="none"),this.cropperContainer.addEventListener("crop",(()=>{this.updateWatermarkPositionAndSize()})),this.watermarkSelect=this.container.querySelector(".raffaello-watermarkSelect"),this.watermarkSelect&&this.watermarkSelect.addEventListener("change",(()=>{this.updateWatermark()})))}updateWatermark(){const t=this.watermarkSelect.options[this.watermarkSelect.selectedIndex].dataset.watermark;t?(this.watermarkDiv.src=t,this.watermarkDiv.style.display="block"):(this.watermarkDiv.src="",this.watermarkDiv.style.display="none"),this.updateWatermarkPositionAndSize()}updateWatermarkPositionAndSize(){const t=this.cropper.getCropBoxData();this.watermarkDiv.style.width=Math.ceil(t.width)+1+"px",this.watermarkDiv.style.height=Math.ceil(t.height)+1+"px",this.watermarkDiv.style.left=t.left-.5+"px",this.watermarkDiv.style.top=t.top-.5+"px"}resetWatermarkList(){this.watermarkSelect.selectedIndex=0,this.watermarkDiv.src="",this.watermarkDiv.style.display="none";const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.ratio;for(let e=1;e<this.watermarkSelect.options.length;e++){const i=this.watermarkSelect.options[e];i.dataset.ratio===t?i.style.display="block":i.style.display="none"}}initFilterControls(){const t=this.container.querySelector(".raffaello-imageFiltres");if(t){t.querySelectorAll('input[type="range"]').forEach((t=>{const e=t.name||t.dataset.filter,i=t.displayName;this.filterValues[e]=t.value,this.updateFilterValue(e,i,t.value),t.addEventListener("input",(t=>{this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),t.addEventListener("dblclick",(t=>{t.target.value=20,this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),this.config.onFilterChange&&(t.addEventListener("input",this.config.onFilterChange),t.addEventListener("dblclick",this.config.onFilterChange))}))}}linear(t,e,i,n,o){return(t-e)/(i-e)*(o-n)+n}updateFilterValue(t,e,i){let n;n="brightness"===t?i<0?this.linear(i,-100,0,.8,1):this.linear(i,0,100,1,1.4):"contrast"===t?i<0?this.linear(i,-100,0,.9,1):this.linear(i,0,100,1,1.3):"saturate"===t?i<0?this.linear(i,-100,0,0,1):this.linear(i,0,100,1,1.3):i;let o=i,r=this.container.querySelector(`.${t}-label`);r&&(r.innerHTML=`${e.charAt(0).toUpperCase()+e.slice(1)} <i>(${o})</i>`),this.filterValues[t]=n}applyFilters(){let t=Object.entries(this.filterValues).map((([t,e])=>`${t}(${e})`)).join(" ");this.config.filter=t;const e=this.container.querySelector(".cropper-crop-box .cropper-view-box"),i=this.container.querySelector(".cropper-wrap-box div");e&&(e.style.filter=t),i&&(i.style.filter=t)}}function d_r(){console.log("d_r()")}function checkImageSrc(t,e){const i=new Image;i.onload=()=>e(!0),i.onerror=()=>e(!1),i.src=t}window.Raffaello_Canvas=class Raffaello_Canvas{constructor(t){if(this.width=t.width??1e3,this.height=t.height??1e3,this.cornerRadius=t.cornerRadius??0,this.previewContainer=t.previewContainer??null,this.nameInputContainer=t.nameInputContainer??null,this.previewQuality=t.previewQuality??"0.8",this.renderQuality=t.renderQuality??"0.96",this.layers=[],this.previewContainer){const e=window.getComputedStyle(this.previewContainer).backgroundColor;t.previewBackgroundColor?this.previewBackgroundColor=t.previewBackgroundColor:e&&"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(this.previewBackgroundColor=e)}}addLayer(t="normal",e=null){let i=new Raffaello_CanvasLayer(this.width,this.height,t,e);return this.layers.push(i),i}updateLayers(t){for(const e of t)this.layers[e]?this.layers[e].update():console.warn(`> updateLayers([${e}]): The canvas does not have a layer ${e}`);this.renderPreview()}resetLayers(){this.layers=[]}render(t=!1){if(!window.r_o)return void console.log(a(2));let e=document.createElement("canvas");e.width=this.width,e.height=this.height;let i=e.getContext("2d");this.cornerRadius>0&&(i.save(),i.beginPath(),i.roundRect(0,0,e.width,e.height,this.cornerRadius),i.clip()),t&&null!=this.previewBackgroundColor&&(i.fillStyle=this.previewBackgroundColor,i.fillRect(0,0,e.width,e.height));for(let t=0;t<this.layers.length;t++){const e=this.layers[t],n=this.layers[t+1];let o=e.canvas;if("alpha"===n?.type){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;let i=t.getContext("2d");i.drawImage(n.canvas,0,0),i.globalCompositeOperation="source-in",i.drawImage(e.canvas,0,0),i.globalCompositeOperation="source-over",o=t}["image","normal"].includes(e.type)&&i.drawImage(o,0,0),"effect"===e.type&&(i.globalCompositeOperation=e.effect,i.drawImage(o,0,0),i.globalCompositeOperation="source-over")}return this.cornerRadius>0&&i.restore(),e}renderPreview(){if(!window.r_o)return void console.log(a(2));if(!this.previewContainer)return;const t=this.previewContainer;/iPad|iPhone|iPod/.test(navigator.userAgent)?t.src=this.render().toDataURL("image/jpeg",.9):t.src=this.render(!0).toDataURL("image/jpeg",this.previewQuality)}downloadImage(){const t=this.render();if(!t)return;let e,i,n=this.nameInputContainer.value.trim(),o=n?n.split(".")[0].replace(/[^a-zA-Z0-9\_-]/g,""):"Image_Raffaello";switch(n.split(".").pop().toLowerCase()){case"jpg":case"jpeg":e="image/jpeg",i=".jpg";break;default:e="image/png",i=".png"}if(/iPad|iPhone|iPod/.test(navigator.userAgent))window.alert("Appuyez et maintenez l'image pour l'enregistrer.");else{const n=document.createElement("a");n.download=o+i,n.href=t.toDataURL(e,"image/jpeg"===e?this.renderQuality:void 0),document.body.appendChild(n),n.click(),document.body.removeChild(n)}}renderBis(){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;const e=t.getContext("2d");return e.fillStyle=atob("I2Y4ZDdkYQ=="),e.fillRect(0,0,this.width,this.height),e.fillStyle=atob("IzcyMWMyNA=="),e.font="bold 24px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(atob("TGljZW5zZSBrZXkgbm90IHZhbGlk"),this.width/2,this.height/2),t}},window.Raffaello_CanvasLayer=Raffaello_CanvasLayer,window.Raffaello_ImageCropper=Raffaello_ImageCropper,window.Raffaello_BatchImageCropper=class Raffaello_BatchImageCropper{constructor(t,e){this.input=t,this.container=this.input.container,this.canvas=this.input.canvas,this.imageConfigs=e,this.imagesAreReady=e.map((t=>!0===t.isOptionnal)),this.inputImages=[],this.initializeCroppers()}initializeCroppers(){this.inputImages=this.imageConfigs.map(((t,e)=>new Raffaello_ImageCropper(this.container.querySelector(t.selector),{width:t.width,height:t.height,viewMode:t.viewMode??2,zoomOnWheel:t.zoomOnWheel??0,onImageReady:()=>{this.markImageAsReady(e)},onCropStart:()=>{this.canvas.previewContainer.style.opacity=.5},onCropEnd:()=>{this.canvas.previewContainer.style.opacity=1,this.canvas.updateLayers([t.layerIndex])},onZoom:()=>{this.canvas.updateLayers([t.layerIndex])},onFilterChange:()=>{this.canvas.updateLayers([t.layerIndex])}})))}markImageAsReady(t){this.imagesAreReady[t]=!0,this.checkImagesAreReady()}checkImagesAreReady(){this.imagesAreReady.every((t=>t))&&(this.removePendingState(),console.log("All images are ready, starting to draw..."),this.input.initiateDrawing())}removePendingState(){this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")))}},window.Raffaello_Image=class Raffaello_Image{constructor(t){const e=t.url;this.img=new Image,this.img.src=e,this.isLoaded=!1,this.img.onload=()=>{this.isLoaded=!0,console.log(`β
Image ${e.split("/").slice(-1)} loaded successfully.`)},this.img.onerror=()=>{console.error("β Failed to load image:",e)}}getImage(){return this.isLoaded?this.img:(console.warn("β Image not loaded yet."),null)}isLoaded(){return this.isLoaded}},window.Raffaello_Font=class Raffaello_Font{constructor(t){const e=t.name;this.font=new FontFace(e,`url(${t.url})`),this.isLoaded=!1;let i=this.font;document.fonts.add(i),i.load().then((()=>{this.isLoaded=!0,console.log(`β
Font ${e} loaded successfully.`)})).catch((()=>{console.error("β Failed to load font:",e)}))}isLoaded(){return this.isLoaded}},window.Raffaello_LUT=class Raffaello_LUT{constructor(t){const e=t.url;this.lutData=null,this.isLoaded=!1,this.name=e.split("/").slice(-1),this.loadLUT(e).then((t=>{this.lutData=t,this.isLoaded=!0,console.log(`β
LUT ${this.name} loaded successfully.`)})).catch((t=>{console.log(`β Failed to load LUT: ${e}`),console.error(t)}))}async loadLUT(t){try{const e=await fetch(t),i=(await e.text()).split("\n"),n=[];let o=0;for(const t of i)if(t.startsWith("LUT_3D_SIZE"))o=parseInt(t.split(" ")[1],10);else if(!t.startsWith("#")&&""!==t.trim()){const e=t.split(" ").map(Number);3===e.length&&n.push(e)}if(!o)throw new Error("Invalid LUT file.");return{size:o,lut:n}}catch(t){throw new Error(`Error parsing LUT file: ${t.message}`)}}getLUT(){return this.isLoaded?this.lutData:(console.warn("β LUT not loaded yet."),null)}isLUTLoaded(){return this.isLoaded}},window.Raffaello_FullScreen=class Raffaello_FullScreen{constructor(t){this.previewContainers=document.querySelectorAll(`.${t.previewContainer}`),this.fullScreenElement=null,this.isFullScreen=!1,this.previewContainers.length?(this.initializeFullScreen(),this.setupEventListeners()):console.error("RAFFAELLO - No preview containers found.")}initializeFullScreen(){this.fullScreenElement=document.createElement("div"),this.fullScreenElement.classList.add("raffaello-fullscreen-overlay"),this.fullScreenElement.style.position="fixed",this.fullScreenElement.style.top="0",this.fullScreenElement.style.left="0",this.fullScreenElement.style.width="100%",this.fullScreenElement.style.height="100%",this.fullScreenElement.style.padding="25px",this.fullScreenElement.style.backgroundColor="rgba(0, 0, 0, 0.9)",this.fullScreenElement.style.display="none",this.fullScreenElement.style.zIndex="9999",this.fullScreenElement.style.cursor="pointer",this.fullScreenElement.style.alignItems="center",this.fullScreenElement.style.justifyContent="center";const t=document.createElement("img");t.style.maxWidth="100%",t.style.maxHeight="100%",t.setAttribute("draggable","false"),t.addEventListener("dragstart",(function(t){t.preventDefault()})),t.addEventListener("contextmenu",(function(t){t.preventDefault()})),this.fullScreenElement.appendChild(t),document.body.appendChild(this.fullScreenElement)}toggleFullScreen(){this.isFullScreen=!this.isFullScreen,this.isFullScreen?(this.fullScreenElement.style.display="flex",document.body.style.overflow="hidden"):(this.fullScreenElement.style.display="none",document.body.style.overflow="auto")}setupEventListeners(){this.previewContainers.forEach((t=>{t.style.cursor="pointer",t.addEventListener("click",(()=>{const e=t.src;this.fullScreenElement.querySelector("img").src=e,this.toggleFullScreen()}))})),this.fullScreenElement.addEventListener("click",(()=>{this.toggleFullScreen()}))}},window.Raffaello_PersistentInputs=class Raffaello_PersistentInputs{constructor({inputs:t,timeout:e}){this.textareas=document.querySelectorAll(`.${t}`),this.timeout=e,this.textareas.length?this.init():console.error(`INFO: No element with class ${t}`)}init(){this.cleanupOldKeys(),this.textareas.forEach(((t,e)=>{const i=this.generateKey(e);this.loadAndValidateContent(t,i);const n=this.debounce((()=>this.saveContent(t,i)),500);t.addEventListener("input",n)}))}cleanupOldKeys(){for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&e.startsWith("textareaContent_")&&localStorage.removeItem(e)}}generateKey(t){return`${window.location.pathname}_textareaContent_${this.timeout}_${t}`}loadAndValidateContent(t,e){const i=`${e}_timestamp`,n=localStorage.getItem(e),o=localStorage.getItem(i);if(n&&o){const r=Date.now()-parseInt(o,10);console.log("elapsed",r),console.log("this.timeout",this.timeout),r<=this.timeout?t.value=n:(console.log(`Key expired: ${e}`),localStorage.removeItem(e),localStorage.removeItem(i))}else localStorage.removeItem(e),localStorage.removeItem(i)}saveContent(t,e){const i=`${e}_timestamp`;localStorage.setItem(e,t.value),localStorage.setItem(i,Date.now().toString())}debounce(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout((()=>t(...n)),e)}}},async function v_k(t=1){console.log(`v_k() #${t}`);const e=document.currentScript||document.querySelector(a(12)),i=e?.dataset?.[atob("bGljZW5jZQ==")]||e?.dataset?.[atob("a2V5")],n=window.location[atob("aG9zdG5hbWU=")];if(!i)return console.log(a(1)),void d_r();const o=`${a(6)}${i}`,r=localStorage.getItem(o),s=Date.now();if(!(r&&s<parseInt(r)))try{const t=await fetch(`${a(4)}${i}${a(5)}${n}`);if((await t.json()).status!==a(10))return console.log(a(2)),void d_r();const e=s+6048e5;localStorage.setItem(o,e.toString())}catch(e){console.log(`${a(3)} (${t}/4)`),t<4?setTimeout((()=>v_k(t+1)),6e4):console.log(a(11))}}()}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raffaello",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A suite of client-side JavaScript objects and tools for image templatisation.",
|
|
5
5
|
"main": "dist/raffaello.min.js",
|
|
6
6
|
"style": "dist/raffaello.min.css",
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "rollup -c"
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"release:patch": "git add . && git commit -m 'Release patch update' && git push origin main && npm version patch && git push --tags && npm publish",
|
|
13
|
+
"release:minor": "git add . && git commit -m 'Release minor update' && git push origin main && npm version minor && git push --tags && npm publish",
|
|
14
|
+
"release:major": "git add . && git commit -m 'Release major update' && git push origin main && npm version major && git push --tags && npm publish"
|
|
12
15
|
},
|
|
13
16
|
"keywords": [
|
|
14
17
|
"javascript",
|