labellife-design-tool 2.3.8 → 2.3.9
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/cjs/canvas/workspace.js +229 -10
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +556 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +215 -3
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js +120 -0
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +120 -0
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +18 -1
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js +231 -12
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +557 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +215 -3
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js +120 -0
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +120 -0
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +18 -1
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var FormatAlignLeftIcon = require('@mui/icons-material/FormatAlignLeft');
|
|
|
47
47
|
var FormatAlignCenterIcon = require('@mui/icons-material/FormatAlignCenter');
|
|
48
48
|
var FormatAlignRightIcon = require('@mui/icons-material/FormatAlignRight');
|
|
49
49
|
var OpacityIcon = require('@mui/icons-material/Opacity');
|
|
50
|
-
require('@mui/icons-material/Crop');
|
|
50
|
+
var CropIcon = require('@mui/icons-material/Crop');
|
|
51
51
|
var AutoAwesomeIcon = require('@mui/icons-material/AutoAwesome');
|
|
52
52
|
var SwapHorizIcon = require('@mui/icons-material/SwapHoriz');
|
|
53
53
|
var SwapVertIcon = require('@mui/icons-material/SwapVert');
|
|
@@ -633,6 +633,84 @@ var Shape = Node.named('Shape').props({
|
|
|
633
633
|
};
|
|
634
634
|
});
|
|
635
635
|
|
|
636
|
+
// Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
|
|
637
|
+
// Mirrors the existing auto-crop calculation in canvas/image-element.js.
|
|
638
|
+
function coverFitCrop(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
639
|
+
var boxAspect = boxWidth / boxHeight;
|
|
640
|
+
var imgAspect = naturalWidth / naturalHeight;
|
|
641
|
+
if (imgAspect > boxAspect) {
|
|
642
|
+
var _cw = naturalHeight * boxAspect;
|
|
643
|
+
return {
|
|
644
|
+
cropX: (naturalWidth - _cw) / 2 / naturalWidth,
|
|
645
|
+
cropY: 0,
|
|
646
|
+
cropWidth: _cw / naturalWidth,
|
|
647
|
+
cropHeight: 1
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
var ch = naturalWidth / boxAspect;
|
|
651
|
+
return {
|
|
652
|
+
cropX: 0,
|
|
653
|
+
cropY: (naturalHeight - ch) / 2 / naturalHeight,
|
|
654
|
+
cropWidth: 1,
|
|
655
|
+
cropHeight: ch / naturalHeight
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Whether stored crop fields represent an explicit (non-default) manual crop.
|
|
660
|
+
function hasManualCrop(cropX, cropY, cropWidth, cropHeight) {
|
|
661
|
+
return cropX !== 0 || cropY !== 0 || cropWidth !== 1 || cropHeight !== 1;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// Convert a crop (fractions of natural image size) + target rect (page units) into an
|
|
665
|
+
// image position/scale such that the crop region renders exactly under the rect.
|
|
666
|
+
function cropToImageTransform(crop, rect, naturalWidth, naturalHeight) {
|
|
667
|
+
var naturalX = crop.cropX * naturalWidth;
|
|
668
|
+
var naturalY = crop.cropY * naturalHeight;
|
|
669
|
+
var naturalW = crop.cropWidth * naturalWidth;
|
|
670
|
+
var scale = naturalW > 0 ? rect.width / naturalW : 1;
|
|
671
|
+
return {
|
|
672
|
+
scale: scale,
|
|
673
|
+
offset: {
|
|
674
|
+
x: rect.x - naturalX * scale,
|
|
675
|
+
y: rect.y - naturalY * scale
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Inverse: given the image's page-space position/scale and a rect, compute crop fractions.
|
|
681
|
+
function rectToCrop(rect, imgOffset, imgScale, naturalWidth, naturalHeight) {
|
|
682
|
+
var naturalX = (rect.x - imgOffset.x) / imgScale;
|
|
683
|
+
var naturalY = (rect.y - imgOffset.y) / imgScale;
|
|
684
|
+
var naturalW = rect.width / imgScale;
|
|
685
|
+
var naturalH = rect.height / imgScale;
|
|
686
|
+
return {
|
|
687
|
+
cropX: naturalX / naturalWidth,
|
|
688
|
+
cropY: naturalY / naturalHeight,
|
|
689
|
+
cropWidth: naturalW / naturalWidth,
|
|
690
|
+
cropHeight: naturalH / naturalHeight
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Minimum scale at which the image (rendered at naturalWidth*scale x naturalHeight*scale)
|
|
695
|
+
// still fully covers rect.
|
|
696
|
+
function minScaleForRect(rect, naturalWidth, naturalHeight) {
|
|
697
|
+
return Math.max(rect.width / naturalWidth, rect.height / naturalHeight);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// Clamp an image page-space offset so the image still fully covers rect at the given scale.
|
|
701
|
+
function clampImageOffset(offset, scale, rect, naturalWidth, naturalHeight) {
|
|
702
|
+
var imgW = naturalWidth * scale;
|
|
703
|
+
var imgH = naturalHeight * scale;
|
|
704
|
+
var minX = rect.x + rect.width - imgW;
|
|
705
|
+
var maxX = rect.x;
|
|
706
|
+
var minY = rect.y + rect.height - imgH;
|
|
707
|
+
var maxY = rect.y;
|
|
708
|
+
return {
|
|
709
|
+
x: Math.min(maxX, Math.max(minX, offset.x)),
|
|
710
|
+
y: Math.min(maxY, Math.max(minY, offset.y))
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
636
714
|
var ImageElement = Shape.named('ImageElement').props({
|
|
637
715
|
type: mobxStateTree.types.optional(mobxStateTree.types.string, 'image'),
|
|
638
716
|
src: mobxStateTree.types.optional(mobxStateTree.types.string, ''),
|
|
@@ -666,12 +744,132 @@ var ImageElement = Shape.named('ImageElement').props({
|
|
|
666
744
|
return s;
|
|
667
745
|
})["volatile"](function () {
|
|
668
746
|
return {
|
|
669
|
-
|
|
747
|
+
// Set once, when the image finishes loading (see canvas/image-element.js).
|
|
748
|
+
_naturalWidth: 0,
|
|
749
|
+
_naturalHeight: 0,
|
|
750
|
+
// Crop-mode editing state — all null/default when not cropping.
|
|
751
|
+
_cropModeEnabled: false,
|
|
752
|
+
_cropEntrySnapshot: null,
|
|
753
|
+
_cropRect: null,
|
|
754
|
+
_cropImgOffset: null,
|
|
755
|
+
_cropImgScale: 1,
|
|
756
|
+
_cropNaturalWidth: 0,
|
|
757
|
+
_cropNaturalHeight: 0
|
|
670
758
|
};
|
|
671
759
|
}).actions(function (self) {
|
|
672
760
|
return {
|
|
673
|
-
|
|
674
|
-
self.
|
|
761
|
+
setNaturalSize: function setNaturalSize(width, height) {
|
|
762
|
+
self._naturalWidth = width;
|
|
763
|
+
self._naturalHeight = height;
|
|
764
|
+
},
|
|
765
|
+
enterCropMode: function enterCropMode() {
|
|
766
|
+
var naturalWidth = self._naturalWidth;
|
|
767
|
+
var naturalHeight = self._naturalHeight;
|
|
768
|
+
if (!naturalWidth || !naturalHeight) return;
|
|
769
|
+
if (self.rotation !== 0 || self.flipX || self.flipY) return;
|
|
770
|
+
self._cropEntrySnapshot = {
|
|
771
|
+
x: self.x,
|
|
772
|
+
y: self.y,
|
|
773
|
+
width: self.width,
|
|
774
|
+
height: self.height,
|
|
775
|
+
cropX: self.cropX,
|
|
776
|
+
cropY: self.cropY,
|
|
777
|
+
cropWidth: self.cropWidth,
|
|
778
|
+
cropHeight: self.cropHeight
|
|
779
|
+
};
|
|
780
|
+
var rect = {
|
|
781
|
+
x: self.x,
|
|
782
|
+
y: self.y,
|
|
783
|
+
width: self.width,
|
|
784
|
+
height: self.height
|
|
785
|
+
};
|
|
786
|
+
var crop = hasManualCrop(self.cropX, self.cropY, self.cropWidth, self.cropHeight) ? {
|
|
787
|
+
cropX: self.cropX,
|
|
788
|
+
cropY: self.cropY,
|
|
789
|
+
cropWidth: self.cropWidth,
|
|
790
|
+
cropHeight: self.cropHeight
|
|
791
|
+
} : coverFitCrop(rect.width, rect.height, naturalWidth, naturalHeight);
|
|
792
|
+
var _cropToImageTransform = cropToImageTransform(crop, rect, naturalWidth, naturalHeight),
|
|
793
|
+
scale = _cropToImageTransform.scale,
|
|
794
|
+
offset = _cropToImageTransform.offset;
|
|
795
|
+
self._cropRect = rect;
|
|
796
|
+
self._cropImgOffset = offset;
|
|
797
|
+
self._cropImgScale = scale;
|
|
798
|
+
self._cropNaturalWidth = naturalWidth;
|
|
799
|
+
self._cropNaturalHeight = naturalHeight;
|
|
800
|
+
self._cropModeEnabled = true;
|
|
801
|
+
},
|
|
802
|
+
setCropRectAndClamp: function setCropRectAndClamp(rect) {
|
|
803
|
+
// Defensive guard (not in the original brief text): without this, a caller invoking
|
|
804
|
+
// this action while crop mode is inactive (e.g. enterCropMode() no-op'd because the
|
|
805
|
+
// image hadn't loaded yet) would hit minScaleForRect/clampImageOffset with
|
|
806
|
+
// _cropNaturalWidth/_cropNaturalHeight still at their 0 defaults, producing
|
|
807
|
+
// Infinity/NaN. Crop mode is only ever active with a nonzero natural size (see
|
|
808
|
+
// enterCropMode's guard above), so gating on _cropModeEnabled here is equivalent to
|
|
809
|
+
// gating on nonzero natural size, without changing behavior for the normal case.
|
|
810
|
+
if (!self._cropModeEnabled) return;
|
|
811
|
+
self._cropRect = rect;
|
|
812
|
+
var minScale = minScaleForRect(rect, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
813
|
+
if (self._cropImgScale < minScale) {
|
|
814
|
+
self._cropImgScale = minScale;
|
|
815
|
+
}
|
|
816
|
+
self._cropImgOffset = clampImageOffset(self._cropImgOffset || {
|
|
817
|
+
x: rect.x,
|
|
818
|
+
y: rect.y
|
|
819
|
+
}, self._cropImgScale, rect, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
820
|
+
},
|
|
821
|
+
panCropImage: function panCropImage(offset) {
|
|
822
|
+
if (!self._cropRect) return;
|
|
823
|
+
self._cropImgOffset = clampImageOffset(offset, self._cropImgScale, self._cropRect, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
824
|
+
},
|
|
825
|
+
setCropZoom: function setCropZoom(scale) {
|
|
826
|
+
if (!self._cropRect) return;
|
|
827
|
+
var minScale = minScaleForRect(self._cropRect, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
828
|
+
var clampedScale = Math.max(minScale, scale);
|
|
829
|
+
self._cropImgScale = clampedScale;
|
|
830
|
+
self._cropImgOffset = clampImageOffset(self._cropImgOffset || {
|
|
831
|
+
x: self._cropRect.x,
|
|
832
|
+
y: self._cropRect.y
|
|
833
|
+
}, clampedScale, self._cropRect, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
834
|
+
},
|
|
835
|
+
resetCropToDefault: function resetCropToDefault() {
|
|
836
|
+
if (!self._cropRect) return;
|
|
837
|
+
var crop = coverFitCrop(self._cropRect.width, self._cropRect.height, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
838
|
+
var _cropToImageTransform2 = cropToImageTransform(crop, self._cropRect, self._cropNaturalWidth, self._cropNaturalHeight),
|
|
839
|
+
scale = _cropToImageTransform2.scale,
|
|
840
|
+
offset = _cropToImageTransform2.offset;
|
|
841
|
+
self._cropImgScale = scale;
|
|
842
|
+
self._cropImgOffset = offset;
|
|
843
|
+
},
|
|
844
|
+
cancelCropMode: function cancelCropMode() {
|
|
845
|
+
if (self._cropEntrySnapshot) {
|
|
846
|
+
self.set(self._cropEntrySnapshot);
|
|
847
|
+
}
|
|
848
|
+
self._cropEntrySnapshot = null;
|
|
849
|
+
self._cropRect = null;
|
|
850
|
+
self._cropImgOffset = null;
|
|
851
|
+
self._cropImgScale = 1;
|
|
852
|
+
self._cropModeEnabled = false;
|
|
853
|
+
},
|
|
854
|
+
commitCropMode: function commitCropMode() {
|
|
855
|
+
if (self._cropRect && self._cropImgOffset) {
|
|
856
|
+
var crop = rectToCrop(self._cropRect, self._cropImgOffset, self._cropImgScale, self._cropNaturalWidth, self._cropNaturalHeight);
|
|
857
|
+
self.set({
|
|
858
|
+
x: self._cropRect.x,
|
|
859
|
+
y: self._cropRect.y,
|
|
860
|
+
width: self._cropRect.width,
|
|
861
|
+
height: self._cropRect.height,
|
|
862
|
+
cropX: crop.cropX,
|
|
863
|
+
cropY: crop.cropY,
|
|
864
|
+
cropWidth: crop.cropWidth,
|
|
865
|
+
cropHeight: crop.cropHeight
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
self._cropEntrySnapshot = null;
|
|
869
|
+
self._cropRect = null;
|
|
870
|
+
self._cropImgOffset = null;
|
|
871
|
+
self._cropImgScale = 1;
|
|
872
|
+
self._cropModeEnabled = false;
|
|
675
873
|
}
|
|
676
874
|
};
|
|
677
875
|
});
|
|
@@ -1766,10 +1964,22 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1766
1964
|
if (self._toolbarPanel) {
|
|
1767
1965
|
var stillSelected = ids.includes(self._toolbarPanel.elementId);
|
|
1768
1966
|
if (!stillSelected) {
|
|
1967
|
+
self._cancelActiveCrop();
|
|
1769
1968
|
self._toolbarPanel = null;
|
|
1770
1969
|
}
|
|
1771
1970
|
}
|
|
1772
1971
|
},
|
|
1972
|
+
// Single choke-point for "cancel whatever element is mid-crop, if any" — must be
|
|
1973
|
+
// called before _toolbarPanel is overwritten/cleared by any path (panel switch,
|
|
1974
|
+
// panel close, or selection change) so an element can never be left stuck in
|
|
1975
|
+
// crop mode with no matching exit trigger.
|
|
1976
|
+
_cancelActiveCrop: function _cancelActiveCrop() {
|
|
1977
|
+
var _self$_toolbarPanel;
|
|
1978
|
+
if (((_self$_toolbarPanel = self._toolbarPanel) === null || _self$_toolbarPanel === void 0 ? void 0 : _self$_toolbarPanel.type) === 'crop') {
|
|
1979
|
+
var el = self.getElementById(self._toolbarPanel.elementId);
|
|
1980
|
+
if (el && el._cropModeEnabled && el.cancelCropMode) el.cancelCropMode();
|
|
1981
|
+
}
|
|
1982
|
+
},
|
|
1773
1983
|
toggleBleed: function toggleBleed(bleedVisible) {
|
|
1774
1984
|
self.bleedVisible = bleedVisible !== undefined ? bleedVisible : !self.bleedVisible;
|
|
1775
1985
|
},
|
|
@@ -1786,6 +1996,7 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1786
1996
|
openToolbarPanel: function openToolbarPanel(type) {
|
|
1787
1997
|
var el = self.selectedElements.length === 1 ? self.selectedElements[0] : null;
|
|
1788
1998
|
if (el) {
|
|
1999
|
+
self._cancelActiveCrop();
|
|
1789
2000
|
self._toolbarPanel = {
|
|
1790
2001
|
type: type,
|
|
1791
2002
|
elementId: el.id
|
|
@@ -1793,6 +2004,7 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1793
2004
|
}
|
|
1794
2005
|
},
|
|
1795
2006
|
closeToolbarPanel: function closeToolbarPanel() {
|
|
2007
|
+
self._cancelActiveCrop();
|
|
1796
2008
|
self._toolbarPanel = null;
|
|
1797
2009
|
},
|
|
1798
2010
|
setScale: function setScale(scale) {
|
|
@@ -6278,6 +6490,115 @@ var ImageMaskPanel = mobxReactLite.observer(function (_ref) {
|
|
|
6278
6490
|
});
|
|
6279
6491
|
ImageMaskPanel.displayName = 'ImageMaskPanel';
|
|
6280
6492
|
|
|
6493
|
+
var ImageCropPanel = mobxReactLite.observer(function (_ref) {
|
|
6494
|
+
var store = _ref.store;
|
|
6495
|
+
var panel = store._toolbarPanel;
|
|
6496
|
+
if (!panel || panel.type !== 'crop') return null;
|
|
6497
|
+
var element = store.getElementById(panel.elementId);
|
|
6498
|
+
if (!element || !element._cropRect) return null;
|
|
6499
|
+
var handleCancel = function handleCancel() {
|
|
6500
|
+
element.cancelCropMode();
|
|
6501
|
+
store.closeToolbarPanel();
|
|
6502
|
+
};
|
|
6503
|
+
var handleDone = function handleDone() {
|
|
6504
|
+
element.commitCropMode();
|
|
6505
|
+
store.closeToolbarPanel();
|
|
6506
|
+
store.history.addUndoState();
|
|
6507
|
+
};
|
|
6508
|
+
var handleReset = function handleReset() {
|
|
6509
|
+
element.resetCropToDefault();
|
|
6510
|
+
};
|
|
6511
|
+
var minScale = minScaleForRect(element._cropRect, element._cropNaturalWidth, element._cropNaturalHeight);
|
|
6512
|
+
var maxScale = minScale * 4;
|
|
6513
|
+
return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
6514
|
+
sx: {
|
|
6515
|
+
width: 280,
|
|
6516
|
+
height: '100%',
|
|
6517
|
+
overflowY: 'auto',
|
|
6518
|
+
overflowX: 'hidden',
|
|
6519
|
+
backgroundColor: '#fff',
|
|
6520
|
+
borderRight: '1px solid #e0e0e0',
|
|
6521
|
+
flexShrink: 0,
|
|
6522
|
+
p: 2
|
|
6523
|
+
},
|
|
6524
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
6525
|
+
sx: {
|
|
6526
|
+
display: 'flex',
|
|
6527
|
+
alignItems: 'center',
|
|
6528
|
+
justifyContent: 'space-between',
|
|
6529
|
+
mb: 2
|
|
6530
|
+
},
|
|
6531
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
6532
|
+
variant: "subtitle1",
|
|
6533
|
+
sx: {
|
|
6534
|
+
fontWeight: 600
|
|
6535
|
+
},
|
|
6536
|
+
children: t('toolbar.crop', 'Crop')
|
|
6537
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
|
|
6538
|
+
size: "small",
|
|
6539
|
+
onClick: handleCancel,
|
|
6540
|
+
children: /*#__PURE__*/jsxRuntime.jsx(CloseIcon, {
|
|
6541
|
+
fontSize: "small"
|
|
6542
|
+
})
|
|
6543
|
+
})]
|
|
6544
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
6545
|
+
variant: "body2",
|
|
6546
|
+
sx: {
|
|
6547
|
+
fontWeight: 500,
|
|
6548
|
+
mb: 0.5
|
|
6549
|
+
},
|
|
6550
|
+
children: t('toolbar.cropZoom', 'Zoom')
|
|
6551
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Slider, {
|
|
6552
|
+
size: "small",
|
|
6553
|
+
value: element._cropImgScale,
|
|
6554
|
+
onChange: function onChange(_, v) {
|
|
6555
|
+
return element.setCropZoom(v);
|
|
6556
|
+
},
|
|
6557
|
+
min: minScale,
|
|
6558
|
+
max: maxScale,
|
|
6559
|
+
step: (maxScale - minScale) / 100 || 0.01,
|
|
6560
|
+
sx: {
|
|
6561
|
+
mb: 3
|
|
6562
|
+
}
|
|
6563
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
6564
|
+
fullWidth: true,
|
|
6565
|
+
variant: "outlined",
|
|
6566
|
+
size: "small",
|
|
6567
|
+
onClick: handleReset,
|
|
6568
|
+
sx: {
|
|
6569
|
+
textTransform: 'none',
|
|
6570
|
+
mb: 3
|
|
6571
|
+
},
|
|
6572
|
+
children: t('toolbar.cropReset', 'Reset')
|
|
6573
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
6574
|
+
sx: {
|
|
6575
|
+
display: 'flex',
|
|
6576
|
+
gap: 1
|
|
6577
|
+
},
|
|
6578
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
6579
|
+
fullWidth: true,
|
|
6580
|
+
variant: "outlined",
|
|
6581
|
+
size: "small",
|
|
6582
|
+
onClick: handleCancel,
|
|
6583
|
+
sx: {
|
|
6584
|
+
textTransform: 'none'
|
|
6585
|
+
},
|
|
6586
|
+
children: t('toolbar.cropCancel', 'Cancel')
|
|
6587
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
6588
|
+
fullWidth: true,
|
|
6589
|
+
variant: "contained",
|
|
6590
|
+
size: "small",
|
|
6591
|
+
onClick: handleDone,
|
|
6592
|
+
sx: {
|
|
6593
|
+
textTransform: 'none'
|
|
6594
|
+
},
|
|
6595
|
+
children: t('toolbar.cropDone', 'Done')
|
|
6596
|
+
})]
|
|
6597
|
+
})]
|
|
6598
|
+
});
|
|
6599
|
+
});
|
|
6600
|
+
ImageCropPanel.displayName = 'ImageCropPanel';
|
|
6601
|
+
|
|
6281
6602
|
var SliderRow = function SliderRow(_ref) {
|
|
6282
6603
|
var label = _ref.label,
|
|
6283
6604
|
value = _ref.value,
|
|
@@ -6803,6 +7124,8 @@ var SidePanel = mobxReactLite.observer(function (_ref) {
|
|
|
6803
7124
|
});
|
|
6804
7125
|
}() : store._toolbarPanel.type === 'mask' ? /*#__PURE__*/jsxRuntime.jsx(ImageMaskPanel, {
|
|
6805
7126
|
store: store
|
|
7127
|
+
}) : store._toolbarPanel.type === 'crop' ? /*#__PURE__*/jsxRuntime.jsx(ImageCropPanel, {
|
|
7128
|
+
store: store
|
|
6806
7129
|
}) : null : (/* Normal panel content */
|
|
6807
7130
|
activeSectionObj && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
6808
7131
|
sx: {
|
|
@@ -8881,6 +9204,13 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
8881
9204
|
store.history.addUndoState();
|
|
8882
9205
|
setFlipAnchor(null);
|
|
8883
9206
|
};
|
|
9207
|
+
var handleCrop = function handleCrop() {
|
|
9208
|
+
if (!element._naturalWidth || !element._naturalHeight) return;
|
|
9209
|
+
element.enterCropMode();
|
|
9210
|
+
if (element._cropModeEnabled) {
|
|
9211
|
+
store.openToolbarPanel('crop');
|
|
9212
|
+
}
|
|
9213
|
+
};
|
|
8884
9214
|
var handleFitToPage = function handleFitToPage() {
|
|
8885
9215
|
element.set({
|
|
8886
9216
|
x: 0,
|
|
@@ -9010,6 +9340,16 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9010
9340
|
} : {}),
|
|
9011
9341
|
onClick: handleMask,
|
|
9012
9342
|
children: hasMask ? t('toolbar.removeMask', 'Remove mask') : t('toolbar.clip', 'Apply mask')
|
|
9343
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
9344
|
+
size: "small",
|
|
9345
|
+
sx: toolbarBtnSx,
|
|
9346
|
+
startIcon: /*#__PURE__*/jsxRuntime.jsx(CropIcon, {
|
|
9347
|
+
sx: {
|
|
9348
|
+
fontSize: '16px !important'
|
|
9349
|
+
}
|
|
9350
|
+
}),
|
|
9351
|
+
onClick: handleCrop,
|
|
9352
|
+
children: t('toolbar.crop', 'Crop')
|
|
9013
9353
|
})]
|
|
9014
9354
|
});
|
|
9015
9355
|
});
|
|
@@ -10179,6 +10519,159 @@ var ZoomButtons = mobxReactLite.observer(function (_ref) {
|
|
|
10179
10519
|
});
|
|
10180
10520
|
ZoomButtons.displayName = 'ZoomButtons';
|
|
10181
10521
|
|
|
10522
|
+
// src/canvas/crop-editor.js
|
|
10523
|
+
var MIN_RECT_SIZE = 20;
|
|
10524
|
+
var VIEWPORT_PAD = 400; // page units of dim area rendered around the crop rect
|
|
10525
|
+
|
|
10526
|
+
var CropEditor = mobxReactLite.observer(function (_ref) {
|
|
10527
|
+
var element = _ref.element,
|
|
10528
|
+
image = _ref.image;
|
|
10529
|
+
var rectRef = React.useRef(null);
|
|
10530
|
+
var transformerRef = React.useRef(null);
|
|
10531
|
+
React.useEffect(function () {
|
|
10532
|
+
if (transformerRef.current && rectRef.current) {
|
|
10533
|
+
var _transformerRef$curre;
|
|
10534
|
+
transformerRef.current.nodes([rectRef.current]);
|
|
10535
|
+
(_transformerRef$curre = transformerRef.current.getLayer()) === null || _transformerRef$curre === void 0 || _transformerRef$curre.batchDraw();
|
|
10536
|
+
}
|
|
10537
|
+
});
|
|
10538
|
+
if (!image || !element._cropRect || !element._cropImgOffset) return null;
|
|
10539
|
+
var natW = image.naturalWidth || image.width;
|
|
10540
|
+
var natH = image.naturalHeight || image.height;
|
|
10541
|
+
var rect = element._cropRect;
|
|
10542
|
+
var offset = element._cropImgOffset;
|
|
10543
|
+
var scale = element._cropImgScale;
|
|
10544
|
+
var handleImageDragMove = function handleImageDragMove(e) {
|
|
10545
|
+
var node = e.target;
|
|
10546
|
+
var clamped = clampImageOffset({
|
|
10547
|
+
x: node.x(),
|
|
10548
|
+
y: node.y()
|
|
10549
|
+
}, scale, rect, natW, natH);
|
|
10550
|
+
node.x(clamped.x);
|
|
10551
|
+
node.y(clamped.y);
|
|
10552
|
+
};
|
|
10553
|
+
var handleImageDragEnd = function handleImageDragEnd(e) {
|
|
10554
|
+
var node = e.target;
|
|
10555
|
+
element.panCropImage({
|
|
10556
|
+
x: node.x(),
|
|
10557
|
+
y: node.y()
|
|
10558
|
+
});
|
|
10559
|
+
};
|
|
10560
|
+
var handleRectDragEnd = function handleRectDragEnd(e) {
|
|
10561
|
+
var node = e.target;
|
|
10562
|
+
element.setCropRectAndClamp({
|
|
10563
|
+
x: node.x(),
|
|
10564
|
+
y: node.y(),
|
|
10565
|
+
width: rect.width,
|
|
10566
|
+
height: rect.height
|
|
10567
|
+
});
|
|
10568
|
+
};
|
|
10569
|
+
|
|
10570
|
+
// Shared by both the live (onTransform) and final (onTransformEnd) handlers: reads the
|
|
10571
|
+
// Konva node's current scale, bakes it into width/height, resets the node's scale back to
|
|
10572
|
+
// 1 (required for the Transformer to keep computing subsequent ticks correctly within the
|
|
10573
|
+
// same drag), and pushes the new rect through the model so the image/mask stay in sync.
|
|
10574
|
+
var applyRectTransform = function applyRectTransform() {
|
|
10575
|
+
var node = rectRef.current;
|
|
10576
|
+
var scaleX = node.scaleX();
|
|
10577
|
+
var scaleY = node.scaleY();
|
|
10578
|
+
var newRect = {
|
|
10579
|
+
x: node.x(),
|
|
10580
|
+
y: node.y(),
|
|
10581
|
+
width: Math.max(MIN_RECT_SIZE, rect.width * scaleX),
|
|
10582
|
+
height: Math.max(MIN_RECT_SIZE, rect.height * scaleY)
|
|
10583
|
+
};
|
|
10584
|
+
node.scaleX(1);
|
|
10585
|
+
node.scaleY(1);
|
|
10586
|
+
node.width(newRect.width);
|
|
10587
|
+
node.height(newRect.height);
|
|
10588
|
+
element.setCropRectAndClamp(newRect);
|
|
10589
|
+
};
|
|
10590
|
+
var handleRectTransform = function handleRectTransform() {
|
|
10591
|
+
return applyRectTransform();
|
|
10592
|
+
};
|
|
10593
|
+
var handleRectTransformEnd = function handleRectTransformEnd() {
|
|
10594
|
+
return applyRectTransform();
|
|
10595
|
+
};
|
|
10596
|
+
|
|
10597
|
+
// Dim mask: four rects framing the hole over `rect`.
|
|
10598
|
+
var vx = rect.x - VIEWPORT_PAD;
|
|
10599
|
+
var vy = rect.y - VIEWPORT_PAD;
|
|
10600
|
+
var vw = rect.width + VIEWPORT_PAD * 2;
|
|
10601
|
+
var vh = rect.height + VIEWPORT_PAD * 2;
|
|
10602
|
+
return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Group, {
|
|
10603
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Image, {
|
|
10604
|
+
name: "display-only crop-interactive",
|
|
10605
|
+
image: image,
|
|
10606
|
+
x: offset.x,
|
|
10607
|
+
y: offset.y,
|
|
10608
|
+
width: natW * scale,
|
|
10609
|
+
height: natH * scale,
|
|
10610
|
+
draggable: true,
|
|
10611
|
+
onDragMove: handleImageDragMove,
|
|
10612
|
+
onDragEnd: handleImageDragEnd
|
|
10613
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10614
|
+
name: "display-only",
|
|
10615
|
+
x: vx,
|
|
10616
|
+
y: vy,
|
|
10617
|
+
width: vw,
|
|
10618
|
+
height: rect.y - vy,
|
|
10619
|
+
fill: "rgba(0,0,0,0.55)",
|
|
10620
|
+
listening: false
|
|
10621
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10622
|
+
name: "display-only",
|
|
10623
|
+
x: vx,
|
|
10624
|
+
y: rect.y + rect.height,
|
|
10625
|
+
width: vw,
|
|
10626
|
+
height: vy + vh - (rect.y + rect.height),
|
|
10627
|
+
fill: "rgba(0,0,0,0.55)",
|
|
10628
|
+
listening: false
|
|
10629
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10630
|
+
name: "display-only",
|
|
10631
|
+
x: vx,
|
|
10632
|
+
y: rect.y,
|
|
10633
|
+
width: rect.x - vx,
|
|
10634
|
+
height: rect.height,
|
|
10635
|
+
fill: "rgba(0,0,0,0.55)",
|
|
10636
|
+
listening: false
|
|
10637
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10638
|
+
name: "display-only",
|
|
10639
|
+
x: rect.x + rect.width,
|
|
10640
|
+
y: rect.y,
|
|
10641
|
+
width: vx + vw - (rect.x + rect.width),
|
|
10642
|
+
height: rect.height,
|
|
10643
|
+
fill: "rgba(0,0,0,0.55)",
|
|
10644
|
+
listening: false
|
|
10645
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10646
|
+
name: "display-only crop-interactive",
|
|
10647
|
+
ref: rectRef,
|
|
10648
|
+
x: rect.x,
|
|
10649
|
+
y: rect.y,
|
|
10650
|
+
width: rect.width,
|
|
10651
|
+
height: rect.height,
|
|
10652
|
+
stroke: "#ffffff",
|
|
10653
|
+
strokeWidth: 1.5,
|
|
10654
|
+
draggable: true,
|
|
10655
|
+
onDragEnd: handleRectDragEnd,
|
|
10656
|
+
onTransform: handleRectTransform,
|
|
10657
|
+
onTransformEnd: handleRectTransformEnd
|
|
10658
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Transformer, {
|
|
10659
|
+
ref: transformerRef,
|
|
10660
|
+
rotateEnabled: false,
|
|
10661
|
+
anchorSize: 8,
|
|
10662
|
+
anchorCornerRadius: 2,
|
|
10663
|
+
borderStroke: "#0d83cd",
|
|
10664
|
+
anchorStroke: "#0d83cd",
|
|
10665
|
+
anchorFill: "#ffffff",
|
|
10666
|
+
boundBoxFunc: function boundBoxFunc(oldBox, newBox) {
|
|
10667
|
+
if (newBox.width < MIN_RECT_SIZE || newBox.height < MIN_RECT_SIZE) return oldBox;
|
|
10668
|
+
return newBox;
|
|
10669
|
+
}
|
|
10670
|
+
})]
|
|
10671
|
+
});
|
|
10672
|
+
});
|
|
10673
|
+
CropEditor.displayName = 'CropEditor';
|
|
10674
|
+
|
|
10182
10675
|
var SepiaFilter = function SepiaFilter(imageData) {
|
|
10183
10676
|
var data = imageData.data;
|
|
10184
10677
|
for (var i = 0; i < data.length; i += 4) {
|
|
@@ -10216,7 +10709,8 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10216
10709
|
var onSelect = _ref.onSelect,
|
|
10217
10710
|
onTransformEnd = _ref.onTransformEnd,
|
|
10218
10711
|
onDragEnd = _ref.onDragEnd,
|
|
10219
|
-
groupChild = _ref.groupChild
|
|
10712
|
+
groupChild = _ref.groupChild,
|
|
10713
|
+
store = _ref.store;
|
|
10220
10714
|
var imageRef = React.useRef(null);
|
|
10221
10715
|
var groupRef = React.useRef(null);
|
|
10222
10716
|
var _useState = React.useState(null),
|
|
@@ -10238,6 +10732,7 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10238
10732
|
img.crossOrigin = 'anonymous';
|
|
10239
10733
|
img.onload = function () {
|
|
10240
10734
|
setImage(img);
|
|
10735
|
+
element.setNaturalSize(img.naturalWidth, img.naturalHeight);
|
|
10241
10736
|
};
|
|
10242
10737
|
img.onerror = function () {
|
|
10243
10738
|
console.warn('Failed to load image:', element.src.substring(0, 100));
|
|
@@ -10272,6 +10767,20 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10272
10767
|
}
|
|
10273
10768
|
}, [image, needsCache, element.blurEnabled, element.blurRadius, element.brightnessEnabled, element.brightness, element.grayscaleEnabled, element.sepiaEnabled, element.warmEnabled, element.coldEnabled, element.cornerRadius, element.shadowEnabled, element.shadowBlur, element.shadowOffsetX, element.shadowOffsetY, element.shadowColor]);
|
|
10274
10769
|
if (!element.visible) return null;
|
|
10770
|
+
if (element._cropModeEnabled) {
|
|
10771
|
+
return /*#__PURE__*/jsxRuntime.jsx(CropEditor, {
|
|
10772
|
+
element: element,
|
|
10773
|
+
image: image
|
|
10774
|
+
});
|
|
10775
|
+
}
|
|
10776
|
+
var handleDblClick = function handleDblClick() {
|
|
10777
|
+
if (!store || groupChild) return;
|
|
10778
|
+
element.enterCropMode();
|
|
10779
|
+
if (element._cropModeEnabled) {
|
|
10780
|
+
store.selectElements([element.id]);
|
|
10781
|
+
store.openToolbarPanel('crop');
|
|
10782
|
+
}
|
|
10783
|
+
};
|
|
10275
10784
|
var handleDragEnd = function handleDragEnd(e) {
|
|
10276
10785
|
var target = groupRef.current || e.target;
|
|
10277
10786
|
element.set({
|
|
@@ -10512,6 +11021,8 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
10512
11021
|
onDragEnd: handleDragEnd,
|
|
10513
11022
|
onTransform: handleTransform,
|
|
10514
11023
|
onTransformEnd: handleTransformEnd,
|
|
11024
|
+
onDblClick: handleDblClick,
|
|
11025
|
+
onDblTap: handleDblClick,
|
|
10515
11026
|
children: [imageNode, hasBorder && /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
10516
11027
|
x: 0,
|
|
10517
11028
|
y: 0,
|
|
@@ -11312,7 +11823,8 @@ var ElementRenderer = mobxReactLite.observer(function (_ref) {
|
|
|
11312
11823
|
onSelect = _ref.onSelect,
|
|
11313
11824
|
onTransformEnd = _ref.onTransformEnd,
|
|
11314
11825
|
onDragEnd = _ref.onDragEnd,
|
|
11315
|
-
groupChild = _ref.groupChild
|
|
11826
|
+
groupChild = _ref.groupChild,
|
|
11827
|
+
store = _ref.store;
|
|
11316
11828
|
var Renderer = ELEMENT_RENDERERS[element.type];
|
|
11317
11829
|
if (!Renderer) {
|
|
11318
11830
|
console.warn("No renderer for element type: ".concat(element.type));
|
|
@@ -11329,7 +11841,8 @@ var ElementRenderer = mobxReactLite.observer(function (_ref) {
|
|
|
11329
11841
|
onSelect: onSelect,
|
|
11330
11842
|
onTransformEnd: onTransformEnd,
|
|
11331
11843
|
onDragEnd: onDragEnd,
|
|
11332
|
-
groupChild: groupChild
|
|
11844
|
+
groupChild: groupChild,
|
|
11845
|
+
store: store
|
|
11333
11846
|
}, extra));
|
|
11334
11847
|
});
|
|
11335
11848
|
ElementRenderer.displayName = 'ElementRenderer';
|
|
@@ -12497,10 +13010,11 @@ var SelectionTransformer = mobxReactLite.observer(function (_ref5) {
|
|
|
12497
13010
|
var transformerRef = React.useRef(null);
|
|
12498
13011
|
var selectedIds = _toConsumableArray(store.selectedElementsIds);
|
|
12499
13012
|
|
|
12500
|
-
// Filter out line elements
|
|
13013
|
+
// Filter out line elements (custom endpoint handles) and elements mid-crop
|
|
13014
|
+
// (CropEditor renders its own Transformer bound to the crop rect instead).
|
|
12501
13015
|
var nonLineIds = selectedIds.filter(function (id) {
|
|
12502
13016
|
var el = store.getElementById(id);
|
|
12503
|
-
return el && el.type !== 'line';
|
|
13017
|
+
return el && el.type !== 'line' && !el._cropModeEnabled;
|
|
12504
13018
|
});
|
|
12505
13019
|
var allText = nonLineIds.length === 1 && function () {
|
|
12506
13020
|
var el = store.getElementById(nonLineIds[0]);
|
|
@@ -12614,7 +13128,25 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
12614
13128
|
}
|
|
12615
13129
|
}, [stageRef.current]);
|
|
12616
13130
|
var handleStageMouseDown = React.useCallback(function (e) {
|
|
12617
|
-
var _target$attrs, _e$evt, _e$evt2;
|
|
13131
|
+
var _store$_toolbarPanel, _target$attrs, _e$evt, _e$evt2;
|
|
13132
|
+
// Clicking anywhere outside the crop rect / pannable image / resize
|
|
13133
|
+
// handles while cropping finishes the crop (like Polotno), then falls
|
|
13134
|
+
// through to the click's normal handling (select whatever was actually
|
|
13135
|
+
// clicked, or deselect).
|
|
13136
|
+
if (((_store$_toolbarPanel = store._toolbarPanel) === null || _store$_toolbarPanel === void 0 ? void 0 : _store$_toolbarPanel.type) === 'crop') {
|
|
13137
|
+
var _e$target$getParent, _e$target;
|
|
13138
|
+
var croppingEl = store.getElementById(store._toolbarPanel.elementId);
|
|
13139
|
+
var isCropInteractive = typeof e.target.hasName === 'function' && e.target.hasName('crop-interactive');
|
|
13140
|
+
// Konva's Transformer adds its resize handles as direct children of
|
|
13141
|
+
// itself, so a handle's parent's className is 'Transformer' — this
|
|
13142
|
+
// catches drags on the crop rect's resize/rotate handles.
|
|
13143
|
+
var isTransformerHandle = ((_e$target$getParent = (_e$target = e.target).getParent) === null || _e$target$getParent === void 0 || (_e$target$getParent = _e$target$getParent.call(_e$target)) === null || _e$target$getParent === void 0 ? void 0 : _e$target$getParent.className) === 'Transformer';
|
|
13144
|
+
if (croppingEl && croppingEl._cropModeEnabled && !isCropInteractive && !isTransformerHandle) {
|
|
13145
|
+
croppingEl.commitCropMode();
|
|
13146
|
+
store.closeToolbarPanel();
|
|
13147
|
+
store.history.addUndoState();
|
|
13148
|
+
}
|
|
13149
|
+
}
|
|
12618
13150
|
var target = e.target;
|
|
12619
13151
|
|
|
12620
13152
|
// Click on empty area or background -> deselect
|
|
@@ -12663,12 +13195,21 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
12663
13195
|
// Keyboard shortcuts
|
|
12664
13196
|
React.useEffect(function () {
|
|
12665
13197
|
var handleKeyDown = function handleKeyDown(e) {
|
|
13198
|
+
var _store$_toolbarPanel2;
|
|
12666
13199
|
// Only handle if stage container or body is focused
|
|
12667
13200
|
var target = e.target;
|
|
12668
13201
|
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') {
|
|
12669
13202
|
return;
|
|
12670
13203
|
}
|
|
12671
13204
|
|
|
13205
|
+
// Escape -> cancel crop mode if active
|
|
13206
|
+
if (e.key === 'Escape' && ((_store$_toolbarPanel2 = store._toolbarPanel) === null || _store$_toolbarPanel2 === void 0 ? void 0 : _store$_toolbarPanel2.type) === 'crop') {
|
|
13207
|
+
var el = store.getElementById(store._toolbarPanel.elementId);
|
|
13208
|
+
if (el && el.cancelCropMode) el.cancelCropMode();
|
|
13209
|
+
store.closeToolbarPanel();
|
|
13210
|
+
e.preventDefault();
|
|
13211
|
+
}
|
|
13212
|
+
|
|
12672
13213
|
// Delete / Backspace
|
|
12673
13214
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
12674
13215
|
var selectedIds = _toConsumableArray(store.selectedElementsIds);
|
|
@@ -12731,9 +13272,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
12731
13272
|
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'G') {
|
|
12732
13273
|
var _selectedIds3 = _toConsumableArray(store.selectedElementsIds);
|
|
12733
13274
|
if (_selectedIds3.length === 1) {
|
|
12734
|
-
var
|
|
12735
|
-
if (
|
|
12736
|
-
store.ungroupElements([
|
|
13275
|
+
var _el = store.getElementById(_selectedIds3[0]);
|
|
13276
|
+
if (_el && _el.type === 'group') {
|
|
13277
|
+
store.ungroupElements([_el.id]);
|
|
12737
13278
|
store.history.addUndoState();
|
|
12738
13279
|
e.preventDefault();
|
|
12739
13280
|
}
|
|
@@ -12829,7 +13370,8 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
12829
13370
|
element: element,
|
|
12830
13371
|
isSelected: store.selectedElementsIds.includes(element.id),
|
|
12831
13372
|
onTransformEnd: handleTransformEnd,
|
|
12832
|
-
onDragEnd: handleDragEnd
|
|
13373
|
+
onDragEnd: handleDragEnd,
|
|
13374
|
+
store: store
|
|
12833
13375
|
}, element.id);
|
|
12834
13376
|
}), /*#__PURE__*/jsxRuntime.jsx(PageOverlayFrame, {
|
|
12835
13377
|
store: store
|