import {
  PriceListCreateProductsSchema,
  PriceListRulesSchema,
  usePriceListCurrencyData,
  usePriceListGridColumns
} from "./chunk-X6ZQMFCT.js";
import {
  exctractPricesFromProducts,
  isProductRow
} from "./chunk-BNOKKKUU.js";
import "./chunk-6IJMSVC6.js";
import {
  useProductTableColumns
} from "./chunk-AAKR2CB4.js";
import "./chunk-G64YUZSL.js";
import {
  useProductTableQuery
} from "./chunk-BEPAXQMU.js";
import "./chunk-FWPGOIFA.js";
import {
  useProductTableFilters
} from "./chunk-LFX6R456.js";
import "./chunk-DB6ANJBO.js";
import "./chunk-PHOCVOZ5.js";
import {
  DataGrid
} from "./chunk-5FBQOAXU.js";
import "./chunk-IQPN4PZJ.js";
import "./chunk-SMQT3ZNO.js";
import "./chunk-TKGWSUEI.js";
import {
  KeyboundForm
} from "./chunk-SITRHMZZ.js";
import {
  RouteFocusModal,
  useRouteModal
} from "./chunk-GDWBOQI5.js";
import {
  Form
} from "./chunk-3QSRE5LS.js";
import "./chunk-FQERBIVS.js";
import {
  _DataTable,
  useDataTable
} from "./chunk-7TQNE3E2.js";
import "./chunk-YN3FGNJM.js";
import "./chunk-KCHYLLVG.js";
import "./chunk-CVXKASWV.js";
import "./chunk-THHRRYRS.js";
import "./chunk-LRD242C7.js";
import "./chunk-52KJSIHS.js";
import "./chunk-WIYFXWRI.js";
import "./chunk-INNFZYX2.js";
import "./chunk-LAVHRER2.js";
import "./chunk-QHQWEERJ.js";
import "./chunk-Y7QKP6QU.js";
import "./chunk-RLRWDHME.js";
import "./chunk-K5324KIX.js";
import "./chunk-FV76G2D7.js";
import "./chunk-GHDLST2P.js";
import "./chunk-YVYYOBAE.js";
import "./chunk-L2NJPDUD.js";
import {
  useCreatePriceList
} from "./chunk-P7UBW2EI.js";
import "./chunk-MR6REQKT.js";
import "./chunk-EPSDO2MJ.js";
import "./chunk-BHEU34FL.js";
import "./chunk-W34KDYZA.js";
import "./chunk-II3CLUXA.js";
import "./chunk-XKEYHWBS.js";
import "./chunk-J2XUEO2E.js";
import "./chunk-656G74I2.js";
import "./chunk-VWPNMEOE.js";
import "./chunk-O72AIZUN.js";
import "./chunk-VUWAOX7H.js";
import "./chunk-5DKUSZQ7.js";
import "./chunk-DIAWPVYS.js";
import "./chunk-4U2BLH45.js";
import {
  useProducts
} from "./chunk-YAUGB4LD.js";
import "./chunk-A5DJIOHN.js";
import "./chunk-RHKRREUU.js";
import "./chunk-ZA2KFUFR.js";
import "./chunk-DTGEFKK4.js";
import "./chunk-NBMM2TZK.js";

// src/pages/price-lists/create/index.tsx
import { useTranslation as useTranslation4 } from "react-i18next";

// src/pages/price-lists/create/price-list-create-form/price-list-create-form.tsx
import { zodResolver } from "@hookform/resolvers/zod";
import { Button, ProgressTabs, toast } from "@medusajs/ui";
import { useForm } from "react-hook-form";
import { useTranslation as useTranslation3 } from "react-i18next";
import { useState as useState2 } from "react";

