@pixldocs/canvas-renderer 0.5.448 → 0.5.449

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.
@@ -11664,34 +11664,25 @@ const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11664
11664
  return updates;
11665
11665
  };
11666
11666
  const applyTransformPreservingFlip = (obj, matrix) => {
11667
- fabric__namespace.util.applyTransformToObject(obj, matrix);
11668
- let sx = obj.scaleX ?? 1;
11669
- let sy = obj.scaleY ?? 1;
11670
- let flipX = false;
11671
- let flipY = false;
11667
+ const intendedFlipX = obj.flipX ?? false;
11668
+ const intendedFlipY = obj.flipY ?? false;
11669
+ const cleanMatrix = toggleLogicalFlipInMatrix(matrix, intendedFlipX, intendedFlipY);
11670
+ fabric__namespace.util.applyTransformToObject(obj, cleanMatrix);
11671
+ let sx = Number(obj.scaleX ?? 1) || 1;
11672
+ let sy = Number(obj.scaleY ?? 1) || 1;
11673
+ let flipX = intendedFlipX;
11674
+ let flipY = intendedFlipY;
11672
11675
  if (sx < 0) {
11673
- flipX = true;
11676
+ flipX = !flipX;
11674
11677
  sx = -sx;
11675
11678
  }
11676
11679
  if (sy < 0) {
11677
- flipY = true;
11680
+ flipY = !flipY;
11678
11681
  sy = -sy;
11679
11682
  }
11680
11683
  obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
11681
11684
  };
