@willphan1712000/frontend 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -10,6 +10,54 @@ function _array_with_holes(arr) {
10
10
  function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
+ try {
15
+ var info = gen[key](arg);
16
+ var value = info.value;
17
+ } catch (error) {
18
+ reject(error);
19
+ return;
20
+ }
21
+ if (info.done) {
22
+ resolve(value);
23
+ } else {
24
+ Promise.resolve(value).then(_next, _throw);
25
+ }
26
+ }
27
+ function _async_to_generator(fn) {
28
+ return function() {
29
+ var self = this, args = arguments;
30
+ return new Promise(function(resolve, reject) {
31
+ var gen = fn.apply(self, args);
32
+ function _next(value) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
34
+ }
35
+ function _throw(err) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
37
+ }
38
+ _next(undefined);
39
+ });
40
+ };
41
+ }
42
+ function _class_call_check(instance, Constructor) {
43
+ if (!(instance instanceof Constructor)) {
44
+ throw new TypeError("Cannot call a class as a function");
45
+ }
46
+ }
47
+ function _defineProperties(target, props) {
48
+ for(var i = 0; i < props.length; i++){
49
+ var descriptor = props[i];
50
+ descriptor.enumerable = descriptor.enumerable || false;
51
+ descriptor.configurable = true;
52
+ if ("value" in descriptor) descriptor.writable = true;
53
+ Object.defineProperty(target, descriptor.key, descriptor);
54
+ }
55
+ }
56
+ function _create_class(Constructor, protoProps, staticProps) {
57
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
58
+ if (staticProps) _defineProperties(Constructor, staticProps);
59
+ return Constructor;
60
+ }
13
61
  function _define_property(obj, key, value) {
14
62
  if (key in obj) {
15
63
  Object.defineProperty(obj, key, {
@@ -23,6 +71,20 @@ function _define_property(obj, key, value) {
23
71
  }
24
72
  return obj;
25
73
  }
74
+ function _extends() {
75
+ _extends = Object.assign || function(target) {
76
+ for(var i = 1; i < arguments.length; i++){
77
+ var source = arguments[i];
78
+ for(var key in source){
79
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
80
+ target[key] = source[key];
81
+ }
82
+ }
83
+ }
84
+ return target;
85
+ };
86
+ return _extends.apply(this, arguments);
87
+ }
26
88
  function _iterable_to_array(iter) {
27
89
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
28
90
  }
@@ -56,6 +118,10 @@ function _non_iterable_rest() {
56
118
  function _non_iterable_spread() {
57
119
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
58
120
  }
121
+ function _object_destructuring_empty(o) {
122
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
123
+ return o;
124
+ }
59
125
  function _object_spread(target) {
60
126
  for(var i = 1; i < arguments.length; i++){
61
127
  var source = arguments[i] != null ? arguments[i] : {};
@@ -95,6 +161,33 @@ function _object_spread_props(target, source) {
95
161
  }
96
162
  return target;
97
163
  }
164
+ function _object_without_properties(source, excluded) {
165
+ if (source == null) return {};
166
+ var target = _object_without_properties_loose(source, excluded);
167
+ var key, i;
168
+ if (Object.getOwnPropertySymbols) {
169
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
170
+ for(i = 0; i < sourceSymbolKeys.length; i++){
171
+ key = sourceSymbolKeys[i];
172
+ if (excluded.indexOf(key) >= 0) continue;
173
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
174
+ target[key] = source[key];
175
+ }
176
+ }
177
+ return target;
178
+ }
179
+ function _object_without_properties_loose(source, excluded) {
180
+ if (source == null) return {};
181
+ var target = {};
182
+ var sourceKeys = Object.keys(source);
183
+ var key, i;
184
+ for(i = 0; i < sourceKeys.length; i++){
185
+ key = sourceKeys[i];
186
+ if (excluded.indexOf(key) >= 0) continue;
187
+ target[key] = source[key];
188
+ }
189
+ return target;
190
+ }
98
191
  function _sliced_to_array(arr, i) {
99
192
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
100
193
  }
@@ -109,6 +202,97 @@ function _unsupported_iterable_to_array(o, minLen) {
109
202
  if (n === "Map" || n === "Set") return Array.from(n);
110
203
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
111
204
  }
205
+ function _ts_generator(thisArg, body) {
206
+ var f, y, t, _ = {
207
+ label: 0,
208
+ sent: function() {
209
+ if (t[0] & 1) throw t[1];
210
+ return t[1];
211
+ },
212
+ trys: [],
213
+ ops: []
214
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
215
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
216
+ return this;
217
+ }), g;
218
+ function verb(n) {
219
+ return function(v) {
220
+ return step([
221
+ n,
222
+ v
223
+ ]);
224
+ };
225
+ }
226
+ function step(op) {
227
+ if (f) throw new TypeError("Generator is already executing.");
228
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
229
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
230
+ if (y = 0, t) op = [
231
+ op[0] & 2,
232
+ t.value
233
+ ];
234
+ switch(op[0]){
235
+ case 0:
236
+ case 1:
237
+ t = op;
238
+ break;
239
+ case 4:
240
+ _.label++;
241
+ return {
242
+ value: op[1],
243
+ done: false
244
+ };
245
+ case 5:
246
+ _.label++;
247
+ y = op[1];
248
+ op = [
249
+ 0
250
+ ];
251
+ continue;
252
+ case 7:
253
+ op = _.ops.pop();
254
+ _.trys.pop();
255
+ continue;
256
+ default:
257
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
258
+ _ = 0;
259
+ continue;
260
+ }
261
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
262
+ _.label = op[1];
263
+ break;
264
+ }
265
+ if (op[0] === 6 && _.label < t[1]) {
266
+ _.label = t[1];
267
+ t = op;
268
+ break;
269
+ }
270
+ if (t && _.label < t[2]) {
271
+ _.label = t[2];
272
+ _.ops.push(op);
273
+ break;
274
+ }
275
+ if (t[2]) _.ops.pop();
276
+ _.trys.pop();
277
+ continue;
278
+ }
279
+ op = body.call(thisArg, _);
280
+ } catch (e) {
281
+ op = [
282
+ 6,
283
+ e
284
+ ];
285
+ y = 0;
286
+ } finally{
287
+ f = t = 0;
288
+ }
289
+ if (op[0] & 5) throw op[1];
290
+ return {
291
+ value: op[0] ? op[1] : void 0,
292
+ done: true
293
+ };
294
+ }
295
+ }
112
296
  import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
113
297
  // src/components/DropdownSelect/context.ts
114
298
  import { createContext, useContext } from "react";