// src/pages/price-lists/create/price-list-create-form/price-list-details-form.tsx
import {
  DatePicker,
  Divider,
  Heading,
  Input,
  RadioGroup,
  Select,
  Text,
  Textarea
} from "@medusajs/ui";
import { useFieldArray } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
var PriceListDetailsForm = ({ form }) => {
  const { t } = useTranslation();
  const { remove: _remove } = useFieldArray({
    control: form.control,
    name: "rules.customer_group_id",
    keyName: "cg_id"
  });
  return /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 px-8 py-16", children: [
    /* @__PURE__ */ jsxs("div", { children: [
      /* @__PURE__ */ jsx(Heading, { children: t("priceLists.create.header") }),
      /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: t("priceLists.create.subheader") })
    ] }),
    /* @__PURE__ */ jsx(
      Form.Field,
      {
        control: form.control,
        name: "type",
        render: ({ field: { onChange, ...rest } }) => {
          return /* @__PURE__ */ jsxs(Form.Item, { children: [
            /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
              /* @__PURE__ */ jsxs("div", { children: [
                /* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.type.label") }),
                /* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.type.hint") })
              ] }),
              /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(
                RadioGroup,
                {
                  onValueChange: onChange,
                  ...rest,
                  className: "grid grid-cols-1 gap-4 md:grid-cols-2",
                  children: [
                    /* @__PURE__ */ jsx(
                      RadioGroup.ChoiceBox,
                      {
                        value: "sale",
                        label: t("priceLists.fields.type.options.sale.label"),
                        description: t(
                          "priceLists.fields.type.options.sale.description"
                        )
                      }
                    ),
                    /* @__PURE__ */ jsx(
                      RadioGroup.ChoiceBox,
                      {
                        value: "override",
                        label: t(
                          "priceLists.fields.type.options.override.label"
                        ),
                        description: t(
                          "priceLists.fields.type.options.override.description"
                        )
                      }
                    )
                  ]
                }
              ) })
            ] }),
            /* @__PURE__ */ jsx(Form.ErrorMessage, {})
          ] });
        }
      }
    ),
    /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
      /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1  gap-4 md:grid-cols-2", children: [
        /* @__PURE__ */ jsx(
          Form.Field,
          {
            control: form.control,
            name: "title",
            render: ({ field }) => {
              return /* @__PURE__ */ jsxs(Form.Item, { children: [
                /* @__PURE__ */ jsx(Form.Label, { children: t("fields.title") }),
                /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
                /* @__PURE__ */ jsx(Form.ErrorMessage, {})
              ] });
            }
          }
        ),
        /* @__PURE__ */ jsx(
          Form.Field,
          {
            control: form.control,
            name: "status",
            render: ({ field: { onChange, ref, ...field } }) => {
              return /* @__PURE__ */ jsxs(Form.Item, { children: [
                /* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.status.label") }),
                /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
                  /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
                  /* @__PURE__ */ jsxs(Select.Content, { children: [
                    /* @__PURE__ */ jsx(Select.Item, { value: "active", children: t("priceLists.fields.status.options.active") }),
                    /* @__PURE__ */ jsx(Select.Item, { value: "draft", children: t("priceLists.fields.status.options.draft") })
                  ] })
                ] }) }),
                /* @__PURE__ */ jsx(Form.ErrorMessage, {})
              ] });
            }
          }
        )
      ] }),
      /* @__PURE__ */ jsx(
        Form.Field,
        {
          control: form.control,
          name: "description",
          render: ({ field }) => {
            return /* @__PURE__ */ jsxs(Form.Item, { children: [
              /* @__PURE__ */ jsx(Form.Label, { children: t("fields.description") }),
              /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
              /* @__PURE__ */ jsx(Form.ErrorMessage, {})
            ] });
          }
        }
      )
    ] }),
    /* @__PURE__ */ jsx(Divider, {}),
    /* @__PURE__ */ jsx(
      Form.Field,
      {
        control: form.control,
        name: "starts_at",
        render: ({ field }) => {
          return /* @__PURE__ */ jsxs(Form.Item, { children: [
            /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [
              /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
                /* @__PURE__ */ jsx(Form.Label, { optional: true, children: t("priceLists.fields.startsAt.label") }),
                /* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.startsAt.hint") })
              ] }),
              /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
                DatePicker,
                {
                  granularity: "minute",
                  shouldCloseOnSelect: false,
                  ...field
                }
              ) })
            ] }),
            /* @__PURE__ */ jsx(Form.ErrorMessage, {})
          ] });
        }
      }
    ),
    /* @__PURE__ */ jsx(Divider, {}),
    /* @__PURE__ */ jsx(
      Form.Field,
      {
        control: form.control,
        name: "ends_at",
        render: ({ field }) => {
          return /* @__PURE__ */ jsxs(Form.Item, { children: [
            /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [
              /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
                /* @__PURE__ */ jsx(Form.Label, { optional: true, children: t("priceLists.fields.endsAt.label") }),
                /* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.endsAt.hint") })
              ] }),
              /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
                DatePicker,
                {
                  granularity: "minute",
                  shouldCloseOnSelect: false,
                  ...field
                }
              ) })
            ] }),
            /* @__PURE__ */ jsx(Form.ErrorMessage, {})
          ] });
        }
      }
    )
  ] }) });
};