11682
- const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
11683
- const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11684
- const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11685
- obj.set({ scaleX: sx, scaleY: sy, skewX: 0, skewY: 0, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11686
- obj.setCoords();
11687
- obj.dirty = true;
11688
- };
11689
- const isBitmapLikeFabricObject = (obj) => {
11690
- var _a2;
11691
- return obj instanceof fabric__namespace.FabricImage || obj instanceof fabric__namespace.Group && !!(obj.__cropGroup || ((_a2 = obj._ct) == null ? void 0 : _a2.isCropGroup));
11692
- };
11693
- const restorePersistedFlipFlagsOnly = (obj, flipX, flipY) => {
11694
- if (!isBitmapLikeFabricObject(obj)) return;
11685
+ const restorePersistedFlipState = (obj, flipX, flipY) => {
11695
11686
  const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11696
11687
  const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11697
11688
  obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
@@ -11805,16 +11796,11 @@ function applyWarpAwareSelectionBorders(selection) {
11805
11796
  selection.calcTransformMatrix()
11806
11797
  );
11807
11798
  kids.forEach((k, index) => {
11808
- var _a3;
11809
11799
  const beforeRestore = summarizeRotDriftObject(k);
11810
11800
  const localMatrix = fabric__namespace.util.multiplyTransformMatrices(
11811
11801
  invSelection,
11812
11802
  worldMatrices[index]
11813
11803
  );
11814
- const isImageLikeKid = k instanceof fabric__namespace.FabricImage || k instanceof fabric__namespace.Group && (k.__cropGroup || ((_a3 = k._ct) == null ? void 0 : _a3.isCropGroup));
11815
- const persistedKidFlipX = !!k.flipX;
11816
- const persistedKidFlipY = !!k.flipY;
11817
- const expectedCleanKidAngle = isImageLikeKid && (persistedKidFlipX || persistedKidFlipY) ? fabric__namespace.util.qrDecompose(toggleLogicalFlipInMatrix(localMatrix, persistedKidFlipX, persistedKidFlipY)).angle ?? 0 : void 0;
11818
11804
  const savedLayout = k.layoutManager;
11819
11805
  try {
11820
11806
  if (savedLayout) k.layoutManager = void 0;
@@ -11824,9 +11810,6 @@ function applyWarpAwareSelectionBorders(selection) {
11824
11810
  );
11825
11811
  const expectedCenter = new fabric__namespace.Point(decomposed.translateX, decomposed.translateY);
11826
11812
  k.setPositionByOrigin(expectedCenter, "center", "center");
11827
- if (isImageLikeKid && (persistedKidFlipX || persistedKidFlipY)) {
11828
- restorePersistedFlipState(k, persistedKidFlipX, persistedKidFlipY, expectedCleanKidAngle);
11829
- }
11830
11813
  } finally {
11831
11814
  if (savedLayout) k.layoutManager = savedLayout;
11832
11815
  }
@@ -14667,7 +14650,7 @@ const PageCanvas = react.forwardRef(
14667
14650
  fabricCanvas.on("selection:cleared", () => {
14668
14651
  });
14669
14652
  fabricCanvas.on("object:scaling", (e) => {
14670
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
14653
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14671
14654
  if (!isActiveRef.current) return;
14672
14655
  const t = e.target;
14673
14656
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14898,66 +14881,11 @@ const PageCanvas = react.forwardRef(
14898
14881
  };
14899
14882
  }
14900
14883
  }
14901
- if (obj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(corner)) {
14902
- const _cur = fabricCanvas._currentTransform;
14903
- const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
14904
- const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14905
- const liveAsSx = Math.abs((obj.scaleX ?? 1) / startSx) || 1;
14906
- const liveAsSy = Math.abs((obj.scaleY ?? 1) / startSy) || 1;
14907
- const uniform = Math.max(1e-3, Math.sqrt(liveAsSx * liveAsSy));
14908
- for (const child of obj.getObjects()) {
14909
- if (!isBitmapLikeFabricObject(child)) continue;
14910
- const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_i = groupSelectionTransformStartRef.current) == null ? void 0 : _i.selectionLeft) ?? obj.left ?? 0}:${((_j = groupSelectionTransformStartRef.current) == null ? void 0 : _j.selectionTop) ?? obj.top ?? 0}`;
14911
- if (child.__asLiveGestureKey !== liveGestureKey) {
14912
- child.__asLiveGestureKey = liveGestureKey;
14913
- child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14914
- child.__asLiveOrigFlipX = !!child.flipX;
14915
- child.__asLiveOrigFlipY = !!child.flipY;
14916
- child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
14917
- child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
14918
- }
14919
- const childAngleDeg = child.__asLiveOrigAngle ?? (child.angle ?? 0);
14920
- const origScaleX = child.__asLiveOrigScaleX;
14921
- const origScaleY = child.__asLiveOrigScaleY;
14922
- const baseW = Math.max(1, Number(((_k = child.__cropData) == null ? void 0 : _k.frameW) ?? child.width ?? 1));
14923
- const baseH = Math.max(1, Number(((_l = child.__cropData) == null ? void 0 : _l.frameH) ?? child.height ?? 1));
14924
- try {
14925
- const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
14926
- const Rtheta = fabric__namespace.util.composeMatrix({ angle: childAngleDeg, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
14927
- const Uscale = fabric__namespace.util.composeMatrix({ angle: 0, scaleX: origScaleX * uniform, scaleY: origScaleY * uniform, translateX: 0, translateY: 0 });
14928
- const M = fabric__namespace.util.multiplyTransformMatrices(
14929
- fabric__namespace.util.multiplyTransformMatrices(inv, Rtheta),
14930
- Uscale
14931
- );
14932
- const dec = fabric__namespace.util.qrDecompose(M);
14933
- child._set("angle", dec.angle);
14934
- child._set("scaleX", dec.scaleX);
14935
- child._set("scaleY", dec.scaleY);
14936
- child._set("skewX", dec.skewX);
14937
- child._set("skewY", dec.skewY);
14938
- child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
14939
- child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
14940
- const worldMatrix = fabric__namespace.util.multiplyTransformMatrices(
14941
- obj.calcTransformMatrix(),
14942
- child.calcOwnMatrix()
14943
- );
14944
- const live = fabric__namespace.util.qrDecompose(worldMatrix);
14945
- child.__asLiveWorldAngle = (obj.angle ?? 0) + childAngleDeg;
14946
- child.__asLiveWorldCenterX = live.translateX;
14947
- child.__asLiveWorldCenterY = live.translateY;
14948
- child.__asLiveFinalW = baseW * origScaleX * uniform;
14949
- child.__asLiveFinalH = baseH * origScaleY * uniform;
14950
- } catch {
14951
- }
14952
- child.setCoords();
14953
- child.dirty = true;
14954
- }
14955
- }
14956
14884
  if (obj instanceof fabric__namespace.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
14957
14885
  const isXSide = corner === "ml" || corner === "mr";
14958
14886
  const _cur = fabricCanvas._currentTransform;
14959
- const startSx = Math.abs(Number(((_m = _cur == null ? void 0 : _cur.original) == null ? void 0 : _m.scaleX) ?? 1)) || 1;
14960
- const startSy = Math.abs(Number(((_n = _cur == null ? void 0 : _cur.original) == null ? void 0 : _n.scaleY) ?? 1)) || 1;
14887
+ const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
14888
+ const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14961
14889
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14962
14890
  if (sAxis > 1e-3) {
14963
14891
  const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
@@ -14976,13 +14904,13 @@ const PageCanvas = react.forwardRef(
14976
14904
  } catch {
14977
14905
  }
14978
14906
  };
14979
- if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) !== obj) {
14907
+ if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14980
14908
  groupShiftReflowSnapshotRef.current = null;
14981
14909
  const logicalGroupId = obj.__pixldocsGroupSelection;
14982
14910
  if (logicalGroupId) {
14983
14911
  try {
14984
14912
  const state = useEditorStore.getState();
14985
- const pageChildren2 = ((_p = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _p.children) ?? [];
14913
+ const pageChildren2 = ((_j = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
14986
14914
  const groupNode = findNodeById(pageChildren2, logicalGroupId);
14987
14915
  if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
14988
14916
  const entries = obj.getObjects().map((c) => ({
@@ -15012,50 +14940,124 @@ const PageCanvas = react.forwardRef(
15012
14940
  const asRect0 = obj.getBoundingRect();
15013
14941
  let didReflowTextChild = false;
15014
14942
  for (const child of obj.getObjects()) {
15015
- const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_q = groupSelectionTransformStartRef.current) == null ? void 0 : _q.selectionLeft) ?? obj.left ?? 0}:${((_r = groupSelectionTransformStartRef.current) == null ? void 0 : _r.selectionTop) ?? obj.top ?? 0}`;
14943
+ const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_k = groupSelectionTransformStartRef.current) == null ? void 0 : _k.selectionLeft) ?? obj.left ?? 0}:${((_l = groupSelectionTransformStartRef.current) == null ? void 0 : _l.selectionTop) ?? obj.top ?? 0}`;
15016
14944
  if (child.__asLiveGestureKey !== liveGestureKey) {
15017
14945
  child.__asLiveGestureKey = liveGestureKey;
15018
14946
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
15019
- child.__asLiveOrigFlipX = !!child.flipX;
15020
- child.__asLiveOrigFlipY = !!child.flipY;
15021
14947
  }
15022
- const liveAsSx = isXSide ? sAxis : 1;
15023
- const liveAsSy = isXSide ? 1 : sAxis;
15024
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_s = child._ct) == null ? void 0 : _s.isCropGroup)) || child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
15025
- const childAngleDeg2 = child.__asLiveOrigAngle ?? (child.angle ?? 0);
15026
- const theta2 = fabric__namespace.util.degreesToRadians(childAngleDeg2);
15027
- const cosT2 = Math.cos(theta2);
15028
- const sinT2 = Math.sin(theta2);
15029
- const dX = isXSide ? Math.max(1e-3, liveAsSx * cosT2 * cosT2 + sinT2 * sinT2) : 1;
15030
- const dY = isXSide ? 1 : Math.max(1e-3, liveAsSy * cosT2 * cosT2 + sinT2 * sinT2);
15031
- if (child.__asLiveOrigScaleX == null) child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
15032
- if (child.__asLiveOrigScaleY == null) child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
15033
- const origScaleX = child.__asLiveOrigScaleX;
15034
- const origScaleY = child.__asLiveOrigScaleY;
15035
- const baseW = Math.max(1, Number(((_t = child.__cropData) == null ? void 0 : _t.frameW) ?? child.width ?? 1));
15036
- const baseH = Math.max(1, Number(((_u = child.__cropData) == null ? void 0 : _u.frameH) ?? child.height ?? 1));
15037
- const liveW = baseW * origScaleX * dX;
15038
- const liveH = baseH * origScaleY * dY;
14948
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14949
+ const ct = child.__cropData;
14950
+ if (!ct) continue;
14951
+ if (child.__asLiveOrigAngle == null) {
14952
+ child.__asLiveOrigAngle = child.angle ?? 0;
14953
+ }
14954
+ const childAngleDegC = child.__asLiveOrigAngle;
14955
+ const asSxC = isXSide ? sAxis : 1;
14956
+ const asSyC = isXSide ? 1 : sAxis;
14957
+ const thetaC = fabric__namespace.util.degreesToRadians(childAngleDegC);
14958
+ const cosTC = Math.cos(thetaC);
14959
+ const sinTC = Math.sin(thetaC);
14960
+ const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14961
+ if (isXSide) {
14962
+ if (child.__asLiveOrigW == null) {
14963
+ const baseW = child.width ?? ct.frameW ?? 0;
14964
+ child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14965
+ }
14966
+ const origW = child.__asLiveOrigW;
14967
+ const newW = Math.max(20, origW * sLocalC);
14968
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14969
+ ct.frameW = newW;
14970
+ child._set("width", newW);
14971
+ }
14972
+ } else {
14973
+ if (child.__asLiveOrigH == null) {
14974
+ const baseH = child.height ?? ct.frameH ?? 0;
14975
+ child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14976
+ }
14977
+ const origH = child.__asLiveOrigH;
14978
+ const newH = Math.max(20, origH * sLocalC);
14979
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14980
+ ct.frameH = newH;
14981
+ child._set("height", newH);
14982
+ }
14983
+ }
15039
14984
  try {
15040
- const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
15041
- const Rtheta = fabric__namespace.util.composeMatrix({ angle: childAngleDeg2, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
15042
- const Dscale = fabric__namespace.util.composeMatrix({ angle: 0, scaleX: origScaleX * dX, scaleY: origScaleY * dY, translateX: 0, translateY: 0 });
15043
- const M = fabric__namespace.util.multiplyTransformMatrices(
15044
- fabric__namespace.util.multiplyTransformMatrices(inv, Rtheta),
15045
- Dscale
15046
- );
15047
- const dec = fabric__namespace.util.qrDecompose(M);
15048
- child._set("angle", dec.angle);
15049
- child._set("scaleX", dec.scaleX);
15050
- child._set("scaleY", dec.scaleY);
15051
- child._set("skewX", dec.skewX);
15052
- child._set("skewY", dec.skewY);
15053
- child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
15054
- child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
14985
+ const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14986
+ const RthetaC = fabric__namespace.util.composeMatrix({
14987
+ angle: childAngleDegC,
14988
+ scaleX: 1,
14989
+ scaleY: 1,
14990
+ translateX: 0,
14991
+ translateY: 0
14992
+ });
14993
+ const MC = fabric__namespace.util.multiplyTransformMatrices(invC, RthetaC);
14994
+ const decC = fabric__namespace.util.qrDecompose(MC);
14995
+ child._set("angle", decC.angle);
14996
+ child._set("scaleX", decC.scaleX);
14997
+ child._set("scaleY", decC.scaleY);
14998
+ child._set("skewX", decC.skewX);
14999
+ child._set("skewY", decC.skewY);
15000
+ } catch {
15001
+ }
15002
+ try {
15003
+ updateCoverLayout(child);
15055
15004
  } catch {
15056
15005
  }
15057
- captureAsLiveWorldSnapshot(child, liveW, liveH);
15058
15006
  child.setCoords();
15007
+ captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
15008
+ child.dirty = true;
15009
+ continue;
15010
+ }
15011
+ if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
15012
+ if (child.__asLiveOrigAngle == null) {
15013
+ child.__asLiveOrigAngle = child.angle ?? 0;
15014
+ }
15015
+ const childAngleDegI = child.__asLiveOrigAngle;
15016
+ const asSxI = isXSide ? sAxis : 1;
15017
+ const asSyI = isXSide ? 1 : sAxis;
15018
+ const thetaI = fabric__namespace.util.degreesToRadians(childAngleDegI);
15019
+ const cosTI = Math.cos(thetaI);
15020
+ const sinTI = Math.sin(thetaI);
15021
+ const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
15022
+ if (isXSide) {
15023
+ if (child.__asLiveOrigW == null) {
15024
+ child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
15025
+ }
15026
+ const origW = child.__asLiveOrigW;
15027
+ const newW = Math.max(1, origW * sLocalI);
15028
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
15029
+ child._set("width", newW);
15030
+ }
15031
+ } else {
15032
+ if (child.__asLiveOrigH == null) {
15033
+ child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
15034
+ }
15035
+ const origH = child.__asLiveOrigH;
15036
+ const newH = Math.max(1, origH * sLocalI);
15037
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
15038
+ child._set("height", newH);
15039
+ }
15040
+ }
15041
+ try {
15042
+ const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
15043
+ const RthetaI = fabric__namespace.util.composeMatrix({
15044
+ angle: childAngleDegI,
15045
+ scaleX: 1,
15046
+ scaleY: 1,
15047
+ translateX: 0,
15048
+ translateY: 0
15049
+ });
15050
+ const MI = fabric__namespace.util.multiplyTransformMatrices(invI, RthetaI);
15051
+ const decI = fabric__namespace.util.qrDecompose(MI);
15052
+ child._set("angle", decI.angle);
15053
+ child._set("scaleX", decI.scaleX);
15054
+ child._set("scaleY", decI.scaleY);
15055
+ child._set("skewX", decI.skewX);
15056
+ child._set("skewY", decI.skewY);
15057
+ } catch {
15058
+ }
15059
+ child.setCoords();
15060
+ captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
15059
15061
  child.dirty = true;
15060
15062
  continue;
15061
15063
  }
@@ -15112,7 +15114,7 @@ const PageCanvas = react.forwardRef(
15112
15114
  child.dirty = true;
15113
15115
  didReflowTextChild = true;
15114
15116
  }
15115
- if (isXSide && ((_v = groupShiftReflowSnapshotRef.current) == null ? void 0 : _v.selection) === obj) {
15117
+ if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15116
15118
  const snap = groupShiftReflowSnapshotRef.current;
15117
15119
  const anchorEntry = snap.children[0];
15118
15120
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15274,7 +15276,7 @@ const PageCanvas = react.forwardRef(
15274
15276
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15275
15277
  if (drilledGroupIdRef.current) {
15276
15278
  try {
15277
- (_w = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _w.call(fabricCanvas);
15279
+ (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15278
15280
  } catch {
15279
15281
  }
15280
15282
  }
@@ -15501,8 +15503,6 @@ const PageCanvas = react.forwardRef(
15501
15503
  for (const child of t.getObjects()) {
15502
15504
  delete child.__asLiveOrigW;
15503
15505
  delete child.__asLiveOrigH;
15504
- delete child.__asLiveOrigScaleX;
15505
- delete child.__asLiveOrigScaleY;
15506
15506
  delete child.__asLiveRotSnap;
15507
15507
  delete child.__asLiveGestureKey;
15508
15508
  }
@@ -16205,12 +16205,10 @@ const PageCanvas = react.forwardRef(
16205
16205
  const ownSy = Math.abs(obj.scaleY ?? 1);
16206
16206
  const bakedW = Math.max(1, intrinsicWidth * ownSx * (imgIsXSide ? sLocalI : 1));
16207
16207
  const bakedH = Math.max(1, intrinsicHeight * ownSy * (imgIsXSide ? 1 : sLocalI));
16208
- const cleanW = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16209
- const cleanH = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16210
16208
  try {
16211
16209
  obj.set({
16212
- width: cleanW,
16213
- height: cleanH,
16210
+ width: bakedW,
16211
+ height: bakedH,
16214
16212
  scaleX: 1,
16215
16213
  scaleY: 1,
16216
16214
  skewX: 0,
@@ -16229,8 +16227,8 @@ const PageCanvas = react.forwardRef(
16229
16227
  obj.setCoords();
16230
16228
  } catch {
16231
16229
  }
16232
- finalWidth = cleanW;
16233
- finalHeight = cleanH;
16230
+ finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16231
+ finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16234
16232
  finalScaleX = 1;
16235
16233
  finalScaleY = 1;
16236
16234
  const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
@@ -16506,9 +16504,8 @@ const PageCanvas = react.forwardRef(
16506
16504
  const objectFlipY = obj.flipY ?? false;
16507
16505
  const persistedFlipX = (sourceElement == null ? void 0 : sourceElement.flipX) ?? objectFlipX;
16508
16506
  const persistedFlipY = (sourceElement == null ? void 0 : sourceElement.flipY) ?? objectFlipY;
16509
- const persistedAngle = sourceElement ? Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0;
16510
16507
  const isActiveSelectionResizeGesture = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb" || activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br";
16511
- const expectedCleanAngle = isActiveSelection && isActiveSelectionResizeGesture ? sourceElement ? Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0 : void 0;
16508
+ const expectedCleanAngle = isActiveSelection && isActiveSelectionResizeGesture ? Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? (sourceElement == null ? void 0 : sourceElement.angle) ?? 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0 : void 0;
16512
16509
  const normalizedFinalAbsoluteMatrix = normalizeMatrixForPersistedFlip(
16513
16510
  toggleLogicalFlipInMatrix(
16514
16511
  finalAbsoluteMatrix,
@@ -16522,13 +16519,7 @@ const PageCanvas = react.forwardRef(
16522
16519
  const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
16523
16520
  const persistedDecomposed = fabric__namespace.util.qrDecompose(cleanTransformMatrix);
16524
16521
  if (isActiveSelection && (obj instanceof fabric__namespace.FabricImage || obj instanceof fabric__namespace.Group && obj.__cropGroup)) {
16525
- activeSelectionFlipRestores.push({
16526
- obj,
16527
- flipX: persistedFlipX,
16528
- flipY: persistedFlipY,
16529
- localAngle: Number.isFinite(obj.angle) ? obj.angle ?? 0 : persistedAngle,
16530
- worldAngle: persistedAngle
16531
- });
16522
+ activeSelectionFlipRestores.push({ obj, flipX: persistedFlipX, flipY: persistedFlipY });
16532
16523
  }
16533
16524
  const elementUpdate = {
16534
16525
  left: storePos.left,
@@ -16609,7 +16600,7 @@ const PageCanvas = react.forwardRef(
16609
16600
  }
16610
16601
  const isCropGroupObj = obj instanceof fabric__namespace.Group && obj.__cropGroup;
16611
16602
  const isPlainImageObj = obj instanceof fabric__namespace.FabricImage && !obj.__cropGroup && !obj.smartElementType;
16612
- if (isActiveSelection && isActiveSelectionResizeGesture && (isCropGroupObj || isPlainImageObj)) {
16603
+ if (isActiveSelection && isActiveSelectionSideHandle && (isCropGroupObj || isPlainImageObj)) {
16613
16604
  const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16614
16605
  const normAng = (childLocalAngleSrc % 360 + 360) % 360;
16615
16606
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
@@ -16658,12 +16649,6 @@ const PageCanvas = react.forwardRef(
16658
16649
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
16659
16650
  });
16660
16651
  }
16661
- if (isActiveSelection && (obj instanceof fabric__namespace.FabricImage || obj instanceof fabric__namespace.Group && obj.__cropGroup)) {
16662
- const restore = activeSelectionFlipRestores.find((entry) => entry.obj === obj);
16663
- if (restore) {
16664
- restore.worldAngle = Number.isFinite(elementUpdate.angle) ? elementUpdate.angle : persistedAngle;
16665
- }
16666
- }
16667
16652
  if (isActiveSelection) {
16668
16653
  logRotGroupImageDrift("store-update-child", {
16669
16654
  time: Math.round(performance.now()),
@@ -16760,7 +16745,7 @@ const PageCanvas = react.forwardRef(
16760
16745
  skipActiveSelectionBakeOnClearRef.current = true;
16761
16746
  try {
16762
16747
  for (const restore of activeSelectionFlipRestores) {
16763
- restorePersistedFlipFlagsOnly(restore.obj, restore.flipX, restore.flipY);
16748
+ restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16764
16749
  }
16765
16750
  fabricCanvas.discardActiveObject();
16766
16751
  } finally {
@@ -16788,9 +16773,6 @@ const PageCanvas = react.forwardRef(
16788
16773
  updateCoverLayout(bake.obj);
16789
16774
  bake.obj.setCoords();
16790
16775
  }
16791
- for (const restore of activeSelectionFlipRestores) {
16792
- restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16793
- }
16794
16776
  if (membersToReselect.length > 1) {
16795
16777
  const newSel = new fabric__namespace.ActiveSelection(membersToReselect, { canvas: fabricCanvas });
16796
16778
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
@@ -16848,10 +16830,6 @@ const PageCanvas = react.forwardRef(
16848
16830
  if (t instanceof fabric__namespace.ActiveSelection) {
16849
16831
  for (const child of t.getObjects()) {
16850
16832
  delete child.__asLiveOrigAngle;
16851
- delete child.__asLiveOrigFlipX;
16852
- delete child.__asLiveOrigFlipY;
16853
- delete child.__asLiveOrigScaleX;
16854
- delete child.__asLiveOrigScaleY;
16855
16833
  delete child.__asLiveGestureKey;
16856
16834
  delete child.__asLiveWorldAngle;
16857
16835
  delete child.__asLiveWorldCenterX;
@@ -25962,9 +25940,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25962
25940
  }
25963
25941
  return svgString;
25964
25942
  }
25965
- const resolvedPackageVersion = "0.5.448";
25943
+ const resolvedPackageVersion = "0.5.449";
25966
25944
  const PACKAGE_VERSION = resolvedPackageVersion;
25967
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.448";
25945
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.449";
25968
25946
  const roundParityValue = (value) => {
25969
25947
  if (typeof value !== "number") return value;
25970
25948
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26778,7 +26756,7 @@ class PixldocsRenderer {
26778
26756
  await this.waitForCanvasScene(container, cloned, i);
26779
26757
  }
26780
26758
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26781
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B9AA07qB.cjs"));
26759
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DDTYu7h6.cjs"));
26782
26760
  const prepared = preparePagesForExport(
26783
26761
  cloned.pages,
26784
26762
  canvasWidth,
@@ -29098,7 +29076,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29098
29076
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29099
29077
  sanitizeSvgTreeForPdf(svgToDraw);
29100
29078
  try {
29101
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B9AA07qB.cjs"));
29079
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DDTYu7h6.cjs"));
29102
29080
  try {
29103
29081
  await logTextMeasurementDiagnostic(svgToDraw);
29104
29082
  } catch {
@@ -29495,4 +29473,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29495
29473
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29496
29474
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29497
29475
  exports.warmTemplateFromForm = warmTemplateFromForm;
29498
- //# sourceMappingURL=index-CzxefTLk.cjs.map
29476
+ //# sourceMappingURL=index-DJhcPNx7.cjs.map