import { useCallback as c } from "react";
import { deepEqual as f } from "../../../../@dnd-kit_state@0.1.21/node_modules/@dnd-kit/state/dist/index.js";
import { defaultSortableTransition as x, Sortable as R } from "../../../../@dnd-kit_dom@0.1.21/node_modules/@dnd-kit/dom/sortable.js";
import { isSortable as rr } from "../../../../@dnd-kit_dom@0.1.21/node_modules/@dnd-kit/dom/sortable.js";
import { useInstance as T } from "./index.js";
import { useDeepSignal as V, useOnValueChange as i, useIsomorphicLayoutEffect as k, useImmediateEffect as q, useOnElementChange as m } from "./hooks.js";
import { currentValue as v } from "./utilities.js";
import { batch as L } from "../../../../@preact_signals-core@1.12.0/node_modules/@preact/signals-core/dist/signals-core.module.js";
var N = Object.defineProperty, U = Object.defineProperties, z = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable, j = (o, t, a) => t in o ? N(o, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[t] = a, _ = (o, t) => {
  for (var a in t || (t = {}))
    A.call(t, a) && j(o, a, t[a]);
  if (I)
    for (var a of I(t))
      B.call(t, a) && j(o, a, t[a]);
  return o;
}, F = (o, t) => U(o, z(t));
function Y(o) {
  const {
    accept: t,
    collisionDetector: a,
    collisionPriority: b,
    id: O,
    data: p,
    element: h,
    handle: y,
    index: g,
    group: D,
    disabled: P,
    feedback: d,
    modifiers: S,
    sensors: w,
    target: C,
    type: E
  } = o, l = _(_({}, x), o.transition), r = T((e) => new R(
    F(_({}, o), {
      transition: l,
      register: !1,
      handle: v(y),
      element: v(h),
      target: v(C),
      feedback: d
    }),
    e
  )), u = V(r, G);
  return i(O, () => r.id = O), k(() => {
    L(() => {
      r.group = D, r.index = g;
    });
  }, [r, D, g]), i(E, () => r.type = E), i(
    t,
    () => r.accept = t,
    void 0,
    f
  ), i(p, () => p && (r.data = p)), i(
    g,
    () => {
      var e;
      (e = r.manager) != null && e.dragOperation.status.idle && l?.idle && r.refreshShape();
    },
    q
  ), m(y, (e) => r.handle = e), m(h, (e) => r.element = e), m(C, (e) => r.target = e), i(P, () => r.disabled = P === !0), i(w, () => r.sensors = w), i(
    a,
    () => r.collisionDetector = a
  ), i(
    b,
    () => r.collisionPriority = b
  ), i(d, () => r.feedback = d ?? "default"), i(
    l,
    () => r.transition = l,
    void 0,
    f
  ), i(
    S,
    () => r.modifiers = S,
    void 0,
    f
  ), i(
    o.alignment,
    () => r.alignment = o.alignment
  ), {
    sortable: u,
    get isDragging() {
      return u.isDragging;
    },
    get isDropping() {
      return u.isDropping;
    },
    get isDragSource() {
      return u.isDragSource;
    },
    get isDropTarget() {
      return u.isDropTarget;
    },
    handleRef: c(
      (e) => {
        r.handle = e ?? void 0;
      },
      [r]
    ),
    ref: c(
      (e) => {
        var n, s;
        !e && ((n = r.element) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.element = e ?? void 0);
      },
      [r]
    ),
    sourceRef: c(
      (e) => {
        var n, s;
        !e && ((n = r.source) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.source = e ?? void 0);
      },
      [r]
    ),
    targetRef: c(
      (e) => {
        var n, s;
        !e && ((n = r.target) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.target = e ?? void 0);
      },
      [r]
    )
  };
}
function G(o, t, a) {
  return !!(o === "isDragSource" && !a && t);
}
export {
  rr as isSortable,
  Y as useSortable
};
//# sourceMappingURL=sortable.js.map
