<template>
  <view :class="rowClass" :style="rowStyle">
    <slot></slot>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed, provide, reactive, toRef } from "vue";
import { splitUnit, classNames, stringifyStyle, createBem } from "../utils";
import {
  rowSymbol,
  mapJustify,
  mapAlign,
  rowProps
} from "../layout/common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "row",
  props: rowProps,
  setup(__props, { expose: __expose }) {
    __expose();
    const props = __props;
    const bem = createBem("row");
    const gutter = computed(() => {
      if (props.gap) {
        const result = splitUnit(props.gap);
        return [result[0] / 2, result[1] || "rpx"];
      }
      return [0, "rpx"];
    });
    provide(
      rowSymbol,
      reactive({
        gap: toRef(props, "gap"),
        gutter
      })
    );
    const rowStyle = computed(() => {
      return stringifyStyle(
        {
          justifyContent: props.justify && mapJustify[props.justify],
          alignItems: props.align && mapAlign[props.align]
        },
        props.gap ? {
          marginLeft: -gutter.value[0] + gutter.value[1],
          marginRight: -gutter.value[0] + gutter.value[1]
        } : null,
        props.rootStyle
      );
    });
    const rowClass = computed(() => {
      return classNames(bem.b(), props.rootClass);
    });
    const __returned__ = { props, bem, gutter, rowStyle, rowClass };
    return __returned__;
  }
});
</script>

<style lang="scss">
@use './index.scss';
</style>