// src/pages/price-lists/create/price-list-create-form/price-list-prices-form.tsx
import { useEffect } from "react";
import { useWatch } from "react-hook-form";
import { jsx as jsx2 } from "react/jsx-runtime";
var PriceListPricesForm = ({
  form,
  currencies,
  regions,
  pricePreferences
}) => {
  const ids = useWatch({
    control: form.control,
    name: "product_ids"
  });
  const existingProducts = useWatch({
    control: form.control,
    name: "products"
  });
  const {
    products: productsRaw,
    isLoading,
    isError,
    error
  } = useProducts({
    fields: "title,thumbnail,*variants,+status,*variants.prices"
  });
  const products = productsRaw?.filter(
    (product) => ids.some((id) => id.id === product.id)
  );
  const { setCloseOnEscape } = useRouteModal();
  const { setValue } = form;
  useEffect(() => {
    if (!isLoading && products) {
      products.forEach((product) => {
        if (existingProducts[product.id] || !product.variants) {
          return;
        }
        setValue(`products.${product.id}.variants`, {
          ...product.variants.reduce((variants, variant) => {
            variants[variant.id] = {
              currency_prices: {},
              region_prices: {}
            };
            return variants;
          }, {})
        });
      });
    }
  }, [products, existingProducts, isLoading, setValue]);
  const columns = usePriceListGridColumns({
    currencies,
    regions,
    pricePreferences
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col divide-y overflow-hidden", children: /* @__PURE__ */ jsx2(
    DataGrid,
    {
      isLoading,
      columns,
      data: products,
      getSubRows: (row) => {
        if (isProductRow(row) && row.variants) {
          return row.variants;
        }
      },
      state: form,
      onEditingChange: (editing) => setCloseOnEscape(!editing)
    }
  ) });
};

