import { defineComponent, TransitionGroup, Transition, h } from "vue";
function createCssTransition(name, origin = "top center 0", mode) {
  return defineComponent({
    name,
    props: {
      group: Boolean,
      hideOnLeave: Boolean,
      leaveAbsolute: Boolean,
      mode: {
        type: String,
        default: mode
      },
      origin: {
        type: String,
        default: origin
      },
      onBeforeEnter: Function,
      onLeave: Function,
      onAfterLeave: Function
    },
    setup(props, { slots, attrs }) {
      return () => {
        const tag = props.group ? TransitionGroup : Transition;
        return h(tag, {
          name,
          mode: props.mode,
          onBeforeEnter(el) {
            var _a;
            el.style.transformOrigin = props.origin;
            (_a = props.onBeforeEnter) == null ? void 0 : _a.call(props, el);
          },
          onLeave(el) {
            var _a;
            if (props.leaveAbsolute) {
              const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = el;
              el._transitionInitialStyles = {
                position: el.style.position,
                top: el.style.top,
                left: el.style.left,
                width: el.style.width,
                height: el.style.height
              };
              el.style.position = "absolute";
              el.style.top = `${offsetTop}px`;
              el.style.left = `${offsetLeft}px`;
              el.style.width = `${offsetWidth}px`;
              el.style.height = `${offsetHeight}px`;
            }
            if (props.hideOnLeave) {
              el._initialDisplay = el.style.display;
              el.style.display = "none";
            }
            (_a = props.onLeave) == null ? void 0 : _a.call(props, el);
          },
          onAfterLeave(el) {
            var _a;
            if (props.leaveAbsolute && (el == null ? void 0 : el._transitionInitialStyles)) {
              const { position, top, left, width, height } = el._transitionInitialStyles;
              delete el._transitionInitialStyles;
              el.style.position = position || "";
              el.style.top = top || "";
              el.style.left = left || "";
              el.style.width = width || "";
              el.style.height = height || "";
            }
            if (props.hideOnLeave && el) {
              el.style.display = el._initialDisplay || "";
            }
            (_a = props.onAfterLeave) == null ? void 0 : _a.call(props, el);
          },
          ...attrs
        }, slots.default);
      };
    }
  });
}
function createJavascriptTransition(name, functions, mode = "in-out") {
  return defineComponent({
    name,
    props: {
      group: Boolean,
      mode: {
        type: String,
        default: mode
      },
      onBeforeEnter: Function,
      onLeave: Function,
      onAfterLeave: Function
    },
    setup(props, { slots }) {
      return () => {
        const tag = props.group ? TransitionGroup : Transition;
        return h(tag, {
          name,
          ...functions,
          onBeforeEnter(el) {
            var _a, _b;
            (_a = functions.onBeforeEnter) == null ? void 0 : _a.call(functions, el);
            (_b = props.onBeforeEnter) == null ? void 0 : _b.call(props, el);
          },
          onLeave(el) {
            var _a, _b;
            (_a = functions.onLeave) == null ? void 0 : _a.call(functions, el);
            (_b = props.onLeave) == null ? void 0 : _b.call(props, el);
          },
          onAfterLeave(el) {
            var _a, _b;
            (_a = functions.onAfterLeave) == null ? void 0 : _a.call(functions, el);
            (_b = props.onAfterLeave) == null ? void 0 : _b.call(props, el);
          }
        }, slots.default);
      };
    }
  });
}
export {
  createCssTransition,
  createJavascriptTransition
};
//# sourceMappingURL=create-transition.mjs.map
