"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import React, { useState, useCallback, useMemo } from "react";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card";
import { Button } from "../ui/button";
import { Badge } from "../ui/badge";
import { Alert, AlertDescription } from "../ui/alert";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle
} from "../ui/dialog";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger
} from "../ui/dropdown-menu";
import {
  Plus,
  Edit,
  Trash2,
  MoreHorizontal,
  ArrowUpDown,
  ArrowUp,
  ArrowDown,
  Copy,
  AlertCircle,
  Loader2
} from "lucide-react";
import { EntityFieldRenderer } from "./EntityFieldRenderer";
import { EntityForm } from "./EntityForm";
import { createTestId, createCyId } from "../../lib/test";
function generateTestIds(parentName, childName) {
  return {
    container: createTestId(`${parentName}-${childName}`, "container"),
    addButton: createTestId(`${parentName}-${childName}`, "button", "add"),
    item: (id) => createTestId(`${parentName}-${childName}`, "item", id),
    editButton: (id) => createTestId(`${parentName}-${childName}`, "button", `edit-${id}`),
    deleteButton: (id) => createTestId(`${parentName}-${childName}`, "button", `delete-${id}`),
    form: createTestId(`${parentName}-${childName}`, "form")
  };
}
function EntityChildManager({
  parentEntityConfig,
  childEntityName,
  childEntityConfig,
  childData = [],
  onChildAdd,
  onChildUpdate,
  onChildDelete,
  onRefresh,
  isLoading = false,
  error = null,
  maxItems,
  className,
  customFormComponent
}) {
  console.log(`[EntityChildManager] childEntityName: ${childEntityName}`);
  console.log(`[EntityChildManager] customFormComponent:`, customFormComponent);
  console.log(`[EntityChildManager] customFormComponent type:`, typeof customFormComponent);
  const [formState, setFormState] = useState({
    isOpen: false,
    mode: "create",
    item: null
  });
  const [isSubmitting, setIsSubmitting] = useState(false);
  const [submissionMode, setSubmissionMode] = useState("create");
  const [deletingItems, setDeletingItems] = useState(/* @__PURE__ */ new Set());
  const [recentlyModified, setRecentlyModified] = useState(/* @__PURE__ */ new Set());
  const [deleteConfirmation, setDeleteConfirmation] = useState({ isOpen: false, item: null });
  const [sortField, setSortField] = useState("");
  const [sortDirection, setSortDirection] = useState("asc");
  const testIds = generateTestIds(parentEntityConfig.slug, childEntityName);
  const addTransitionEffect = useCallback((itemId) => {
    setRecentlyModified((prev) => new Set(prev).add(itemId));
    setTimeout(() => {
      setRecentlyModified((prev) => {
        const newSet = new Set(prev);
        newSet.delete(itemId);
        return newSet;
      });
    }, 2e3);
  }, []);
  const visibleFields = useMemo(() => {
    return childEntityConfig.fields.map((field) => ({
      ...field,
      api: {
        searchable: false,
        sortable: true,
        readOnly: false
      },
      display: field.display || {
        label: field.name,
        description: `${field.name} field`,
        showInList: true,
        showInDetail: true,
        showInForm: true,
        order: 1
      }
    })).filter((field) => {
      var _a;
      return ((_a = field.display) == null ? void 0 : _a.showInList) !== false;
    }).sort((a, b) => {
      var _a, _b;
      return (((_a = a.display) == null ? void 0 : _a.order) || 0) - (((_b = b.display) == null ? void 0 : _b.order) || 0);
    });
  }, [childEntityConfig.fields]);
  const sortedChildData = useMemo(() => {
    if (!sortField) return childData;
    const sorted = [...childData].sort((a, b) => {
      const aValue = a[sortField];
      const bValue = b[sortField];
      if (aValue < bValue) return sortDirection === "asc" ? -1 : 1;
      if (aValue > bValue) return sortDirection === "asc" ? 1 : -1;
      return 0;
    });
    return sorted;
  }, [childData, sortField, sortDirection]);
  const handleSort = useCallback((field) => {
    if (sortField === field) {
      setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
    } else {
      setSortField(field);
      setSortDirection("asc");
    }
  }, [sortField]);
  const getSortIcon = useCallback((field) => {
    if (sortField !== field) return /* @__PURE__ */ jsx(ArrowUpDown, { className: "ml-1 h-3 w-3" });
    return sortDirection === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "ml-1 h-3 w-3" }) : /* @__PURE__ */ jsx(ArrowDown, { className: "ml-1 h-3 w-3" });
  }, [sortField, sortDirection]);
  const handleCreate = useCallback(() => {
    setFormState({
      isOpen: true,
      mode: "create",
      item: null
    });
  }, []);
  const handleEdit = useCallback((item, index) => {
    setFormState({
      isOpen: true,
      mode: "edit",
      item,
      index
    });
  }, []);
  const handleFormSubmit = useCallback(async (data) => {
    const currentMode = formState.mode;
    setSubmissionMode(currentMode);
    setFormState({ isOpen: false, mode: "create", item: null });
    setIsSubmitting(true);
    try {
      let resultId;
      if (currentMode === "create") {
        const result = await (onChildAdd == null ? void 0 : onChildAdd(data));
        resultId = typeof result === "string" ? result : void 0;
        if (resultId) {
          addTransitionEffect(resultId);
        }
      } else if (currentMode === "edit" && formState.item) {
        const itemId = String(formState.item.id);
        await (onChildUpdate == null ? void 0 : onChildUpdate(itemId, data));
        addTransitionEffect(itemId);
      }
    } catch (error2) {
      console.error("Child entity operation failed:", error2);
      throw error2;
    } finally {
      setIsSubmitting(false);
    }
  }, [formState, onChildAdd, onChildUpdate, addTransitionEffect]);
  const handleDelete = useCallback((item) => {
    setDeleteConfirmation({ isOpen: true, item });
  }, []);
  const handleConfirmedDelete = useCallback(async () => {
    const { item } = deleteConfirmation;
    if (!onChildDelete || !item) return;
    const itemId = String(item.id);
    setDeleteConfirmation({ isOpen: false, item: null });
    setDeletingItems((prev) => new Set(prev).add(itemId));
    try {
      await onChildDelete(itemId);
    } catch (error2) {
      console.error("Delete failed:", error2);
    } finally {
      setDeletingItems((prev) => {
        const newSet = new Set(prev);
        newSet.delete(itemId);
        return newSet;
      });
    }
  }, [deleteConfirmation, onChildDelete]);
  const handleCancelDelete = useCallback(() => {
    setDeleteConfirmation({ isOpen: false, item: null });
  }, []);
  const handleFormCancel = useCallback(() => {
    setFormState({ isOpen: false, mode: "create", item: null });
  }, []);
  const isAtMaxItems = maxItems ? childData.length >= maxItems : false;
  const childEntityFormConfig = useMemo(() => ({
    name: childEntityName,
    slug: childEntityName,
    // Use same as name for child entities
    displayName: childEntityConfig.display.title.slice(0, -1),
    // Remove 's' from plural
    pluralName: childEntityConfig.display.title,
    icon: parentEntityConfig.icon,
    // Use parent icon
    public: false,
    // Child entities are not public
    hasArchivePage: false,
    // Child entities don't have archive pages
    hasSinglePage: false,
    // Child entities don't have single pages
    features: {
      enabled: true,
      showInMenu: false,
      searchable: false,
      allowSearch: false,
      hasExternalAPI: false,
      supportsMetas: false,
      sortable: true,
      filterable: false,
      supportsBulkOperations: false,
      supportsImportExport: false
    },
    fields: childEntityConfig.fields.map((field) => ({
      ...field,
      api: {
        searchable: false,
        sortable: true,
        readOnly: false
      },
      display: field.display || {
        label: field.name,
        description: `${field.name} field`,
        showInList: true,
        showInDetail: true,
        showInForm: true,
        order: 1
      }
    })),
    permissions: {
      actions: [
        { action: "create", label: "Create", roles: ["owner", "admin", "member"] },
        { action: "read", label: "View", roles: ["owner", "admin", "member", "viewer"] },
        { action: "list", label: "List", roles: ["owner", "admin", "member", "viewer"] },
        { action: "update", label: "Edit", roles: ["owner", "admin", "member"] },
        { action: "delete", label: "Delete", roles: ["owner", "admin"], dangerous: true }
      ]
    },
    planLimits: {
      availableInPlans: ["free", "starter", "premium"],
      limits: {
        free: { maxRecords: "unlimited" },
        starter: { maxRecords: "unlimited" },
        premium: { maxRecords: "unlimited" }
      }
    },
    routes: {
      list: "",
      detail: "",
      create: "",
      edit: ""
    },
    hooks: {
      beforeCreate: [],
      afterCreate: [],
      beforeUpdate: [],
      afterUpdate: [],
      beforeDelete: [],
      afterDelete: []
    },
    database: {
      tableName: "",
      primaryKey: "id",
      timestamps: true,
      softDelete: false
    },
    api: {
      apiPath: "",
      enabled: false,
      rateLimit: { requests: 100, windowMs: 6e4 }
    }
  }), [childEntityName, childEntityConfig, parentEntityConfig.icon]);
  if (isLoading) {
    return /* @__PURE__ */ jsx("div", { className: `space-y-4 ${className || ""}`, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-8", children: [
      /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground mr-2" }),
      /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Loading..." })
    ] }) });
  }
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: `space-y-4 ${className || ""}`,
      "data-testid": testIds.container,
      "data-cy": createCyId(`${parentEntityConfig.slug}-${childEntityName}`, "container"),
      children: [
        /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
          /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
            /* @__PURE__ */ jsx("h3", { className: "text-lg font-medium", children: childEntityConfig.display.title }),
            childEntityConfig.display.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: childEntityConfig.display.description })
          ] }),
          /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
            childData.length > 0 && /* @__PURE__ */ jsxs(Badge, { variant: "outline", children: [
              childData.length,
              maxItems && ` / ${maxItems}`
            ] }),
            onChildAdd && !isAtMaxItems && /* @__PURE__ */ jsxs(
              Button,
              {
                size: "sm",
                onClick: handleCreate,
                "data-testid": testIds.addButton,
                "data-cy": createCyId(`${parentEntityConfig.slug}-${childEntityName}`, "add-button"),
                children: [
                  /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
                  "Add ",
                  childEntityConfig.display.title.slice(0, -1)
                ]
              }
            )
          ] })
        ] }),
        isSubmitting && /* @__PURE__ */ jsxs(Alert, { children: [
          /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
          /* @__PURE__ */ jsxs(AlertDescription, { children: [
            submissionMode === "create" ? "Creando" : "Actualizando",
            " ",
            childEntityConfig.display.title.slice(0, -1).toLowerCase(),
            "..."
          ] })
        ] }),
        error && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
          /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsx(AlertDescription, { children: error })
        ] }),
        isAtMaxItems && /* @__PURE__ */ jsxs(Alert, { children: [
          /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsxs(AlertDescription, { children: [
            "Maximum number of ",
            childEntityConfig.display.title.toLowerCase(),
            " reached (",
            maxItems,
            ")"
          ] })
        ] }),
        sortedChildData.length === 0 ? /* @__PURE__ */ jsx(Card, { className: "border-dashed", children: /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-col items-center justify-center py-12", children: [
          React.createElement(parentEntityConfig.icon, {
            className: "h-12 w-12 text-muted-foreground/50 mb-4"
          }),
          /* @__PURE__ */ jsxs("h4", { className: "font-medium mb-2", children: [
            "No ",
            childEntityConfig.display.title.toLowerCase()
          ] }),
          /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground text-center mb-4", children: [
            "This ",
            parentEntityConfig.names.singular.toLowerCase(),
            " doesn't have any ",
            childEntityConfig.display.title.toLowerCase(),
            " yet."
          ] }),
          onChildAdd && !isAtMaxItems && /* @__PURE__ */ jsxs(Button, { onClick: handleCreate, variant: "outline", children: [
            /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
            "Add First ",
            childEntityConfig.display.title.slice(0, -1)
          ] })
        ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: childEntityConfig.display.mode === "table" ? (
          // Table view
          /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full", children: [
            /* @__PURE__ */ jsx("thead", { className: "border-b bg-muted/50", children: /* @__PURE__ */ jsxs("tr", { children: [
              visibleFields.map((field) => {
                var _a;
                return /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-sm font-medium", children: /* @__PURE__ */ jsxs(
                  Button,
                  {
                    variant: "ghost",
                    size: "sm",
                    onClick: () => handleSort(field.name),
                    className: "h-auto p-0 font-medium hover:bg-transparent",
                    children: [
                      ((_a = field.display) == null ? void 0 : _a.label) || field.name,
                      getSortIcon(field.name)
                    ]
                  }
                ) }, field.name);
              }),
              /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-right text-sm font-medium w-16", children: "Actions" })
            ] }) }),
            /* @__PURE__ */ jsx("tbody", { className: "divide-y", children: sortedChildData.map((item, index) => {
              const itemId = String(item.id);
              const isRecentlyModified = recentlyModified.has(itemId);
              return /* @__PURE__ */ jsxs(
                "tr",
                {
                  className: `hover:bg-muted/50 transition-colors duration-1000 ${isRecentlyModified ? "bg-accent/50" : ""}`,
                  "data-testid": testIds.item(String(item.id || index)),
                  children: [
                    visibleFields.map((field) => /* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx(
                      EntityFieldRenderer,
                      {
                        field,
                        value: item[field.name],
                        mode: "list",
                        context: {
                          entityType: `${parentEntityConfig.slug}_${childEntityName}`,
                          // Child entity type
                          formData: item
                          // Pass the record data
                        }
                      }
                    ) }, field.name)),
                    /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
                      /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }),
                      /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
                        /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Actions" }),
                        onChildUpdate && /* @__PURE__ */ jsxs(
                          DropdownMenuItem,
                          {
                            onClick: () => handleEdit(item, index),
                            "data-testid": testIds.editButton(String(item.id || index)),
                            children: [
                              /* @__PURE__ */ jsx(Edit, { className: "mr-2 h-4 w-4" }),
                              "Edit"
                            ]
                          }
                        ),
                        /* @__PURE__ */ jsxs(
                          DropdownMenuItem,
                          {
                            onClick: () => navigator.clipboard.writeText(String(item.id)),
                            children: [
                              /* @__PURE__ */ jsx(Copy, { className: "mr-2 h-4 w-4" }),
                              "Copy ID"
                            ]
                          }
                        ),
                        onChildDelete && /* @__PURE__ */ jsxs(Fragment, { children: [
                          /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
                          /* @__PURE__ */ jsxs(
                            DropdownMenuItem,
                            {
                              className: "text-destructive",
                              onClick: () => handleDelete(item),
                              disabled: deletingItems.has(String(item.id)),
                              "data-testid": testIds.deleteButton(String(item.id || index)),
                              children: [
                                deletingItems.has(String(item.id)) ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Trash2, { className: "mr-2 h-4 w-4" }),
                                "Delete"
                              ]
                            }
                          )
                        ] })
                      ] })
                    ] }) })
                  ]
                },
                itemId || index
              );
            }) })
          ] }) }) })
        ) : (
          // Card view
          /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4", children: sortedChildData.map((item, index) => {
            const itemId = String(item.id);
            const isRecentlyModified = recentlyModified.has(itemId);
            return /* @__PURE__ */ jsxs(
              Card,
              {
                className: `transition-colors duration-1000 ${isRecentlyModified ? "bg-accent/30 border-accent" : ""}`,
                "data-testid": testIds.item(String(item.id || index)),
                children: [
                  /* @__PURE__ */ jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
                    /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
                      /* @__PURE__ */ jsx(CardTitle, { className: "text-base", children: String(item.title || item.name || `Item ${index + 1}`) }),
                      typeof item.description === "string" && item.description && /* @__PURE__ */ jsx(CardDescription, { className: "text-xs line-clamp-2", children: item.description })
                    ] }),
                    /* @__PURE__ */ jsxs(DropdownMenu, { children: [
                      /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }),
                      /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
                        onChildUpdate && /* @__PURE__ */ jsxs(
                          DropdownMenuItem,
                          {
                            onClick: () => handleEdit(item, index),
                            "data-testid": testIds.editButton(String(item.id || index)),
                            children: [
                              /* @__PURE__ */ jsx(Edit, { className: "mr-2 h-4 w-4" }),
                              "Edit"
                            ]
                          }
                        ),
                        onChildDelete && /* @__PURE__ */ jsxs(
                          DropdownMenuItem,
                          {
                            className: "text-destructive",
                            onClick: () => handleDelete(item),
                            disabled: deletingItems.has(String(item.id)),
                            "data-testid": testIds.deleteButton(String(item.id || index)),
                            children: [
                              deletingItems.has(String(item.id)) ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Trash2, { className: "mr-2 h-4 w-4" }),
                              "Delete"
                            ]
                          }
                        )
                      ] })
                    ] })
                  ] }) }),
                  /* @__PURE__ */ jsx(CardContent, { className: "space-y-3", children: visibleFields.slice(0, 3).map((field) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
                    EntityFieldRenderer,
                    {
                      field,
                      value: item[field.name],
                      mode: "display"
                    }
                  ) }, field.name)) })
                ]
              },
              itemId || index
            );
          }) })
        ) }),
        /* @__PURE__ */ jsx(Dialog, { open: formState.isOpen, onOpenChange: (open) => !open && handleFormCancel(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl max-h-[90vh] overflow-y-auto", children: [
          /* @__PURE__ */ jsxs(DialogHeader, { children: [
            /* @__PURE__ */ jsxs(DialogTitle, { children: [
              formState.mode === "create" ? "Add" : "Edit",
              " ",
              childEntityConfig.display.title.slice(0, -1)
            ] }),
            /* @__PURE__ */ jsx(DialogDescription, { children: formState.mode === "create" ? `Add a new ${childEntityConfig.display.title.slice(0, -1).toLowerCase()} to this ${parentEntityConfig.names.singular.toLowerCase()}.` : `Update the details for this ${childEntityConfig.display.title.slice(0, -1).toLowerCase()}.` })
          ] }),
          /* @__PURE__ */ jsx("div", { "data-testid": testIds.form, children: useMemo(() => {
            console.log("[EntityChildManager RENDER] Rendering form for:", childEntityName);
            console.log("[EntityChildManager RENDER] customFormComponent:", customFormComponent);
            console.log("[EntityChildManager RENDER] Using custom form?:", !!customFormComponent);
            if (customFormComponent) {
              console.log("[EntityChildManager RENDER] Creating custom component with stable props");
              return React.createElement(customFormComponent, {
                entityConfig: childEntityFormConfig,
                initialData: formState.item || {},
                mode: formState.mode,
                onSubmit: handleFormSubmit,
                onCancel: handleFormCancel,
                onRefresh,
                isLoading: isSubmitting,
                className: "border-0 shadow-none p-0"
              });
            } else {
              console.log("[EntityChildManager RENDER] Using generic EntityForm");
              return /* @__PURE__ */ jsx(
                EntityForm,
                {
                  entityConfig: childEntityFormConfig,
                  initialData: formState.item || {},
                  mode: formState.mode,
                  onSubmit: handleFormSubmit,
                  isLoading: isSubmitting,
                  className: "border-0 shadow-none p-0"
                }
              );
            }
          }, [
            customFormComponent,
            childEntityFormConfig,
            formState.item,
            formState.mode,
            handleFormSubmit,
            handleFormCancel,
            onRefresh,
            isSubmitting,
            childEntityName
          ]) })
        ] }) }),
        /* @__PURE__ */ jsx(Dialog, { open: deleteConfirmation.isOpen, onOpenChange: (open) => !open && handleCancelDelete(), children: /* @__PURE__ */ jsxs(DialogContent, { children: [
          /* @__PURE__ */ jsxs(DialogHeader, { children: [
            /* @__PURE__ */ jsx(DialogTitle, { children: "Confirm Delete" }),
            /* @__PURE__ */ jsxs(DialogDescription, { children: [
              "\xBFEst\xE1s seguro de que quieres eliminar este ",
              childEntityConfig.display.title.slice(0, -1).toLowerCase(),
              "? Esta acci\xF3n no se puede deshacer."
            ] })
          ] }),
          /* @__PURE__ */ jsxs(DialogFooter, { children: [
            /* @__PURE__ */ jsx(
              Button,
              {
                variant: "outline",
                onClick: handleCancelDelete,
                disabled: false,
                children: "Cancelar"
              }
            ),
            /* @__PURE__ */ jsx(
              Button,
              {
                variant: "destructive",
                onClick: handleConfirmedDelete,
                disabled: false,
                children: "Eliminar"
              }
            )
          ] })
        ] }) })
      ]
    }
  );
}
export {
  EntityChildManager
};