// src/pages/price-lists/create/price-list-create-form/price-list-products-form.tsx
import { Checkbox } from "@medusajs/ui";
import { keepPreviousData } from "@tanstack/react-query";
import {
  createColumnHelper
} from "@tanstack/react-table";
import { useMemo, useState } from "react";
import { useWatch as useWatch2 } from "react-hook-form";
import { useTranslation as useTranslation2 } from "react-i18next";
import { jsx as jsx3 } from "react/jsx-runtime";
var PAGE_SIZE = 50;
var PREFIX = "p";
function getInitialSelection(products) {
  return products.reduce((acc, curr) => {
    acc[curr.id] = true;
    return acc;
  }, {});
}
var PriceListProductsForm = ({ form }) => {
  const { t } = useTranslation2();
  const { control, setValue } = form;
  const selectedIds = useWatch2({
    control,
    name: "product_ids"
  });
  const productRecords = useWatch2({
    control,
    name: "products"
  });
  const [rowSelection, setRowSelection] = useState(
    getInitialSelection(selectedIds)
  );
  const { searchParams, raw } = useProductTableQuery({
    pageSize: PAGE_SIZE,
    prefix: PREFIX
  });
  const { products, count, isLoading, isError, error } = useProducts(
    { ...searchParams, fields: "+thumbnail" },
    {
      placeholderData: keepPreviousData
    }
  );
  const updater = (fn) => {
    const state = typeof fn === "function" ? fn(rowSelection) : fn;
    const ids = Object.keys(state);
    const productRecordKeys = Object.keys(productRecords);
    const updatedRecords = productRecordKeys.reduce((acc, key) => {
      if (ids.includes(key)) {
        acc[key] = productRecords[key];
      }
      return acc;
    }, {});
    const update = ids.map((id) => ({ id }));
    setValue("product_ids", update, {
      shouldDirty: true,
      shouldTouch: true
    });
    setValue("products", updatedRecords, {
      shouldDirty: true,
      shouldTouch: true
    });
    setRowSelection(state);
  };
  const columns = useColumns();
  const filters = useProductTableFilters();
  const { table } = useDataTable({
    data: products || [],
    columns,
    count,
    enablePagination: true,
    enableRowSelection: (row) => {
      return !!row.original.variants?.length;
    },
    getRowId: (row) => row.id,
    rowSelection: {
      state: rowSelection,
      updater
    },
    pageSize: PAGE_SIZE
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx3("div", { className: "flex size-full flex-col", children: /* @__PURE__ */ jsx3(
    _DataTable,
    {
      table,
      columns,
      filters,
      pageSize: PAGE_SIZE,
      prefix: PREFIX,
      count,
      isLoading,
      layout: "fill",
      orderBy: [
        { key: "title", label: t("fields.title") },
        { key: "status", label: t("fields.status") },
        {
          key: "created_at",
          label: t("fields.createdAt")
        },
        {
          key: "updated_at",
          label: t("fields.updatedAt")
        }
      ],
      pagination: true,
      search: true,
      queryObject: raw,
      noRecords: {
        message: t("priceLists.create.products.list.noRecordsMessage")
      }
    }
  ) });
};
var columnHelper = createColumnHelper();
var useColumns = () => {
  const base = useProductTableColumns();
  return useMemo(
    () => [
      columnHelper.display({
        id: "select",
        header: ({ table }) => {
          return /* @__PURE__ */ jsx3(
            Checkbox,
            {
              checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
              onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
            }
          );
        },
        cell: ({ row }) => {
          return /* @__PURE__ */ jsx3(
            Checkbox,
            {
              checked: row.getIsSelected(),
              disabled: !row.getCanSelect(),
              onCheckedChange: (value) => row.toggleSelected(!!value),
              onClick: (e) => {
                e.stopPropagation();
              }
            }
          );
        }
      }),
      ...base
    ],
    [base]
  );
};

// src/pages/price-lists/create/price-list-create-form/schema.ts
import { z } from "zod";
var PricingCustomerGroupsArray = z.array(
  z.object({
    id: z.string(),
    name: z.string()
  })
);
var PricingCreateSchema = z.object({
  type: z.enum(["sale", "override"]),
  status: z.enum(["draft", "active"]),
  title: z.string().min(1),
  description: z.string().min(1),
  starts_at: z.date().nullish(),
  ends_at: z.date().nullish(),
  product_ids: z.array(z.object({ id: z.string() })).min(1),
  products: PriceListCreateProductsSchema,
  rules: PriceListRulesSchema.nullish()
});
var PricingDetailsSchema = PricingCreateSchema.pick({
  type: true,
  title: true,
  description: true,
  starts_at: true,
  ends_at: true,
  customer_group_ids: true
});
var PricingDetailsFields = Object.keys(
  PricingDetailsSchema.shape
);
var PricingProductsSchema = PricingCreateSchema.pick({
  product_ids: true
});
var PricingProductsFields = Object.keys(
  PricingProductsSchema.shape
);
var PricingPricesSchema = PricingCreateSchema.pick({
  products: true
});
var PricingPricesFields = Object.keys(
  PricingPricesSchema.shape
);

// src/pages/price-lists/create/price-list-create-form/price-list-create-form.tsx
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
var tabOrder = ["detail" /* DETAIL */, "product" /* PRODUCT */, "price" /* PRICE */];
var initialTabState = {
  ["detail" /* DETAIL */]: "in-progress",
  ["product" /* PRODUCT */]: "not-started",
  ["price" /* PRICE */]: "not-started"
};
var PriceListCreateForm = ({
  regions,
  currencies,
  pricePreferences
}) => {
  const [tab, setTab] = useState2("detail" /* DETAIL */);
  const [tabState, setTabState] = useState2(initialTabState);
  const { t } = useTranslation3();
  const { handleSuccess } = useRouteModal();
  const form = useForm({
    defaultValues: {
      type: "sale",
      status: "active",
      title: "",
      description: "",
      starts_at: null,
      ends_at: null,
      product_ids: [],
      products: {},
      rules: {
        customer_group_id: []
      }
    },
    resolver: zodResolver(PricingCreateSchema)
  });
  const { mutateAsync, isPending } = useCreatePriceList();
  const handleSubmit = form.handleSubmit(async (data) => {
    const { rules, products } = data;
    const rulesPayload = rules?.customer_group_id?.length ? { "customer.groups.id": rules.customer_group_id.map((cg) => cg.id) } : void 0;
    const prices = exctractPricesFromProducts(products, regions);
    await mutateAsync(
      {
        title: data.title,
        type: data.type,
        status: data.status,
        description: data.description,
        starts_at: data.starts_at ? data.starts_at.toISOString() : null,
        ends_at: data.ends_at ? data.ends_at.toISOString() : null,
        rules: rulesPayload,
        prices
      },
      {
        onSuccess: ({ price_list }) => {
          toast.success(
            t("priceLists.create.successToast", {
              title: price_list.title
            })
          );
          handleSuccess(`../${price_list.id}`);
        },
        onError: (error) => {
          toast.error(error.message);
        }
      }
    );
  });
  const partialFormValidation = (fields, schema) => {
    form.clearErrors(fields);
    const values = fields.reduce(
      (acc, key) => {
        acc[key] = form.getValues(key);
        return acc;
      },
      {}
    );
    const validationResult = schema.safeParse(values);
    if (!validationResult.success) {
      validationResult.error.errors.forEach(({ path, message, code }) => {
        form.setError(path.join("."), {
          type: code,
          message
        });
      });
      return false;
    }
    return true;
  };
  const isTabDirty = (tab2) => {
    switch (tab2) {
      case "detail" /* DETAIL */: {
        const fields = PricingDetailsFields;
        return fields.some((field) => {
          return form.getFieldState(field).isDirty;
        });
      }
      case "product" /* PRODUCT */: {
        const fields = PricingProductsFields;
        return fields.some((field) => {
          return form.getFieldState(field).isDirty;
        });
      }
      case "price" /* PRICE */: {
        const fields = PricingPricesFields;
        return fields.some((field) => {
          return form.getFieldState(field).isDirty;
        });
      }
    }
  };
  const handleChangeTab = (update) => {
    if (tab === update) {
      return;
    }
    if (tabOrder.indexOf(update) < tabOrder.indexOf(tab)) {
      const isCurrentTabDirty = isTabDirty(tab);
      setTabState((prev) => ({
        ...prev,
        [tab]: isCurrentTabDirty ? prev[tab] : "not-started",
        [update]: "in-progress"
      }));
      setTab(update);
      return;
    }
    const tabs = tabOrder.slice(0, tabOrder.indexOf(update));
    for (const tab2 of tabs) {
      if (tab2 === "detail" /* DETAIL */) {
        if (!partialFormValidation(PricingDetailsFields, PricingDetailsSchema)) {
          setTabState((prev) => ({
            ...prev,
            [tab2]: "in-progress"
          }));
          setTab(tab2);
          return;
        }
        setTabState((prev) => ({
          ...prev,
          [tab2]: "completed"
        }));
      } else if (tab2 === "product" /* PRODUCT */) {
        if (!partialFormValidation(PricingProductsFields, PricingProductsSchema)) {
          toast.error(t("priceLists.create.products.errors.noProducts"));
          setTabState((prev) => ({
            ...prev,
            [tab2]: "in-progress"
          }));
          setTab(tab2);
          return;
        }
        setTabState((prev) => ({
          ...prev,
          [tab2]: "completed"
        }));
      }
    }
    setTabState((prev) => ({
      ...prev,
      [tab]: "completed",
      [update]: "in-progress"
    }));
    setTab(update);
  };
  const handleNextTab = (tab2) => {
    if (tabOrder.indexOf(tab2) + 1 >= tabOrder.length) {
      return;
    }
    const nextTab = tabOrder[tabOrder.indexOf(tab2) + 1];
    handleChangeTab(nextTab);
  };
  return /* @__PURE__ */ jsx4(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsx4(
    ProgressTabs,
    {
      value: tab,
      onValueChange: (tab2) => handleChangeTab(tab2),
      className: "flex h-full flex-col overflow-hidden",
      children: /* @__PURE__ */ jsxs2(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
        /* @__PURE__ */ jsx4(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx4("div", { className: "flex w-full items-center justify-between gap-x-4", children: /* @__PURE__ */ jsx4("div", { className: "-my-2 w-full max-w-[600px] border-l", children: /* @__PURE__ */ jsxs2(ProgressTabs.List, { className: "grid w-full grid-cols-3", children: [
          /* @__PURE__ */ jsx4(
            ProgressTabs.Trigger,
            {
              status: tabState.detail,
              value: "detail" /* DETAIL */,
              children: t("priceLists.create.tabs.details")
            }
          ),
          /* @__PURE__ */ jsx4(
            ProgressTabs.Trigger,
            {
              status: tabState.product,
              value: "product" /* PRODUCT */,
              children: t("priceLists.create.tabs.products")
            }
          ),
          /* @__PURE__ */ jsx4(
            ProgressTabs.Trigger,
            {
              status: tabState.price,
              value: "price" /* PRICE */,
              children: t("priceLists.create.tabs.prices")
            }
          )
        ] }) }) }) }),
        /* @__PURE__ */ jsxs2(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: [
          /* @__PURE__ */ jsx4(
            ProgressTabs.Content,
            {
              className: "size-full overflow-y-auto",
              value: "detail" /* DETAIL */,
              children: /* @__PURE__ */ jsx4(PriceListDetailsForm, { form })
            }
          ),
          /* @__PURE__ */ jsx4(
            ProgressTabs.Content,
            {
              className: "size-full overflow-y-auto",
              value: "product" /* PRODUCT */,
              children: /* @__PURE__ */ jsx4(PriceListProductsForm, { form })
            }
          ),
          /* @__PURE__ */ jsx4(
            ProgressTabs.Content,
            {
              className: "size-full overflow-hidden",
              value: "price" /* PRICE */,
              children: /* @__PURE__ */ jsx4(
                PriceListPricesForm,
                {
                  form,
                  regions,
                  currencies,
                  pricePreferences
                }
              )
            }
          )
        ] }),
        /* @__PURE__ */ jsx4(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2", children: [
          /* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(Button, { variant: "secondary", size: "small", children: t("actions.cancel") }) }),
          /* @__PURE__ */ jsx4(
            PrimaryButton,
            {
              tab,
              next: handleNextTab,
              isLoading: isPending
            }
          )
        ] }) })
      ] })
    }
  ) });
};
var PrimaryButton = ({ tab, next, isLoading }) => {
  const { t } = useTranslation3();
  if (tab === "price" /* PRICE */) {
    return /* @__PURE__ */ jsx4(
      Button,
      {
        type: "submit",
        variant: "primary",
        size: "small",
        isLoading,
        children: t("actions.save")
      },
      "submit-button"
    );
  }
  return /* @__PURE__ */ jsx4(
    Button,
    {
      type: "button",
      variant: "primary",
      size: "small",
      onClick: () => next(tab),
      children: t("actions.continue")
    },
    "next-button"
  );
};

// src/pages/price-lists/create/index.tsx
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
var Component = () => {
  const { t } = useTranslation4();
  const { isReady, regions, currencies, pricePreferences } = usePriceListCurrencyData();
  return /* @__PURE__ */ jsxs3(RouteFocusModal, { children: [
    /* @__PURE__ */ jsx5(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: t("priceLists.create.header") }) }),
    /* @__PURE__ */ jsx5(RouteFocusModal.Description, { className: "sr-only", children: t("priceLists.create.subheader") }),
    isReady && /* @__PURE__ */ jsx5(
      PriceListCreateForm,
      {
        regions,
        currencies,
        pricePreferences
      }
    )
  ] });
};
export {
  Component
};
