{"version":3,"file":"utils.min.mjs","sources":["../../../../src/LayoutManager/LayoutStrategies/utils.ts"],"sourcesContent":["import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n  calcPlaneChangeMatrix,\n  sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n  destinationGroup: Group,\n  object: FabricObject\n): Point[] => {\n  const {\n    strokeUniform,\n    strokeWidth,\n    width,\n    height,\n    group: currentGroup,\n  } = object;\n  const t =\n    currentGroup && currentGroup !== destinationGroup\n      ? calcPlaneChangeMatrix(\n          currentGroup.calcTransformMatrix(),\n          destinationGroup.calcTransformMatrix()\n        )\n      : null;\n  const objectCenter = t\n    ? object.getRelativeCenterPoint().transform(t)\n    : object.getRelativeCenterPoint();\n  const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n  const strokeUniformVector =\n    strokeUniform && accountForStroke\n      ? sendVectorToPlane(\n          new Point(strokeWidth, strokeWidth),\n          undefined,\n          destinationGroup.calcTransformMatrix()\n        )\n      : ZERO;\n  const scalingStrokeWidth =\n    !strokeUniform && accountForStroke ? strokeWidth : 0;\n  const sizeVector = sizeAfterTransform(\n    width + scalingStrokeWidth,\n    height + scalingStrokeWidth,\n    multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true)\n  )\n    .add(strokeUniformVector)\n    .scalarDivide(2);\n  return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n"],"names":["getObjectBounds","destinationGroup","object","strokeUniform","strokeWidth","width","height","group","currentGroup","t","calcPlaneChangeMatrix","calcTransformMatrix","objectCenter","getRelativeCenterPoint","transform","accountForStroke","strokeUniformVector","sendVectorToPlane","Point","undefined","ZERO","scalingStrokeWidth","sizeVector","sizeAfterTransform","multiplyTransformMatrixArray","calcOwnMatrix","add","scalarDivide","subtract"],"mappings":"2TAeaA,EAAkBA,CAC7BC,EACAC,KAEA,MAAMC,cACJA,EAAaC,YACbA,EAAWC,MACXA,EAAKC,OACLA,EACAC,MAAOC,GACLN,EACEO,EACJD,GAAgBA,IAAiBP,EAC7BS,EACEF,EAAaG,sBACbV,EAAiBU,uBAEnB,KACAC,EAAeH,EACjBP,EAAOW,yBAAyBC,UAAUL,GAC1CP,EAAOW,yBACLE,GAAoBb,EAAyC,mCAC7Dc,EACJb,GAAiBY,EACbE,EACE,IAAIC,EAAMd,EAAaA,QACvBe,EACAlB,EAAiBU,uBAEnBS,EACAC,GACHlB,GAAiBY,EAAmBX,EAAc,EAC/CkB,EAAaC,EACjBlB,EAAQgB,EACRf,EAASe,EACTG,EAA6B,CAACf,EAAGP,EAAOuB,kBAAkB,IAEzDC,IAAIV,GACJW,aAAa,GAChB,MAAO,CAACf,EAAagB,SAASN,GAAaV,EAAac,IAAIJ,GAAY"}