import { computed, onActivated, onBeforeUnmount, onDeactivated, ref } from "vue";
import { getCurrentInstance, getUid, propsFactory } from "@veno-ui/utils";
import { useLayout } from "./layout";
const makeLayoutItemProps = propsFactory({
  modelValue: {
    type: Boolean,
    default: true
  },
  name: String,
  position: {
    type: String,
    default: "absolute"
  },
  anchor: {
    type: String,
    default: "left"
  },
  priority: {
    type: [String, Number],
    default: 0
  }
}, "layout-item");
function useLayoutItem(props) {
  const layout = useLayout();
  const id = props.value.name ?? `layout-item-${getUid()}`;
  const vm = getCurrentInstance("useLayoutItem");
  const isKeptAlive = ref(false);
  const {
    layoutItemStyles,
    layoutItemScrimStyles
  } = layout.register(vm, id, computed(() => ({
    ...props.value,
    active: !isKeptAlive.value && props.value.active
  })));
  onDeactivated(() => isKeptAlive.value = true);
  onActivated(() => isKeptAlive.value = false);
  onBeforeUnmount(() => layout.unregister(id));
  return {
    layoutItemStyles,
    layoutRect: layout.layoutRect,
    layoutItemScrimStyles
  };
}
export {
  makeLayoutItemProps,
  useLayoutItem
};
//# sourceMappingURL=layout-item.mjs.map