@@ -950,7 +1134,7 @@ var Search2 = function(param) {
950
1134
  return /* @__PURE__ */ jsx7("div", {
951
1135
  style: styles_default5.search_border,
952
1136
  children: /* @__PURE__ */ jsx7("input", {
953
- placeholder: "Search",
1137
+ placeholder: "Search...",
954
1138
  style: styles_default5.search,
955
1139
  id: "search",
956
1140
  name: "search",
@@ -1135,4 +1319,1579 @@ var MultiSelect = function(param) {
1135
1319
  });
1136
1320
  };
1137
1321
  var MultiSelect_default = MultiSelect;
1138
- export { ColorPickerSlider_default as ColorPickerSlider, DropdownSelect_default as DropdownSelect, MultiSelect_default as MultiSelect, OptionSlider_default as OptionSlider, RangeSlider_default as RangeSlider };
1322
+ // src/components/Buttons/Button.tsx
1323
+ import { createContext as createContext3, useContext as useContext3 } from "react";
1324
+ // src/components/Buttons/gradient/Gradient.tsx
1325
+ import { motion } from "framer-motion";
1326
+ // src/components/Buttons/gradient/styles.ts
1327
+ var borderRadius = "20px";
1328
+ var styles6 = function(first, second) {
1329
+ var styles11 = {
1330
+ container: {
1331
+ position: "relative",
1332
+ borderRadius: borderRadius,
1333
+ padding: "3px"
1334
+ },
1335
+ btn: {
1336
+ position: "relative",
1337
+ zIndex: 1,
1338
+ display: "flex",
1339
+ justifyContent: "center",
1340
+ alignItems: "center",
1341
+ padding: "2px",
1342
+ borderRadius: borderRadius,
1343
+ backgroundColor: "".concat(first),
1344
+ backgroundImage: "linear-gradient(43deg, ".concat(first, " 0%, ").concat(second, " 100%)"),
1345
+ border: "none",
1346
+ cursor: "pointer"
1347
+ },
1348
+ btnAfter: {
1349
+ position: "absolute",
1350
+ top: 0,
1351
+ left: 0,
1352
+ width: "100%",
1353
+ height: "100%",
1354
+ content: '""',
1355
+ zIndex: 0,
1356
+ backgroundColor: "".concat(first),
1357
+ backgroundImage: "linear-gradient(43deg, ".concat(first, " 0%, ").concat(second, " 100%)"),
1358
+ filter: "blur(10px)"
1359
+ },
1360
+ label: {
1361
+ backgroundColor: "#111723",
1362
+ borderRadius: borderRadius,
1363
+ padding: "0.5rem 2rem",
1364
+ color: "white"
1365
+ },
1366
+ labelBefore: {
1367
+ position: "absolute",
1368
+ top: "20%",
1369
+ right: "50%",
1370
+ width: "50%",
1371
+ height: "50%",
1372
+ content: '""',
1373
+ zIndex: 0,
1374
+ backgroundColor: "".concat(first),
1375
+ filter: "blur(15px)"
1376
+ },
1377
+ labelAfter: {
1378
+ position: "absolute",
1379
+ top: "20%",
1380
+ left: "50%",
1381
+ width: "50%",
1382
+ height: "50%",
1383
+ content: '""',
1384
+ zIndex: 0,
1385
+ backgroundColor: "".concat(second),
1386
+ filter: "blur(20px)"
1387
+ },
1388
+ p: {
1389
+ position: "relative",
1390
+ zIndex: 1,
1391
+ margin: 0
1392
+ },
1393
+ neon: {
1394
+ content: '""',
1395
+ background: "conic-gradient(transparent 270deg, green, transparent)",
1396
+ position: "absolute",
1397
+ top: "50%",
1398
+ left: "50%",
1399
+ transform: "translate(-50%, -50%)",
1400
+ aspectRatio: 1,
1401
+ width: "100%"
1402
+ }
1403
+ };
1404
+ return styles11;
1405
+ };
1406
+ var styles_default6 = styles6;
1407
+ // src/components/Buttons/gradient/Gradient.tsx
1408
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1409
+ var Gradient = function() {
1410
+ var data = useButtonContext();
1411
+ var styles11 = styles_default6(data.first, data.second);
1412
+ return /* @__PURE__ */ jsxs8("div", {
1413
+ style: _object_spread_props(_object_spread({}, styles11.container), {
1414
+ overflow: data.isLoading ? "hidden" : ""
1415
+ }),
1416
+ children: [
1417
+ /* @__PURE__ */ jsx10("button", _object_spread_props(_object_spread({
1418
+ style: styles11.btn
1419
+ }, data.props), {
1420
+ children: /* @__PURE__ */ jsxs8("div", {
1421
+ style: {
1422
+ position: "relative"
1423
+ },
1424
+ children: [
1425
+ /* @__PURE__ */ jsx10("div", {
1426
+ style: styles11.labelBefore
1427
+ }),
1428
+ /* @__PURE__ */ jsx10("div", {
1429
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1430
+ backgroundColor: data.main
1431
+ }),
1432
+ children: /* @__PURE__ */ jsxs8("p", {
1433
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1434
+ color: "".concat(data.text)
1435
+ }),
1436
+ children: [
1437
+ data.children,
1438
+ " ",
1439
+ data.content
1440
+ ]
1441
+ })
1442
+ }),
1443
+ /* @__PURE__ */ jsx10("div", {
1444
+ style: styles11.labelAfter
1445
+ })
1446
+ ]
1447
+ })
1448
+ })),
1449
+ !data.isLoading && /* @__PURE__ */ jsx10("div", {
1450
+ style: styles11.btnAfter
1451
+ }),
1452
+ data.isLoading && /* @__PURE__ */ jsx10(motion.div, {
1453
+ style: styles11.btnAfter,
1454
+ animate: {
1455
+ rotate: 360
1456
+ },
1457
+ transition: {
1458
+ ease: "linear",
1459
+ repeat: Infinity,
1460
+ duration: 3
1461
+ }
1462
+ })
1463
+ ]
1464
+ });
1465
+ };
1466
+ var Gradient_default = Gradient;
1467
+ // src/components/Buttons/solid/styles.ts
1468
+ var styles7 = function(first) {
1469
+ var styles11 = {
1470
+ btn: {
1471
+ cursor: "pointer",
1472
+ position: "relative",
1473
+ zIndex: 0,
1474
+ display: "flex",
1475
+ justifyContent: "center",
1476
+ alignItems: "center",
1477
+ padding: "2px",
1478
+ borderRadius: "0.75rem",
1479
+ backgroundColor: first,
1480
+ border: "none"
1481
+ },
1482
+ btnAfter: {
1483
+ position: "absolute",
1484
+ top: 0,
1485
+ left: 0,
1486
+ width: "100%",
1487
+ height: "100%",
1488
+ zIndex: -1,
1489
+ backgroundColor: first,
1490
+ filter: "blur(10px)"
1491
+ },
1492
+ label: {
1493
+ borderRadius: "0.75rem",
1494
+ padding: "0.5rem 2rem",
1495
+ color: "white"
1496
+ },
1497
+ labelBefore: {
1498
+ position: "absolute",
1499
+ top: "20%",
1500
+ right: "50%",
1501
+ width: "50%",
1502
+ height: "50%",
1503
+ content: '""',
1504
+ // See note below
1505
+ zIndex: 0,
1506
+ backgroundColor: first,
1507
+ filter: "blur(15px)"
1508
+ },
1509
+ labelAfter: {
1510
+ position: "absolute",
1511
+ top: "20%",
1512
+ left: "50%",
1513
+ width: "50%",
1514
+ height: "50%",
1515
+ content: '""',
1516
+ // See note below
1517
+ zIndex: 0,
1518
+ filter: "blur(20px)"
1519
+ },
1520
+ p: {
1521
+ zIndex: 1,
1522
+ position: "relative",
1523
+ margin: 0
1524
+ }
1525
+ };
1526
+ return styles11;
1527
+ };
1528
+ var styles_default7 = styles7;
1529
+ // src/components/Buttons/solid/Solid.tsx
1530
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1531
+ var Solid = function() {
1532
+ var data = useButtonContext();
1533
+ var styles11 = styles_default7(data.first);
1534
+ return /* @__PURE__ */ jsxs9("div", {
1535
+ style: {
1536
+ position: "relative"
1537
+ },
1538
+ children: [
1539
+ /* @__PURE__ */ jsx11("button", _object_spread_props(_object_spread({
1540
+ style: styles11.btn
1541
+ }, data.props), {
1542
+ children: /* @__PURE__ */ jsxs9("div", {
1543
+ style: {
1544
+ position: "relative"
1545
+ },
1546
+ children: [
1547
+ /* @__PURE__ */ jsx11("div", {
1548
+ style: styles11.labelBefore
1549
+ }),
1550
+ /* @__PURE__ */ jsx11("div", {
1551
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1552
+ backgroundColor: data.main
1553
+ }),
1554
+ children: /* @__PURE__ */ jsxs9("p", {
1555
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1556
+ color: "".concat(data.text)
1557
+ }),
1558
+ children: [
1559
+ data.children,
1560
+ " ",
1561
+ data.content
1562
+ ]
1563
+ })
1564
+ }),
1565
+ /* @__PURE__ */ jsx11("div", {
1566
+ style: styles11.labelAfter
1567
+ })
1568
+ ]
1569
+ })
1570
+ })),
1571
+ /* @__PURE__ */ jsx11("div", {
1572
+ style: styles11.btnAfter
1573
+ })
1574
+ ]
1575
+ });
1576
+ };
1577
+ var Solid_default = Solid;
1578
+ // src/components/Buttons/Button.tsx
1579
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1580
+ var ButtonContext = createContext3(void 0);
1581
+ function useButtonContext() {
1582
+ var data = useContext3(ButtonContext);
1583
+ if (data === void 0) {
1584
+ throw new Error("Select Context is undefined");
1585
+ }
1586
+ return data;
1587
+ }
1588
+ var Button = function(_param) {
1589
+ var _param_buttonType = _param.buttonType, buttonType = _param_buttonType === void 0 ? "normal" : _param_buttonType, _param_content = _param.content, content = _param_content === void 0 ? "" : _param_content, _param_main = _param.main, main = _param_main === void 0 ? "#111723" : _param_main, _param_first = _param.first, first = _param_first === void 0 ? "#3e8fbc" : _param_first, _param_second = _param.second, second = _param_second === void 0 ? "#aa6392" : _param_second, _param_text = _param.text, text = _param_text === void 0 ? "#fff" : _param_text, _param_isLoading = _param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, _param_children = _param.children, children = _param_children === void 0 ? void 0 : _param_children, props = _object_without_properties(_param, [
1590
+ "buttonType",
1591
+ "content",
1592
+ "main",
1593
+ "first",
1594
+ "second",
1595
+ "text",
1596
+ "isLoading",
1597
+ "children"
1598
+ ]);
1599
+ switch(buttonType){
1600
+ case "gradient":
1601
+ return /* @__PURE__ */ jsx12(ButtonContext.Provider, {
1602
+ value: {
1603
+ content: content,
1604
+ main: main,
1605
+ first: first,
1606
+ second: second,
1607
+ text: text,
1608
+ props: props,
1609
+ isLoading: isLoading,
1610
+ children: children
1611
+ },
1612
+ children: /* @__PURE__ */ jsx12(Gradient_default, {})
1613
+ });
1614
+ case "solid":
1615
+ return /* @__PURE__ */ jsx12(ButtonContext.Provider, {
1616
+ value: {
1617
+ content: content,
1618
+ main: main,
1619
+ first: first,
1620
+ text: text,
1621
+ props: props,
1622
+ isLoading: isLoading,
1623
+ children: children
1624
+ },
1625
+ children: /* @__PURE__ */ jsx12(Solid_default, {})
1626
+ });
1627
+ default:
1628
+ return /* @__PURE__ */ jsxs10("button", _object_spread_props(_object_spread({}, props), {
1629
+ children: [
1630
+ children,
1631
+ " ",
1632
+ content
1633
+ ]
1634
+ }));
1635
+ }
1636
+ };
1637
+ var Button_default = Button;
1638
+ // src/components/Avatar/Avatar.tsx
1639
+ import { IoCloudUploadOutline } from "react-icons/io5";
1640
+ import { FaTrashCan } from "react-icons/fa6";
1641
+ import { RiEditLine } from "react-icons/ri";
1642
+ // src/components/Avatar/styles.ts
1643
+ var others = {
1644
+ iconSize: "20"
1645
+ };
1646
+ var button = {
1647
+ fontSize: "0.8rem",
1648
+ border: "none",
1649
+ borderRadius: "15px",
1650
+ padding: "3%",
1651
+ display: "flex",
1652
+ gap: "5px",
1653
+ justifyContent: "center",
1654
+ alignItems: "center",
1655
+ cursor: "pointer",
1656
+ position: "absolute"
1657
+ };
1658
+ var styles8 = {
1659
+ container: {
1660
+ width: "100%",
1661
+ height: "100%",
1662
+ display: "flex",
1663
+ position: "relative"
1664
+ },
1665
+ image: {
1666
+ borderRadius: "50%",
1667
+ background: "white",
1668
+ objectFit: "cover",
1669
+ width: "100%",
1670
+ height: "100%"
1671
+ },
1672
+ unknown: {
1673
+ display: "flex",
1674
+ justifyContent: "center",
1675
+ alignItems: "center",
1676
+ width: "100%",
1677
+ height: "100%"
1678
+ },
1679
+ upload: _object_spread_props(_object_spread({}, button), {
1680
+ bottom: 0,
1681
+ right: 0
1682
+ }),
1683
+ remove: _object_spread_props(_object_spread({}, button), {
1684
+ top: 0,
1685
+ right: 0
1686
+ }),
1687
+ edit: _object_spread({}, button)
1688
+ };
1689
+ var styles_default8 = styles8;
1690
+ // src/components/Avatar/Avatar.tsx
1691
+ import { useEffect as useEffect7, useRef as useRef7, useState as useState7 } from "react";
1692
+ import { Fragment, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1693
+ var Avatar = function(param) {
1694
+ var src = param.src, setValue = param.setValue;
1695
+ var setSrc = function setSrc() {
1696
+ return _async_to_generator(function() {
1697
+ var translatedSrc;
1698
+ return _ts_generator(this, function(_state) {
1699
+ switch(_state.label){
1700
+ case 0:
1701
+ return [
1702
+ 4,
1703
+ Image_default2.FromStringToImageSrc(src)
1704
+ ];
1705
+ case 1:
1706
+ translatedSrc = _state.sent();
1707
+ if (!translatedSrc) return [
1708
+ 2
1709
+ ];
1710
+ defaultImage.current = translatedSrc;
1711
+ setValue(translatedSrc);
1712
+ return [
1713
+ 2
1714
+ ];
1715
+ }
1716
+ });
1717
+ })();
1718
+ };
1719
+ var _useState7 = _sliced_to_array(useState7(false), 2), isOpen = _useState7[0], setOpen = _useState7[1];
1720
+ var _useState71 = _sliced_to_array(useState7(false), 2), isNew = _useState71[0], setNew = _useState71[1];
1721
+ var uploadImageRef = useRef7(null);
1722
+ var defaultImage = useRef7("");
1723
+ useEffect7(function() {
1724
+ setSrc();
1725
+ }, [
1726
+ src
1727
+ ]);
1728
+ return /* @__PURE__ */ jsxs11("div", {
1729
+ style: styles_default8.container,
1730
+ children: [
1731
+ /* @__PURE__ */ jsx13(ImageEditor_default, {
1732
+ src: src,
1733
+ setSrc: setValue,
1734
+ isOpen: isOpen,
1735
+ setOpen: setOpen,
1736
+ isNew: isNew
1737
+ }),
1738
+ /* @__PURE__ */ jsx13(Image_default, {
1739
+ src: src,
1740
+ style: styles_default8.image
1741
+ }),
1742
+ /* @__PURE__ */ jsxs11(Button_default, {
1743
+ style: styles_default8.upload,
1744
+ onClick: function() {
1745
+ var _uploadImageRef_current;
1746
+ return (_uploadImageRef_current = uploadImageRef.current) === null || _uploadImageRef_current === void 0 ? void 0 : _uploadImageRef_current.click();
1747
+ },
1748
+ children: [
1749
+ /* @__PURE__ */ jsx13(IoCloudUploadOutline, {
1750
+ size: others.iconSize
1751
+ }),
1752
+ "Upload"
1753
+ ]
1754
+ }),
1755
+ /* @__PURE__ */ jsx13(UploadImage_default, {
1756
+ ref: uploadImageRef,
1757
+ setSrc: function(e) {
1758
+ setValue(e);
1759
+ setOpen(true);
1760
+ setNew(function(prev) {
1761
+ return !prev;
1762
+ });
1763
+ }
1764
+ }),
1765
+ src !== defaultImage.current && /* @__PURE__ */ jsxs11(Fragment, {
1766
+ children: [
1767
+ /* @__PURE__ */ jsxs11(Button_default, {
1768
+ style: styles_default8.remove,
1769
+ onClick: function() {
1770
+ setValue(defaultImage.current);
1771
+ setNew(function(prev) {
1772
+ return !prev;
1773
+ });
1774
+ },
1775
+ children: [
1776
+ /* @__PURE__ */ jsx13(FaTrashCan, {
1777
+ size: others.iconSize,
1778
+ color: "red"
1779
+ }),
1780
+ "Remove"
1781
+ ]
1782
+ }),
1783
+ /* @__PURE__ */ jsxs11(Button_default, {
1784
+ style: styles_default8.edit,
1785
+ onClick: function() {
1786
+ return setOpen(function(prev) {
1787
+ return !prev;
1788
+ });
1789
+ },
1790
+ children: [
1791
+ /* @__PURE__ */ jsx13(RiEditLine, {
1792
+ size: others.iconSize
1793
+ }),
1794
+ "Edit"
1795
+ ]
1796
+ })
1797
+ ]
1798
+ })
1799
+ ]
1800
+ });
1801
+ };
1802
+ var Avatar_default = Avatar;
1803
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1804
+ import { useEffect as useEffect8, useRef as useRef8, useState as useState8 } from "react";
1805
+ // src/components/Input/InputGoogle/InputGoogle.styles.ts
1806
+ var others2 = {
1807
+ topRelease: "50%",
1808
+ topFocus: "0",
1809
+ fontSizeRelease: "16px",
1810
+ fontSizeFocus: "14px",
1811
+ borderRelease: "#cbcbcb",
1812
+ borderFocus: "#0957d0",
1813
+ textRelease: "#000",
1814
+ textFocus: "#0957d0",
1815
+ border: "solid 2px"
1816
+ };
1817
+ var styles9 = {
1818
+ input: {
1819
+ boxSizing: "border-box",
1820
+ height: "40px",
1821
+ width: "100%",
1822
+ border: "".concat(others2.border, " ").concat(others2.borderRelease),
1823
+ borderRadius: "6px",
1824
+ padding: "10px",
1825
+ outline: "none"
1826
+ },
1827
+ container: {
1828
+ width: "100%",
1829
+ position: "relative"
1830
+ },
1831
+ label: {
1832
+ position: "absolute",
1833
+ top: "50%",
1834
+ left: "10px",
1835
+ fontSize: "16px",
1836
+ transform: "translateY(-50%)",
1837
+ transition: "all .1s linear",
1838
+ padding: "0px 5px",
1839
+ backgroundColor: "white"
1840
+ }
1841
+ };
1842
+ var InputGoogle_styles_default = styles9;
1843
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1844
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1845
+ var InputGoogle = function(_param) {
1846
+ var transitionOnFocus = function transitionOnFocus() {
1847
+ setFocus(true);
1848
+ if (spanRef.current) {
1849
+ spanRef.current.style.top = others2.topFocus;
1850
+ spanRef.current.style.fontSize = others2.fontSizeFocus;
1851
+ }
1852
+ };
1853
+ var transitionOffFocus = function transitionOffFocus() {
1854
+ setFocus(false);
1855
+ if (value) return;
1856
+ if (spanRef.current) {
1857
+ spanRef.current.style.top = others2.topRelease;
1858
+ spanRef.current.style.fontSize = others2.fontSizeRelease;
1859
+ }
1860
+ };
1861
+ var handleClickOnLabel = function handleClickOnLabel() {
1862
+ var _inputRef_current;
1863
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
1864
+ };
1865
+ var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, _param_setValue = _param.setValue, setValue = _param_setValue === void 0 ? function() {} : _param_setValue, _param_label = _param.label, label = _param_label === void 0 ? "Input Google Component Label" : _param_label, options = _param.options, props = _object_without_properties(_param, [
1866
+ "value",
1867
+ "setValue",
1868
+ "label",
1869
+ "options"
1870
+ ]);
1871
+ var _useState8 = _sliced_to_array(useState8(false), 2), isFocus = _useState8[0], setFocus = _useState8[1];
1872
+ var spanRef = useRef8(null);
1873
+ var inputRef = useRef8(null);
1874
+ var inputBorder = isFocus ? "".concat(others2.border, " ").concat(options ? options.focusColor : others2.borderFocus) : "".concat(others2.border, " ").concat(others2.borderRelease);
1875
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others2.textFocus) : "".concat(others2.textRelease);
1876
+ useEffect8(function() {
1877
+ transitionOnFocus();
1878
+ transitionOffFocus();
1879
+ }, []);
1880
+ return /* @__PURE__ */ jsxs12("div", {
1881
+ style: InputGoogle_styles_default.container,
1882
+ children: [
1883
+ /* @__PURE__ */ jsx14("input", _object_spread({
1884
+ id: "will-input-google",
1885
+ ref: inputRef,
1886
+ value: value,
1887
+ onChange: function(e) {
1888
+ return setValue(e.target.value);
1889
+ },
1890
+ type: "text",
1891
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.input), {
1892
+ border: inputBorder
1893
+ }),
1894
+ onFocus: transitionOnFocus,
1895
+ onBlur: transitionOffFocus
1896
+ }, props)),
1897
+ /* @__PURE__ */ jsx14("span", {
1898
+ ref: spanRef,
1899
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.label), {
1900
+ color: labelTextColor
1901
+ }),
1902
+ onClick: handleClickOnLabel,
1903
+ children: label
1904
+ })
1905
+ ]
1906
+ });
1907
+ };
1908
+ var InputGoogle_default = InputGoogle;
1909
+ // src/components/Input/TextArea/TextArea.tsx
1910
+ import { useEffect as useEffect9, useRef as useRef9, useState as useState9 } from "react";
1911
+ // src/components/Input/TextArea/TextArea.styles.ts
1912
+ var labelHeight = 20;
1913
+ var others3 = {
1914
+ topRelease: "".concat(labelHeight + 5, "px"),
1915
+ topFocus: "0",
1916
+ fontSizeRelease: "16px",
1917
+ fontSizeFocus: "14px",
1918
+ borderRelease: "#cbcbcb",
1919
+ borderFocus: "#0957d0",
1920
+ textRelease: "#000",
1921
+ textFocus: "#0957d0",
1922
+ border: "solid 2px"
1923
+ };
1924
+ var styles10 = {
1925
+ input: {
1926
+ boxSizing: "border-box",
1927
+ height: "100%",
1928
+ width: "100%",
1929
+ border: "".concat(others3.border, " ").concat(others3.borderRelease),
1930
+ borderRadius: "6px",
1931
+ padding: "10px",
1932
+ outline: "none",
1933
+ resize: "none"
1934
+ },
1935
+ container: {
1936
+ width: "100%",
1937
+ height: "100%",
1938
+ position: "relative"
1939
+ },
1940
+ label: {
1941
+ height: "".concat(labelHeight, "px"),
1942
+ position: "absolute",
1943
+ top: "".concat(labelHeight + 5, "px"),
1944
+ left: "10px",
1945
+ fontSize: "16px",
1946
+ transform: "translateY(-50%)",
1947
+ transition: "all .1s linear",
1948
+ padding: "0px 5px",
1949
+ backgroundColor: "white"
1950
+ }
1951
+ };
1952
+ var TextArea_styles_default = styles10;
1953
+ // src/components/Input/TextArea/TextArea.tsx
1954
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1955
+ var TextArea = function(_param) {
1956
+ var transitionOnFocus = function transitionOnFocus() {
1957
+ setFocus(true);
1958
+ if (spanRef.current) {
1959
+ spanRef.current.style.top = others3.topFocus;
1960
+ spanRef.current.style.fontSize = others3.fontSizeFocus;
1961
+ }
1962
+ };
1963
+ var transitionOffFocus = function transitionOffFocus() {
1964
+ setFocus(false);
1965
+ if (value) return;
1966
+ if (spanRef.current) {
1967
+ spanRef.current.style.top = others3.topRelease;
1968
+ spanRef.current.style.fontSize = others3.fontSizeRelease;
1969
+ }
1970
+ };
1971
+ var handleClickOnLabel = function handleClickOnLabel() {
1972
+ var _inputRef_current;
1973
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
1974
+ };
1975
+ var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, _param_setValue = _param.setValue, setValue = _param_setValue === void 0 ? function() {} : _param_setValue, _param_label = _param.label, label = _param_label === void 0 ? "Text Component Label" : _param_label, options = _param.options, props = _object_without_properties(_param, [
1976
+ "value",
1977
+ "setValue",
1978
+ "label",
1979
+ "options"
1980
+ ]);
1981
+ var _useState9 = _sliced_to_array(useState9(false), 2), isFocus = _useState9[0], setFocus = _useState9[1];
1982
+ var spanRef = useRef9(null);
1983
+ var inputRef = useRef9(null);
1984
+ var inputBorder = isFocus ? "".concat(others3.border, " ").concat(options ? options.focusColor : others3.borderFocus) : "".concat(others3.border, " ").concat(others3.borderRelease);
1985
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others3.textFocus) : "".concat(others3.textRelease);
1986
+ useEffect9(function() {
1987
+ transitionOnFocus();
1988
+ transitionOffFocus();
1989
+ }, []);
1990
+ return /* @__PURE__ */ jsxs13("div", {
1991
+ style: TextArea_styles_default.container,
1992
+ children: [
1993
+ /* @__PURE__ */ jsx15("textarea", _object_spread({
1994
+ id: "will-textarea",
1995
+ ref: inputRef,
1996
+ value: value,
1997
+ onChange: function(e) {
1998
+ return setValue(e.target.value);
1999
+ },
2000
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.input), {
2001
+ border: inputBorder
2002
+ }),
2003
+ onFocus: transitionOnFocus,
2004
+ onBlur: transitionOffFocus
2005
+ }, props)),
2006
+ /* @__PURE__ */ jsx15("span", {
2007
+ ref: spanRef,
2008
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.label), {
2009
+ color: labelTextColor
2010
+ }),
2011
+ onClick: handleClickOnLabel,
2012
+ children: label
2013
+ })
2014
+ ]
2015
+ });
2016
+ };
2017
+ var TextArea_default = TextArea;
2018
+ // src/components/Input/InputFile.tsx
2019
+ import { useState as useState10 } from "react";
2020
+ import { jsx as jsx16 } from "react/jsx-runtime";
2021
+ var InputFile = function(_param) {
2022
+ var file = _param.file, onChoose = _param.onChoose, _param_onCancel = _param.onCancel, onCancel = _param_onCancel === void 0 ? function() {} : _param_onCancel, _param_acceptType = _param.acceptType, acceptType = _param_acceptType === void 0 ? "image/*" : _param_acceptType, props = _object_without_properties(_param, [
2023
+ "file",
2024
+ "onChoose",
2025
+ "onCancel",
2026
+ "acceptType"
2027
+ ]);
2028
+ var _useState10 = _sliced_to_array(useState10(Date.now()), 2), key = _useState10[0], setKey = _useState10[1];
2029
+ return /* @__PURE__ */ jsx16("input", _object_spread_props(_object_spread({
2030
+ type: "file"
2031
+ }, props), {
2032
+ onChange: function(e) {
2033
+ var _target_files;
2034
+ var target = e.target;
2035
+ var file2 = (_target_files = target.files) === null || _target_files === void 0 ? void 0 : _target_files[0];
2036
+ if (file2) {
2037
+ setKey(Date.now());
2038
+ onChoose(file2);
2039
+ } else {
2040
+ onCancel();
2041
+ }
2042
+ }
2043
+ }), key);
2044
+ };
2045
+ var InputFile_default = InputFile;
2046
+ // src/components/Image/UploadImage.tsx
2047
+ import { Fragment as Fragment2, jsx as jsx17 } from "react/jsx-runtime";
2048
+ var UploadImage = function(_param) {
2049
+ var handleSetSrc = function handleSetSrc(file) {
2050
+ return _async_to_generator(function() {
2051
+ var src;
2052
+ return _ts_generator(this, function(_state) {
2053
+ switch(_state.label){
2054
+ case 0:
2055
+ return [
2056
+ 4,
2057
+ Image_default2.FromFileToImageSrc(file)
2058
+ ];
2059
+ case 1:
2060
+ src = _state.sent();
2061
+ if (!src) return [
2062
+ 2
2063
+ ];
2064
+ setSrc(src);
2065
+ return [
2066
+ 2
2067
+ ];
2068
+ }
2069
+ });
2070
+ })();
2071
+ };
2072
+ var _param_setSrc = _param.setSrc, setSrc = _param_setSrc === void 0 ? function() {} : _param_setSrc, props = _object_without_properties(_param, [
2073
+ "setSrc"
2074
+ ]);
2075
+ return /* @__PURE__ */ jsx17(Fragment2, {
2076
+ children: /* @__PURE__ */ jsx17(InputFile_default, _object_spread_props(_object_spread({
2077
+ onChoose: handleSetSrc,
2078
+ acceptType: "image/*"
2079
+ }, props), {
2080
+ hidden: true
2081
+ }))
2082
+ });
2083
+ };
2084
+ var UploadImage_default = UploadImage;
2085
+ // src/components/Image/Image.tsx
2086
+ import { jsx as jsx18 } from "react/jsx-runtime";
2087
+ var Image = function(_param) {
2088
+ var props = _extends({}, _object_destructuring_empty(_param));
2089
+ return /* @__PURE__ */ jsx18("img", _object_spread_props(_object_spread({
2090
+ style: {
2091
+ width: "100%",
2092
+ height: "100%"
2093
+ }
2094
+ }, props), {
2095
+ alt: "Will-Image-Component",
2096
+ draggable: false
2097
+ }));
2098
+ };
2099
+ var Image_default = Image;
2100
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2101
+ import { useEffect as useEffect10, useMemo, useRef as useRef10, useState as useState11 } from "react";
2102
+ // src/components/Image/ImageEditor/ImageEditor.styles.ts
2103
+ var imageEditorStyles = {
2104
+ imageEditor: {
2105
+ width: "100vw",
2106
+ height: "100dvh",
2107
+ display: "flex",
2108
+ flexDirection: "column",
2109
+ justifyContent: "center",
2110
+ alignItems: "center",
2111
+ position: "fixed",
2112
+ top: 0,
2113
+ left: 0,
2114
+ backdropFilter: "blur(20px)",
2115
+ zIndex: 99,
2116
+ paddingLeft: "30px",
2117
+ paddingRight: "30px"
2118
+ },
2119
+ frame: {
2120
+ padding: "50px",
2121
+ backgroundColor: "white",
2122
+ border: "solid 4px #000",
2123
+ borderStyle: "dashed",
2124
+ borderRadius: "50%",
2125
+ overflow: "hidden",
2126
+ maxWidth: "500px",
2127
+ width: "100%",
2128
+ maxHeight: "500px",
2129
+ aspectRatio: 1 / 1,
2130
+ position: "relative"
2131
+ },
2132
+ wrapper: {
2133
+ position: "absolute",
2134
+ transformOrigin: "top left",
2135
+ userSelect: "none"
2136
+ },
2137
+ img: {
2138
+ objectFit: "contain",
2139
+ position: "absolute",
2140
+ top: 0,
2141
+ left: 0,
2142
+ display: "block",
2143
+ zIndex: 1,
2144
+ transform: "translate(-50%, -50%)"
2145
+ },
2146
+ buttons: {
2147
+ display: "flex",
2148
+ justifyContent: "center",
2149
+ alignItems: "center",
2150
+ gap: "20px",
2151
+ padding: "30px"
2152
+ }
2153
+ };
2154
+ var ImageEditor_styles_default = imageEditorStyles;
2155
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2156
+ import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
2157
+ var ImageEditor = function(param) {
2158
+ var src = param.src, _param_setSrc = param.setSrc, setSrc = _param_setSrc === void 0 ? function() {} : _param_setSrc, _param_isOpen = param.isOpen, isOpen = _param_isOpen === void 0 ? false : _param_isOpen, _param_setOpen = param.setOpen, setOpen = _param_setOpen === void 0 ? function() {} : _param_setOpen, _param_isNew = param.isNew, isNew = _param_isNew === void 0 ? false : _param_isNew;
2159
+ var createTransform = function createTransform() {
2160
+ return _async_to_generator(function() {
2161
+ var transform2;
2162
+ return _ts_generator(this, function(_state) {
2163
+ switch(_state.label){
2164
+ case 0:
2165
+ if (!frame.current || !wrapper.current || !img.current) return [
2166
+ 2
2167
+ ];
2168
+ transform2 = new Transform(wrapper.current, frame.current);
2169
+ return [
2170
+ 4,
2171
+ transform2.initialize()
2172
+ ];
2173
+ case 1:
2174
+ _state.sent();
2175
+ if (transformState.current) {
2176
+ transform2.setState(transformState.current);
2177
+ } else {
2178
+ transform2.reset();
2179
+ }
2180
+ setTransform(transform2);
2181
+ return [
2182
+ 2
2183
+ ];
2184
+ }
2185
+ });
2186
+ })();
2187
+ };
2188
+ var handleCanvasToSrc = function handleCanvasToSrc() {
2189
+ if (!frame.current || !wrapper.current || !img.current || !transform) return;
2190
+ var canvasInstance = new Canvas();
2191
+ var _canvasInstance_createCanvas = canvasInstance.createCanvas(700, 700), canvas = _canvasInstance_createCanvas.canvas, context = _canvasInstance_createCanvas.context;
2192
+ var _transform_exportData = transform.exportData(), x = _transform_exportData.x, y = _transform_exportData.y, angle = _transform_exportData.angle;
2193
+ transformState.current = transform.exportData();
2194
+ var _canvasInstance_drawImage = canvasInstance.drawImage(img.current, context, x, y, 1, angle, canvas, frame.current.clientWidth, frame.current.clientHeight), src2 = _canvasInstance_drawImage.src;
2195
+ return src2;
2196
+ };
2197
+ var handleAccept = function handleAccept() {
2198
+ setSrc(handleCanvasToSrc());
2199
+ setOpen(false);
2200
+ };
2201
+ var handleCancel = function handleCancel() {
2202
+ setOpen(false);
2203
+ };
2204
+ var handleReset = function handleReset() {
2205
+ if (!transform) return;
2206
+ transform.reset();
2207
+ };
2208
+ var frame = useRef10(null);
2209
+ var wrapper = useRef10(null);
2210
+ var img = useRef10(null);
2211
+ var _useState11 = _sliced_to_array(useState11(void 0), 2), transform = _useState11[0], setTransform = _useState11[1];
2212
+ var transformState = useRef10(void 0);
2213
+ var originalSrc = useMemo(function() {
2214
+ transformState.current = void 0;
2215
+ return src;
2216
+ }, [
2217
+ isNew
2218
+ ]);
2219
+ useEffect10(function() {
2220
+ isOpen ? createTransform() : setTransform(void 0);
2221
+ }, [
2222
+ isOpen
2223
+ ]);
2224
+ if (!isOpen) return;
2225
+ return /* @__PURE__ */ jsxs14("div", {
2226
+ style: ImageEditor_styles_default.imageEditor,
2227
+ children: [
2228
+ /* @__PURE__ */ jsx19("p", {
2229
+ children: "Drag, Zoom, or Rotate image"
2230
+ }),
2231
+ /* @__PURE__ */ jsx19("div", {
2232
+ ref: frame,
2233
+ style: ImageEditor_styles_default.frame,
2234
+ children: /* @__PURE__ */ jsx19("div", {
2235
+ ref: wrapper,
2236
+ style: ImageEditor_styles_default.wrapper,
2237
+ children: /* @__PURE__ */ jsx19("img", {
2238
+ src: originalSrc,
2239
+ style: ImageEditor_styles_default.img,
2240
+ ref: img
2241
+ })
2242
+ })
2243
+ }),
2244
+ /* @__PURE__ */ jsxs14("div", {
2245
+ style: ImageEditor_styles_default.buttons,
2246
+ children: [
2247
+ /* @__PURE__ */ jsx19(Button_default, {
2248
+ buttonType: "solid",
2249
+ content: "Accept",
2250
+ onClick: handleAccept
2251
+ }),
2252
+ /* @__PURE__ */ jsx19(Button_default, {
2253
+ buttonType: "solid",
2254
+ content: "Cancel",
2255
+ onClick: handleCancel
2256
+ }),
2257
+ /* @__PURE__ */ jsx19(Button_default, {
2258
+ buttonType: "solid",
2259
+ content: "Reset",
2260
+ onClick: handleReset
2261
+ })
2262
+ ]
2263
+ })
2264
+ ]
2265
+ });
2266
+ };
2267
+ var ImageEditor_default = ImageEditor;
2268
+ // src/utilities/canvas/Canvas.ts
2269
+ var Canvas = /*#__PURE__*/ function() {
2270
+ "use strict";
2271
+ function Canvas() {
2272
+ _class_call_check(this, Canvas);
2273
+ }
2274
+ _create_class(Canvas, [
2275
+ {
2276
+ key: "createCanvas",
2277
+ value: function createCanvas(width, height) {
2278
+ var canvas = document.createElement("canvas");
2279
+ var context = canvas.getContext("2d");
2280
+ canvas.width = width;
2281
+ canvas.height = height;
2282
+ return {
2283
+ canvas: canvas,
2284
+ context: context
2285
+ };
2286
+ }
2287
+ },
2288
+ {
2289
+ key: "drawImage",
2290
+ value: function drawImage(e, ctx, x, y, scale, angle, canvas, containerWidth, containerHeight) {
2291
+ var ratioX = canvas.width / containerWidth;
2292
+ var ratioY = canvas.height / containerHeight;
2293
+ var finalX = x * ratioX;
2294
+ var finalY = y * ratioY;
2295
+ var midleWidth = e.width * ratioX;
2296
+ var midleHeight = e.height * ratioY;
2297
+ var finalWidth = e.width * ratioX * scale;
2298
+ var finalHeight = e.height * ratioY * scale;
2299
+ ctx.save();
2300
+ ctx.translate(finalX + midleWidth / 2, finalY + midleHeight / 2);
2301
+ ctx.rotate(angle * Math.PI / 180);
2302
+ ctx.drawImage(e, -finalWidth / 2, -finalHeight / 2, finalWidth, finalHeight);
2303
+ ctx.restore();
2304
+ var src = ctx.canvas.toDataURL();
2305
+ var srcEncoded = src.split(",")[1];
2306
+ return {
2307
+ context: ctx,
2308
+ src: src
2309
+ };
2310
+ }
2311
+ },
2312
+ {
2313
+ key: "drawColor",
2314
+ value: function drawColor(type, color, ctx, width, ratio) {
2315
+ if (type === "") color = "#ffffff";
2316
+ if (type === "gradient") {
2317
+ var breakdownArr = color.split(",");
2318
+ var _ref = [
2319
+ Number(breakdownArr[0]),
2320
+ breakdownArr[1],
2321
+ Number(breakdownArr[2]),
2322
+ breakdownArr[3],
2323
+ Number(breakdownArr[4])
2324
+ ], angle = _ref[0], color1 = _ref[1], percent1 = _ref[2], color2 = _ref[3], percent2 = _ref[4];
2325
+ var radians = (angle - 180) * Math.PI / 180;
2326
+ var x0 = width / 2 + width / 2 * Math.cos(radians - Math.PI / 2);
2327
+ var y0 = width * ratio / 2 + width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2328
+ var x1 = width / 2 - width / 2 * Math.cos(radians - Math.PI / 2);
2329
+ var y1 = width * ratio / 2 - width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2330
+ var gradient = ctx.createLinearGradient(x0, y0, x1, y1);
2331
+ gradient.addColorStop(percent1 / 100, color1);
2332
+ gradient.addColorStop(percent2 / 100, color2);
2333
+ ctx.fillStyle = gradient;
2334
+ ctx.fillRect(0, 0, width, width * ratio);
2335
+ var srcEncoded = ctx.canvas.toDataURL().split(",")[1];
2336
+ return [
2337
+ ctx,
2338
+ srcEncoded
2339
+ ];
2340
+ } else {
2341
+ ctx.fillStyle = color;
2342
+ ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
2343
+ var srcEncoded1 = ctx.canvas.toDataURL().split(",")[1];
2344
+ return [
2345
+ ctx,
2346
+ srcEncoded1
2347
+ ];
2348
+ }
2349
+ }
2350
+ }
2351
+ ]);
2352
+ return Canvas;
2353
+ }();
2354
+ // src/utilities/canvas/Image.ts
2355
+ var Image2 = {
2356
+ /**
2357
+ * Convert file (blob) to base64 string format
2358
+ * @param file
2359
+ * @returns
2360
+ */ FromFileToImageSrc: function FromFileToImageSrc(file) {
2361
+ return new Promise(function(resolve, reject) {
2362
+ if (!file) return resolve(null);
2363
+ var reader = new FileReader();
2364
+ reader.readAsDataURL(file);
2365
+ reader.onload = function(readerEvent) {
2366
+ var _readerEvent_target;
2367
+ if ((_readerEvent_target = readerEvent.target) === null || _readerEvent_target === void 0 ? void 0 : _readerEvent_target.result) {
2368
+ var _readerEvent_target1;
2369
+ return resolve((_readerEvent_target1 = readerEvent.target) === null || _readerEvent_target1 === void 0 ? void 0 : _readerEvent_target1.result);
2370
+ }
2371
+ reject("Error getting the image source");
2372
+ };
2373
+ reader.onerror = function() {
2374
+ reject("Error getting the image source");
2375
+ };
2376
+ });
2377
+ },
2378
+ FromStringToImageSrc: /**
2379
+ * Convert urlst
2380
+ * @param url
2381
+ * @returns
2382
+ */ function FromStringToImageSrc(url) {
2383
+ return _async_to_generator(function() {
2384
+ var res, blob, src;
2385
+ return _ts_generator(this, function(_state) {
2386
+ switch(_state.label){
2387
+ case 0:
2388
+ if (!url || Image2.isBase64(url)) return [
2389
+ 2,
2390
+ null
2391
+ ];
2392
+ return [
2393
+ 4,
2394
+ fetch(url)
2395
+ ];
2396
+ case 1:
2397
+ res = _state.sent();
2398
+ return [
2399
+ 4,
2400
+ res.blob()
2401
+ ];
2402
+ case 2:
2403
+ blob = _state.sent();
2404
+ return [
2405
+ 4,
2406
+ Image2.FromFileToImageSrc(blob)
2407
+ ];
2408
+ case 3:
2409
+ src = _state.sent();
2410
+ return [
2411
+ 2,
2412
+ src
2413
+ ];
2414
+ }
2415
+ });
2416
+ })();
2417
+ },
2418
+ /**
2419
+ * Check if the url is base64 format
2420
+ * @param url
2421
+ * @deprecated Using a weak condition and might be changed later. Use checkBase64 instead
2422
+ */ checkBase64: function checkBase64(url) {
2423
+ if (!url || url === "") return false;
2424
+ return url.includes("base64,");
2425
+ },
2426
+ isBase64: function isBase64(url) {
2427
+ return Image2.checkBase64(url);
2428
+ }
2429
+ };
2430
+ var Image_default2 = Image2;
2431
+ // src/utilities/Transform/Transform.ts
2432
+ import $2 from "jquery";
2433
+ // src/utilities/Transform/TransformController.ts
2434
+ import $ from "jquery";
2435
+ import { icon } from "@fortawesome/fontawesome-svg-core";
2436
+ import { faRotate, faTrash } from "@fortawesome/free-solid-svg-icons";
2437
+ var TransformController = /*#__PURE__*/ function() {
2438
+ "use strict";
2439
+ function TransformController(wrapper, frame, controller) {
2440
+ _class_call_check(this, TransformController);
2441
+ this.wrapper = wrapper;
2442
+ this.frame = frame;
2443
+ this.controller = controller;
2444
+ }
2445
+ _create_class(TransformController, [
2446
+ {
2447
+ key: "addController",
2448
+ value: function addController() {
2449
+ var _this = this;
2450
+ return new Promise(function(res) {
2451
+ var styleElement = document.createElement("style");
2452
+ styleElement.textContent = _this.css();
2453
+ document.head.appendChild(styleElement);
2454
+ $("." + _this.frame).after(_this.controllerTemplate());
2455
+ res();
2456
+ });
2457
+ }
2458
+ },
2459
+ {
2460
+ key: "css",
2461
+ value: function css() {
2462
+ return "\n .".concat(this.wrapper, " {\n position: absolute;\n transform-origin: top left;\n user-select: none;\n }\n .").concat(this.wrapper, " > img {\n object-fit: contain;\n position: absolute;\n top: 0;\n left: 0;\n display: block;\n z-index: 1;\n transform: translate(-50%, -50%)\n }\n .").concat(this.controller, "--container {\n position: absolute;\n transform-origin: top left;\n user-select: none;\n }\n .").concat(this.controller, " {\n position: absolute;\n user-select: none;\n border: solid 3px #6924d5;\n z-index: 1;\n top: 0;\n left: 0;\n transform: translate(-50%, -50%);\n }\n .").concat(this.controller, " .resize {\n background-color: #fff;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;\n transition: all .1s linear;\n }\n .").concat(this.controller, " .resize.show {\n background-color: #6924d5;\n }\n .").concat(this.controller, " .resize > .circle {\n background-color: #f0f0f0a8;\n position: absolute;\n top: -15px;\n left: -15px;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;\n z-index: -1;\n visibility: hidden;\n transition: all .1s linear;\n }\n .").concat(this.controller, " .resize > .circle.show {\n visibility: visible;\n }\n .").concat(this.controller, " .resize.resize-topleft {\n position: absolute;\n top: -10px;\n left: -10px;\n }\n .").concat(this.controller, " .resize.resize-topright {\n position: absolute;\n top: -10px;\n right: -10px;\n }\n .").concat(this.controller, " .resize.resize-bottomleft {\n position: absolute;\n bottom: -10px;\n left: -10px;\n }\n .").concat(this.controller, " .resize.resize-bottomright {\n position: absolute;\n bottom: -10px;\n right: -10px;\n }\n .").concat(this.controller, " .rotate {\n position: absolute;\n top: -50px;\n left: calc(50% - 15px);\n width: 30px;\n height: 30px;\n background-color: #fff;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .").concat(this.controller, " .delete {\n position: absolute;\n bottom: -50px;\n left: calc(50% + 40px);\n width: 30px;\n height: 30px;\n background-color: #fff;\n border-radius: 50%;\n display: none;\n justify-content: center;\n align-items: center;\n }\n ");
2463
+ }
2464
+ },
2465
+ {
2466
+ key: "controllerTemplate",
2467
+ value: function controllerTemplate() {
2468
+ return '\n <div class="'.concat(this.controller, '--container">\n <div class="').concat(this.controller, '">\n <div class="dot resize resize-topleft"><div class="circle"></div></div>\n <div class="dot resize resize-topright"><div class="circle"></div></div>\n <div class="dot resize resize-bottomleft"><div class="circle"></div></div>\n <div class="dot resize resize-bottomright"><div class="circle"></div></div>\n <div class="dot rotate">').concat(icon(faRotate).html[0], '</div>\n <div class="dot rotate shadow" style="visibility: hidden;">').concat(icon(faRotate).html[0], '</div>\n <div class="dot delete">').concat(icon(faTrash).html[0], '</div>\n <div class="dot delete shadow" style="visibility: hidden;">').concat(icon(faTrash).html[0], "</div>\n </div>\n </div>\n ");
2469
+ }
2470
+ }
2471
+ ]);
2472
+ return TransformController;
2473
+ }();
2474
+ // src/utilities/Transform/Transform.ts
2475
+ var Transform = /*#__PURE__*/ function() {
2476
+ "use strict";
2477
+ function Transform(ele1, ele2, ele3) {
2478
+ _class_call_check(this, Transform);
2479
+ this.ele1 = ele1;
2480
+ this.ele2 = ele2;
2481
+ this.x = 0;
2482
+ this.y = 0;
2483
+ this.angle = 90;
2484
+ this.w = 0;
2485
+ this.h = 0;
2486
+ if (this.ele1 === null) {
2487
+ throw new Error("wrapper elemenet is not defined or not rendered yet");
2488
+ }
2489
+ this.wrapperClass = "_" + (Date.now() + 5e3).toString();
2490
+ $2(this.ele1).addClass(this.wrapperClass);
2491
+ this.imgFrame = this.ele2;
2492
+ if (this.imgFrame === null) {
2493
+ throw new Error("frame element is not defined or not rendered yet");
2494
+ }
2495
+ this.frameClass = "_" + (Date.now() - 5e3).toString();
2496
+ $2(this.ele2).addClass(this.frameClass);
2497
+ this.img = this.ele1.querySelector("img");
2498
+ if (this.img === null) {
2499
+ throw new Error("image element is not defined or not rendered yet");
2500
+ }
2501
+ this.ratio = this.img.clientWidth / this.img.clientHeight;
2502
+ this.controllerClassName = "_" + Date.now().toString();
2503
+ this.isRotateOffScreen = false;
2504
+ }
2505
+ _create_class(Transform, [
2506
+ {
2507
+ key: "initialize",
2508
+ value: function initialize() {
2509
+ return _async_to_generator(function() {
2510
+ var transformController;
2511
+ return _ts_generator(this, function(_state) {
2512
+ switch(_state.label){
2513
+ case 0:
2514
+ transformController = new TransformController(this.wrapperClass, this.frameClass, this.controllerClassName);
2515
+ return [
2516
+ 4,
2517
+ transformController.addController()
2518
+ ];
2519
+ case 1:
2520
+ _state.sent();
2521
+ this.controllerContainer = document.querySelector("." + this.controllerClassName + "--container");
2522
+ this.controller = document.querySelector("." + this.controllerClassName);
2523
+ this.handleElementGoOffScreen("." + this.controllerClassName + " .rotate", "." + this.controllerClassName + " .rotate.shadow", "rotate").handleElementGoOffScreen("." + this.controllerClassName + " .delete", "." + this.controllerClassName + " .delete.shadow", "delete").transform();
2524
+ return [
2525
+ 2
2526
+ ];
2527
+ }
2528
+ });
2529
+ }).call(this);
2530
+ }
2531
+ },
2532
+ {
2533
+ key: "reset",
2534
+ value: function reset() {
2535
+ this.setState({
2536
+ x: 0,
2537
+ y: this.imgFrame.clientHeight / 2 - this.img.height / 2,
2538
+ angle: 0,
2539
+ w: this.imgFrame.clientWidth
2540
+ });
2541
+ }
2542
+ },
2543
+ {
2544
+ key: "setState",
2545
+ value: function setState(param) {
2546
+ var x = param.x, y = param.y, angle = param.angle, w = param.w;
2547
+ this.repositionElement(x + this.imgFrame.clientWidth / 2, y + this.img.height / 2);
2548
+ this.rotateBox(angle);
2549
+ this.resize(w, w / this.ratio);
2550
+ this.setValue(x, y, angle, w, w / this.ratio);
2551
+ }
2552
+ },
2553
+ {
2554
+ key: "setValue",
2555
+ value: function setValue(x, y, angle, w, h) {
2556
+ this.x = x !== void 0 ? x : this.x;
2557
+ this.y = y !== void 0 ? y : this.y;
2558
+ this.angle = angle !== void 0 ? angle : this.angle;
2559
+ this.w = w !== void 0 ? w : this.w;
2560
+ this.h = h !== void 0 ? h : this.h;
2561
+ }
2562
+ },
2563
+ {
2564
+ key: "exportData",
2565
+ value: function exportData() {
2566
+ return {
2567
+ x: this.x,
2568
+ y: this.y,
2569
+ angle: this.angle,
2570
+ w: this.w,
2571
+ h: this.h
2572
+ };
2573
+ }
2574
+ },
2575
+ {
2576
+ key: "repositionElement",
2577
+ value: function repositionElement(x, y) {
2578
+ var controllerWrapper = this.controllerContainer;
2579
+ var boxWrapper = this.ele1;
2580
+ boxWrapper.style.left = x + "px";
2581
+ boxWrapper.style.top = y + "px";
2582
+ controllerWrapper.style.left = x + this.imgFrame.offsetLeft + 3 + "px";
2583
+ controllerWrapper.style.top = y + this.imgFrame.offsetTop + 3 + "px";
2584
+ }
2585
+ },
2586
+ {
2587
+ key: "resize",
2588
+ value: function resize(w, h) {
2589
+ var controller = this.controller;
2590
+ var img = this.img;
2591
+ var wrapper = this.ele1;
2592
+ controller.style.width = w + "px";
2593
+ controller.style.height = h + "px";
2594
+ img.style.width = w + "px";
2595
+ wrapper.style.width = w + "px";
2596
+ }
2597
+ },
2598
+ {
2599
+ key: "rotateBox",
2600
+ value: function rotateBox(deg) {
2601
+ var controllerWrapper = this.controllerContainer;
2602
+ var boxWrapper = this.ele1;
2603
+ boxWrapper.style.transform = "rotate(".concat(deg, "deg)");
2604
+ controllerWrapper.style.rotate = "".concat(deg, "deg");
2605
+ }
2606
+ },
2607
+ {
2608
+ key: "handleElementGoOffScreen",
2609
+ value: function handleElementGoOffScreen(main, shadow, type) {
2610
+ var _this = this;
2611
+ var mainEle = document.querySelector(main);
2612
+ var shadowEle = document.querySelector(shadow);
2613
+ var options = {
2614
+ root: null,
2615
+ rootMargin: "0px",
2616
+ threshold: 0.1
2617
+ };
2618
+ var callback = function(entries) {
2619
+ entries.forEach(function(entry) {
2620
+ switch(type){
2621
+ case "rotate":
2622
+ if (!entry.isIntersecting) {
2623
+ mainEle.style.top = "auto";
2624
+ mainEle.style.bottom = "-50px";
2625
+ _this.isRotateOffScreen = true;
2626
+ } else {
2627
+ mainEle.style.bottom = "auto";
2628
+ mainEle.style.top = "-50px";
2629
+ _this.isRotateOffScreen = false;
2630
+ }
2631
+ break;
2632
+ case "delete":
2633
+ if (!entry.isIntersecting) {
2634
+ mainEle.style.bottom = "auto";
2635
+ mainEle.style.top = "-50px";
2636
+ } else {
2637
+ mainEle.style.top = "auto";
2638
+ mainEle.style.bottom = "-50px";
2639
+ }
2640
+ break;
2641
+ }
2642
+ });
2643
+ };
2644
+ var observer = new IntersectionObserver(callback, options);
2645
+ observer.observe(shadowEle);
2646
+ return this;
2647
+ }
2648
+ },
2649
+ {
2650
+ key: "transform",
2651
+ value: function transform() {
2652
+ var _this = this;
2653
+ var _this1 = this;
2654
+ var controllerWrapper = this.controllerContainer;
2655
+ var boxWrapper = this.ele1;
2656
+ var minWidth = 40;
2657
+ var minHeight = 40;
2658
+ var initX, initY, mousePressX, mousePressY, initW, initH, initRotate;
2659
+ function getCurrentRotation(el) {
2660
+ var st = window.getComputedStyle(el, null);
2661
+ var tm = st.getPropertyValue("-webkit-transform") || st.getPropertyValue("-moz-transform") || st.getPropertyValue("-ms-transform") || st.getPropertyValue("-o-transform") || st.getPropertyValue("transform");
2662
+ "none";
2663
+ if (tm != "none") {
2664
+ var values = tm.split("(")[1].split(")")[0].split(",");
2665
+ var angle = Math.round(Math.atan2(Number(values[1]), Number(values[0])) * (180 / Math.PI));
2666
+ return angle < 0 ? angle + 360 : angle;
2667
+ }
2668
+ return 0;
2669
+ }
2670
+ function mousedownCb(event) {
2671
+ event.target.classList.add("show");
2672
+ event.target.querySelector(".circle").classList.add("show");
2673
+ }
2674
+ function mouseupCb(event) {
2675
+ event.target.classList.remove("show");
2676
+ event.target.querySelector(".circle").classList.remove("show");
2677
+ }
2678
+ var handleDrag = function(event, type) {
2679
+ event.stopPropagation();
2680
+ var initX2 = boxWrapper.offsetLeft;
2681
+ var initY2 = boxWrapper.offsetTop;
2682
+ var mousePressX2 = type === "desk" ? event.clientX : event.touches[0].clientX;
2683
+ var mousePressY2 = type === "desk" ? event.clientY : event.touches[0].clientY;
2684
+ var _this_exportData = _this.exportData(), w = _this_exportData.w, h = _this_exportData.h;
2685
+ var eventMoveHandler = function(event2) {
2686
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2687
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2688
+ var posX = initX2 + (x - mousePressX2);
2689
+ var posY = initY2 + (y - mousePressY2);
2690
+ _this.repositionElement(posX, posY);
2691
+ _this.setValue(posX - w / 2, posY - h / 2, void 0, void 0, void 0);
2692
+ };
2693
+ if (type === "desk") {
2694
+ controllerWrapper.addEventListener("mousemove", eventMoveHandler, false);
2695
+ window.addEventListener("mouseup", function eventEndHandler() {
2696
+ controllerWrapper.removeEventListener("mousemove", eventMoveHandler, false);
2697
+ window.removeEventListener("mouseup", eventEndHandler);
2698
+ }, false);
2699
+ } else {
2700
+ controllerWrapper.addEventListener("touchmove", eventMoveHandler, {
2701
+ passive: true
2702
+ });
2703
+ window.addEventListener("touchend", function eventEndHandler() {
2704
+ controllerWrapper.removeEventListener("touchmove", eventMoveHandler);
2705
+ window.removeEventListener("touchend", eventEndHandler);
2706
+ }, false);
2707
+ }
2708
+ };
2709
+ controllerWrapper.addEventListener("mousedown", function(e) {
2710
+ return handleDrag(e, "desk");
2711
+ }, false);
2712
+ controllerWrapper.addEventListener("touchstart", function(e) {
2713
+ return handleDrag(e, "touch");
2714
+ }, {
2715
+ passive: true
2716
+ });
2717
+ var leftTop = document.querySelector("." + this.controllerClassName + " .resize-topleft");
2718
+ var rightTop = document.querySelector("." + this.controllerClassName + " .resize-topright");
2719
+ var rightBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomright");
2720
+ var leftBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomleft");
2721
+ var resizeHandler = function(event) {
2722
+ var left = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, top = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false, xResize = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, yResize = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false, type = arguments.length > 5 ? arguments[5] : void 0;
2723
+ event.stopPropagation();
2724
+ initX = boxWrapper.offsetLeft;
2725
+ initY = boxWrapper.offsetTop;
2726
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2727
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2728
+ initW = _this1.img.offsetWidth;
2729
+ initH = _this1.img.offsetHeight;
2730
+ initRotate = getCurrentRotation(boxWrapper);
2731
+ var initRadians = initRotate * Math.PI / 180;
2732
+ var cosFraction = Math.cos(initRadians);
2733
+ var sinFraction = Math.sin(initRadians);
2734
+ mousedownCb(event);
2735
+ var vectorC = [
2736
+ mousePressX - initX - _this1.imgFrame.offsetLeft,
2737
+ mousePressY - initY - _this1.imgFrame.offsetTop
2738
+ ];
2739
+ var eventMoveHandler = function(event2) {
2740
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2741
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2742
+ var wDiff = x - mousePressX;
2743
+ var hDiff = y - mousePressY;
2744
+ var vectorD = [
2745
+ wDiff,
2746
+ hDiff
2747
+ ];
2748
+ var c = (vectorC[0] * vectorD[0] + vectorC[1] * vectorD[1]) / (vectorC[0] * vectorC[0] + vectorC[1] * vectorC[1]);
2749
+ var vectorH = [
2750
+ c * vectorC[0],
2751
+ c * vectorC[1]
2752
+ ];
2753
+ var rotatedWDiff = cosFraction * vectorH[0] + sinFraction * vectorH[1];
2754
+ var rotatedHDiff = cosFraction * vectorH[1] - sinFraction * vectorH[0];
2755
+ rotatedHDiff = rotatedHDiff * rotatedWDiff > 0 ? rotatedWDiff / _this1.ratio : -rotatedWDiff / _this1.ratio;
2756
+ var newW = initW, newH = initH, newX = initX, newY = initY;
2757
+ if (xResize) {
2758
+ if (left) {
2759
+ newW = initW - rotatedWDiff;
2760
+ if (newW < minWidth) {
2761
+ newW = minWidth;
2762
+ rotatedWDiff = initW - minWidth;
2763
+ }
2764
+ } else {
2765
+ newW = initW + rotatedWDiff;
2766
+ if (newW < minWidth) {
2767
+ newW = minWidth;
2768
+ rotatedWDiff = minWidth - initW;
2769
+ }
2770
+ }
2771
+ newX += 0.5 * rotatedWDiff * cosFraction;
2772
+ newY += 0.5 * rotatedWDiff * sinFraction;
2773
+ }
2774
+ if (yResize) {
2775
+ if (top) {
2776
+ newH = initH - rotatedHDiff;
2777
+ if (newH < minHeight) {
2778
+ newH = minHeight;
2779
+ rotatedHDiff = initH - minHeight;
2780
+ }
2781
+ } else {
2782
+ newH = initH + rotatedHDiff;
2783
+ if (newH < minHeight) {
2784
+ newH = minHeight;
2785
+ rotatedHDiff = minHeight - initH;
2786
+ }
2787
+ }
2788
+ newX -= 0.5 * rotatedHDiff * sinFraction;
2789
+ newY += 0.5 * rotatedHDiff * cosFraction;
2790
+ }
2791
+ _this1.resize(newW, newH);
2792
+ _this1.repositionElement(newX, newY);
2793
+ _this1.setValue(newX - newW / 2, newY - newH / 2, void 0, newW, newH);
2794
+ };
2795
+ if (type === "desk") {
2796
+ window.addEventListener("mousemove", eventMoveHandler, false);
2797
+ window.addEventListener("mouseup", function eventEndHandler() {
2798
+ mouseupCb(event);
2799
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2800
+ window.removeEventListener("mouseup", eventEndHandler);
2801
+ }, false);
2802
+ } else {
2803
+ window.addEventListener("touchmove", eventMoveHandler, {
2804
+ passive: true
2805
+ });
2806
+ window.addEventListener("touchend", function eventEndHandler() {
2807
+ mouseupCb(event);
2808
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2809
+ window.removeEventListener("touchend", eventEndHandler);
2810
+ }, false);
2811
+ }
2812
+ };
2813
+ leftTop.addEventListener("mousedown", function(e) {
2814
+ return resizeHandler(e, true, true, true, true, "desk");
2815
+ });
2816
+ rightTop.addEventListener("mousedown", function(e) {
2817
+ return resizeHandler(e, false, true, true, true, "desk");
2818
+ });
2819
+ rightBottom.addEventListener("mousedown", function(e) {
2820
+ return resizeHandler(e, false, false, true, true, "desk");
2821
+ });
2822
+ leftBottom.addEventListener("mousedown", function(e) {
2823
+ return resizeHandler(e, true, false, true, true, "desk");
2824
+ });
2825
+ leftTop.addEventListener("touchstart", function(e) {
2826
+ return resizeHandler(e, true, true, true, true, "touch");
2827
+ }, {
2828
+ passive: true
2829
+ });
2830
+ rightTop.addEventListener("touchstart", function(e) {
2831
+ return resizeHandler(e, false, true, true, true, "touch");
2832
+ }, {
2833
+ passive: true
2834
+ });
2835
+ rightBottom.addEventListener("touchstart", function(e) {
2836
+ return resizeHandler(e, false, false, true, true, "touch");
2837
+ }, {
2838
+ passive: true
2839
+ });
2840
+ leftBottom.addEventListener("touchstart", function(e) {
2841
+ return resizeHandler(e, true, false, true, true, "touch");
2842
+ }, {
2843
+ passive: true
2844
+ });
2845
+ var rotate = document.querySelector("." + this.controllerClassName + " .rotate");
2846
+ var handleRotate = function(event, type) {
2847
+ event.stopPropagation();
2848
+ initX = event.target.offsetLeft;
2849
+ initY = event.target.offsetTop;
2850
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2851
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2852
+ var arrow = _this.controller;
2853
+ var arrowRects = arrow.getBoundingClientRect();
2854
+ var arrowX = arrowRects.left + arrowRects.width / 2;
2855
+ var arrowY = arrowRects.top + arrowRects.height / 2;
2856
+ var compensation = _this.isRotateOffScreen ? 180 : 0;
2857
+ var eventMoveHandler = function(event2) {
2858
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2859
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2860
+ var angle = Math.atan2(y - arrowY, x - arrowX) + Math.PI / 2;
2861
+ angle *= 180 / Math.PI;
2862
+ angle += compensation;
2863
+ _this.rotateBox(angle);
2864
+ _this.setValue(void 0, void 0, angle, void 0, void 0);
2865
+ };
2866
+ if (type === "desk") {
2867
+ window.addEventListener("mousemove", eventMoveHandler, false);
2868
+ window.addEventListener("mouseup", function eventEndHandler() {
2869
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2870
+ window.removeEventListener("mouseup", eventEndHandler);
2871
+ }, false);
2872
+ } else {
2873
+ window.addEventListener("touchmove", eventMoveHandler, {
2874
+ passive: true
2875
+ });
2876
+ window.addEventListener("touchend", function eventEndHandler() {
2877
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2878
+ window.removeEventListener("touchend", eventEndHandler);
2879
+ }, false);
2880
+ }
2881
+ };
2882
+ rotate.addEventListener("mousedown", function(e) {
2883
+ return handleRotate(e, "desk");
2884
+ }, false);
2885
+ rotate.addEventListener("touchstart", function(e) {
2886
+ return handleRotate(e, "touch");
2887
+ }, {
2888
+ passive: true
2889
+ });
2890
+ this.reset();
2891
+ return this;
2892
+ }
2893
+ }
2894
+ ]);
2895
+ return Transform;
2896
+ }();
2897
+ export { Avatar_default as Avatar, Button_default as Button, Canvas, ColorPickerSlider_default as ColorPickerSlider, DropdownSelect_default as DropdownSelect, Image_default as Image, ImageEditor_default as ImageEditor, Image_default2 as ImageUtilities, InputFile_default as InputFile, InputGoogle_default as InputGoogle, MultiSelect_default as MultiSelect, OptionSlider_default as OptionSlider, RangeSlider_default as RangeSlider, TextArea_default as TextArea, Transform, UploadImage_default as UploadImage };