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CAAA,CAAA,GAAI,CAAC,CAAI,GAAA;AAAA,KAClC,CAAA;AAAA;AAUJ,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA1Ba,aAyBJ,CAAA,SAAA,GAAYC,sBAAa,aAAY,CAAA;AAzBvC,IAAM,YAAN,GAAA","file":"modifiers.cjs","sourcesContent":["import {\n  configurator,\n  Modifier,\n  type DragDropManager,\n  type DragOperation,\n} from '@dnd-kit/abstract';\n\n/**\n * Options for configuring an axis modifier.\n *\n * @property axis - The axis to restrict movement to ('x' or 'y')\n * @property value - The fixed value to set for the specified axis\n */\ninterface Options {\n  axis: 'x' | 'y';\n  value: number;\n}\n\n/**\n * A modifier that restricts drag movement to a specific axis and value.\n *\n * @remarks\n * This modifier can be used to:\n * - Restrict movement to a specific axis\n * - Set a fixed value for the specified axis\n * - Create horizontal or vertical movement constraints\n */\nexport class AxisModifier extends Modifier<DragDropManager<any, any>, Options> {\n  /**\n   * Applies the axis restriction to the drag operation.\n   *\n   * @param operation - The current drag operation\n   * @returns The modified transform with the axis restriction applied\n   */\n  apply({transform}: DragOperation) {\n    if (!this.options) {\n      return transform;\n    }\n\n    const {axis, value} = this.options;\n\n    return {\n      ...transform,\n      [axis]: value,\n    };\n  }\n\n  /**\n   * Creates a configured instance of the AxisModifier.\n   *\n   * @param options - The axis restriction options\n   * @returns A configured AxisModifier instance\n   */\n  static configure = configurator(AxisModifier);\n}\n\n/**\n * A pre-configured modifier that restricts movement to the vertical axis.\n *\n * @remarks\n * This modifier fixes the x-axis value to 0, allowing only vertical movement.\n */\nexport const RestrictToVerticalAxis = AxisModifier.configure({\n  axis: 'x',\n  value: 0,\n});\n\n/**\n * A pre-configured modifier that restricts movement to the horizontal axis.\n *\n * @remarks\n * This modifier fixes the y-axis value to 0, allowing only horizontal movement.\n */\nexport const RestrictToHorizontalAxis = AxisModifier.configure({\n  axis: 'y',\n  value: 0,\n});\n","import type {BoundingRectangle, Coordinates, Shape} from '@dnd-kit/geometry';\n\n/**\n * Restricts a shape's movement to stay within a bounding rectangle.\n *\n * @param shape - The shape to restrict\n * @param transform - The current transform coordinates\n * @param boundingRect - The bounding rectangle to restrict movement within\n * @returns The modified transform coordinates that keep the shape within bounds\n *\n * @remarks\n * This function:\n * - Prevents the shape from moving outside the bounding rectangle\n * - Adjusts the transform coordinates to keep the shape's edges within bounds\n * - Maintains the shape's position relative to the bounding rectangle\n *\n * @example\n * ```typescript\n * const shape = { boundingRectangle: { top: 0, left: 0, right: 100, bottom: 100 } };\n * const transform = { x: 50, y: 50 };\n * const bounds = { top: 0, left: 0, width: 200, height: 200 };\n *\n * const restricted = restrictShapeToBoundingRectangle(shape, transform, bounds);\n * ```\n */\nexport function restrictShapeToBoundingRectangle(\n  shape: Shape,\n  transform: Coordinates,\n  boundingRect: BoundingRectangle\n) {\n  const value = {\n    ...transform,\n  };\n\n  if (shape.boundingRectangle.top + transform.y <= boundingRect.top) {\n    value.y = boundingRect.top - shape.boundingRectangle.top;\n  } else if (\n    shape.boundingRectangle.bottom + transform.y >=\n    boundingRect.top + boundingRect.height\n  ) {\n    value.y =\n      boundingRect.top + boundingRect.height - shape.boundingRectangle.bottom;\n  }\n\n  if (shape.boundingRectangle.left + transform.x <= boundingRect.left) {\n    value.x = boundingRect.left - shape.boundingRectangle.left;\n  } else if (\n    shape.boundingRectangle.right + transform.x >=\n    boundingRect.left + boundingRect.width\n  ) {\n    value.x =\n      boundingRect.left + boundingRect.width - shape.boundingRectangle.right;\n  }\n\n  return value;\n}\n","import {\n  configurator,\n  Modifier,\n  type DragDropManager,\n  type DragOperation,\n} from '@dnd-kit/abstract';\n\n/**\n * Options for configuring a snap modifier.\n *\n * @property size - The grid size to snap to, either a single number for both axes\n *                 or separate x and y values\n */\ninterface Options {\n  size: number | {x: number; y: number};\n}\n\n/**\n * A modifier that snaps drag movement to a grid.\n *\n * @remarks\n * This modifier:\n * - Snaps drag coordinates to the nearest grid point\n * - Supports different grid sizes for x and y axes\n * - Uses ceiling rounding to ensure consistent snapping behavior\n *\n * @example\n * ```typescript\n * // Snap to a 20x20 grid\n * const modifier = SnapModifier.configure({ size: 20 });\n *\n * // Snap to a 10x20 grid\n * const modifier = SnapModifier.configure({ size: { x: 10, y: 20 } });\n * ```\n */\nexport class SnapModifier extends Modifier<DragDropManager<any, any>, Options> {\n  /**\n   * Applies the snap grid to the drag operation.\n   *\n   * @param operation - The current drag operation\n   * @returns The modified transform with coordinates snapped to the grid\n   */\n  apply({transform}: DragOperation) {\n    const {size = 20} = this.options ?? {};\n    const x = typeof size === 'number' ? size : size.x;\n    const y = typeof size === 'number' ? size : size.y;\n\n    return {\n      ...transform,\n      x: Math.ceil(transform.x / x) * x,\n      y: Math.ceil(transform.y / y) * y,\n    };\n  }\n\n  /**\n   * Creates a configured instance of the SnapModifier.\n   *\n   * @param options - The snap grid options\n   * @returns A configured SnapModifier instance\n   */\n  static configure = configurator(SnapModifier);\n}\n"]}