import {
  TaxRegionTable,
  useTaxRegionTable
} from "./chunk-DKA6GR53.js";
import {
  SingleColumnPage
} from "./chunk-XIZLPYEE.js";
import {
  useTaxRegionTableQuery
} from "./chunk-AYVH6Q5O.js";
import {
  useTaxRegions
} from "./chunk-VME3CJER.js";

// src/pages/tax-regions/tax-region-list/tax-region-list.tsx
import { Children as Children3 } from "react";

// src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx
import { Children as Children2 } from "react";
import { Container } from "@medusajs/ui";

// src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-data-table.tsx
import { keepPreviousData } from "@tanstack/react-query";
import { jsx } from "react/jsx-runtime";
var PAGE_SIZE = 20;
var TaxRegionListDataTable = () => {
  const { searchParams, raw } = useTaxRegionTableQuery({
    pageSize: PAGE_SIZE
  });
  const { tax_regions, count, isPending, isError, error } = useTaxRegions(
    {
      ...searchParams,
      parent_id: "null"
    },
    {
      placeholderData: keepPreviousData
    }
  );
  const { table } = useTaxRegionTable({
    count,
    data: tax_regions,
    pageSize: PAGE_SIZE
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx(
    TaxRegionTable,
    {
      renderHeader: false,
      isPending,
      queryObject: raw,
      table,
      count
    }
  );
};

// src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-header.tsx
import { Children } from "react";
import { Button, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
var TaxRegionListTitle = () => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsxs("div", { children: [
    /* @__PURE__ */ jsx2(Heading, { children: t("taxes.domain") }),
    /* @__PURE__ */ jsx2(Text, { size: "small", className: "text-pretty text-ui-fg-subtle", children: t("taxRegions.list.hint") })
  ] });
};
var TaxRegionListActions = ({
  children
}) => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-center gap-x-2", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsx2(Link, { to: "create", children: /* @__PURE__ */ jsx2(Button, { size: "small", variant: "secondary", children: t("actions.create") }) }) });
};
var TaxRegionListHeader = ({
  children
}) => {
  return /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-between px-6 py-4", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx2(TaxRegionListTitle, {}),
    /* @__PURE__ */ jsx2(TaxRegionListActions, {})
  ] }) });
};

// src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
var TaxRegionListView = ({
  children
}) => {
  return /* @__PURE__ */ jsx3(Container, { className: "divide-y p-0", children: Children2.count(children) > 0 ? children : /* @__PURE__ */ jsxs2(Fragment2, { children: [
    /* @__PURE__ */ jsx3(TaxRegionListHeader, {}),
    /* @__PURE__ */ jsx3(TaxRegionListDataTable, {})
  ] }) });
};

// src/pages/tax-regions/tax-region-list/tax-region-list.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var Root = ({ children }) => {
  return /* @__PURE__ */ jsx4(SingleColumnPage, { hasOutlet: true, children: Children3.count(children) > 0 ? children : /* @__PURE__ */ jsx4(TaxRegionListView, {}) });
};
var TaxRegionListPage = Object.assign(Root, {
  Table: TaxRegionListView,
  Header: TaxRegionListHeader,
  HeaderTitle: TaxRegionListTitle,
  HeaderActions: TaxRegionListActions,
  DataTable: TaxRegionListDataTable
});

export {
  TaxRegionListPage
};
